Browse Source

Added BufferGeometry for direct rendering from typed arrays.

Work in progress. For the moment works just with CTMLoader. Still not sure where some pieces of code would go.

Upsides:
	- initialization time cut down significantly (1.8 seconds => 0.7 seconds for CTM example)
	- much smaller GL buffers thanks to fully used indexing (Walt has 6x less vertices)
	- consequently much smaller memory footprint all around, both for main and GPU memories,
	  which means less swapping and better vertex caching

Downsides:
	- can't have anymore sharp per-face effects like flat shading (at least if mesh is not constructed in a way where each face has own vertices)
	- can't have multiple materials per mesh
	- no more easy manipulation of anything (for the moment actually no runtime manipulation at all, typed arrays are just thrown away, dynamic geometries code path not yet implemented)
alteredq 13 years ago
parent
commit
8ec6317ef8

+ 362 - 357
build/Three.js

@@ -18,66 +18,66 @@ this.y=Math.asin(a.n13);Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),
 THREE.Vector4.prototype={constructor:THREE.Vector4,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!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-
 THREE.Vector4.prototype={constructor:THREE.Vector4,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!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-
 b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};
-THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);q=o.dot(b);if(q<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(q));return s=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);r=o.dot(o);u=o.dot(p);t=o.dot(m);z=p.dot(p);A=p.dot(m);E=1/(r*z-u*u);D=(z*t-u*A)*E;B=(r*A-u*t)*E;return D>=0&&B>=0&&D+B<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
-c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3;this.intersectObject=function(m){for(var n,q=[],o=0,p=m.children.length;o<p;o++)Array.prototype.push.apply(q,this.intersectObject(m.children[o]));if(m instanceof THREE.Particle){o=
+THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);q=o.dot(b);if(q<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(q));return s=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);r=o.dot(o);u=o.dot(p);t=o.dot(m);A=p.dot(p);B=p.dot(m);z=1/(r*A-u*u);D=(A*t-u*B)*z;H=(r*B-u*t)*z;return D>=0&&H>=0&&D+H<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
+c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3;this.intersectObject=function(m){for(var n,q=[],o=0,p=m.children.length;o<p;o++)Array.prototype.push.apply(q,this.intersectObject(m.children[o]));if(m instanceof THREE.Particle){o=
 c(this.origin,this.direction,m.matrixWorld.getPosition());if(o===null||o>m.scale.x)return[];n={distance:o,point:m.position,face:null,object:m};q.push(n)}else if(m instanceof THREE.Mesh){o=c(this.origin,this.direction,m.matrixWorld.getPosition());if(o===null||o>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return q;var s,r=m.geometry,u=r.vertices,t;m.matrixRotationWorld.extractRotation(m.matrixWorld);o=0;for(p=r.faces.length;o<p;o++)if(n=r.faces[o],a.copy(this.origin),
 c(this.origin,this.direction,m.matrixWorld.getPosition());if(o===null||o>m.scale.x)return[];n={distance:o,point:m.position,face:null,object:m};q.push(n)}else if(m instanceof THREE.Mesh){o=c(this.origin,this.direction,m.matrixWorld.getPosition());if(o===null||o>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return q;var s,r=m.geometry,u=r.vertices,t;m.matrixRotationWorld.extractRotation(m.matrixWorld);o=0;for(p=r.faces.length;o<p;o++)if(n=r.faces[o],a.copy(this.origin),
-b.copy(this.direction),t=m.matrixWorld,i=t.multiplyVector3(i.copy(n.centroid)).subSelf(a),s=i.dot(b),!(s<=0)&&(e=t.multiplyVector3(e.copy(u[n.a].position)),f=t.multiplyVector3(f.copy(u[n.b].position)),g=t.multiplyVector3(g.copy(u[n.c].position)),n instanceof THREE.Face4&&(h=t.multiplyVector3(h.copy(u[n.d].position))),k=m.matrixRotationWorld.multiplyVector3(k.copy(n.normal)),s=b.dot(k),m.doubleSided||(m.flipSided?s>0:s<0)))if(s=k.dot(i.sub(e,a))/s,j.add(a,b.multiplyScalar(s)),n instanceof THREE.Face3)d(j,
-e,f,g)&&(n={distance:a.distanceTo(j),point:j.clone(),face:n,object:m},q.push(n));else if(n instanceof THREE.Face4&&(d(j,e,f,h)||d(j,f,g,h)))n={distance:a.distanceTo(j),point:j.clone(),face:n,object:m},q.push(n)}return q};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,q,n,s,r,u,t,z,A,E,D,B};
-THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,o){h=!1;b=f;c=g;d=j;e=o;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
-function(f,g,j,o,p,m){h?(h=!1,b=f<j?f<p?f:p:j<p?j:p,c=g<o?g<m?g:m:o<m?o:m,d=f>j?f>p?f:p:j>p?j:p,e=g>o?g>m?g:m:o>m?o:m):(b=f<j?f<p?f<b?f:b:p<b?p:b:j<p?j<b?j:b:p<b?p:b,c=g<o?g<m?g<c?g:c:m<c?m:c:o<m?o<c?o:c:m<c?m:c,d=f>j?f>p?f>d?f:d:p>d?p:d:j>p?j>d?j:d:p>d?p:d,e=g>o?g>m?g>e?g:e:m>e?m:e:o>m?o>e?o:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
+b.copy(this.direction),t=m.matrixWorld,i=t.multiplyVector3(i.copy(n.centroid)).subSelf(a),s=i.dot(b),!(s<=0)&&(e=t.multiplyVector3(e.copy(u[n.a].position)),f=t.multiplyVector3(f.copy(u[n.b].position)),g=t.multiplyVector3(g.copy(u[n.c].position)),n instanceof THREE.Face4&&(h=t.multiplyVector3(h.copy(u[n.d].position))),j=m.matrixRotationWorld.multiplyVector3(j.copy(n.normal)),s=b.dot(j),m.doubleSided||(m.flipSided?s>0:s<0)))if(s=j.dot(i.sub(e,a))/s,k.add(a,b.multiplyScalar(s)),n instanceof THREE.Face3)d(k,
+e,f,g)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},q.push(n));else if(n instanceof THREE.Face4&&(d(k,e,f,h)||d(k,f,g,h)))n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},q.push(n)}return q};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,q,n,s,r,u,t,A,B,z,D,H};
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,o){h=!1;b=f;c=g;d=k;e=o;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
+function(f,g,k,o,p,m){h?(h=!1,b=f<k?f<p?f:p:k<p?k:p,c=g<o?g<m?g:m:o<m?o:m,d=f>k?f>p?f:p:k>p?k:p,e=g>o?g>m?g:m:o>m?o:m):(b=f<k?f<p?f<b?f:b:p<b?p:b:k<p?k<b?k:b:p<b?p:b,c=g<o?g<m?g<c?g:c:m<c?m:c:o<m?o<c?o:c:m<c?m:c,d=f>k?f>p?f>d?f:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,e=g>o?g>m?g>e?g:e:m>e?m:e:o>m?o>e?o:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){if(d<a.getLeft())return!1;if(b>a.getRight())return!1;if(e<a.getTop())return!1;if(c>a.getBottom())return!1;return!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){if(d<a.getLeft())return!1;if(b>a.getRight())return!1;if(e<a.getTop())return!1;if(c>a.getBottom())return!1;return!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
 THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
 THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,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.Matrix3.prototype={constructor:THREE.Matrix3,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,f,g,h,i,k,j,o,p,m,q,n){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,i||0,k||0,j!==void 0?j:1,o||0,p||0,m||0,q||0,n!==void 0?n:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,k,j,o,p,m,q,n){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=i;this.n32=k;this.n33=j;this.n34=o;this.n41=p;this.n42=m;this.n43=q;this.n44=n;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,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;d.cross(c,f).normalize();d.length()===0&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,i=a.n23,k=a.n24,j=a.n31,o=a.n32,p=a.n33,m=a.n34,q=a.n41,n=a.n42,s=a.n43,
-r=a.n44,u=b.n11,t=b.n12,z=b.n13,A=b.n14,E=b.n21,D=b.n22,B=b.n23,w=b.n24,G=b.n31,y=b.n32,K=b.n33,$=b.n34,Q=b.n41,Y=b.n42,S=b.n43,R=b.n44;this.n11=c*u+d*E+e*G+f*Q;this.n12=c*t+d*D+e*y+f*Y;this.n13=c*z+d*B+e*K+f*S;this.n14=c*A+d*w+e*$+f*R;this.n21=g*u+h*E+i*G+k*Q;this.n22=g*t+h*D+i*y+k*Y;this.n23=g*z+h*B+i*K+k*S;this.n24=g*A+h*w+i*$+k*R;this.n31=j*u+o*E+p*G+m*Q;this.n32=j*t+o*D+p*y+m*Y;this.n33=j*z+o*B+p*K+m*S;this.n34=j*A+o*w+p*$+m*R;this.n41=q*u+n*E+s*G+r*Q;this.n42=q*t+n*D+s*y+r*Y;this.n43=q*z+n*
-B+s*K+r*S;this.n44=q*A+n*w+s*$+r*R;return this},multiplySelf:function(a){return this.multiply(this,a)},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},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,j,k,o,p,m,q,n){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,i||0,j||0,k!==void 0?k:1,o||0,p||0,m||0,q||0,n!==void 0?n:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,j,k,o,p,m,q,n){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=i;this.n32=j;this.n33=k;this.n34=o;this.n41=p;this.n42=m;this.n43=q;this.n44=n;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,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;d.cross(c,f).normalize();d.length()===0&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,i=a.n23,j=a.n24,k=a.n31,o=a.n32,p=a.n33,m=a.n34,q=a.n41,n=a.n42,s=a.n43,
+r=a.n44,u=b.n11,t=b.n12,A=b.n13,B=b.n14,z=b.n21,D=b.n22,H=b.n23,w=b.n24,F=b.n31,y=b.n32,K=b.n33,$=b.n34,Q=b.n41,X=b.n42,T=b.n43,R=b.n44;this.n11=c*u+d*z+e*F+f*Q;this.n12=c*t+d*D+e*y+f*X;this.n13=c*A+d*H+e*K+f*T;this.n14=c*B+d*w+e*$+f*R;this.n21=g*u+h*z+i*F+j*Q;this.n22=g*t+h*D+i*y+j*X;this.n23=g*A+h*H+i*K+j*T;this.n24=g*B+h*w+i*$+j*R;this.n31=k*u+o*z+p*F+m*Q;this.n32=k*t+o*D+p*y+m*X;this.n33=k*A+o*H+p*K+m*T;this.n34=k*B+o*w+p*$+m*R;this.n41=q*u+n*z+s*F+r*Q;this.n42=q*t+n*D+s*y+r*X;this.n43=q*A+n*
+H+s*K+r*T;this.n44=q*B+n*w+s*$+r*R;return this},multiplySelf:function(a){return this.multiply(this,a)},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},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},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*
 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},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*
 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},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,i=this.n31,k=this.n32,j=this.n33,o=this.n34,p=this.n41,m=this.n42,q=this.n43,n=this.n44;return d*g*k*p-c*h*k*p-d*f*j*p+b*h*j*p+c*f*o*p-b*g*o*p-d*g*i*m+c*h*i*m+d*e*j*m-a*h*j*m-c*e*o*m+a*g*o*m+d*f*i*q-b*h*i*q-d*e*k*q+a*h*k*q+b*e*o*q-a*f*o*q-c*f*i*n+b*g*i*n+c*e*k*n-a*g*k*n-b*e*j*n+a*f*j*n},transpose:function(){var a;
+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},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,i=this.n31,j=this.n32,k=this.n33,o=this.n34,p=this.n41,m=this.n42,q=this.n43,n=this.n44;return d*g*j*p-c*h*j*p-d*f*k*p+b*h*k*p+c*f*o*p-b*g*o*p-d*g*i*m+c*h*i*m+d*e*k*m-a*h*k*m-c*e*o*m+a*g*o*m+d*f*i*q-b*h*i*q-d*e*j*q+a*h*j*q+b*e*o*q-a*f*o*q-c*f*i*n+b*g*i*n+c*e*j*n-a*g*j*n-b*e*k*n+a*f*k*n},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.n34=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=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.n34=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.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},
 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},
 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,f=a.x,g=a.y,h=a.z,i=e*f,k=e*g;this.set(i*f+c,i*g-d*h,i*h+d*g,0,i*g+d*h,k*g+c,k*h-d*f,0,i*h-d*g,k*h+d*f,e*h*h+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(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
-this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,f=a.n21,g=a.n22,h=a.n23,i=a.n24,k=a.n31,j=a.n32,o=a.n33,p=a.n34,m=a.n41,q=a.n42,n=a.n43,s=a.n44;this.n11=h*p*q-i*o*q+i*j*n-g*p*n-h*j*s+g*o*s;this.n12=e*o*q-d*p*q-e*j*n+c*p*n+d*j*s-c*o*s;this.n13=d*i*q-e*h*q+e*g*n-c*i*n-d*g*s+c*h*s;this.n14=e*h*j-d*i*j-e*g*o+c*i*o+d*g*p-c*h*p;this.n21=i*o*m-h*p*m-i*k*n+f*p*n+h*k*s-f*o*s;this.n22=d*p*m-e*o*m+
-e*k*n-b*p*n-d*k*s+b*o*s;this.n23=e*h*m-d*i*m-e*f*n+b*i*n+d*f*s-b*h*s;this.n24=d*i*k-e*h*k+e*f*o-b*i*o-d*f*p+b*h*p;this.n31=g*p*m-i*j*m+i*k*q-f*p*q-g*k*s+f*j*s;this.n32=e*j*m-c*p*m-e*k*q+b*p*q+c*k*s-b*j*s;this.n33=c*i*m-e*g*m+e*f*q-b*i*q-c*f*s+b*g*s;this.n34=e*g*k-c*i*k-e*f*j+b*i*j+c*f*p-b*g*p;this.n41=h*j*m-g*o*m-h*k*q+f*o*q+g*k*n-f*j*n;this.n42=c*o*m-d*j*m+d*k*q-b*o*q-c*k*n+b*j*n;this.n43=d*g*m-c*h*m-d*f*q+b*h*q+c*f*n-b*g*n;this.n44=c*h*k-d*g*k+d*f*j-b*h*j-c*f*o+b*g*o;this.multiplyScalar(1/a.determinant());
-return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var i=g*h,k=g*e,j=d*h,o=d*e;this.n11=i+o*c;this.n12=j*c-k;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=k*c-j;this.n32=o+i*c;this.n33=f*g;break;case "ZXY":i=g*h;k=g*e;j=d*h;o=d*e;this.n11=i-o*c;this.n12=-f*e;this.n13=j+k*c;this.n21=k+j*c;this.n22=f*h;this.n23=o-i*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":i=
-f*h;k=f*e;j=c*h;o=c*e;this.n11=g*h;this.n12=j*d-k;this.n13=i*d+o;this.n21=g*e;this.n22=o*d+i;this.n23=k*d-j;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":i=f*g;k=f*d;j=c*g;o=c*d;this.n11=g*h;this.n12=o-i*e;this.n13=j*e+k;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=k*e+j;this.n33=i-o*e;break;case "XZY":i=f*g;k=f*d;j=c*g;o=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=i*e+o;this.n22=f*h;this.n23=k*e-j;this.n31=j*e-k;this.n32=c*h;this.n33=o*e+i;break;default:i=f*h,k=f*
-e,j=c*h,o=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=k+j*d,this.n22=i-o*d,this.n23=-c*g,this.n31=o-i*d,this.n32=j+k*d,this.n33=f*g}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,h=d+d,a=b*f,i=b*g;b*=h;var k=c*g;c*=h;d*=h;f*=e;g*=e;e*=h;this.n11=1-(k+d);this.n12=i-e;this.n13=b+g;this.n21=i+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+k);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,i=e*f,j=e*g;this.set(i*f+c,i*g-d*h,i*h+d*g,0,i*g+d*h,j*g+c,j*h-d*f,0,i*h-d*g,j*h+d*f,e*h*h+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(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
+this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,f=a.n21,g=a.n22,h=a.n23,i=a.n24,j=a.n31,k=a.n32,o=a.n33,p=a.n34,m=a.n41,q=a.n42,n=a.n43,s=a.n44;this.n11=h*p*q-i*o*q+i*k*n-g*p*n-h*k*s+g*o*s;this.n12=e*o*q-d*p*q-e*k*n+c*p*n+d*k*s-c*o*s;this.n13=d*i*q-e*h*q+e*g*n-c*i*n-d*g*s+c*h*s;this.n14=e*h*k-d*i*k-e*g*o+c*i*o+d*g*p-c*h*p;this.n21=i*o*m-h*p*m-i*j*n+f*p*n+h*j*s-f*o*s;this.n22=d*p*m-e*o*m+
+e*j*n-b*p*n-d*j*s+b*o*s;this.n23=e*h*m-d*i*m-e*f*n+b*i*n+d*f*s-b*h*s;this.n24=d*i*j-e*h*j+e*f*o-b*i*o-d*f*p+b*h*p;this.n31=g*p*m-i*k*m+i*j*q-f*p*q-g*j*s+f*k*s;this.n32=e*k*m-c*p*m-e*j*q+b*p*q+c*j*s-b*k*s;this.n33=c*i*m-e*g*m+e*f*q-b*i*q-c*f*s+b*g*s;this.n34=e*g*j-c*i*j-e*f*k+b*i*k+c*f*p-b*g*p;this.n41=h*k*m-g*o*m-h*j*q+f*o*q+g*j*n-f*k*n;this.n42=c*o*m-d*k*m+d*j*q-b*o*q-c*j*n+b*k*n;this.n43=d*g*m-c*h*m-d*f*q+b*h*q+c*f*n-b*g*n;this.n44=c*h*j-d*g*j+d*f*k-b*h*k-c*f*o+b*g*o;this.multiplyScalar(1/a.determinant());
+return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var i=g*h,j=g*e,k=d*h,o=d*e;this.n11=i+o*c;this.n12=k*c-j;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=j*c-k;this.n32=o+i*c;this.n33=f*g;break;case "ZXY":i=g*h;j=g*e;k=d*h;o=d*e;this.n11=i-o*c;this.n12=-f*e;this.n13=k+j*c;this.n21=j+k*c;this.n22=f*h;this.n23=o-i*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":i=
+f*h;j=f*e;k=c*h;o=c*e;this.n11=g*h;this.n12=k*d-j;this.n13=i*d+o;this.n21=g*e;this.n22=o*d+i;this.n23=j*d-k;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":i=f*g;j=f*d;k=c*g;o=c*d;this.n11=g*h;this.n12=o-i*e;this.n13=k*e+j;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=j*e+k;this.n33=i-o*e;break;case "XZY":i=f*g;j=f*d;k=c*g;o=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=i*e+o;this.n22=f*h;this.n23=j*e-k;this.n31=k*e-j;this.n32=c*h;this.n33=o*e+i;break;default:i=f*h,j=f*
+e,k=c*h,o=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=j+k*d,this.n22=i-o*d,this.n23=-c*g,this.n31=o-i*d,this.n32=k+j*d,this.n33=f*g}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,h=d+d,a=b*f,i=b*g;b*=h;var j=c*g;c*=h;d*=h;f*=e;g*=e;e*=h;this.n11=1-(j+d);this.n12=i-e;this.n13=b+g;this.n21=i+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;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},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(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},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();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*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);else if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);else if(a.x===0&&a.y===
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();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*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);else if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);else if(a.x===0&&a.y===
-0&&a.z===1)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e);c/=f;d/=f;e/=f;var f=c*c,g=d*d,h=e*e,i=Math.cos(b),k=Math.sin(b),j=1-i,o=c*d*j,p=c*e*j;j*=d*e;c*=k;var m=d*k;k*=e;e=f+(1-f)*i;f=o+k;d=p-m;o-=k;g+=(1-g)*i;k=j+c;p+=m;j-=c;h+=(1-h)*i;var i=this.n11,c=this.n21,m=this.n31,q=this.n41,n=this.n12,s=this.n22,r=this.n32,u=this.n42,t=this.n13,z=this.n23,A=this.n33,E=this.n43;this.n11=e*i+f*n+d*t;this.n21=e*c+f*s+d*z;this.n31=e*m+f*r+d*A;this.n41=e*q+f*u+d*E;this.n12=o*i+g*n+k*
-t;this.n22=o*c+g*s+k*z;this.n32=o*m+g*r+k*A;this.n42=o*q+g*u+k*E;this.n13=p*i+j*n+h*t;this.n23=p*c+j*s+h*z;this.n33=p*m+j*r+h*A;this.n43=p*q+j*u+h*E;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,i=this.n43,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*f;this.n22=k*c+a*g;this.n32=k*d+a*h;this.n42=k*e+a*i;this.n13=k*f-a*b;this.n23=k*g-a*c;this.n33=k*h-a*d;this.n43=k*i-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,
-e=this.n41,f=this.n13,g=this.n23,h=this.n33,i=this.n43,k=Math.cos(a),a=Math.sin(a);this.n11=k*b-a*f;this.n21=k*c-a*g;this.n31=k*d-a*h;this.n41=k*e-a*i;this.n13=k*f+a*b;this.n23=k*g+a*c;this.n33=k*h+a*d;this.n43=k*i+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,i=this.n42,k=Math.cos(a),a=Math.sin(a);this.n11=k*b+a*f;this.n21=k*c+a*g;this.n31=k*d+a*h;this.n41=k*e+a*i;this.n12=k*f-a*b;this.n22=k*g-a*c;this.n32=k*h-a*d;this.n42=k*
+0&&a.z===1)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e);c/=f;d/=f;e/=f;var f=c*c,g=d*d,h=e*e,i=Math.cos(b),j=Math.sin(b),k=1-i,o=c*d*k,p=c*e*k;k*=d*e;c*=j;var m=d*j;j*=e;e=f+(1-f)*i;f=o+j;d=p-m;o-=j;g+=(1-g)*i;j=k+c;p+=m;k-=c;h+=(1-h)*i;var i=this.n11,c=this.n21,m=this.n31,q=this.n41,n=this.n12,s=this.n22,r=this.n32,u=this.n42,t=this.n13,A=this.n23,B=this.n33,z=this.n43;this.n11=e*i+f*n+d*t;this.n21=e*c+f*s+d*A;this.n31=e*m+f*r+d*B;this.n41=e*q+f*u+d*z;this.n12=o*i+g*n+j*
+t;this.n22=o*c+g*s+j*A;this.n32=o*m+g*r+j*B;this.n42=o*q+g*u+j*z;this.n13=p*i+k*n+h*t;this.n23=p*c+k*s+h*A;this.n33=p*m+k*r+h*B;this.n43=p*q+k*u+h*z;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,i=this.n43,j=Math.cos(a),a=Math.sin(a);this.n12=j*b+a*f;this.n22=j*c+a*g;this.n32=j*d+a*h;this.n42=j*e+a*i;this.n13=j*f-a*b;this.n23=j*g-a*c;this.n33=j*h-a*d;this.n43=j*i-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,
+e=this.n41,f=this.n13,g=this.n23,h=this.n33,i=this.n43,j=Math.cos(a),a=Math.sin(a);this.n11=j*b-a*f;this.n21=j*c-a*g;this.n31=j*d-a*h;this.n41=j*e-a*i;this.n13=j*f+a*b;this.n23=j*g+a*c;this.n33=j*h+a*d;this.n43=j*i+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,i=this.n42,j=Math.cos(a),a=Math.sin(a);this.n11=j*b+a*f;this.n21=j*c+a*g;this.n31=j*d+a*h;this.n41=j*e+a*i;this.n12=j*f-a*b;this.n22=j*g-a*c;this.n32=j*h-a*d;this.n42=j*
 i-a*e;return this},translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
 i-a*e;return this},translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
-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,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,o=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*k;if(a===0)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*i;c[6]=a*k;c[7]=a*j;c[8]=a*o;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,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,o=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*j;if(a===0)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*i;c[6]=a*j;c[7]=a*k;c[8]=a*o;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};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.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};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,f){var g,h,i,k;g=new THREE.Matrix4;h=b-a;i=c-d;k=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/i;g.n23=0;g.n24=-((c+d)/i);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((f+e)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,h,i,j;g=new THREE.Matrix4;h=b-a;i=c-d;j=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/i;g.n23=0;g.n24=-((c+d)/i);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+e)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
 THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
 THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
 !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={constructor:THREE.Object3D,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)},add:function(a){if(this.children.indexOf(a)===
 THREE.Object3D.prototype={constructor:THREE.Object3D,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)},add:function(a){if(this.children.indexOf(a)===
 -1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=void 0;this.children.splice(b,1);for(b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeObject(a)}},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;
 -1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=void 0;this.children.splice(b,1);for(b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeObject(a)}},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),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=k[i]=k[i]||new THREE.RenderableVertex;i++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var e,f,g=[],h,i,k=[],
-j,o,p=[],m,q=[],n,s,r=[],u,t,z=[],A={objects:[],sprites:[],lights:[],elements:[]},E=new THREE.Vector3,D=new THREE.Vector4,B=new THREE.Matrix4,w=new THREE.Matrix4,G=new THREE.Frustum,y=new THREE.Vector4,K=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);B.multiply(b.projectionMatrix,b.matrixWorldInverse);B.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);B.multiply(b.matrixWorld,
-b.projectionMatrixInverse);B.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;A.objects.length=0;A.sprites.length=0;A.lights.length=0;var g=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||G.contains(b))?(B.multiplyVector3(E.copy(b.position)),e=a(),e.object=
-b,e.z=E.z,A.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(B.multiplyVector3(E.copy(b.position)),e=a(),e.object=b,e.z=E.z,A.sprites.push(e)):b instanceof THREE.Light&&A.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&A.objects.sort(c);return A};this.projectScene=function(a,e,f){var g=e.near,E=e.far,l,W,v,X,L,Z,da,ba,T,U,O,aa,ca,ga,va,fa;t=s=m=o=0;A.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);B.multiply(e.projectionMatrix,e.matrixWorldInverse);G.setFromMatrix(B);A=this.projectGraph(a,!1);a=0;for(l=A.objects.length;a<l;a++)if(T=A.objects[a].object,U=T.matrixWorld,aa=T.material,i=0,T instanceof THREE.Mesh){O=T.geometry;ca=T.geometry.materials;X=O.vertices;ga=O.faces;va=O.faceVertexUvs;O=T.matrixRotationWorld.extractRotation(U);W=0;for(v=X.length;W<v;W++)h=b(),h.positionWorld.copy(X[W].position),U.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),B.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<E;X=0;for(W=ga.length;X<W;X++){v=ga[X];if(v instanceof THREE.Face3)if(L=k[v.a],Z=k[v.b],da=k[v.c],L.visible&&Z.visible&&da.visible&&(T.doubleSided||T.flipSided!=(da.positionScreen.x-L.positionScreen.x)*(Z.positionScreen.y-L.positionScreen.y)-(da.positionScreen.y-L.positionScreen.y)*(Z.positionScreen.x-
-L.positionScreen.x)<0))ba=p[o]=p[o]||new THREE.RenderableFace3,o++,j=ba,j.v1.copy(L),j.v2.copy(Z),j.v3.copy(da);else continue;else if(v instanceof THREE.Face4)if(L=k[v.a],Z=k[v.b],da=k[v.c],ba=k[v.d],L.visible&&Z.visible&&da.visible&&ba.visible&&(T.doubleSided||T.flipSided!=((ba.positionScreen.x-L.positionScreen.x)*(Z.positionScreen.y-L.positionScreen.y)-(ba.positionScreen.y-L.positionScreen.y)*(Z.positionScreen.x-L.positionScreen.x)<0||(Z.positionScreen.x-da.positionScreen.x)*(ba.positionScreen.y-
-da.positionScreen.y)-(Z.positionScreen.y-da.positionScreen.y)*(ba.positionScreen.x-da.positionScreen.x)<0)))fa=q[m]=q[m]||new THREE.RenderableFace4,m++,j=fa,j.v1.copy(L),j.v2.copy(Z),j.v3.copy(da),j.v4.copy(ba);else continue;j.normalWorld.copy(v.normal);O.multiplyVector3(j.normalWorld);j.centroidWorld.copy(v.centroid);U.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);B.multiplyVector3(j.centroidScreen);da=v.vertexNormals;L=0;for(Z=da.length;L<Z;L++)ba=j.vertexNormalsWorld[L],
-ba.copy(da[L]),O.multiplyVector3(ba);L=0;for(Z=va.length;L<Z;L++)if(fa=va[L][X]){da=0;for(ba=fa.length;da<ba;da++)j.uvs[L][da]=fa[da]}j.material=aa;j.faceMaterial=v.materialIndex!==null?ca[v.materialIndex]:null;j.z=j.centroidScreen.z;A.elements.push(j)}}else if(T instanceof THREE.Line){w.multiply(B,U);X=T.geometry.vertices;L=b();L.positionScreen.copy(X[0].position);w.multiplyVector4(L.positionScreen);W=1;for(v=X.length;W<v;W++)if(L=b(),L.positionScreen.copy(X[W].position),w.multiplyVector4(L.positionScreen),
-Z=k[i-2],y.copy(L.positionScreen),K.copy(Z.positionScreen),d(y,K))y.multiplyScalar(1/y.w),K.multiplyScalar(1/K.w),T=r[s]=r[s]||new THREE.RenderableLine,s++,n=T,n.v1.positionScreen.copy(y),n.v2.positionScreen.copy(K),n.z=Math.max(y.z,K.z),n.material=aa,A.elements.push(n)}a=0;for(l=A.sprites.length;a<l;a++)if(T=A.sprites[a].object,U=T.matrixWorld,T instanceof THREE.Particle&&(D.set(U.n14,U.n24,U.n34,1),B.multiplyVector4(D),D.z/=D.w,D.z>0&&D.z<1))g=z[t]=z[t]||new THREE.RenderableParticle,t++,u=g,u.x=
-D.x/D.w,u.y=D.y/D.w,u.z=D.z,u.rotation=T.rotation.z,u.scale.x=T.scale.x*Math.abs(u.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),u.scale.y=T.scale.y*Math.abs(u.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),u.material=T.material,A.elements.push(u);f&&A.elements.sort(c);return A}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=j[i]=j[i]||new THREE.RenderableVertex;i++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var e,f,g=[],h,i,j=[],
+k,o,p=[],m,q=[],n,s,r=[],u,t,A=[],B={objects:[],sprites:[],lights:[],elements:[]},z=new THREE.Vector3,D=new THREE.Vector4,H=new THREE.Matrix4,w=new THREE.Matrix4,F=new THREE.Frustum,y=new THREE.Vector4,K=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);H.multiply(b.projectionMatrix,b.matrixWorldInverse);H.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);H.multiply(b.matrixWorld,
+b.projectionMatrixInverse);H.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;B.objects.length=0;B.sprites.length=0;B.lights.length=0;var g=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||F.contains(b))?(H.multiplyVector3(z.copy(b.position)),e=a(),e.object=
+b,e.z=z.z,B.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(H.multiplyVector3(z.copy(b.position)),e=a(),e.object=b,e.z=z.z,B.sprites.push(e)):b instanceof THREE.Light&&B.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&B.objects.sort(c);return B};this.projectScene=function(a,e,f){var g=e.near,R=e.far,l,z,v,W,M,Z,ca,aa,ea,U,L,V,ba,ga,va,fa;t=s=m=o=0;B.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);H.multiply(e.projectionMatrix,e.matrixWorldInverse);F.setFromMatrix(H);B=this.projectGraph(a,!1);a=0;for(l=B.objects.length;a<l;a++)if(ea=B.objects[a].object,U=ea.matrixWorld,V=ea.material,i=0,ea instanceof THREE.Mesh){L=ea.geometry;ba=ea.geometry.materials;W=L.vertices;ga=L.faces;va=L.faceVertexUvs;L=ea.matrixRotationWorld.extractRotation(U);z=0;for(v=W.length;z<v;z++)h=b(),h.positionWorld.copy(W[z].position),U.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),H.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<R;W=0;for(z=ga.length;W<z;W++){v=ga[W];if(v instanceof THREE.Face3)if(M=j[v.a],Z=j[v.b],ca=j[v.c],M.visible&&Z.visible&&ca.visible&&(ea.doubleSided||ea.flipSided!=(ca.positionScreen.x-M.positionScreen.x)*(Z.positionScreen.y-M.positionScreen.y)-(ca.positionScreen.y-M.positionScreen.y)*(Z.positionScreen.x-
+M.positionScreen.x)<0))aa=p[o]=p[o]||new THREE.RenderableFace3,o++,k=aa,k.v1.copy(M),k.v2.copy(Z),k.v3.copy(ca);else continue;else if(v instanceof THREE.Face4)if(M=j[v.a],Z=j[v.b],ca=j[v.c],aa=j[v.d],M.visible&&Z.visible&&ca.visible&&aa.visible&&(ea.doubleSided||ea.flipSided!=((aa.positionScreen.x-M.positionScreen.x)*(Z.positionScreen.y-M.positionScreen.y)-(aa.positionScreen.y-M.positionScreen.y)*(Z.positionScreen.x-M.positionScreen.x)<0||(Z.positionScreen.x-ca.positionScreen.x)*(aa.positionScreen.y-
+ca.positionScreen.y)-(Z.positionScreen.y-ca.positionScreen.y)*(aa.positionScreen.x-ca.positionScreen.x)<0)))fa=q[m]=q[m]||new THREE.RenderableFace4,m++,k=fa,k.v1.copy(M),k.v2.copy(Z),k.v3.copy(ca),k.v4.copy(aa);else continue;k.normalWorld.copy(v.normal);L.multiplyVector3(k.normalWorld);k.centroidWorld.copy(v.centroid);U.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);H.multiplyVector3(k.centroidScreen);ca=v.vertexNormals;M=0;for(Z=ca.length;M<Z;M++)aa=k.vertexNormalsWorld[M],
+aa.copy(ca[M]),L.multiplyVector3(aa);M=0;for(Z=va.length;M<Z;M++)if(fa=va[M][W]){ca=0;for(aa=fa.length;ca<aa;ca++)k.uvs[M][ca]=fa[ca]}k.material=V;k.faceMaterial=v.materialIndex!==null?ba[v.materialIndex]:null;k.z=k.centroidScreen.z;B.elements.push(k)}}else if(ea instanceof THREE.Line){w.multiply(H,U);W=ea.geometry.vertices;M=b();M.positionScreen.copy(W[0].position);w.multiplyVector4(M.positionScreen);z=1;for(v=W.length;z<v;z++)if(M=b(),M.positionScreen.copy(W[z].position),w.multiplyVector4(M.positionScreen),
+Z=j[i-2],y.copy(M.positionScreen),K.copy(Z.positionScreen),d(y,K))y.multiplyScalar(1/y.w),K.multiplyScalar(1/K.w),ea=r[s]=r[s]||new THREE.RenderableLine,s++,n=ea,n.v1.positionScreen.copy(y),n.v2.positionScreen.copy(K),n.z=Math.max(y.z,K.z),n.material=V,B.elements.push(n)}a=0;for(l=B.sprites.length;a<l;a++)if(ea=B.sprites[a].object,U=ea.matrixWorld,ea instanceof THREE.Particle&&(D.set(U.n14,U.n24,U.n34,1),H.multiplyVector4(D),D.z/=D.w,D.z>0&&D.z<1))g=A[t]=A[t]||new THREE.RenderableParticle,t++,u=g,
+u.x=D.x/D.w,u.y=D.y/D.w,u.z=D.z,u.rotation=ea.rotation.z,u.scale.x=ea.scale.x*Math.abs(u.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),u.scale.y=ea.scale.y*Math.abs(u.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),u.material=ea.material,B.elements.push(u);f&&B.elements.sort(c);return B}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,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=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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,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=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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-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},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();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);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.normalize();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);a===0?this.w=this.z=this.y=this.x=0:(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,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;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,f=this.x,g=this.y,h=this.z,i=this.w,k=i*c+g*e-h*d,j=i*d+h*c-f*e,o=i*e+f*d-g*c,c=-f*
-c-g*d-h*e;b.x=k*i+c*-f+j*-h-o*-g;b.y=j*i+c*-g+o*-f-k*-h;b.z=o*i+c*-h+k*-g-j*-f;return b}};
+this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;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,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,k=i*d+h*c-f*e,o=i*e+f*d-g*c,c=-f*
+c-g*d-h*e;b.x=j*i+c*-f+k*-h-o*-g;b.y=k*i+c*-g+o*-f-j*-h;b.z=o*i+c*-h+j*-g-k*-f;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;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return 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),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.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;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return 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),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){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.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,f){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.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,e,f,g){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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
@@ -88,14 +88,14 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid
 b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],f=this.vertices[c.c],g.sub(f.position,e.position),h.sub(d.position,e.position),g.crossSelf(h),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices===void 0){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++)if(c=
 b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],f=this.vertices[c.c],g.sub(f.position,e.position),h.sub(d.position,e.position),g.crossSelf(h),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices===void 0){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++)if(c=
 this.faces[a],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],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),
 this.faces[a],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],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):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],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])):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(a,
 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],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])):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(a,
-b,c,d,e,f,B){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;j=g[e];o=g[f];p=g[B];m=i.x-h.x;q=k.x-h.x;n=i.y-h.y;s=k.y-h.y;r=i.z-h.z;u=k.z-h.z;t=o.u-j.u;z=p.u-j.u;A=o.v-j.v;E=p.v-j.v;D=1/(t*E-z*A);y.set((E*m-A*q)*D,(E*n-A*s)*D,(E*r-A*u)*D);K.set((t*q-z*m)*D,(t*s-z*n)*D,(t*u-z*r)*D);w[b].addSelf(y);w[c].addSelf(y);w[d].addSelf(y);G[b].addSelf(K);G[c].addSelf(K);G[d].addSelf(K)}var b,c,d,e,f,g,h,i,k,j,o,p,m,q,n,s,r,u,t,z,A,E,D,B,w=[],G=[],y=new THREE.Vector3,K=new THREE.Vector3,
-$=new THREE.Vector3,Q=new THREE.Vector3,Y=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)w[b]=new THREE.Vector3,G[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var S=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)Y.copy(f.vertexNormals[d]),e=f[S[d]],
-B=w[e],$.copy(B),$.subSelf(Y.multiplyScalar(Y.dot(B))).normalize(),Q.cross(f.vertexNormals[d],B),e=Q.dot(G[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
-this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
+b,c,d,e,f,H){h=a.vertices[b].position;i=a.vertices[c].position;j=a.vertices[d].position;k=g[e];o=g[f];p=g[H];m=i.x-h.x;q=j.x-h.x;n=i.y-h.y;s=j.y-h.y;r=i.z-h.z;u=j.z-h.z;t=o.u-k.u;A=p.u-k.u;B=o.v-k.v;z=p.v-k.v;D=1/(t*z-A*B);y.set((z*m-B*q)*D,(z*n-B*s)*D,(z*r-B*u)*D);K.set((t*q-A*m)*D,(t*s-A*n)*D,(t*u-A*r)*D);w[b].addSelf(y);w[c].addSelf(y);w[d].addSelf(y);F[b].addSelf(K);F[c].addSelf(K);F[d].addSelf(K)}var b,c,d,e,f,g,h,i,j,k,o,p,m,q,n,s,r,u,t,A,B,z,D,H,w=[],F=[],y=new THREE.Vector3,K=new THREE.Vector3,
+$=new THREE.Vector3,Q=new THREE.Vector3,X=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)w[b]=new THREE.Vector3,F[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var T=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)X.copy(f.vertexNormals[d]),e=f[T[d]],
+H=w[e],$.copy(H),$.subSelf(X.multiplyScalar(X.dot(H))).normalize(),Q.cross(f.vertexNormals[d],H),e=Q.dot(F[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
+this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
-THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,k,j,o,p;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;k=this.points[c[0]];j=this.points[c[1]];
-o=this.points[c[2]];p=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,j.x,o.x,p.x,g,h,i);d.y=b(k.y,j.y,o.y,p.y,g,h,i);d.z=b(k.z,j.z,o.z,p.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),
-f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,j=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=j.chunks[b]-j.chunks[b-1];g=Math.ceil(a*c/j.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=
+THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,j,k,o,p;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;j=this.points[c[0]];k=this.points[c[1]];
+o=this.points[c[2]];p=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,k.x,o.x,p.x,g,h,i);d.y=b(j.y,k.y,o.y,p.y,g,h,i);d.z=b(j.z,k.z,o.z,p.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),
+f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,k=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=k.chunks[b]-k.chunks[b-1];g=Math.ceil(a*c/k.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=
 h}};THREE.Edge=function(a,b,c,d){this.vertices=[a,b];this.vertexIndices=[c,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
 h}};THREE.Edge=function(a,b,c,d){this.vertices=[a,b];this.vertexIndices=[c,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
 THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
 THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
@@ -153,47 +153,47 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=
 THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.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);var b=this.__objectsRemoved.indexOf(a);b!==-1&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.addObject(a.children[b])};
 THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.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);var b=this.__objectsRemoved.indexOf(a);b!==-1&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.addObject(a.children[b])};
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),b!==-1&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),b!==-1&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
 THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b!==void 0?b:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==void 0?b:2.5E-4};
 THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b!==void 0?b:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==void 0?b:2.5E-4};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var i,k,j,o,p,m,q,n;a=b.projectScene(c,d);i=0;for(k=a.length;i<k;i++)if(p=a[i],p instanceof THREE.RenderableParticle){q=p.x*e+e;n=p.y*f+f;j=0;for(o=p.material.length;j<o;j++)if(m=p.material[j],m instanceof THREE.ParticleDOMMaterial)m=m.domElement,m.style.left=q+"px",m.style.top=n+"px"}}};
-THREE.CanvasRenderer=function(a){function b(a){if(u!=a)n.globalAlpha=u=a}function c(a){if(t!=a){switch(a){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}t=a}}function d(a){if(z!=a)n.strokeStyle=z=a}function e(a){if(A!=a)n.fillStyle=A=a}var f=this,g,h,i,k=new THREE.Projector,a=a||{},j=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
-o,p,m,q,n=j.getContext("2d"),s=new THREE.Color(0),r=0,u=1,t=0,z=null,A=null,E=null,D=null,B=null,w,G,y,K,$=new THREE.RenderableVertex,Q=new THREE.RenderableVertex,Y,S,R,l,W,v,X,L,Z,da,ba,T,U=new THREE.Color,O=new THREE.Color,aa=new THREE.Color,ca=new THREE.Color,ga=new THREE.Color,va=[],fa=[],na,ja,sa,qa,Ba,wa,xa,ya,za,Aa,la=new THREE.Rectangle,ta=new THREE.Rectangle,pa=new THREE.Rectangle,Ia=!1,ea=new THREE.Color,V=new THREE.Color,H=new THREE.Color,ra=new THREE.Vector3,Ka,La,Oa,Ca,Ma,C,a=16;Ka=document.createElement("canvas");
-Ka.width=Ka.height=2;La=Ka.getContext("2d");La.fillStyle="rgba(0,0,0,1)";La.fillRect(0,0,2,2);Oa=La.getImageData(0,0,2,2);Ca=Oa.data;Ma=document.createElement("canvas");Ma.width=Ma.height=a;C=Ma.getContext("2d");C.translate(-a/2,-a/2);C.scale(a,a);a--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;p=b;m=Math.floor(o/2);q=Math.floor(p/2);j.width=o;j.height=p;la.set(-m,-q,m,q);ta.set(-m,-q,m,q);u=1;t=0;B=
-D=E=A=z=null};this.setClearColor=function(a,b){s.copy(a);r=b;ta.set(-m,-q,m,q)};this.setClearColorHex=function(a,b){s.setHex(a);r=b;ta.set(-m,-q,m,q)};this.clear=function(){n.setTransform(1,0,0,-1,m,q);ta.isEmpty()||(ta.minSelf(la),ta.inflate(2),r<1&&n.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight())),r>0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+r+")"),n.fillRect(Math.floor(ta.getX()),
-Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(a,j){function o(a){var b,c,d,e;ea.setRGB(0,0,0);V.setRGB(0,0,0);H.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(ea.r+=e.r,ea.g+=e.g,ea.b+=e.b):d instanceof THREE.DirectionalLight?(V.r+=e.r,V.g+=e.g,V.b+=e.b):d instanceof THREE.PointLight&&(H.r+=e.r,H.g+=e.g,H.b+=e.b)}function p(a,b,c,d){var e,f,g,ea,h,l;e=0;for(f=a.length;e<f;e++)g=a[e],ea=g.color,
-g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),l=c.dot(h),l<=0||(l*=g.intensity,d.r+=ea.r*l,d.g+=ea.g*l,d.b+=ea.b*l)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),l=c.dot(ra.sub(h,b).normalize()),l<=0||(l*=g.distance==0?1:1-Math.min(b.distanceTo(h)/g.distance,1),l!=0&&(l*=g.intensity,d.r+=ea.r*l,d.g+=ea.g*l,d.b+=ea.b*l)))}function s(a,f,g){b(g.opacity);c(g.blending);var ea,h,l,i,j,H;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=g.map.image,j=i.width>>
-1,H=i.height>>1,g=f.scale.x*m,l=f.scale.y*q,ea=g*j,h=l*H,pa.set(a.x-ea,a.y-h,a.x+ea,a.y+h),la.intersects(pa)&&(n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(g,-l),n.translate(-j,-H),n.drawImage(i,0,0),n.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(ea=f.scale.x*m,h=f.scale.y*q,pa.set(a.x-ea,a.y-h,a.x+ea,a.y+h),la.intersects(pa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(ea,h),g.program(n),n.restore()))}
-function r(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(E!=a)n.lineWidth=E=a;a=g.linecap;if(D!=a)n.lineCap=D=a;a=g.linejoin;if(B!=a)n.lineJoin=B=a;d(g.color.getContextStyle());n.stroke();pa.inflate(g.linewidth*2)}}function u(a,d,e,g,h,H,k,V){f.info.render.vertices+=3;f.info.render.faces++;b(V.opacity);c(V.blending);Y=a.positionScreen.x;
-S=a.positionScreen.y;R=d.positionScreen.x;l=d.positionScreen.y;W=e.positionScreen.x;v=e.positionScreen.y;z(Y,S,R,l,W,v);if(V instanceof THREE.MeshBasicMaterial)if(V.map)V.map.mapping instanceof THREE.UVMapping&&(qa=k.uvs[0],Pa(Y,S,R,l,W,v,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[H].u,qa[H].v,V.map));else if(V.envMap){if(V.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=j.matrixWorldInverse,ra.copy(k.vertexNormalsWorld[g]),Ba=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,wa=-(ra.x*a.n21+ra.y*a.n22+
-ra.z*a.n23)*0.5+0.5,ra.copy(k.vertexNormalsWorld[h]),xa=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,ya=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(k.vertexNormalsWorld[H]),za=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,Aa=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,Pa(Y,S,R,l,W,v,Ba,wa,xa,ya,za,Aa,V.envMap)}else V.wireframe?J(V.color,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Ea(V.color);else if(V instanceof THREE.MeshLambertMaterial)V.map&&!V.wireframe&&(V.map.mapping instanceof
-THREE.UVMapping&&(qa=k.uvs[0],Pa(Y,S,R,l,W,v,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[H].u,qa[H].v,V.map)),c(THREE.SubtractiveBlending)),Ia?!V.wireframe&&V.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==3?(O.r=aa.r=ca.r=ea.r,O.g=aa.g=ca.g=ea.g,O.b=aa.b=ca.b=ea.b,p(i,k.v1.positionWorld,k.vertexNormalsWorld[0],O),p(i,k.v2.positionWorld,k.vertexNormalsWorld[1],aa),p(i,k.v3.positionWorld,k.vertexNormalsWorld[2],ca),O.r=Math.max(0,Math.min(V.color.r*O.r,1)),O.g=Math.max(0,Math.min(V.color.g*O.g,
-1)),O.b=Math.max(0,Math.min(V.color.b*O.b,1)),aa.r=Math.max(0,Math.min(V.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(V.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(V.color.b*aa.b,1)),ca.r=Math.max(0,Math.min(V.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(V.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(V.color.b*ca.b,1)),ga.r=(aa.r+ca.r)*0.5,ga.g=(aa.g+ca.g)*0.5,ga.b=(aa.b+ca.b)*0.5,sa=P(O,aa,ca,ga),Ja(Y,S,R,l,W,v,0,0,1,0,0,1,sa)):(U.r=ea.r,U.g=ea.g,U.b=ea.b,p(i,k.centroidWorld,k.normalWorld,U),U.r=Math.max(0,
-Math.min(V.color.r*U.r,1)),U.g=Math.max(0,Math.min(V.color.g*U.g,1)),U.b=Math.max(0,Math.min(V.color.b*U.b,1)),V.wireframe?J(U,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Ea(U)):V.wireframe?J(V.color,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Ea(V.color);else if(V instanceof THREE.MeshDepthMaterial)na=j.near,ja=j.far,O.r=O.g=O.b=1-M(a.positionScreen.z,na,ja),aa.r=aa.g=aa.b=1-M(d.positionScreen.z,na,ja),ca.r=ca.g=ca.b=1-M(e.positionScreen.z,na,ja),ga.r=(aa.r+ca.r)*
-0.5,ga.g=(aa.g+ca.g)*0.5,ga.b=(aa.b+ca.b)*0.5,sa=P(O,aa,ca,ga),Ja(Y,S,R,l,W,v,0,0,1,0,0,1,sa);else if(V instanceof THREE.MeshNormalMaterial)U.r=N(k.normalWorld.x),U.g=N(k.normalWorld.y),U.b=N(k.normalWorld.z),V.wireframe?J(U,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Ea(U)}function t(a,d,e,g,h,V,H,k,n){f.info.render.vertices+=4;f.info.render.faces++;b(k.opacity);c(k.blending);if(k.map||k.envMap)u(a,d,g,0,1,3,H,k,n),u(h,e,V,1,2,3,H,k,n);else if(Y=a.positionScreen.x,S=a.positionScreen.y,
-R=d.positionScreen.x,l=d.positionScreen.y,W=e.positionScreen.x,v=e.positionScreen.y,X=g.positionScreen.x,L=g.positionScreen.y,Z=h.positionScreen.x,da=h.positionScreen.y,ba=V.positionScreen.x,T=V.positionScreen.y,k instanceof THREE.MeshBasicMaterial)A(Y,S,R,l,W,v,X,L),k.wireframe?J(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Ea(k.color);else if(k instanceof THREE.MeshLambertMaterial)Ia?!k.wireframe&&k.shading==THREE.SmoothShading&&H.vertexNormalsWorld.length==4?(O.r=aa.r=ca.r=
-ga.r=ea.r,O.g=aa.g=ca.g=ga.g=ea.g,O.b=aa.b=ca.b=ga.b=ea.b,p(i,H.v1.positionWorld,H.vertexNormalsWorld[0],O),p(i,H.v2.positionWorld,H.vertexNormalsWorld[1],aa),p(i,H.v4.positionWorld,H.vertexNormalsWorld[3],ca),p(i,H.v3.positionWorld,H.vertexNormalsWorld[2],ga),O.r=Math.max(0,Math.min(k.color.r*O.r,1)),O.g=Math.max(0,Math.min(k.color.g*O.g,1)),O.b=Math.max(0,Math.min(k.color.b*O.b,1)),aa.r=Math.max(0,Math.min(k.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(k.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(k.color.b*
-aa.b,1)),ca.r=Math.max(0,Math.min(k.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(k.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(k.color.b*ca.b,1)),ga.r=Math.max(0,Math.min(k.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(k.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(k.color.b*ga.b,1)),sa=P(O,aa,ca,ga),z(Y,S,R,l,X,L),Ja(Y,S,R,l,X,L,0,0,1,0,0,1,sa),z(Z,da,W,v,ba,T),Ja(Z,da,W,v,ba,T,1,0,1,1,0,1,sa)):(U.r=ea.r,U.g=ea.g,U.b=ea.b,p(i,H.centroidWorld,H.normalWorld,U),U.r=Math.max(0,Math.min(k.color.r*U.r,1)),U.g=Math.max(0,
-Math.min(k.color.g*U.g,1)),U.b=Math.max(0,Math.min(k.color.b*U.b,1)),A(Y,S,R,l,W,v,X,L),k.wireframe?J(U,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Ea(U)):(A(Y,S,R,l,W,v,X,L),k.wireframe?J(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Ea(k.color));else if(k instanceof THREE.MeshNormalMaterial)U.r=N(H.normalWorld.x),U.g=N(H.normalWorld.y),U.b=N(H.normalWorld.z),A(Y,S,R,l,W,v,X,L),k.wireframe?J(U,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Ea(U);
-else if(k instanceof THREE.MeshDepthMaterial)na=j.near,ja=j.far,O.r=O.g=O.b=1-M(a.positionScreen.z,na,ja),aa.r=aa.g=aa.b=1-M(d.positionScreen.z,na,ja),ca.r=ca.g=ca.b=1-M(g.positionScreen.z,na,ja),ga.r=ga.g=ga.b=1-M(e.positionScreen.z,na,ja),sa=P(O,aa,ca,ga),z(Y,S,R,l,X,L),Ja(Y,S,R,l,X,L,0,0,1,0,0,1,sa),z(Z,da,W,v,ba,T),Ja(Z,da,W,v,ba,T,1,0,1,1,0,1,sa)}function z(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function A(a,b,c,d,e,f,g,ea){n.beginPath();
-n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,ea);n.lineTo(a,b);n.closePath()}function J(a,b,c,e){if(E!=b)n.lineWidth=E=b;if(D!=c)n.lineCap=D=c;if(B!=e)n.lineJoin=B=e;d(a.getContextStyle());n.stroke();pa.inflate(b*2)}function Ea(a){e(a.getContextStyle());n.fill()}function Pa(a,b,c,d,f,g,ea,h,l,i,k,j,V){if(V.image.width!=0){if(V.needsUpdate==!0||va[V.id]==void 0){var H=V.wrapS==THREE.RepeatWrapping,m=V.wrapT==THREE.RepeatWrapping;va[V.id]=n.createPattern(V.image,H&&m?"repeat":H&&!m?"repeat-x":
-!H&&m?"repeat-y":"no-repeat");V.needsUpdate=!1}e(va[V.id]);var H=V.offset.x/V.repeat.x,m=V.offset.y/V.repeat.y,o=V.image.width*V.repeat.x,p=V.image.height*V.repeat.y,ea=(ea+H)*o,h=(h+m)*p,l=(l+H)*o,i=(i+m)*p,k=(k+H)*o,j=(j+m)*p;c-=a;d-=b;f-=a;g-=b;l-=ea;i-=h;k-=ea;j-=h;H=l*j-k*i;if(H==0){if(fa[V.id]==void 0)b=document.createElement("canvas"),b.width=V.image.width,b.height=V.image.height,a=b.getContext("2d"),a.drawImage(V.image,0,0),fa[V.id]=a.getImageData(0,0,V.image.width,V.image.height).data,delete b;
-b=fa[V.id];ea=(Math.floor(ea)+Math.floor(h)*V.image.width)*4;U.setRGB(b[ea]/255,b[ea+1]/255,b[ea+2]/255);Ea(U)}else H=1/H,V=(j*c-i*f)*H,i=(j*d-i*g)*H,c=(l*f-k*c)*H,d=(l*g-k*d)*H,a=a-V*ea-c*h,ea=b-i*ea-d*h,n.save(),n.transform(V,i,c,d,a,ea),n.fill(),n.restore()}}function Ja(a,b,c,d,e,f,g,ea,h,l,i,V,k){var j,H;j=k.width-1;H=k.height-1;g*=j;ea*=H;h*=j;l*=H;i*=j;V*=H;c-=a;d-=b;e-=a;f-=b;h-=g;l-=ea;i-=g;V-=ea;H=1/(h*V-i*l);j=(V*c-l*e)*H;l=(V*d-l*f)*H;c=(h*e-i*c)*H;d=(h*f-i*d)*H;a=a-j*g-c*ea;b=b-l*g-d*
-ea;n.save();n.transform(j,l,c,d,a,b);n.clip();n.drawImage(k,0,0);n.restore()}function P(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),ea=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),l=~~(c.g*255),c=~~(c.b*255),i=~~(d.r*255),V=~~(d.g*255),d=~~(d.b*255);Ca[0]=e<0?0:e>255?255:e;Ca[1]=f<0?0:f>255?255:f;Ca[2]=a<0?0:a>255?255:a;Ca[4]=g<0?0:g>255?255:g;Ca[5]=ea<0?0:ea>255?255:ea;Ca[6]=b<0?0:b>255?255:b;Ca[8]=h<0?0:h>255?255:h;Ca[9]=l<0?0:l>255?255:l;Ca[10]=c<0?0:c>255?255:c;Ca[12]=i<0?
-0:i>255?255:i;Ca[13]=V<0?0:V>255?255:V;Ca[14]=d<0?0:d>255?255:d;La.putImageData(Oa,0,0);C.drawImage(Ka,0,0);return Ma}function M(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function N(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Fa(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Na,Qa,ua,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,q);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,j,this.sortElements);h=g.elements;
-i=g.lights;(Ia=i.length>0)&&o(i);Na=0;for(Qa=h.length;Na<Qa;Na++)if(ua=h[Na],Da=ua.material,Da=Da instanceof THREE.MeshFaceMaterial?ua.faceMaterial:Da,!(Da==null||Da.opacity==0)){pa.empty();if(ua instanceof THREE.RenderableParticle)w=ua,w.x*=m,w.y*=q,s(w,ua,Da,a);else if(ua instanceof THREE.RenderableLine)w=ua.v1,G=ua.v2,w.positionScreen.x*=m,w.positionScreen.y*=q,G.positionScreen.x*=m,G.positionScreen.y*=q,pa.addPoint(w.positionScreen.x,w.positionScreen.y),pa.addPoint(G.positionScreen.x,G.positionScreen.y),
-la.intersects(pa)&&r(w,G,ua,Da,a);else if(ua instanceof THREE.RenderableFace3)w=ua.v1,G=ua.v2,y=ua.v3,w.positionScreen.x*=m,w.positionScreen.y*=q,G.positionScreen.x*=m,G.positionScreen.y*=q,y.positionScreen.x*=m,y.positionScreen.y*=q,Da.overdraw&&(Fa(w.positionScreen,G.positionScreen),Fa(G.positionScreen,y.positionScreen),Fa(y.positionScreen,w.positionScreen)),pa.add3Points(w.positionScreen.x,w.positionScreen.y,G.positionScreen.x,G.positionScreen.y,y.positionScreen.x,y.positionScreen.y),la.intersects(pa)&&
-u(w,G,y,0,1,2,ua,Da,a);else if(ua instanceof THREE.RenderableFace4)w=ua.v1,G=ua.v2,y=ua.v3,K=ua.v4,w.positionScreen.x*=m,w.positionScreen.y*=q,G.positionScreen.x*=m,G.positionScreen.y*=q,y.positionScreen.x*=m,y.positionScreen.y*=q,K.positionScreen.x*=m,K.positionScreen.y*=q,$.positionScreen.copy(G.positionScreen),Q.positionScreen.copy(K.positionScreen),Da.overdraw&&(Fa(w.positionScreen,G.positionScreen),Fa(G.positionScreen,K.positionScreen),Fa(K.positionScreen,w.positionScreen),Fa(y.positionScreen,
-$.positionScreen),Fa(y.positionScreen,Q.positionScreen)),pa.addPoint(w.positionScreen.x,w.positionScreen.y),pa.addPoint(G.positionScreen.x,G.positionScreen.y),pa.addPoint(y.positionScreen.x,y.positionScreen.y),pa.addPoint(K.positionScreen.x,K.positionScreen.y),la.intersects(pa)&&t(w,G,y,K,$,Q,ua,Da,a);ta.addRectangle(pa)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,k;e=0;for(f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),k=c.dot(i),k<=0||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(w.sub(i,b).normalize()),k<=0||(k*=g.distance==0?1:1-Math.min(b.distanceTo(i)/g.distance,1),k!=0&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){G[a]==null&&(G[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),Y==0&&G[a].setAttribute("shape-rendering","crispEdges"));return G[a]}function c(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,j,o,p,m,q,n,s,r=new THREE.Rectangle,u=new THREE.Rectangle,t=!1,z=new THREE.Color,A=new THREE.Color,E=new THREE.Color,D=new THREE.Color,B,w=new THREE.Vector3,G=[],y=[],K,$,Q,Y=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
-faces:0}};this.setQuality=function(a){switch(a){case "high":Y=1;break;case "low":Y=0}};this.setSize=function(a,b){k=a;j=b;o=k/2;p=j/2;i.setAttribute("viewBox",-o+" "+-p+" "+k+" "+j);i.setAttribute("width",k);i.setAttribute("height",j);r.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var l,G,v,w;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);f=e.elements;
-g=e.lights;Q=$=0;if(t=g.length>0){A.setRGB(0,0,0);E.setRGB(0,0,0);D.setRGB(0,0,0);l=0;for(G=g.length;l<G;l++)w=g[l],v=w.color,w instanceof THREE.AmbientLight?(A.r+=v.r,A.g+=v.g,A.b+=v.b):w instanceof THREE.DirectionalLight?(E.r+=v.r,E.g+=v.g,E.b+=v.b):w instanceof THREE.PointLight&&(D.r+=v.r,D.g+=v.g,D.b+=v.b)}l=0;for(G=f.length;l<G;l++)if(v=f[l],w=v.material,w=w instanceof THREE.MeshFaceMaterial?v.faceMaterial:w,!(w==null||w.opacity==0))if(u.empty(),v instanceof THREE.RenderableParticle)m=v,m.x*=
-o,m.y*=-p;else if(v instanceof THREE.RenderableLine){if(m=v.v1,q=v.v2,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),r.intersects(u)){v=m;var L=q,Z=Q++;y[Z]==null&&(y[Z]=document.createElementNS("http://www.w3.org/2000/svg","line"),Y==0&&y[Z].setAttribute("shape-rendering","crispEdges"));K=y[Z];K.setAttribute("x1",v.positionScreen.x);K.setAttribute("y1",v.positionScreen.y);
-K.setAttribute("x2",L.positionScreen.x);K.setAttribute("y2",L.positionScreen.y);w instanceof THREE.LineBasicMaterial&&(K.setAttribute("style","fill: none; stroke: "+w.color.getContextStyle()+"; stroke-width: "+w.linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.linecap+"; stroke-linejoin: "+w.linejoin),i.appendChild(K))}}else if(v instanceof THREE.RenderableFace3){if(m=v.v1,q=v.v2,n=v.v3,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,n.positionScreen.x*=
-o,n.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),u.addPoint(n.positionScreen.x,n.positionScreen.y),r.intersects(u)){var L=m,Z=q,da=n;d.info.render.vertices+=3;d.info.render.faces++;K=b($++);K.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");w instanceof THREE.MeshBasicMaterial?z.copy(w.color):w instanceof THREE.MeshLambertMaterial?
-t?(z.r=A.r,z.g=A.g,z.b=A.b,a(g,v.centroidWorld,v.normalWorld,z),z.r=Math.max(0,Math.min(w.color.r*z.r,1)),z.g=Math.max(0,Math.min(w.color.g*z.g,1)),z.b=Math.max(0,Math.min(w.color.b*z.b,1))):z.copy(w.color):w instanceof THREE.MeshDepthMaterial?(B=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear),z.setRGB(B,B,B)):w instanceof THREE.MeshNormalMaterial&&z.setRGB(c(v.normalWorld.x),c(v.normalWorld.y),c(v.normalWorld.z));w.wireframe?K.setAttribute("style","fill: none; stroke: "+z.getContextStyle()+"; stroke-width: "+
-w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):K.setAttribute("style","fill: "+z.getContextStyle()+"; fill-opacity: "+w.opacity);i.appendChild(K)}}else if(v instanceof THREE.RenderableFace4&&(m=v.v1,q=v.v2,n=v.v3,s=v.v4,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,n.positionScreen.x*=o,n.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,
-m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),u.addPoint(n.positionScreen.x,n.positionScreen.y),u.addPoint(s.positionScreen.x,s.positionScreen.y),r.intersects(u))){var L=m,Z=q,da=n,ba=s;d.info.render.vertices+=4;d.info.render.faces++;K=b($++);K.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");w instanceof THREE.MeshBasicMaterial?
-z.copy(w.color):w instanceof THREE.MeshLambertMaterial?t?(z.r=A.r,z.g=A.g,z.b=A.b,a(g,v.centroidWorld,v.normalWorld,z),z.r=Math.max(0,Math.min(w.color.r*z.r,1)),z.g=Math.max(0,Math.min(w.color.g*z.g,1)),z.b=Math.max(0,Math.min(w.color.b*z.b,1))):z.copy(w.color):w instanceof THREE.MeshDepthMaterial?(B=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear),z.setRGB(B,B,B)):w instanceof THREE.MeshNormalMaterial&&z.setRGB(c(v.normalWorld.x),c(v.normalWorld.y),c(v.normalWorld.z));w.wireframe?K.setAttribute("style",
-"fill: none; stroke: "+z.getContextStyle()+"; stroke-width: "+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):K.setAttribute("style","fill: "+z.getContextStyle()+"; fill-opacity: "+w.opacity);i.appendChild(K)}}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var i,j,k,o,p,m,q,n;a=b.projectScene(c,d);i=0;for(j=a.length;i<j;i++)if(p=a[i],p instanceof THREE.RenderableParticle){q=p.x*e+e;n=p.y*f+f;k=0;for(o=p.material.length;k<o;k++)if(m=p.material[k],m instanceof THREE.ParticleDOMMaterial)m=m.domElement,m.style.left=q+"px",m.style.top=n+"px"}}};
+THREE.CanvasRenderer=function(a){function b(a){if(u!=a)n.globalAlpha=u=a}function c(a){if(t!=a){switch(a){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}t=a}}function d(a){if(A!=a)n.strokeStyle=A=a}function e(a){if(B!=a)n.fillStyle=B=a}var f=this,g,h,i,j=new THREE.Projector,a=a||{},k=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
+o,p,m,q,n=k.getContext("2d"),s=new THREE.Color(0),r=0,u=1,t=0,A=null,B=null,z=null,D=null,H=null,w,F,y,K,$=new THREE.RenderableVertex,Q=new THREE.RenderableVertex,X,T,R,l,S,v,W,M,Z,ca,aa,ea,U=new THREE.Color,L=new THREE.Color,V=new THREE.Color,ba=new THREE.Color,ga=new THREE.Color,va=[],fa=[],na,ja,sa,qa,Ba,wa,xa,ya,za,Aa,la=new THREE.Rectangle,ta=new THREE.Rectangle,pa=new THREE.Rectangle,Ia=!1,da=new THREE.Color,Y=new THREE.Color,G=new THREE.Color,ra=new THREE.Vector3,Ka,La,Oa,Ca,Ma,C,a=16;Ka=document.createElement("canvas");
+Ka.width=Ka.height=2;La=Ka.getContext("2d");La.fillStyle="rgba(0,0,0,1)";La.fillRect(0,0,2,2);Oa=La.getImageData(0,0,2,2);Ca=Oa.data;Ma=document.createElement("canvas");Ma.width=Ma.height=a;C=Ma.getContext("2d");C.translate(-a/2,-a/2);C.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;p=b;m=Math.floor(o/2);q=Math.floor(p/2);k.width=o;k.height=p;la.set(-m,-q,m,q);ta.set(-m,-q,m,q);u=1;t=0;H=
+D=z=B=A=null};this.setClearColor=function(a,b){s.copy(a);r=b;ta.set(-m,-q,m,q)};this.setClearColorHex=function(a,b){s.setHex(a);r=b;ta.set(-m,-q,m,q)};this.clear=function(){n.setTransform(1,0,0,-1,m,q);ta.isEmpty()||(ta.minSelf(la),ta.inflate(2),r<1&&n.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight())),r>0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+r+")"),n.fillRect(Math.floor(ta.getX()),
+Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(a,k){function o(a){var b,c,d,e;da.setRGB(0,0,0);Y.setRGB(0,0,0);G.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(da.r+=e.r,da.g+=e.g,da.b+=e.b):d instanceof THREE.DirectionalLight?(Y.r+=e.r,Y.g+=e.g,Y.b+=e.b):d instanceof THREE.PointLight&&(G.r+=e.r,G.g+=e.g,G.b+=e.b)}function p(a,b,c,d){var e,f,g,da,h,l;e=0;for(f=a.length;e<f;e++)g=a[e],da=g.color,
+g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),l=c.dot(h),l<=0||(l*=g.intensity,d.r+=da.r*l,d.g+=da.g*l,d.b+=da.b*l)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),l=c.dot(ra.sub(h,b).normalize()),l<=0||(l*=g.distance==0?1:1-Math.min(b.distanceTo(h)/g.distance,1),l!=0&&(l*=g.intensity,d.r+=da.r*l,d.g+=da.g*l,d.b+=da.b*l)))}function s(a,f,g){b(g.opacity);c(g.blending);var da,h,l,i,k,G;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=g.map.image,k=i.width>>
+1,G=i.height>>1,g=f.scale.x*m,l=f.scale.y*q,da=g*k,h=l*G,pa.set(a.x-da,a.y-h,a.x+da,a.y+h),la.intersects(pa)&&(n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(g,-l),n.translate(-k,-G),n.drawImage(i,0,0),n.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(da=f.scale.x*m,h=f.scale.y*q,pa.set(a.x-da,a.y-h,a.x+da,a.y+h),la.intersects(pa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(da,h),g.program(n),n.restore()))}
+function r(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(z!=a)n.lineWidth=z=a;a=g.linecap;if(D!=a)n.lineCap=D=a;a=g.linejoin;if(H!=a)n.lineJoin=H=a;d(g.color.getContextStyle());n.stroke();pa.inflate(g.linewidth*2)}}function u(a,d,e,g,h,G,Y,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending);X=a.positionScreen.x;
+T=a.positionScreen.y;R=d.positionScreen.x;l=d.positionScreen.y;S=e.positionScreen.x;v=e.positionScreen.y;A(X,T,R,l,S,v);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(qa=Y.uvs[0],Pa(X,T,R,l,S,v,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[G].u,qa[G].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,ra.copy(Y.vertexNormalsWorld[g]),Ba=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,wa=-(ra.x*a.n21+ra.y*a.n22+
+ra.z*a.n23)*0.5+0.5,ra.copy(Y.vertexNormalsWorld[h]),xa=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,ya=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(Y.vertexNormalsWorld[G]),za=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,Aa=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,Pa(X,T,R,l,S,v,Ba,wa,xa,ya,za,Aa,j.envMap)}else j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof
+THREE.UVMapping&&(qa=Y.uvs[0],Pa(X,T,R,l,S,v,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[G].u,qa[G].v,j.map)),c(THREE.SubtractiveBlending)),Ia?!j.wireframe&&j.shading==THREE.SmoothShading&&Y.vertexNormalsWorld.length==3?(L.r=V.r=ba.r=da.r,L.g=V.g=ba.g=da.g,L.b=V.b=ba.b=da.b,p(i,Y.v1.positionWorld,Y.vertexNormalsWorld[0],L),p(i,Y.v2.positionWorld,Y.vertexNormalsWorld[1],V),p(i,Y.v3.positionWorld,Y.vertexNormalsWorld[2],ba),L.r=Math.max(0,Math.min(j.color.r*L.r,1)),L.g=Math.max(0,Math.min(j.color.g*L.g,1)),
+L.b=Math.max(0,Math.min(j.color.b*L.b,1)),V.r=Math.max(0,Math.min(j.color.r*V.r,1)),V.g=Math.max(0,Math.min(j.color.g*V.g,1)),V.b=Math.max(0,Math.min(j.color.b*V.b,1)),ba.r=Math.max(0,Math.min(j.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(j.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(j.color.b*ba.b,1)),ga.r=(V.r+ba.r)*0.5,ga.g=(V.g+ba.g)*0.5,ga.b=(V.b+ba.b)*0.5,sa=P(L,V,ba,ga),Ja(X,T,R,l,S,v,0,0,1,0,0,1,sa)):(U.r=da.r,U.g=da.g,U.b=da.b,p(i,Y.centroidWorld,Y.normalWorld,U),U.r=Math.max(0,Math.min(j.color.r*
+U.r,1)),U.g=Math.max(0,Math.min(j.color.g*U.g,1)),U.b=Math.max(0,Math.min(j.color.b*U.b,1)),j.wireframe?J(U,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(U)):j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(j.color);else if(j instanceof THREE.MeshDepthMaterial)na=k.near,ja=k.far,L.r=L.g=L.b=1-N(a.positionScreen.z,na,ja),V.r=V.g=V.b=1-N(d.positionScreen.z,na,ja),ba.r=ba.g=ba.b=1-N(e.positionScreen.z,na,ja),ga.r=(V.r+ba.r)*0.5,ga.g=(V.g+ba.g)*0.5,
+ga.b=(V.b+ba.b)*0.5,sa=P(L,V,ba,ga),Ja(X,T,R,l,S,v,0,0,1,0,0,1,sa);else if(j instanceof THREE.MeshNormalMaterial)U.r=O(Y.normalWorld.x),U.g=O(Y.normalWorld.y),U.b=O(Y.normalWorld.z),j.wireframe?J(U,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(U)}function t(a,d,e,g,h,j,G,Y,n){f.info.render.vertices+=4;f.info.render.faces++;b(Y.opacity);c(Y.blending);if(Y.map||Y.envMap)u(a,d,g,0,1,3,G,Y,n),u(h,e,j,1,2,3,G,Y,n);else if(X=a.positionScreen.x,T=a.positionScreen.y,R=d.positionScreen.x,
+l=d.positionScreen.y,S=e.positionScreen.x,v=e.positionScreen.y,W=g.positionScreen.x,M=g.positionScreen.y,Z=h.positionScreen.x,ca=h.positionScreen.y,aa=j.positionScreen.x,ea=j.positionScreen.y,Y instanceof THREE.MeshBasicMaterial)B(X,T,R,l,S,v,W,M),Y.wireframe?J(Y.color,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ea(Y.color);else if(Y instanceof THREE.MeshLambertMaterial)Ia?!Y.wireframe&&Y.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==4?(L.r=V.r=ba.r=ga.r=da.r,L.g=V.g=
+ba.g=ga.g=da.g,L.b=V.b=ba.b=ga.b=da.b,p(i,G.v1.positionWorld,G.vertexNormalsWorld[0],L),p(i,G.v2.positionWorld,G.vertexNormalsWorld[1],V),p(i,G.v4.positionWorld,G.vertexNormalsWorld[3],ba),p(i,G.v3.positionWorld,G.vertexNormalsWorld[2],ga),L.r=Math.max(0,Math.min(Y.color.r*L.r,1)),L.g=Math.max(0,Math.min(Y.color.g*L.g,1)),L.b=Math.max(0,Math.min(Y.color.b*L.b,1)),V.r=Math.max(0,Math.min(Y.color.r*V.r,1)),V.g=Math.max(0,Math.min(Y.color.g*V.g,1)),V.b=Math.max(0,Math.min(Y.color.b*V.b,1)),ba.r=Math.max(0,
+Math.min(Y.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(Y.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(Y.color.b*ba.b,1)),ga.r=Math.max(0,Math.min(Y.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(Y.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(Y.color.b*ga.b,1)),sa=P(L,V,ba,ga),A(X,T,R,l,W,M),Ja(X,T,R,l,W,M,0,0,1,0,0,1,sa),A(Z,ca,S,v,aa,ea),Ja(Z,ca,S,v,aa,ea,1,0,1,1,0,1,sa)):(U.r=da.r,U.g=da.g,U.b=da.b,p(i,G.centroidWorld,G.normalWorld,U),U.r=Math.max(0,Math.min(Y.color.r*U.r,1)),U.g=Math.max(0,Math.min(Y.color.g*
+U.g,1)),U.b=Math.max(0,Math.min(Y.color.b*U.b,1)),B(X,T,R,l,S,v,W,M),Y.wireframe?J(U,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ea(U)):(B(X,T,R,l,S,v,W,M),Y.wireframe?J(Y.color,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ea(Y.color));else if(Y instanceof THREE.MeshNormalMaterial)U.r=O(G.normalWorld.x),U.g=O(G.normalWorld.y),U.b=O(G.normalWorld.z),B(X,T,R,l,S,v,W,M),Y.wireframe?J(U,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ea(U);else if(Y instanceof
+THREE.MeshDepthMaterial)na=k.near,ja=k.far,L.r=L.g=L.b=1-N(a.positionScreen.z,na,ja),V.r=V.g=V.b=1-N(d.positionScreen.z,na,ja),ba.r=ba.g=ba.b=1-N(g.positionScreen.z,na,ja),ga.r=ga.g=ga.b=1-N(e.positionScreen.z,na,ja),sa=P(L,V,ba,ga),A(X,T,R,l,W,M),Ja(X,T,R,l,W,M,0,0,1,0,0,1,sa),A(Z,ca,S,v,aa,ea),Ja(Z,ca,S,v,aa,ea,1,0,1,1,0,1,sa)}function A(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function B(a,b,c,d,e,f,g,da){n.beginPath();n.moveTo(a,b);n.lineTo(c,
+d);n.lineTo(e,f);n.lineTo(g,da);n.lineTo(a,b);n.closePath()}function J(a,b,c,e){if(z!=b)n.lineWidth=z=b;if(D!=c)n.lineCap=D=c;if(H!=e)n.lineJoin=H=e;d(a.getContextStyle());n.stroke();pa.inflate(b*2)}function Ea(a){e(a.getContextStyle());n.fill()}function Pa(a,b,c,d,f,g,da,h,l,i,Y,j,G){if(G.image.width!=0){if(G.needsUpdate==!0||va[G.id]==void 0){var k=G.wrapS==THREE.RepeatWrapping,m=G.wrapT==THREE.RepeatWrapping;va[G.id]=n.createPattern(G.image,k&&m?"repeat":k&&!m?"repeat-x":!k&&m?"repeat-y":"no-repeat");
+G.needsUpdate=!1}e(va[G.id]);var k=G.offset.x/G.repeat.x,m=G.offset.y/G.repeat.y,o=G.image.width*G.repeat.x,p=G.image.height*G.repeat.y,da=(da+k)*o,h=(h+m)*p,l=(l+k)*o,i=(i+m)*p,Y=(Y+k)*o,j=(j+m)*p;c-=a;d-=b;f-=a;g-=b;l-=da;i-=h;Y-=da;j-=h;k=l*j-Y*i;if(k==0){if(fa[G.id]==void 0)b=document.createElement("canvas"),b.width=G.image.width,b.height=G.image.height,a=b.getContext("2d"),a.drawImage(G.image,0,0),fa[G.id]=a.getImageData(0,0,G.image.width,G.image.height).data,delete b;b=fa[G.id];da=(Math.floor(da)+
+Math.floor(h)*G.image.width)*4;U.setRGB(b[da]/255,b[da+1]/255,b[da+2]/255);Ea(U)}else k=1/k,G=(j*c-i*f)*k,i=(j*d-i*g)*k,c=(l*f-Y*c)*k,d=(l*g-Y*d)*k,a=a-G*da-c*h,da=b-i*da-d*h,n.save(),n.transform(G,i,c,d,a,da),n.fill(),n.restore()}}function Ja(a,b,c,d,e,f,g,da,h,l,i,Y,G){var k,j;k=G.width-1;j=G.height-1;g*=k;da*=j;h*=k;l*=j;i*=k;Y*=j;c-=a;d-=b;e-=a;f-=b;h-=g;l-=da;i-=g;Y-=da;j=1/(h*Y-i*l);k=(Y*c-l*e)*j;l=(Y*d-l*f)*j;c=(h*e-i*c)*j;d=(h*f-i*d)*j;a=a-k*g-c*da;b=b-l*g-d*da;n.save();n.transform(k,l,c,
+d,a,b);n.clip();n.drawImage(G,0,0);n.restore()}function P(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),da=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),l=~~(c.g*255),c=~~(c.b*255),i=~~(d.r*255),Y=~~(d.g*255),d=~~(d.b*255);Ca[0]=e<0?0:e>255?255:e;Ca[1]=f<0?0:f>255?255:f;Ca[2]=a<0?0:a>255?255:a;Ca[4]=g<0?0:g>255?255:g;Ca[5]=da<0?0:da>255?255:da;Ca[6]=b<0?0:b>255?255:b;Ca[8]=h<0?0:h>255?255:h;Ca[9]=l<0?0:l>255?255:l;Ca[10]=c<0?0:c>255?255:c;Ca[12]=i<0?0:i>255?255:i;Ca[13]=Y<0?0:Y>255?
+255:Y;Ca[14]=d<0?0:d>255?255:d;La.putImageData(Oa,0,0);C.drawImage(Ka,0,0);return Ma}function N(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function O(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Fa(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Na,Qa,ua,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,q);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,k,this.sortElements);h=g.elements;i=g.lights;(Ia=i.length>0)&&o(i);
+Na=0;for(Qa=h.length;Na<Qa;Na++)if(ua=h[Na],Da=ua.material,Da=Da instanceof THREE.MeshFaceMaterial?ua.faceMaterial:Da,!(Da==null||Da.opacity==0)){pa.empty();if(ua instanceof THREE.RenderableParticle)w=ua,w.x*=m,w.y*=q,s(w,ua,Da,a);else if(ua instanceof THREE.RenderableLine)w=ua.v1,F=ua.v2,w.positionScreen.x*=m,w.positionScreen.y*=q,F.positionScreen.x*=m,F.positionScreen.y*=q,pa.addPoint(w.positionScreen.x,w.positionScreen.y),pa.addPoint(F.positionScreen.x,F.positionScreen.y),la.intersects(pa)&&r(w,
+F,ua,Da,a);else if(ua instanceof THREE.RenderableFace3)w=ua.v1,F=ua.v2,y=ua.v3,w.positionScreen.x*=m,w.positionScreen.y*=q,F.positionScreen.x*=m,F.positionScreen.y*=q,y.positionScreen.x*=m,y.positionScreen.y*=q,Da.overdraw&&(Fa(w.positionScreen,F.positionScreen),Fa(F.positionScreen,y.positionScreen),Fa(y.positionScreen,w.positionScreen)),pa.add3Points(w.positionScreen.x,w.positionScreen.y,F.positionScreen.x,F.positionScreen.y,y.positionScreen.x,y.positionScreen.y),la.intersects(pa)&&u(w,F,y,0,1,2,
+ua,Da,a);else if(ua instanceof THREE.RenderableFace4)w=ua.v1,F=ua.v2,y=ua.v3,K=ua.v4,w.positionScreen.x*=m,w.positionScreen.y*=q,F.positionScreen.x*=m,F.positionScreen.y*=q,y.positionScreen.x*=m,y.positionScreen.y*=q,K.positionScreen.x*=m,K.positionScreen.y*=q,$.positionScreen.copy(F.positionScreen),Q.positionScreen.copy(K.positionScreen),Da.overdraw&&(Fa(w.positionScreen,F.positionScreen),Fa(F.positionScreen,K.positionScreen),Fa(K.positionScreen,w.positionScreen),Fa(y.positionScreen,$.positionScreen),
+Fa(y.positionScreen,Q.positionScreen)),pa.addPoint(w.positionScreen.x,w.positionScreen.y),pa.addPoint(F.positionScreen.x,F.positionScreen.y),pa.addPoint(y.positionScreen.x,y.positionScreen.y),pa.addPoint(K.positionScreen.x,K.positionScreen.y),la.intersects(pa)&&t(w,F,y,K,$,Q,ua,Da,a);ta.addRectangle(pa)}n.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,k;e=0;for(f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),k=c.dot(i),k<=0||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(w.sub(i,b).normalize()),k<=0||(k*=g.distance==0?1:1-Math.min(b.distanceTo(i)/g.distance,1),k!=0&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){F[a]==null&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg",
+"path"),X==0&&F[a].setAttribute("shape-rendering","crispEdges"));return F[a]}function c(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,k,o,p,m,q,n,s,r=new THREE.Rectangle,u=new THREE.Rectangle,t=!1,A=new THREE.Color,B=new THREE.Color,z=new THREE.Color,D=new THREE.Color,H,w=new THREE.Vector3,F=[],y=[],K,$,Q,X=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
+faces:0}};this.setQuality=function(a){switch(a){case "high":X=1;break;case "low":X=0}};this.setSize=function(a,b){j=a;k=b;o=j/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+j+" "+k);i.setAttribute("width",j);i.setAttribute("height",k);r.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var l,F,v,w;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);f=e.elements;
+g=e.lights;Q=$=0;if(t=g.length>0){B.setRGB(0,0,0);z.setRGB(0,0,0);D.setRGB(0,0,0);l=0;for(F=g.length;l<F;l++)w=g[l],v=w.color,w instanceof THREE.AmbientLight?(B.r+=v.r,B.g+=v.g,B.b+=v.b):w instanceof THREE.DirectionalLight?(z.r+=v.r,z.g+=v.g,z.b+=v.b):w instanceof THREE.PointLight&&(D.r+=v.r,D.g+=v.g,D.b+=v.b)}l=0;for(F=f.length;l<F;l++)if(v=f[l],w=v.material,w=w instanceof THREE.MeshFaceMaterial?v.faceMaterial:w,!(w==null||w.opacity==0))if(u.empty(),v instanceof THREE.RenderableParticle)m=v,m.x*=
+o,m.y*=-p;else if(v instanceof THREE.RenderableLine){if(m=v.v1,q=v.v2,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),r.intersects(u)){v=m;var M=q,Z=Q++;y[Z]==null&&(y[Z]=document.createElementNS("http://www.w3.org/2000/svg","line"),X==0&&y[Z].setAttribute("shape-rendering","crispEdges"));K=y[Z];K.setAttribute("x1",v.positionScreen.x);K.setAttribute("y1",v.positionScreen.y);
+K.setAttribute("x2",M.positionScreen.x);K.setAttribute("y2",M.positionScreen.y);w instanceof THREE.LineBasicMaterial&&(K.setAttribute("style","fill: none; stroke: "+w.color.getContextStyle()+"; stroke-width: "+w.linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.linecap+"; stroke-linejoin: "+w.linejoin),i.appendChild(K))}}else if(v instanceof THREE.RenderableFace3){if(m=v.v1,q=v.v2,n=v.v3,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,n.positionScreen.x*=
+o,n.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),u.addPoint(n.positionScreen.x,n.positionScreen.y),r.intersects(u)){var M=m,Z=q,ca=n;d.info.render.vertices+=3;d.info.render.faces++;K=b($++);K.setAttribute("d","M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");w instanceof THREE.MeshBasicMaterial?A.copy(w.color):w instanceof THREE.MeshLambertMaterial?
+t?(A.r=B.r,A.g=B.g,A.b=B.b,a(g,v.centroidWorld,v.normalWorld,A),A.r=Math.max(0,Math.min(w.color.r*A.r,1)),A.g=Math.max(0,Math.min(w.color.g*A.g,1)),A.b=Math.max(0,Math.min(w.color.b*A.b,1))):A.copy(w.color):w instanceof THREE.MeshDepthMaterial?(H=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear),A.setRGB(H,H,H)):w instanceof THREE.MeshNormalMaterial&&A.setRGB(c(v.normalWorld.x),c(v.normalWorld.y),c(v.normalWorld.z));w.wireframe?K.setAttribute("style","fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+
+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):K.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+w.opacity);i.appendChild(K)}}else if(v instanceof THREE.RenderableFace4&&(m=v.v1,q=v.v2,n=v.v3,s=v.v4,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,n.positionScreen.x*=o,n.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,u.addPoint(m.positionScreen.x,
+m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),u.addPoint(n.positionScreen.x,n.positionScreen.y),u.addPoint(s.positionScreen.x,s.positionScreen.y),r.intersects(u))){var M=m,Z=q,ca=n,aa=s;d.info.render.vertices+=4;d.info.render.faces++;K=b($++);K.setAttribute("d","M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");w instanceof THREE.MeshBasicMaterial?
+A.copy(w.color):w instanceof THREE.MeshLambertMaterial?t?(A.r=B.r,A.g=B.g,A.b=B.b,a(g,v.centroidWorld,v.normalWorld,A),A.r=Math.max(0,Math.min(w.color.r*A.r,1)),A.g=Math.max(0,Math.min(w.color.g*A.g,1)),A.b=Math.max(0,Math.min(w.color.b*A.b,1))):A.copy(w.color):w instanceof THREE.MeshDepthMaterial?(H=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear),A.setRGB(H,H,H)):w instanceof THREE.MeshNormalMaterial&&A.setRGB(c(v.normalWorld.x),c(v.normalWorld.y),c(v.normalWorld.z));w.wireframe?K.setAttribute("style",
+"fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):K.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+w.opacity);i.appendChild(K)}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#endif",
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",
@@ -232,109 +232,113 @@ return!1}function g(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,k=
 1]=e.g,m[f+2]=e.b;if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.boundTo===void 0||h.boundTo==="vertices")if(f=0,e=h.value.length,h.size===1)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(h.size===2)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,
 1]=e.g,m[f+2]=e.b;if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.boundTo===void 0||h.boundTo==="vertices")if(f=0,e=h.value.length,h.size===1)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(h.size===2)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,
 f+=3;else if(h.size===4)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=d*3,j[f]=e.x,j[f+1]=e.y,j[f+2]=e.z;if(p)for(d=0;d<k;d++)e=i[d],f=d*3,m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.needsUpdate&&(h.boundTo===void 0||h.boundTo==="vertices"))if(e=h.value.length,f=0,h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++)g=h.value[d],
 f+=3;else if(h.size===4)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=d*3,j[f]=e.x,j[f+1]=e.y,j[f+2]=e.z;if(p)for(d=0;d<k;d++)e=i[d],f=d*3,m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.needsUpdate&&(h.boundTo===void 0||h.boundTo==="vertices"))if(e=h.value.length,f=0,h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++)g=h.value[d],
 h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}if(o||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,j,b);if(p||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,
 h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}if(o||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,j,b);if(p||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,
-a.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,m,b);if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.needsUpdate||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,h.buffer),l.bufferData(l.ARRAY_BUFFER,h.array,b)}}function h(a,b){return b.z-a.z}function i(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)v=null,L=Z=aa=O=U=-1,a[d].render(b,c,Ba,wa),v=null,L=Z=aa=O=U=-1}function k(a,b,c,d,e,f,g,h){var i,l,k,j;b?(l=a.length-1,j=b=-1):(l=0,b=a.length,j=1);for(var n=l;n!==b;n+=j)if(i=a[n],i.render){l=i.object;
-k=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&R.setBlending(i.blending);R.setDepthTest(i.depthTest);u(i.depthWrite);t(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}R.setObjectFaces(l);R.renderBuffer(d,e,f,i,k,l)}}function j(a,b,c,d,e,f,g){for(var h,i,l=0,k=a.length;l<k;l++)if(h=a[l],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&R.setBlending(h.blending);R.setDepthTest(h.depthTest);u(h.depthWrite);t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}R.renderImmediateObject(c,
-d,e,h,i)}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function m(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function q(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function s(a,b,c,d,e){d.program||R.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=
-new Float32Array(R.maxMorphTargets);for(var f=0,g=R.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==v&&(l.useProgram(f),v=f,h=!0);if(d.id!==L)L=d.id,h=!0;if(h){l.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||
-d instanceof THREE.MeshLambertMaterial||d.lights){for(var k,j,n=0,m=0,o=0,p,q,s=Aa,r=s.directional.colors,y=s.directional.positions,u=s.point.colors,t=s.point.positions,K=s.point.distances,z=0,G=0,B=q=0,c=0,h=b.length;c<h;c++)if(k=b[c],j=k.color,p=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)R.gammaInput?(n+=j.r*j.r,m+=j.g*j.g,o+=j.b*j.b):(n+=j.r,m+=j.g,o+=j.b);else if(k instanceof THREE.DirectionalLight)q=z*3,R.gammaInput?(r[q]=j.r*j.r*p*p,r[q+1]=j.g*j.g*p*p,r[q+2]=j.b*j.b*p*p):(r[q]=
-j.r*p,r[q+1]=j.g*p,r[q+2]=j.b*p),k=k.matrixWorld.getPosition(),j=1/k.length(),y[q]=k.x*j,y[q+1]=k.y*j,y[q+2]=k.z*j,z+=1;else if(k instanceof THREE.SpotLight)q=z*3,R.gammaInput?(r[q]=j.r*j.r*p*p,r[q+1]=j.g*j.g*p*p,r[q+2]=j.b*j.b*p*p):(r[q]=j.r*p,r[q+1]=j.g*p,r[q+2]=j.b*p),k=k.matrixWorld.getPosition(),j=1/k.length(),y[q]=k.x*j,y[q+1]=k.y*j,y[q+2]=k.z*j,z+=1;else if(k instanceof THREE.PointLight)B=G*3,R.gammaInput?(u[B]=j.r*j.r*p*p,u[B+1]=j.g*j.g*p*p,u[B+2]=j.b*j.b*p*p):(u[B]=j.r*p,u[B+1]=j.g*p,u[B+
-2]=j.b*p),k=k.matrixWorld.getPosition(),t[B]=k.x,t[B+1]=k.y,t[B+2]=k.z,K[G]=q,G+=1;c=z*3;for(h=r.length;c<h;c++)r[c]=0;c=G*3;for(h=u.length;c<h;c++)u[c]=0;s.point.length=G;s.directional.length=z;s.ambient[0]=n;s.ambient[1]=m;s.ambient[2]=o;b=Aa;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=
-b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,R.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,i.reflectivity.value=d.reflectivity,
-i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=w.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,R.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),
-i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular);else if(d instanceof THREE.MeshLambertMaterial)R.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<R.shadowMapPlugin.shadowMatrix.length;b++)i.shadowMatrix.value[b]=
-R.shadowMapPlugin.shadowMatrix[b],i.shadowMap.texture[b]=R.shadowMapPlugin.shadowMap[b];i.shadowDarkness.value=R.shadowMapDarkness;i.shadowBias.value=R.shadowMapBias}b=d.uniformsList;i=0;for(c=b.length;i<c;i++)if(m=f.uniforms[b[i][1]])if(n=b[i][0],o=n.type,h=n.value,o==="i")l.uniform1i(m,h);else if(o==="f")l.uniform1f(m,h);else if(o==="v2")l.uniform2f(m,h.x,h.y);else if(o==="v3")l.uniform3f(m,h.x,h.y,h.z);else if(o==="v4")l.uniform4f(m,h.x,h.y,h.z,h.w);else if(o==="c")l.uniform3f(m,h.r,h.g,h.b);else if(o===
-"fv1")l.uniform1fv(m,h);else if(o==="fv")l.uniform3fv(m,h);else if(o==="v3v"){if(!n._array)n._array=new Float32Array(3*h.length);o=0;for(s=h.length;o<s;o++)r=o*3,n._array[r]=h[o].x,n._array[r+1]=h[o].y,n._array[r+2]=h[o].z;l.uniform3fv(m,n._array)}else if(o==="m4"){if(!n._array)n._array=new Float32Array(16);h.flattenToArray(n._array);l.uniformMatrix4fv(m,!1,n._array)}else if(o==="m4v"){if(!n._array)n._array=new Float32Array(16*h.length);o=0;for(s=h.length;o<s;o++)h[o].flattenToArrayOffset(n._array,
-o*16);l.uniformMatrix4fv(m,!1,n._array)}else if(o==="t"){if(l.uniform1i(m,h),m=n.texture)if(m.image instanceof Array&&m.image.length===6){if(n=m,n.image.length===6)if(n.needsUpdate){if(!n.image.__webglTextureCube)n.image.__webglTextureCube=l.createTexture();l.activeTexture(l.TEXTURE0+h);l.bindTexture(l.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);h=A(l.TEXTURE_CUBE_MAP,n,n.image[0]);for(m=0;m<6;m++)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,n.image[m]);h&&l.generateMipmap(l.TEXTURE_CUBE_MAP);
-n.needsUpdate=!1}else l.activeTexture(l.TEXTURE0+h),l.bindTexture(l.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(n=m,l.activeTexture(l.TEXTURE0+h),l.bindTexture(l.TEXTURE_CUBE_MAP,n.__webglTexture)):R.setTexture(m,h)}else if(o==="tv"){if(!n._array){n._array=[];o=0;for(s=n.texture.length;o<s;o++)n._array[o]=h+o}l.uniform1iv(m,n._array);o=0;for(s=n.texture.length;o<s;o++)(m=n.texture[o])&&R.setTexture(m,n._array[o])}(d instanceof THREE.ShaderMaterial||
-d instanceof THREE.MeshPhongMaterial||d.envMap)&&g.cameraPosition!==null&&l.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&g.viewMatrix!==null&&l.uniformMatrix4fv(g.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(l.uniformMatrix4fv(g.cameraInverseMatrix,!1,a._viewMatrixArray),l.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}l.uniformMatrix4fv(g.modelViewMatrix,
-!1,e._modelViewMatrixArray);g.normalMatrix&&l.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&g.objectMatrix!==null&&l.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function u(a){aa!==a&&
-(l.depthMask(a),aa=a)}function t(a,b,c){ca!==a&&(a?l.enable(l.POLYGON_OFFSET_FILL):l.disable(l.POLYGON_OFFSET_FILL),ca=a);if(a&&(ga!==b||va!==c))l.polygonOffset(b,c),ga=b,va=c}function z(a,b){var c;a==="fragment"?c=l.createShader(l.FRAGMENT_SHADER):a==="vertex"&&(c=l.createShader(l.VERTEX_SHADER));l.shaderSource(c,b);l.compileShader(c);if(!l.getShaderParameter(c,l.COMPILE_STATUS))return console.error(l.getShaderInfoLog(c)),console.error(b),null;return c}function A(a,b,c){return(c.width&c.width-1)===
-0&&(c.height&c.height-1)===0?(l.texParameteri(a,l.TEXTURE_WRAP_S,B(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,B(b.wrapT)),l.texParameteri(a,l.TEXTURE_MAG_FILTER,B(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,B(b.minFilter)),!0):(l.texParameteri(a,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_MAG_FILTER,D(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,D(b.minFilter)),!1)}function E(a,b){l.bindRenderbuffer(l.RENDERBUFFER,
-a);b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function D(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return l.NEAREST;
-default:return l.LINEAR}}function B(a){switch(a){case THREE.RepeatWrapping:return l.REPEAT;case THREE.ClampToEdgeWrapping:return l.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return l.MIRRORED_REPEAT;case THREE.NearestFilter:return l.NEAREST;case THREE.NearestMipMapNearestFilter:return l.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return l.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return l.LINEAR;case THREE.LinearMipMapNearestFilter:return l.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return l.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return l.BYTE;case THREE.UnsignedByteType:return l.UNSIGNED_BYTE;case THREE.ShortType:return l.SHORT;case THREE.UnsignedShortType:return l.UNSIGNED_SHORT;case THREE.IntType:return l.INT;case THREE.UnsignedShortType:return l.UNSIGNED_INT;case THREE.FloatType:return l.FLOAT;case THREE.AlphaFormat:return l.ALPHA;case THREE.RGBFormat:return l.RGB;case THREE.RGBAFormat:return l.RGBA;case THREE.LuminanceFormat:return l.LUMINANCE;case THREE.LuminanceAlphaFormat:return l.LUMINANCE_ALPHA}return 0}
-var a=a||{},w=a.canvas!==void 0?a.canvas:document.createElement("canvas"),G=a.precision!==void 0?a.precision:"mediump",y=a.antialias!==void 0?a.antialias:!1,K=a.stencil!==void 0?a.stencil:!0,$=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,Q=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),Y=a.clearAlpha!==void 0?a.clearAlpha:0,S=a.maxLights!==void 0?a.maxLights:4;this.domElement=w;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=
-this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,
-vertices:0,faces:0,points:0}};var R=this,l,W=[],v=null,X=null,L=-1,Z=null,da=0,ba=null,T=null,U=null,O=null,aa=null,ca=null,ga=null,va=null,fa=null,na=0,ja=0,sa=0,qa=0,Ba=0,wa=0,xa=new THREE.Frustum,ya=new THREE.Matrix4,za=new THREE.Vector4,Aa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};l=function(){var a;try{if(!(a=w.getContext("experimental-webgl",{antialias:y,stencil:K,preserveDrawingBuffer:$})))throw"Error creating WebGL context.";
-console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();l.clearColor(0,0,0,1);l.clearDepth(1);l.clearStencil(0);l.enable(l.DEPTH_TEST);l.depthFunc(l.LEQUAL);l.frontFace(l.CCW);l.cullFace(l.BACK);l.enable(l.CULL_FACE);l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA);l.clearColor(Q.r,Q.g,Q.b,Y);this.context=
-l;var la=l.getParameter(l.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return l};this.supportsVertexTextures=function(){return la};this.setSize=function(a,b){w.width=a;w.height=b;this.setViewport(0,0,w.width,w.height)};this.setViewport=function(a,b,c,d){na=a;ja=b;sa=c;qa=d;l.viewport(na,ja,sa,qa)};this.setScissor=function(a,b,c,d){l.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?l.enable(l.SCISSOR_TEST):l.disable(l.SCISSOR_TEST)};this.setClearColorHex=function(a,b){Q.setHex(a);
-Y=b;l.clearColor(Q.r,Q.g,Q.b,Y)};this.setClearColor=function(a,b){Q.copy(a);Y=b;l.clearColor(Q.r,Q.g,Q.b,Y)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return Y};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=l.COLOR_BUFFER_BIT;if(b===void 0||b)d|=l.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=l.STENCIL_BUFFER_BIT;l.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};
-this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];l.deleteBuffer(c.__webglVertexBuffer);l.deleteBuffer(c.__webglNormalBuffer);l.deleteBuffer(c.__webglTangentBuffer);l.deleteBuffer(c.__webglColorBuffer);
-l.deleteBuffer(c.__webglUVBuffer);l.deleteBuffer(c.__webglUV2Buffer);l.deleteBuffer(c.__webglSkinVertexABuffer);l.deleteBuffer(c.__webglSkinVertexBBuffer);l.deleteBuffer(c.__webglSkinIndicesBuffer);l.deleteBuffer(c.__webglSkinWeightsBuffer);l.deleteBuffer(c.__webglFaceBuffer);l.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)l.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)l.deleteBuffer(c.__webglCustomAttributesList[d].buffer);
-R.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--};this.deallocateTexture=
-function(a){if(a.__webglInit)a.__webglInit=!1,l.deleteTexture(a.__webglTexture),R.info.memory.textures--};this.updateShadowMap=function(a,b){v=null;L=Z=aa=O=U=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=l.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=l.createBuffer();a.hasPos&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,a.positionArray,l.DYNAMIC_DRAW),l.enableVertexAttribArray(b.attributes.position),
-l.vertexAttribPointer(b.attributes.position,3,l.FLOAT,!1,0,0));if(a.hasNormal){l.bindBuffer(l.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,j,n,m,o=a.count*3;for(m=0;m<o;m+=9)c=a.normalArray,d=c[m],e=c[m+1],f=c[m+2],g=c[m+3],i=c[m+4],j=c[m+5],h=c[m+6],k=c[m+7],n=c[m+8],d=(d+g+h)/3,e=(e+i+k)/3,f=(f+j+n)/3,c[m]=d,c[m+1]=e,c[m+2]=f,c[m+3]=d,c[m+4]=e,c[m+5]=f,c[m+6]=d,c[m+7]=e,c[m+8]=f}l.bufferData(l.ARRAY_BUFFER,a.normalArray,l.DYNAMIC_DRAW);l.enableVertexAttribArray(b.attributes.normal);
-l.vertexAttribPointer(b.attributes.normal,3,l.FLOAT,!1,0,0)}l.drawArrays(l.TRIANGLES,0,a.count);a.count=0};this.renderBuffer=function(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=s(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==Z&&(Z=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(l.bindBuffer(l.ARRAY_BUFFER,
-e.__webglMorphTargetsBuffers[f.morphTargetBase]),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):c.position>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[g]=
-h[i[g]],g++}else{var i=[],k=-1,j=0;h=f.morphTargetInfluences;var m,n=h.length;g=0;for(f.morphTargetBase!==-1&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(m=0;m<n;m++)!i[m]&&h[m]>k&&(j=m,k=h[j]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j]);l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[j]=1;k=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=
+a.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,m,b);if(q){i=0;for(k=q.length;i<k;i++)if(h=q[i],h.needsUpdate||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,h.buffer),l.bufferData(l.ARRAY_BUFFER,h.array,b)}}function h(a,b){return b.z-a.z}function i(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)v=null,M=Z=V=L=U=-1,a[d].render(b,c,Ba,wa),v=null,M=Z=V=L=U=-1}function j(a,b,c,d,e,f,g,h){var l,i,k,j;b?(i=a.length-1,j=b=-1):(i=0,b=a.length,j=1);for(var n=i;n!==b;n+=j)if(l=a[n],l.render){i=l.object;
+k=l.buffer;if(h)l=h;else{l=l[c];if(!l)continue;g&&R.setBlending(l.blending);R.setDepthTest(l.depthTest);u(l.depthWrite);t(l.polygonOffset,l.polygonOffsetFactor,l.polygonOffsetUnits)}R.setObjectFaces(i);k instanceof THREE.BufferGeometry?R.renderBufferDirect(d,e,f,l,k,i):R.renderBuffer(d,e,f,l,k,i)}}function k(a,b,c,d,e,f,g){for(var h,l,i=0,k=a.length;i<k;i++)if(h=a[i],l=h.object,l.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&R.setBlending(h.blending);R.setDepthTest(h.depthTest);u(h.depthWrite);
+t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}R.renderImmediateObject(c,d,e,h,l)}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function m(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function q(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function s(a,b,c,d,e){d.program||
+R.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(R.maxMorphTargets);for(var f=0,g=R.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==v&&(l.useProgram(f),v=f,h=!0);if(d.id!==M)M=d.id,h=!0;if(h){l.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;
+else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){for(var k,j,n=0,m=0,o=0,p,q,s=Aa,r=s.directional.colors,y=s.directional.positions,u=s.point.colors,t=s.point.positions,K=s.point.distances,A=0,F=0,z=q=0,c=0,h=b.length;c<h;c++)if(k=b[c],j=k.color,p=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)R.gammaInput?(n+=j.r*j.r,m+=j.g*j.g,o+=j.b*j.b):(n+=j.r,m+=j.g,o+=j.b);else if(k instanceof
+THREE.DirectionalLight)q=A*3,R.gammaInput?(r[q]=j.r*j.r*p*p,r[q+1]=j.g*j.g*p*p,r[q+2]=j.b*j.b*p*p):(r[q]=j.r*p,r[q+1]=j.g*p,r[q+2]=j.b*p),k=k.matrixWorld.getPosition(),j=1/k.length(),y[q]=k.x*j,y[q+1]=k.y*j,y[q+2]=k.z*j,A+=1;else if(k instanceof THREE.SpotLight)q=A*3,R.gammaInput?(r[q]=j.r*j.r*p*p,r[q+1]=j.g*j.g*p*p,r[q+2]=j.b*j.b*p*p):(r[q]=j.r*p,r[q+1]=j.g*p,r[q+2]=j.b*p),k=k.matrixWorld.getPosition(),j=1/k.length(),y[q]=k.x*j,y[q+1]=k.y*j,y[q+2]=k.z*j,A+=1;else if(k instanceof THREE.PointLight)z=
+F*3,R.gammaInput?(u[z]=j.r*j.r*p*p,u[z+1]=j.g*j.g*p*p,u[z+2]=j.b*j.b*p*p):(u[z]=j.r*p,u[z+1]=j.g*p,u[z+2]=j.b*p),k=k.matrixWorld.getPosition(),t[z]=k.x,t[z+1]=k.y,t[z+2]=k.z,K[F]=q,F+=1;c=A*3;for(h=r.length;c<h;c++)r[c]=0;c=F*3;for(h=u.length;c<h;c++)u[c]=0;s.point.length=F;s.directional.length=A;s.ambient[0]=n;s.ambient[1]=m;s.ambient[2]=o;b=Aa;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=
+b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,R.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=
+d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,i.reflectivity.value=d.reflectivity,i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=w.height/2,i.map.texture=d.map;else if(d instanceof
+THREE.MeshPhongMaterial)i.shininess.value=d.shininess,R.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular);else if(d instanceof THREE.MeshLambertMaterial)R.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=
+d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<R.shadowMapPlugin.shadowMatrix.length;b++)i.shadowMatrix.value[b]=R.shadowMapPlugin.shadowMatrix[b],i.shadowMap.texture[b]=R.shadowMapPlugin.shadowMap[b];i.shadowDarkness.value=R.shadowMapDarkness;i.shadowBias.value=R.shadowMapBias}b=d.uniformsList;i=0;for(c=b.length;i<c;i++)if(m=f.uniforms[b[i][1]])if(n=b[i][0],o=n.type,h=n.value,o==="i")l.uniform1i(m,h);else if(o==="f")l.uniform1f(m,h);else if(o==="v2")l.uniform2f(m,h.x,h.y);
+else if(o==="v3")l.uniform3f(m,h.x,h.y,h.z);else if(o==="v4")l.uniform4f(m,h.x,h.y,h.z,h.w);else if(o==="c")l.uniform3f(m,h.r,h.g,h.b);else if(o==="fv1")l.uniform1fv(m,h);else if(o==="fv")l.uniform3fv(m,h);else if(o==="v3v"){if(!n._array)n._array=new Float32Array(3*h.length);o=0;for(s=h.length;o<s;o++)r=o*3,n._array[r]=h[o].x,n._array[r+1]=h[o].y,n._array[r+2]=h[o].z;l.uniform3fv(m,n._array)}else if(o==="m4"){if(!n._array)n._array=new Float32Array(16);h.flattenToArray(n._array);l.uniformMatrix4fv(m,
+!1,n._array)}else if(o==="m4v"){if(!n._array)n._array=new Float32Array(16*h.length);o=0;for(s=h.length;o<s;o++)h[o].flattenToArrayOffset(n._array,o*16);l.uniformMatrix4fv(m,!1,n._array)}else if(o==="t"){if(l.uniform1i(m,h),m=n.texture)if(m.image instanceof Array&&m.image.length===6){if(n=m,n.image.length===6)if(n.needsUpdate){if(!n.image.__webglTextureCube)n.image.__webglTextureCube=l.createTexture();l.activeTexture(l.TEXTURE0+h);l.bindTexture(l.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);h=B(l.TEXTURE_CUBE_MAP,
+n,n.image[0]);for(m=0;m<6;m++)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,n.image[m]);h&&l.generateMipmap(l.TEXTURE_CUBE_MAP);n.needsUpdate=!1}else l.activeTexture(l.TEXTURE0+h),l.bindTexture(l.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(n=m,l.activeTexture(l.TEXTURE0+h),l.bindTexture(l.TEXTURE_CUBE_MAP,n.__webglTexture)):R.setTexture(m,h)}else if(o==="tv"){if(!n._array){n._array=[];o=0;for(s=n.texture.length;o<s;o++)n._array[o]=
+h+o}l.uniform1iv(m,n._array);o=0;for(s=n.texture.length;o<s;o++)(m=n.texture[o])&&R.setTexture(m,n._array[o])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&g.cameraPosition!==null&&l.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&g.viewMatrix!==null&&l.uniformMatrix4fv(g.viewMatrix,!1,a._viewMatrixArray);d.skinning&&
+(l.uniformMatrix4fv(g.cameraInverseMatrix,!1,a._viewMatrixArray),l.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}l.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&l.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&g.objectMatrix!==null&&l.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,
+a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function u(a){V!==a&&(l.depthMask(a),V=a)}function t(a,b,c){ba!==a&&(a?l.enable(l.POLYGON_OFFSET_FILL):l.disable(l.POLYGON_OFFSET_FILL),ba=a);if(a&&(ga!==b||va!==c))l.polygonOffset(b,c),ga=b,va=c}function A(a,b){var c;a==="fragment"?c=l.createShader(l.FRAGMENT_SHADER):a==="vertex"&&(c=l.createShader(l.VERTEX_SHADER));l.shaderSource(c,b);l.compileShader(c);if(!l.getShaderParameter(c,
+l.COMPILE_STATUS))return console.error(l.getShaderInfoLog(c)),console.error(b),null;return c}function B(a,b,c){return(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(l.texParameteri(a,l.TEXTURE_WRAP_S,H(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,H(b.wrapT)),l.texParameteri(a,l.TEXTURE_MAG_FILTER,H(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,H(b.minFilter)),!0):(l.texParameteri(a,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_MAG_FILTER,
+D(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,D(b.minFilter)),!1)}function z(a,b){l.bindRenderbuffer(l.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):
+l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function D(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return l.NEAREST;default:return l.LINEAR}}function H(a){switch(a){case THREE.RepeatWrapping:return l.REPEAT;case THREE.ClampToEdgeWrapping:return l.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return l.MIRRORED_REPEAT;case THREE.NearestFilter:return l.NEAREST;case THREE.NearestMipMapNearestFilter:return l.NEAREST_MIPMAP_NEAREST;
+case THREE.NearestMipMapLinearFilter:return l.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return l.LINEAR;case THREE.LinearMipMapNearestFilter:return l.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return l.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return l.BYTE;case THREE.UnsignedByteType:return l.UNSIGNED_BYTE;case THREE.ShortType:return l.SHORT;case THREE.UnsignedShortType:return l.UNSIGNED_SHORT;case THREE.IntType:return l.INT;case THREE.UnsignedShortType:return l.UNSIGNED_INT;case THREE.FloatType:return l.FLOAT;
+case THREE.AlphaFormat:return l.ALPHA;case THREE.RGBFormat:return l.RGB;case THREE.RGBAFormat:return l.RGBA;case THREE.LuminanceFormat:return l.LUMINANCE;case THREE.LuminanceAlphaFormat:return l.LUMINANCE_ALPHA}return 0}var a=a||{},w=a.canvas!==void 0?a.canvas:document.createElement("canvas"),F=a.precision!==void 0?a.precision:"mediump",y=a.antialias!==void 0?a.antialias:!1,K=a.stencil!==void 0?a.stencil:!0,$=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,Q=a.clearColor!==void 0?new THREE.Color(a.clearColor):
+new THREE.Color(0),X=a.clearAlpha!==void 0?a.clearAlpha:0,T=a.maxLights!==void 0?a.maxLights:4;this.domElement=w;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=
+50;this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var R=this,l,S=[],v=null,W=null,M=-1,Z=null,ca=0,aa=null,ea=null,U=null,L=null,V=null,ba=null,ga=null,va=null,fa=null,na=0,ja=0,sa=0,qa=0,Ba=0,wa=0,xa=new THREE.Frustum,ya=new THREE.Matrix4,za=new THREE.Vector4,Aa={ambient:[0,0,0],directional:{length:0,
+colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};l=function(){var a;try{if(!(a=w.getContext("experimental-webgl",{antialias:y,stencil:K,preserveDrawingBuffer:$})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();l.clearColor(0,0,0,1);l.clearDepth(1);l.clearStencil(0);
+l.enable(l.DEPTH_TEST);l.depthFunc(l.LEQUAL);l.frontFace(l.CCW);l.cullFace(l.BACK);l.enable(l.CULL_FACE);l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA);l.clearColor(Q.r,Q.g,Q.b,X);this.context=l;var la=l.getParameter(l.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return l};this.supportsVertexTextures=function(){return la};this.setSize=function(a,b){w.width=a;w.height=b;this.setViewport(0,0,w.width,w.height)};this.setViewport=function(a,
+b,c,d){na=a;ja=b;sa=c;qa=d;l.viewport(na,ja,sa,qa)};this.setScissor=function(a,b,c,d){l.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?l.enable(l.SCISSOR_TEST):l.disable(l.SCISSOR_TEST)};this.setClearColorHex=function(a,b){Q.setHex(a);X=b;l.clearColor(Q.r,Q.g,Q.b,X)};this.setClearColor=function(a,b){Q.copy(a);X=b;l.clearColor(Q.r,Q.g,Q.b,X)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return X};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=l.COLOR_BUFFER_BIT;
+if(b===void 0||b)d|=l.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=l.STENCIL_BUFFER_BIT;l.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,
+a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];l.deleteBuffer(c.__webglVertexBuffer);l.deleteBuffer(c.__webglNormalBuffer);l.deleteBuffer(c.__webglTangentBuffer);l.deleteBuffer(c.__webglColorBuffer);l.deleteBuffer(c.__webglUVBuffer);l.deleteBuffer(c.__webglUV2Buffer);l.deleteBuffer(c.__webglSkinVertexABuffer);l.deleteBuffer(c.__webglSkinVertexBBuffer);l.deleteBuffer(c.__webglSkinIndicesBuffer);l.deleteBuffer(c.__webglSkinWeightsBuffer);l.deleteBuffer(c.__webglFaceBuffer);
+l.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)l.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)l.deleteBuffer(c.__webglCustomAttributesList[d].buffer);R.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,
+l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,l.deleteTexture(a.__webglTexture),R.info.memory.textures--};this.updateShadowMap=function(a,b){v=null;M=Z=V=L=U=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=
+function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=l.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=l.createBuffer();a.hasPos&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,a.positionArray,l.DYNAMIC_DRAW),l.enableVertexAttribArray(b.attributes.position),l.vertexAttribPointer(b.attributes.position,3,l.FLOAT,!1,0,0));if(a.hasNormal){l.bindBuffer(l.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,j,n,m,o=a.count*
+3;for(m=0;m<o;m+=9)c=a.normalArray,d=c[m],e=c[m+1],f=c[m+2],g=c[m+3],i=c[m+4],j=c[m+5],h=c[m+6],k=c[m+7],n=c[m+8],d=(d+g+h)/3,e=(e+i+k)/3,f=(f+j+n)/3,c[m]=d,c[m+1]=e,c[m+2]=f,c[m+3]=d,c[m+4]=e,c[m+5]=f,c[m+6]=d,c[m+7]=e,c[m+8]=f}l.bufferData(l.ARRAY_BUFFER,a.normalArray,l.DYNAMIC_DRAW);l.enableVertexAttribArray(b.attributes.normal);l.vertexAttribPointer(b.attributes.normal,3,l.FLOAT,!1,0,0)}l.drawArrays(l.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(d.opacity!==
+0&&(c=s(a,b,c,d,f),a=c.attributes,b=!1,d=e.id*16777215+c.id*2+(d.wireframe?1:0),d!==Z&&(Z=d,b=!0),f instanceof THREE.Mesh)){d=e.offsets;for(f=0;f<d.length;++f)b&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexPositionBuffer),l.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,l.FLOAT,!1,0,d[f].index*12),a.normal>=0&&e.vertexNormalBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexNormalBuffer),l.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,l.FLOAT,!1,0,d[f].index*12)),a.uv>=0&&e.vertexUvBuffer&&
+(e.vertexUvBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.vertexUvBuffer),l.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,l.FLOAT,!1,0,d[f].index*8),l.enableVertexAttribArray(a.uv)):l.disableVertexAttribArray(a.uv)),a.color>=0&&e.vertexColorBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexColorBuffer),l.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,l.FLOAT,!1,0,d[f].index*16)),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),l.drawElements(l.TRIANGLES,d[f].count,l.UNSIGNED_SHORT,d[f].start*
+2),R.info.render.calls++,R.info.render.vertices+=d[f].count,R.info.render.faces+=d[f].count/3}};this.renderBuffer=function(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=s(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==Z&&(Z=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),
+l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):c.position>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],k=-1,
+j=0;h=f.morphTargetInfluences;var m,n=h.length;g=0;for(f.morphTargetBase!==-1&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(m=0;m<n;m++)!i[m]&&h[m]>k&&(j=m,k=h[j]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j]);l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[j]=1;k=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=
 0;for(h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],b[c.buffer.belongsToAttribute]>=0&&(l.bindBuffer(l.ARRAY_BUFFER,c.buffer),l.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,l.FLOAT,!1,0,0))}b.color>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglColorBuffer),l.vertexAttribPointer(b.color,3,l.FLOAT,!1,0,0));b.normal>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglNormalBuffer),l.vertexAttribPointer(b.normal,3,l.FLOAT,!1,0,0));b.tangent>=0&&(l.bindBuffer(l.ARRAY_BUFFER,
 0;for(h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],b[c.buffer.belongsToAttribute]>=0&&(l.bindBuffer(l.ARRAY_BUFFER,c.buffer),l.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,l.FLOAT,!1,0,0))}b.color>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglColorBuffer),l.vertexAttribPointer(b.color,3,l.FLOAT,!1,0,0));b.normal>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglNormalBuffer),l.vertexAttribPointer(b.normal,3,l.FLOAT,!1,0,0));b.tangent>=0&&(l.bindBuffer(l.ARRAY_BUFFER,
 e.__webglTangentBuffer),l.vertexAttribPointer(b.tangent,4,l.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUVBuffer),l.vertexAttribPointer(b.uv,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv)):l.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUV2Buffer),l.vertexAttribPointer(b.uv2,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv2)):l.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=
 e.__webglTangentBuffer),l.vertexAttribPointer(b.tangent,4,l.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUVBuffer),l.vertexAttribPointer(b.uv,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv)):l.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUV2Buffer),l.vertexAttribPointer(b.uv2,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv2)):l.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=
 0&&b.skinIndex>=0&&b.skinWeight>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexABuffer),l.vertexAttribPointer(b.skinVertexA,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),l.vertexAttribPointer(b.skinVertexB,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?
 0&&b.skinIndex>=0&&b.skinWeight>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexABuffer),l.vertexAttribPointer(b.skinVertexA,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),l.vertexAttribPointer(b.skinVertexB,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?
 (d=d.wireframeLinewidth,d!==fa&&(l.lineWidth(d),fa=d),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,e.__webglLineCount,l.UNSIGNED_SHORT,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,l.UNSIGNED_SHORT,0)),R.info.render.calls++,R.info.render.vertices+=e.__webglFaceCount,R.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!==
 (d=d.wireframeLinewidth,d!==fa&&(l.lineWidth(d),fa=d),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,e.__webglLineCount,l.UNSIGNED_SHORT,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,l.UNSIGNED_SHORT,0)),R.info.render.calls++,R.info.render.vertices+=e.__webglFaceCount,R.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!==
-fa&&(l.lineWidth(d),fa=d),l.drawArrays(f,0,e.__webglLineCount),R.info.render.calls++):f instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,0,e.__webglParticleCount),R.info.render.calls++,R.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,m,n=a.lights,o=a.fog;L=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+fa&&(l.lineWidth(d),fa=d),l.drawArrays(f,0,e.__webglLineCount),R.info.render.calls++):f instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,0,e.__webglParticleCount),R.info.render.calls++,R.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,m,n=a.lights,o=a.fog;M=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
 a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);R.info.render.calls=0;R.info.render.vertices=0;R.info.render.faces=0;R.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);ya.multiply(b.projectionMatrix,
 a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);R.info.render.calls=0;R.info.render.vertices=0;R.info.render.faces=0;R.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);ya.multiply(b.projectionMatrix,
 b.matrixWorldInverse);xa.setFromMatrix(ya);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d<e;d++)if(f=m[d],g=f.object,f.render=!1,g.visible&&(!(g instanceof THREE.Mesh||g instanceof THREE.ParticleSystem)||!g.frustumCulled||xa.contains(g))){g.matrixWorld.flattenToArray(g._objectMatrixArray);r(g,b);var p=f,q=p.object,s=p.buffer,y=void 0,y=y=void 0,y=q.material;if(y instanceof THREE.MeshFaceMaterial){if(y=
 b.matrixWorldInverse);xa.setFromMatrix(ya);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d<e;d++)if(f=m[d],g=f.object,f.render=!1,g.visible&&(!(g instanceof THREE.Mesh||g instanceof THREE.ParticleSystem)||!g.frustumCulled||xa.contains(g))){g.matrixWorld.flattenToArray(g._objectMatrixArray);r(g,b);var p=f,q=p.object,s=p.buffer,y=void 0,y=y=void 0,y=q.material;if(y instanceof THREE.MeshFaceMaterial){if(y=
 s.materialIndex,y>=0)y=q.geometry.materials[y],y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null)}else if(y)y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(za.copy(g.position),ya.multiplyVector3(za),f.z=za.z)}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d<e;d++)if(f=m[d],g=f.object,g.visible)g.matrixAutoUpdate&&g.matrixWorld.flattenToArray(g._objectMatrixArray),
 s.materialIndex,y>=0)y=q.geometry.materials[y],y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null)}else if(y)y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(za.copy(g.position),ya.multiplyVector3(za),f.z=za.z)}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d<e;d++)if(f=m[d],g=f.object,g.visible)g.matrixAutoUpdate&&g.matrixWorld.flattenToArray(g._objectMatrixArray),
-r(g,b),g=f.object.material,g.transparent?(f.transparent=g,f.opaque=null):(f.opaque=g,f.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),u(a.overrideMaterial.depthWrite),t(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,n,o,!0,a.overrideMaterial),j(a.__webglObjectsImmediate,"",b,n,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
-k(a.__webglObjects,!0,"opaque",b,n,o,!1),j(a.__webglObjectsImmediate,"opaque",b,n,o,!1),k(a.__webglObjects,!1,"transparent",b,n,o,!0),j(a.__webglObjectsImmediate,"transparent",b,n,o,!0));i(this.renderPluginsPost,a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP,c.__webglTexture),l.generateMipmap(l.TEXTURE_CUBE_MAP),l.bindTexture(l.TEXTURE_CUBE_MAP,null)):(l.bindTexture(l.TEXTURE_2D,c.__webglTexture),
+r(g,b),g=f.object.material,g.transparent?(f.transparent=g,f.opaque=null):(f.opaque=g,f.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),u(a.overrideMaterial.depthWrite),t(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),j(a.__webglObjects,!1,"",b,n,o,!0,a.overrideMaterial),k(a.__webglObjectsImmediate,"",b,n,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
+j(a.__webglObjects,!0,"opaque",b,n,o,!1),k(a.__webglObjectsImmediate,"opaque",b,n,o,!1),j(a.__webglObjects,!1,"transparent",b,n,o,!0),k(a.__webglObjectsImmediate,"transparent",b,n,o,!0));i(this.renderPluginsPost,a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP,c.__webglTexture),l.generateMipmap(l.TEXTURE_CUBE_MAP),l.bindTexture(l.TEXTURE_CUBE_MAP,null)):(l.bindTexture(l.TEXTURE_2D,c.__webglTexture),
 l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,e){var f=s(a,b,c,d,e);Z=-1;R.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,l,xa):e.render(function(a){R.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=a,k=void 0,j=void 0,
 l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,e){var f=s(a,b,c,d,e);Z=-1;R.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,l,xa):e.render(function(a){R.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=a,k=void 0,j=void 0,
-H=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){j=h.geometry;if(j.geometryGroups===void 0){var H=j,s=void 0,r=void 0,y=void 0,u=void 0,t=void 0,w=void 0,C=void 0,v={},z=H.morphTargets.length;H.geometryGroups={};s=0;for(r=H.faces.length;s<r;s++)y=H.faces[s],u=y.materialIndex,
-w=u!==void 0?u:-1,v[w]===void 0&&(v[w]={hash:w,counter:0}),C=v[w].hash+"_"+v[w].counter,H.geometryGroups[C]===void 0&&(H.geometryGroups[C]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:z}),t=y instanceof THREE.Face3?3:4,H.geometryGroups[C].vertices+t>65535&&(v[w].counter+=1,C=v[w].hash+"_"+v[w].counter,H.geometryGroups[C]===void 0&&(H.geometryGroups[C]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:z})),y instanceof THREE.Face3?H.geometryGroups[C].faces3.push(s):
-H.geometryGroups[C].faces4.push(s),H.geometryGroups[C].vertices+=t;H.geometryGroupsList=[];s=void 0;for(s in H.geometryGroups)H.geometryGroups[s].id=da++,H.geometryGroupsList.push(H.geometryGroups[s])}for(k in j.geometryGroups)if(H=j.geometryGroups[k],!H.__webglVertexBuffer){s=H;s.__webglVertexBuffer=l.createBuffer();s.__webglNormalBuffer=l.createBuffer();s.__webglTangentBuffer=l.createBuffer();s.__webglColorBuffer=l.createBuffer();s.__webglUVBuffer=l.createBuffer();s.__webglUV2Buffer=l.createBuffer();
-s.__webglSkinVertexABuffer=l.createBuffer();s.__webglSkinVertexBBuffer=l.createBuffer();s.__webglSkinIndicesBuffer=l.createBuffer();s.__webglSkinWeightsBuffer=l.createBuffer();s.__webglFaceBuffer=l.createBuffer();s.__webglLineBuffer=l.createBuffer();if(s.numMorphTargets){y=r=void 0;s.__webglMorphTargetsBuffers=[];r=0;for(y=s.numMorphTargets;r<y;r++)s.__webglMorphTargetsBuffers.push(l.createBuffer())}R.info.memory.geometries++;u=h;t=u.geometry;r=H.faces3;w=H.faces4;s=r.length*3+w.length*4;y=r.length*
-1+w.length*2;w=r.length*3+w.length*4;r=c(u,H);C=f(r);v=d(r);z=e(r);H.__vertexArray=new Float32Array(s*3);if(v)H.__normalArray=new Float32Array(s*3);if(t.hasTangents)H.__tangentArray=new Float32Array(s*4);if(z)H.__colorArray=new Float32Array(s*3);if(C){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)H.__uvArray=new Float32Array(s*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)H.__uv2Array=new Float32Array(s*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length)H.__skinVertexAArray=
-new Float32Array(s*4),H.__skinVertexBArray=new Float32Array(s*4),H.__skinIndexArray=new Float32Array(s*4),H.__skinWeightArray=new Float32Array(s*4);H.__faceArray=new Uint16Array(y*3);H.__lineArray=new Uint16Array(w*2);if(H.numMorphTargets){H.__morphTargetsArrays=[];u=0;for(t=H.numMorphTargets;u<t;u++)H.__morphTargetsArrays.push(new Float32Array(s*3))}H.__webglFaceCount=y*3;H.__webglLineCount=w*2;if(r.attributes){if(H.__webglCustomAttributesList===void 0)H.__webglCustomAttributesList=[];y=void 0;for(y in r.attributes){var u=
-r.attributes[y],t={},K;for(K in u)t[K]=u[K];if(!t.__webglInitialized||t.createUniqueBuffers)t.__webglInitialized=!0,w=1,t.type==="v2"?w=2:t.type==="v3"?w=3:t.type==="v4"?w=4:t.type==="c"&&(w=3),t.size=w,t.array=new Float32Array(s*w),t.buffer=l.createBuffer(),t.buffer.belongsToAttribute=y,u.needsUpdate=!0,t.__original=u;H.__webglCustomAttributesList.push(t)}}H.__inittedArrays=!0;j.__dirtyVertices=!0;j.__dirtyMorphTargets=!0;j.__dirtyElements=!0;j.__dirtyUvs=!0;j.__dirtyNormals=!0;j.__dirtyTangents=
-!0;j.__dirtyColors=!0}}else if(h instanceof THREE.Ribbon){if(j=h.geometry,!j.__webglVertexBuffer)H=j,H.__webglVertexBuffer=l.createBuffer(),H.__webglColorBuffer=l.createBuffer(),R.info.memory.geometries++,H=j,s=H.vertices.length,H.__vertexArray=new Float32Array(s*3),H.__colorArray=new Float32Array(s*3),H.__webglVertexCount=s,j.__dirtyVertices=!0,j.__dirtyColors=!0}else if(h instanceof THREE.Line){if(j=h.geometry,!j.__webglVertexBuffer)H=j,H.__webglVertexBuffer=l.createBuffer(),H.__webglColorBuffer=
-l.createBuffer(),R.info.memory.geometries++,H=j,s=h,r=H.vertices.length,H.__vertexArray=new Float32Array(r*3),H.__colorArray=new Float32Array(r*3),H.__webglLineCount=r,b(H,s),j.__dirtyVertices=!0,j.__dirtyColors=!0}else if(h instanceof THREE.ParticleSystem&&(j=h.geometry,!j.__webglVertexBuffer))H=j,H.__webglVertexBuffer=l.createBuffer(),H.__webglColorBuffer=l.createBuffer(),R.info.geometries++,H=j,s=h,r=H.vertices.length,H.__vertexArray=new Float32Array(r*3),H.__colorArray=new Float32Array(r*3),H.__sortArray=
-[],H.__webglParticleCount=r,b(H,s),j.__dirtyVertices=!0,j.__dirtyColors=!0;if(!h.__webglActive){if(h instanceof THREE.Mesh)for(k in j=h.geometry,j.geometryGroups)H=j.geometryGroups[k],o(i.__webglObjects,H,h);else h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem?(j=h.geometry,o(i.__webglObjects,j,h)):THREE.MarchingCubes!==void 0&&h instanceof THREE.MarchingCubes||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,opaque:null,transparent:null}):h instanceof
-THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;)h=a.__objectsRemoved[0],i=a,h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem||h instanceof THREE.Ribbon||h instanceof THREE.Line?q(i.__webglObjects,h):h instanceof THREE.Sprite?n(i.__webglSprites,h):h instanceof THREE.LensFlare?n(i.__webglFlares,h):(h instanceof THREE.MarchingCubes||h.immediateRenderCallback)&&q(i.__webglObjectsImmediate,
-h),h.__webglActive=!1,a.__objectsRemoved.splice(0,1);h=0;for(i=a.__webglObjects.length;h<i;h++)if(K=a.__webglObjects[h].object,k=K.geometry,j=y=r=void 0,K instanceof THREE.Mesh){H=0;for(s=k.geometryGroupsList.length;H<s;H++)if(r=k.geometryGroupsList[H],j=c(K,r),y=j.attributes&&p(j),k.__dirtyVertices||k.__dirtyMorphTargets||k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||y){var G=K,y=l.DYNAMIC_DRAW,u=!k.dynamic,C=j;if(r.__inittedArrays){var t=d(C),w=e(C),B=f(C),
-E=t===THREE.SmoothShading,A=v=C=void 0,I=void 0,L=void 0,Q=void 0,J=void 0,D=void 0,$=void 0,Z=A=void 0,P=void 0,M=void 0,N=void 0,S=I=void 0,U=void 0,Y=void 0,X=I=$=void 0,W=void 0,aa=N=M=P=J=void 0,T=I=N=M=P=aa=N=M=P=aa=N=M=P=void 0,O=void 0,ca=Q=void 0,ga=void 0,ba=void 0,va=void 0,fa=void 0,na=Z=ba=O=0,la=0,ja=T=A=0,ha=J=S=0,F=0,ma=void 0,ha=r.__vertexArray,ga=r.__uvArray,F=r.__uv2Array,ca=r.__normalArray,L=r.__tangentArray,U=r.__colorArray,X=r.__skinVertexAArray,W=r.__skinVertexBArray,D=r.__skinIndexArray,
-oa=r.__skinWeightArray,aa=r.__morphTargetsArrays,z=r.__webglCustomAttributesList,x=void 0,x=r.__faceArray,ma=r.__lineArray,Y=G.geometry,qa=Y.__dirtyElements,sa=Y.__dirtyUvs,Q=Y.__dirtyNormals,$=Y.__dirtyTangents,za=Y.__dirtyColors,va=Y.__dirtyMorphTargets,fa=Y.vertices,G=r.faces3,ia=r.faces4,ka=Y.faces,ya=Y.faceVertexUvs[0],Ba=Y.faceVertexUvs[1],wa=Y.skinVerticesA,xa=Y.skinVerticesB,Aa=Y.skinIndices,Ga=Y.skinWeights,Ha=Y.morphTargets;if(Y.__dirtyVertices){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],P=fa[I.a].position,
-M=fa[I.b].position,N=fa[I.c].position,ha[ba]=P.x,ha[ba+1]=P.y,ha[ba+2]=P.z,ha[ba+3]=M.x,ha[ba+4]=M.y,ha[ba+5]=M.z,ha[ba+6]=N.x,ha[ba+7]=N.y,ha[ba+8]=N.z,ba+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=fa[I.a].position,M=fa[I.b].position,N=fa[I.c].position,I=fa[I.d].position,ha[ba]=P.x,ha[ba+1]=P.y,ha[ba+2]=P.z,ha[ba+3]=M.x,ha[ba+4]=M.y,ha[ba+5]=M.z,ha[ba+6]=N.x,ha[ba+7]=N.y,ha[ba+8]=N.z,ha[ba+9]=I.x,ha[ba+10]=I.y,ha[ba+11]=I.z,ba+=12;l.bindBuffer(l.ARRAY_BUFFER,r.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,
-ha,y)}if(va){ba=0;for(va=Ha.length;ba<va;ba++){C=ha=0;for(v=G.length;C<v;C++)I=ka[G[C]],P=Ha[ba].vertices[I.a].position,M=Ha[ba].vertices[I.b].position,N=Ha[ba].vertices[I.c].position,fa=aa[ba],fa[ha]=P.x,fa[ha+1]=P.y,fa[ha+2]=P.z,fa[ha+3]=M.x,fa[ha+4]=M.y,fa[ha+5]=M.z,fa[ha+6]=N.x,fa[ha+7]=N.y,fa[ha+8]=N.z,ha+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=Ha[ba].vertices[I.a].position,M=Ha[ba].vertices[I.b].position,N=Ha[ba].vertices[I.c].position,I=Ha[ba].vertices[I.d].position,fa=aa[ba],fa[ha]=P.x,
-fa[ha+1]=P.y,fa[ha+2]=P.z,fa[ha+3]=M.x,fa[ha+4]=M.y,fa[ha+5]=M.z,fa[ha+6]=N.x,fa[ha+7]=N.y,fa[ha+8]=N.z,fa[ha+9]=I.x,fa[ha+10]=I.y,fa[ha+11]=I.z,ha+=12;l.bindBuffer(l.ARRAY_BUFFER,r.__webglMorphTargetsBuffers[ba]);l.bufferData(l.ARRAY_BUFFER,aa[ba],y)}}if(Ga.length){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],P=Ga[I.a],M=Ga[I.b],N=Ga[I.c],oa[J]=P.x,oa[J+1]=P.y,oa[J+2]=P.z,oa[J+3]=P.w,oa[J+4]=M.x,oa[J+5]=M.y,oa[J+6]=M.z,oa[J+7]=M.w,oa[J+8]=N.x,oa[J+9]=N.y,oa[J+10]=N.z,oa[J+11]=N.w,P=Aa[I.a],M=Aa[I.b],N=
-Aa[I.c],D[J]=P.x,D[J+1]=P.y,D[J+2]=P.z,D[J+3]=P.w,D[J+4]=M.x,D[J+5]=M.y,D[J+6]=M.z,D[J+7]=M.w,D[J+8]=N.x,D[J+9]=N.y,D[J+10]=N.z,D[J+11]=N.w,P=wa[I.a],M=wa[I.b],N=wa[I.c],X[J]=P.x,X[J+1]=P.y,X[J+2]=P.z,X[J+3]=1,X[J+4]=M.x,X[J+5]=M.y,X[J+6]=M.z,X[J+7]=1,X[J+8]=N.x,X[J+9]=N.y,X[J+10]=N.z,X[J+11]=1,P=xa[I.a],M=xa[I.b],N=xa[I.c],W[J]=P.x,W[J+1]=P.y,W[J+2]=P.z,W[J+3]=1,W[J+4]=M.x,W[J+5]=M.y,W[J+6]=M.z,W[J+7]=1,W[J+8]=N.x,W[J+9]=N.y,W[J+10]=N.z,W[J+11]=1,J+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=Ga[I.a],
-M=Ga[I.b],N=Ga[I.c],aa=Ga[I.d],oa[J]=P.x,oa[J+1]=P.y,oa[J+2]=P.z,oa[J+3]=P.w,oa[J+4]=M.x,oa[J+5]=M.y,oa[J+6]=M.z,oa[J+7]=M.w,oa[J+8]=N.x,oa[J+9]=N.y,oa[J+10]=N.z,oa[J+11]=N.w,oa[J+12]=aa.x,oa[J+13]=aa.y,oa[J+14]=aa.z,oa[J+15]=aa.w,P=Aa[I.a],M=Aa[I.b],N=Aa[I.c],aa=Aa[I.d],D[J]=P.x,D[J+1]=P.y,D[J+2]=P.z,D[J+3]=P.w,D[J+4]=M.x,D[J+5]=M.y,D[J+6]=M.z,D[J+7]=M.w,D[J+8]=N.x,D[J+9]=N.y,D[J+10]=N.z,D[J+11]=N.w,D[J+12]=aa.x,D[J+13]=aa.y,D[J+14]=aa.z,D[J+15]=aa.w,P=wa[I.a],M=wa[I.b],N=wa[I.c],aa=wa[I.d],X[J]=
-P.x,X[J+1]=P.y,X[J+2]=P.z,X[J+3]=1,X[J+4]=M.x,X[J+5]=M.y,X[J+6]=M.z,X[J+7]=1,X[J+8]=N.x,X[J+9]=N.y,X[J+10]=N.z,X[J+11]=1,X[J+12]=aa.x,X[J+13]=aa.y,X[J+14]=aa.z,X[J+15]=1,P=xa[I.a],M=xa[I.b],N=xa[I.c],I=xa[I.d],W[J]=P.x,W[J+1]=P.y,W[J+2]=P.z,W[J+3]=1,W[J+4]=M.x,W[J+5]=M.y,W[J+6]=M.z,W[J+7]=1,W[J+8]=N.x,W[J+9]=N.y,W[J+10]=N.z,W[J+11]=1,W[J+12]=I.x,W[J+13]=I.y,W[J+14]=I.z,W[J+15]=1,J+=16;J>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinVertexABuffer),l.bufferData(l.ARRAY_BUFFER,X,y),l.bindBuffer(l.ARRAY_BUFFER,
-r.__webglSkinVertexBBuffer),l.bufferData(l.ARRAY_BUFFER,W,y),l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,D,y),l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,oa,y))}if(za&&w){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],J=I.vertexColors,D=I.color,J.length===3&&w===THREE.VertexColors?(I=J[0],X=J[1],W=J[2]):W=X=I=D,U[S]=I.r,U[S+1]=I.g,U[S+2]=I.b,U[S+3]=X.r,U[S+4]=X.g,U[S+5]=X.b,U[S+6]=W.r,U[S+7]=W.g,U[S+8]=W.b,S+=9;C=0;for(v=ia.length;C<
-v;C++)I=ka[ia[C]],J=I.vertexColors,D=I.color,J.length===4&&w===THREE.VertexColors?(I=J[0],X=J[1],W=J[2],J=J[3]):J=W=X=I=D,U[S]=I.r,U[S+1]=I.g,U[S+2]=I.b,U[S+3]=X.r,U[S+4]=X.g,U[S+5]=X.b,U[S+6]=W.r,U[S+7]=W.g,U[S+8]=W.b,U[S+9]=J.r,U[S+10]=J.g,U[S+11]=J.b,S+=12;S>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,U,y))}if($&&Y.hasTangents){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],$=I.vertexTangents,S=$[0],U=$[1],Y=$[2],L[T]=S.x,L[T+1]=S.y,L[T+2]=S.z,L[T+3]=S.w,L[T+4]=U.x,
-L[T+5]=U.y,L[T+6]=U.z,L[T+7]=U.w,L[T+8]=Y.x,L[T+9]=Y.y,L[T+10]=Y.z,L[T+11]=Y.w,T+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],$=I.vertexTangents,S=$[0],U=$[1],Y=$[2],$=$[3],L[T]=S.x,L[T+1]=S.y,L[T+2]=S.z,L[T+3]=S.w,L[T+4]=U.x,L[T+5]=U.y,L[T+6]=U.z,L[T+7]=U.w,L[T+8]=Y.x,L[T+9]=Y.y,L[T+10]=Y.z,L[T+11]=Y.w,L[T+12]=$.x,L[T+13]=$.y,L[T+14]=$.z,L[T+15]=$.w,T+=16;l.bindBuffer(l.ARRAY_BUFFER,r.__webglTangentBuffer);l.bufferData(l.ARRAY_BUFFER,L,y)}if(Q&&t){C=0;for(v=G.length;C<v;C++)if(I=ka[G[C]],L=I.vertexNormals,
-Q=I.normal,L.length===3&&E)for(T=0;T<3;T++)Q=L[T],ca[A]=Q.x,ca[A+1]=Q.y,ca[A+2]=Q.z,A+=3;else for(T=0;T<3;T++)ca[A]=Q.x,ca[A+1]=Q.y,ca[A+2]=Q.z,A+=3;C=0;for(v=ia.length;C<v;C++)if(I=ka[ia[C]],L=I.vertexNormals,Q=I.normal,L.length===4&&E)for(T=0;T<4;T++)Q=L[T],ca[A]=Q.x,ca[A+1]=Q.y,ca[A+2]=Q.z,A+=3;else for(T=0;T<4;T++)ca[A]=Q.x,ca[A+1]=Q.y,ca[A+2]=Q.z,A+=3;l.bindBuffer(l.ARRAY_BUFFER,r.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER,ca,y)}if(sa&&ya&&B){C=0;for(v=G.length;C<v;C++)if(A=G[C],A=ya[A],
-A!==void 0)for(T=0;T<3;T++)ca=A[T],ga[Z]=ca.u,ga[Z+1]=ca.v,Z+=2;C=0;for(v=ia.length;C<v;C++)if(A=ia[C],A=ya[A],A!==void 0)for(T=0;T<4;T++)ca=A[T],ga[Z]=ca.u,ga[Z+1]=ca.v,Z+=2;Z>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,ga,y))}if(sa&&Ba&&B){C=0;for(v=G.length;C<v;C++)if(A=G[C],Z=Ba[A],Z!==void 0)for(T=0;T<3;T++)ga=Z[T],F[na]=ga.u,F[na+1]=ga.v,na+=2;C=0;for(v=ia.length;C<v;C++)if(A=ia[C],Z=Ba[A],Z!==void 0)for(T=0;T<4;T++)ga=Z[T],F[na]=ga.u,F[na+1]=ga.v,na+=2;na>
-0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,F,y))}if(qa){C=0;for(v=G.length;C<v;C++)x[la]=O,x[la+1]=O+1,x[la+2]=O+2,la+=3,ma[ja]=O,ma[ja+1]=O+1,ma[ja+2]=O,ma[ja+3]=O+2,ma[ja+4]=O+1,ma[ja+5]=O+2,ja+=6,O+=3;C=0;for(v=ia.length;C<v;C++)x[la]=O,x[la+1]=O+1,x[la+2]=O+3,x[la+3]=O+1,x[la+4]=O+2,x[la+5]=O+3,la+=6,ma[ja]=O,ma[ja+1]=O+1,ma[ja+2]=O,ma[ja+3]=O+3,ma[ja+4]=O+1,ma[ja+5]=O+2,ma[ja+6]=O+2,ma[ja+7]=O+3,ja+=8,O+=4;l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,r.__webglFaceBuffer);
-l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,y);l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,r.__webglLineBuffer);l.bufferData(l.ELEMENT_ARRAY_BUFFER,ma,y)}if(z){T=0;for(O=z.length;T<O;T++)if(x=z[T],x.__original.needsUpdate){F=0;if(x.size===1)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],x.array[F]=x.value[I.a],x.array[F+1]=x.value[I.b],x.array[F+2]=x.value[I.c],F+=3;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],x.array[F]=x.value[I.a],x.array[F+1]=x.value[I.b],x.array[F+2]=x.value[I.c],
-x.array[F+3]=x.value[I.d],F+=4}else{if(x.boundTo==="faces"){C=0;for(v=G.length;C<v;C++)ma=x.value[G[C]],x.array[F]=ma,x.array[F+1]=ma,x.array[F+2]=ma,F+=3;C=0;for(v=ia.length;C<v;C++)ma=x.value[ia[C]],x.array[F]=ma,x.array[F+1]=ma,x.array[F+2]=ma,x.array[F+3]=ma,F+=4}}else if(x.size===2)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=M.x,x.array[F+3]=M.y,x.array[F+4]=N.x,
-x.array[F+5]=N.y,F+=6;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],I=x.value[I.d],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=M.x,x.array[F+3]=M.y,x.array[F+4]=N.x,x.array[F+5]=N.y,x.array[F+6]=I.x,x.array[F+7]=I.y,F+=8}else{if(x.boundTo==="faces"){C=0;for(v=G.length;C<v;C++)N=M=P=ma=x.value[G[C]],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=M.x,x.array[F+3]=M.y,x.array[F+4]=N.x,x.array[F+5]=N.y,F+=6;C=0;for(v=ia.length;C<v;C++)I=N=M=P=ma=x.value[ia[C]],x.array[F]=
-P.x,x.array[F+1]=P.y,x.array[F+2]=M.x,x.array[F+3]=M.y,x.array[F+4]=N.x,x.array[F+5]=N.y,x.array[F+6]=I.x,x.array[F+7]=I.y,F+=8}}else if(x.size===3)if(t=x.type==="c"?["r","g","b"]:["x","y","z"],x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=G.length;C<v;C++)I=ka[G[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],x.array[F]=P[t[0]],x.array[F+1]=P[t[1]],x.array[F+2]=P[t[2]],x.array[F+3]=M[t[0]],x.array[F+4]=M[t[1]],x.array[F+5]=M[t[2]],x.array[F+6]=N[t[0]],x.array[F+7]=N[t[1]],x.array[F+8]=N[t[2]],
-F+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],I=x.value[I.d],x.array[F]=P[t[0]],x.array[F+1]=P[t[1]],x.array[F+2]=P[t[2]],x.array[F+3]=M[t[0]],x.array[F+4]=M[t[1]],x.array[F+5]=M[t[2]],x.array[F+6]=N[t[0]],x.array[F+7]=N[t[1]],x.array[F+8]=N[t[2]],x.array[F+9]=I[t[0]],x.array[F+10]=I[t[1]],x.array[F+11]=I[t[2]],F+=12}else{if(x.boundTo==="faces"){C=0;for(v=G.length;C<v;C++)N=M=P=ma=x.value[G[C]],x.array[F]=P[t[0]],x.array[F+1]=P[t[1]],x.array[F+2]=P[t[2]],
-x.array[F+3]=M[t[0]],x.array[F+4]=M[t[1]],x.array[F+5]=M[t[2]],x.array[F+6]=N[t[0]],x.array[F+7]=N[t[1]],x.array[F+8]=N[t[2]],F+=9;C=0;for(v=ia.length;C<v;C++)I=N=M=P=ma=x.value[ia[C]],x.array[F]=P[t[0]],x.array[F+1]=P[t[1]],x.array[F+2]=P[t[2]],x.array[F+3]=M[t[0]],x.array[F+4]=M[t[1]],x.array[F+5]=M[t[2]],x.array[F+6]=N[t[0]],x.array[F+7]=N[t[1]],x.array[F+8]=N[t[2]],x.array[F+9]=I[t[0]],x.array[F+10]=I[t[1]],x.array[F+11]=I[t[2]],F+=12}}else if(x.size===4)if(x.boundTo===void 0||x.boundTo==="vertices"){C=
-0;for(v=G.length;C<v;C++)I=ka[G[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=P.z,x.array[F+3]=P.w,x.array[F+4]=M.x,x.array[F+5]=M.y,x.array[F+6]=M.z,x.array[F+7]=M.w,x.array[F+8]=N.x,x.array[F+9]=N.y,x.array[F+10]=N.z,x.array[F+11]=N.w,F+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],M=x.value[I.b],N=x.value[I.c],I=x.value[I.d],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=P.z,x.array[F+3]=P.w,x.array[F+4]=M.x,x.array[F+5]=M.y,x.array[F+
-6]=M.z,x.array[F+7]=M.w,x.array[F+8]=N.x,x.array[F+9]=N.y,x.array[F+10]=N.z,x.array[F+11]=N.w,x.array[F+12]=I.x,x.array[F+13]=I.y,x.array[F+14]=I.z,x.array[F+15]=I.w,F+=16}else if(x.boundTo==="faces"){C=0;for(v=G.length;C<v;C++)N=M=P=ma=x.value[G[C]],x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=P.z,x.array[F+3]=P.w,x.array[F+4]=M.x,x.array[F+5]=M.y,x.array[F+6]=M.z,x.array[F+7]=M.w,x.array[F+8]=N.x,x.array[F+9]=N.y,x.array[F+10]=N.z,x.array[F+11]=N.w,F+=12;C=0;for(v=ia.length;C<v;C++)I=N=M=P=ma=x.value[ia[C]],
-x.array[F]=P.x,x.array[F+1]=P.y,x.array[F+2]=P.z,x.array[F+3]=P.w,x.array[F+4]=M.x,x.array[F+5]=M.y,x.array[F+6]=M.z,x.array[F+7]=M.w,x.array[F+8]=N.x,x.array[F+9]=N.y,x.array[F+10]=N.z,x.array[F+11]=N.w,x.array[F+12]=I.x,x.array[F+13]=I.y,x.array[F+14]=I.z,x.array[F+15]=I.w,F+=16}l.bindBuffer(l.ARRAY_BUFFER,x.buffer);l.bufferData(l.ARRAY_BUFFER,x.array,y)}}u&&(delete r.__inittedArrays,delete r.__colorArray,delete r.__normalArray,delete r.__tangentArray,delete r.__uvArray,delete r.__uv2Array,delete r.__faceArray,
-delete r.__vertexArray,delete r.__lineArray,delete r.__skinVertexAArray,delete r.__skinVertexBArray,delete r.__skinIndexArray,delete r.__skinWeightArray)}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=!1;j.attributes&&m(j)}else if(K instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){j=k;K=l.DYNAMIC_DRAW;t=H=t=u=u=void 0;w=j.vertices;s=j.colors;C=w.length;r=s.length;v=j.__vertexArray;y=j.__colorArray;
-z=j.__dirtyColors;if(j.__dirtyVertices){for(u=0;u<C;u++)t=w[u].position,H=u*3,v[H]=t.x,v[H+1]=t.y,v[H+2]=t.z;l.bindBuffer(l.ARRAY_BUFFER,j.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,v,K)}if(z){for(u=0;u<r;u++)t=s[u],H=u*3,y[H]=t.r,y[H+1]=t.g,y[H+2]=t.b;l.bindBuffer(l.ARRAY_BUFFER,j.__webglColorBuffer);l.bufferData(l.ARRAY_BUFFER,y,K)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(K instanceof THREE.Line){j=c(K,r);y=j.attributes&&p(j);if(k.__dirtyVertices||k.__dirtyColors||y){K=k;H=l.DYNAMIC_DRAW;
-C=s=E=w=B=void 0;w=K.vertices;r=K.colors;C=w.length;y=r.length;v=K.__vertexArray;u=K.__colorArray;z=K.__dirtyColors;t=K.__webglCustomAttributesList;O=ka=ia=G=E=B=void 0;if(K.__dirtyVertices){for(B=0;B<C;B++)E=w[B].position,s=B*3,v[s]=E.x,v[s+1]=E.y,v[s+2]=E.z;l.bindBuffer(l.ARRAY_BUFFER,K.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,v,H)}if(z){for(w=0;w<y;w++)C=r[w],s=w*3,u[s]=C.r,u[s+1]=C.g,u[s+2]=C.b;l.bindBuffer(l.ARRAY_BUFFER,K.__webglColorBuffer);l.bufferData(l.ARRAY_BUFFER,u,H)}if(t){B=
-0;for(E=t.length;B<E;B++)if(O=t[B],O.needsUpdate&&(O.boundTo===void 0||O.boundTo==="vertices")){s=0;ia=O.value.length;if(O.size===1)for(G=0;G<ia;G++)O.array[G]=O.value[G];else if(O.size===2)for(G=0;G<ia;G++)ka=O.value[G],O.array[s]=ka.x,O.array[s+1]=ka.y,s+=2;else if(O.size===3)if(O.type==="c")for(G=0;G<ia;G++)ka=O.value[G],O.array[s]=ka.r,O.array[s+1]=ka.g,O.array[s+2]=ka.b,s+=3;else for(G=0;G<ia;G++)ka=O.value[G],O.array[s]=ka.x,O.array[s+1]=ka.y,O.array[s+2]=ka.z,s+=3;else if(O.size===4)for(G=
-0;G<ia;G++)ka=O.value[G],O.array[s]=ka.x,O.array[s+1]=ka.y,O.array[s+2]=ka.z,O.array[s+3]=ka.w,s+=4;l.bindBuffer(l.ARRAY_BUFFER,O.buffer);l.bufferData(l.ARRAY_BUFFER,O.array,H)}}}k.__dirtyVertices=!1;k.__dirtyColors=!1;j.attributes&&m(j)}else if(K instanceof THREE.ParticleSystem)j=c(K,r),y=j.attributes&&p(j),(k.__dirtyVertices||k.__dirtyColors||K.sortParticles||y)&&g(k,l.DYNAMIC_DRAW,K),k.__dirtyVertices=!1,k.__dirtyColors=!1,j.attributes&&m(j)};this.initMaterial=function(a,b,c,d){var e,f,g,h;a instanceof
-THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,m;j=m=i=0;for(k=
-b.length;j<k;j++)g=b[j],g instanceof THREE.SpotLight&&m++,g instanceof THREE.DirectionalLight&&m++,g instanceof THREE.PointLight&&i++;i+m<=S?j=m:(j=Math.ceil(S*m/(i+m)),i=S-j);g={directional:j,point:i};i=m=0;for(j=b.length;i<j;i++)k=b[i],k instanceof THREE.SpotLight&&k.castShadow&&m++;var n=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)n=d.bones.length;var o;a:{j=a.fragmentShader;k=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,
-fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:n,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},p,d=[];h?d.push(h):(d.push(j),d.push(k));for(p in c)d.push(p),d.push(c[p]);
-h=d.join();p=0;for(d=W.length;p<d;p++)if(W[p].code===h){o=W[p].program;break a}p=l.createProgram();d=[la?"#define VERTEX_TEXTURES":"",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":
-"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-g=["precision "+G+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
-"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");l.attachShader(p,z("fragment",g+j));l.attachShader(p,z("vertex",
+G=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(j=h.geometry,j instanceof THREE.Geometry){if(j.geometryGroups===void 0){var G=j,s=void 0,r=void 0,y=void 0,u=void 0,t=void 0,w=void 0,C=void 0,v={},A=G.morphTargets.length;G.geometryGroups={};s=0;for(r=G.faces.length;s<
+r;s++)y=G.faces[s],u=y.materialIndex,w=u!==void 0?u:-1,v[w]===void 0&&(v[w]={hash:w,counter:0}),C=v[w].hash+"_"+v[w].counter,G.geometryGroups[C]===void 0&&(G.geometryGroups[C]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:A}),t=y instanceof THREE.Face3?3:4,G.geometryGroups[C].vertices+t>65535&&(v[w].counter+=1,C=v[w].hash+"_"+v[w].counter,G.geometryGroups[C]===void 0&&(G.geometryGroups[C]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:A})),y instanceof THREE.Face3?
+G.geometryGroups[C].faces3.push(s):G.geometryGroups[C].faces4.push(s),G.geometryGroups[C].vertices+=t;G.geometryGroupsList=[];s=void 0;for(s in G.geometryGroups)G.geometryGroups[s].id=ca++,G.geometryGroupsList.push(G.geometryGroups[s])}for(k in j.geometryGroups)if(G=j.geometryGroups[k],!G.__webglVertexBuffer){s=G;s.__webglVertexBuffer=l.createBuffer();s.__webglNormalBuffer=l.createBuffer();s.__webglTangentBuffer=l.createBuffer();s.__webglColorBuffer=l.createBuffer();s.__webglUVBuffer=l.createBuffer();
+s.__webglUV2Buffer=l.createBuffer();s.__webglSkinVertexABuffer=l.createBuffer();s.__webglSkinVertexBBuffer=l.createBuffer();s.__webglSkinIndicesBuffer=l.createBuffer();s.__webglSkinWeightsBuffer=l.createBuffer();s.__webglFaceBuffer=l.createBuffer();s.__webglLineBuffer=l.createBuffer();if(s.numMorphTargets){y=r=void 0;s.__webglMorphTargetsBuffers=[];r=0;for(y=s.numMorphTargets;r<y;r++)s.__webglMorphTargetsBuffers.push(l.createBuffer())}R.info.memory.geometries++;u=h;t=u.geometry;r=G.faces3;w=G.faces4;
+s=r.length*3+w.length*4;y=r.length*1+w.length*2;w=r.length*3+w.length*4;r=c(u,G);C=f(r);v=d(r);A=e(r);G.__vertexArray=new Float32Array(s*3);if(v)G.__normalArray=new Float32Array(s*3);if(t.hasTangents)G.__tangentArray=new Float32Array(s*4);if(A)G.__colorArray=new Float32Array(s*3);if(C){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)G.__uvArray=new Float32Array(s*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(s*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length)G.__skinVertexAArray=
+new Float32Array(s*4),G.__skinVertexBArray=new Float32Array(s*4),G.__skinIndexArray=new Float32Array(s*4),G.__skinWeightArray=new Float32Array(s*4);G.__faceArray=new Uint16Array(y*3);G.__lineArray=new Uint16Array(w*2);if(G.numMorphTargets){G.__morphTargetsArrays=[];u=0;for(t=G.numMorphTargets;u<t;u++)G.__morphTargetsArrays.push(new Float32Array(s*3))}G.__webglFaceCount=y*3;G.__webglLineCount=w*2;if(r.attributes){if(G.__webglCustomAttributesList===void 0)G.__webglCustomAttributesList=[];y=void 0;for(y in r.attributes){var u=
+r.attributes[y],t={},K;for(K in u)t[K]=u[K];if(!t.__webglInitialized||t.createUniqueBuffers)t.__webglInitialized=!0,w=1,t.type==="v2"?w=2:t.type==="v3"?w=3:t.type==="v4"?w=4:t.type==="c"&&(w=3),t.size=w,t.array=new Float32Array(s*w),t.buffer=l.createBuffer(),t.buffer.belongsToAttribute=y,u.needsUpdate=!0,t.__original=u;G.__webglCustomAttributesList.push(t)}}G.__inittedArrays=!0;j.__dirtyVertices=!0;j.__dirtyMorphTargets=!0;j.__dirtyElements=!0;j.__dirtyUvs=!0;j.__dirtyNormals=!0;j.__dirtyTangents=
+!0;j.__dirtyColors=!0}}}else if(h instanceof THREE.Ribbon){if(j=h.geometry,!j.__webglVertexBuffer)G=j,G.__webglVertexBuffer=l.createBuffer(),G.__webglColorBuffer=l.createBuffer(),R.info.memory.geometries++,G=j,s=G.vertices.length,G.__vertexArray=new Float32Array(s*3),G.__colorArray=new Float32Array(s*3),G.__webglVertexCount=s,j.__dirtyVertices=!0,j.__dirtyColors=!0}else if(h instanceof THREE.Line){if(j=h.geometry,!j.__webglVertexBuffer)G=j,G.__webglVertexBuffer=l.createBuffer(),G.__webglColorBuffer=
+l.createBuffer(),R.info.memory.geometries++,G=j,s=h,r=G.vertices.length,G.__vertexArray=new Float32Array(r*3),G.__colorArray=new Float32Array(r*3),G.__webglLineCount=r,b(G,s),j.__dirtyVertices=!0,j.__dirtyColors=!0}else if(h instanceof THREE.ParticleSystem&&(j=h.geometry,!j.__webglVertexBuffer))G=j,G.__webglVertexBuffer=l.createBuffer(),G.__webglColorBuffer=l.createBuffer(),R.info.geometries++,G=j,s=h,r=G.vertices.length,G.__vertexArray=new Float32Array(r*3),G.__colorArray=new Float32Array(r*3),G.__sortArray=
+[],G.__webglParticleCount=r,b(G,s),j.__dirtyVertices=!0,j.__dirtyColors=!0;if(!h.__webglActive){if(h instanceof THREE.Mesh)if(j=h.geometry,j instanceof THREE.BufferGeometry)o(i.__webglObjects,j,h);else for(k in j.geometryGroups)G=j.geometryGroups[k],o(i.__webglObjects,G,h);else h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem?(j=h.geometry,o(i.__webglObjects,j,h)):THREE.MarchingCubes!==void 0&&h instanceof THREE.MarchingCubes||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,
+opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;)h=a.__objectsRemoved[0],i=a,h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem||h instanceof THREE.Ribbon||h instanceof THREE.Line?q(i.__webglObjects,h):h instanceof THREE.Sprite?n(i.__webglSprites,h):h instanceof THREE.LensFlare?n(i.__webglFlares,h):(h instanceof THREE.MarchingCubes||
+h.immediateRenderCallback)&&q(i.__webglObjectsImmediate,h),h.__webglActive=!1,a.__objectsRemoved.splice(0,1);h=0;for(i=a.__webglObjects.length;h<i;h++)if(K=a.__webglObjects[h].object,k=K.geometry,j=y=r=void 0,K instanceof THREE.Mesh)if(k instanceof THREE.BufferGeometry)k.__dirtyVertices=!1,k.__dirtyElements=!1,k.__dirtyUvs=!1,k.__dirtyNormals=!1,k.__dirtyColors=!1;else{G=0;for(s=k.geometryGroupsList.length;G<s;G++)if(r=k.geometryGroupsList[G],j=c(K,r),y=j.attributes&&p(j),k.__dirtyVertices||k.__dirtyMorphTargets||
+k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||y){var F=K,y=l.DYNAMIC_DRAW,u=!k.dynamic,C=j;if(r.__inittedArrays){var t=d(C),w=e(C),z=f(C),H=t===THREE.SmoothShading,B=v=C=void 0,I=void 0,M=void 0,Q=void 0,J=void 0,D=void 0,$=void 0,Z=B=void 0,P=void 0,N=void 0,O=void 0,T=I=void 0,U=void 0,X=void 0,W=I=$=void 0,V=void 0,ea=O=N=P=J=void 0,L=I=O=N=P=ea=O=N=P=ea=O=N=P=void 0,S=void 0,ba=Q=void 0,ga=void 0,aa=void 0,va=void 0,fa=void 0,na=Z=aa=S=0,la=0,ja=L=B=0,
+ha=J=T=0,E=0,ma=void 0,ha=r.__vertexArray,ga=r.__uvArray,E=r.__uv2Array,ba=r.__normalArray,M=r.__tangentArray,U=r.__colorArray,W=r.__skinVertexAArray,V=r.__skinVertexBArray,D=r.__skinIndexArray,oa=r.__skinWeightArray,ea=r.__morphTargetsArrays,A=r.__webglCustomAttributesList,x=void 0,x=r.__faceArray,ma=r.__lineArray,X=F.geometry,qa=X.__dirtyElements,sa=X.__dirtyUvs,Q=X.__dirtyNormals,$=X.__dirtyTangents,za=X.__dirtyColors,va=X.__dirtyMorphTargets,fa=X.vertices,F=r.faces3,ia=r.faces4,ka=X.faces,ya=
+X.faceVertexUvs[0],Ba=X.faceVertexUvs[1],wa=X.skinVerticesA,xa=X.skinVerticesB,Aa=X.skinIndices,Ga=X.skinWeights,Ha=X.morphTargets;if(X.__dirtyVertices){C=0;for(v=F.length;C<v;C++)I=ka[F[C]],P=fa[I.a].position,N=fa[I.b].position,O=fa[I.c].position,ha[aa]=P.x,ha[aa+1]=P.y,ha[aa+2]=P.z,ha[aa+3]=N.x,ha[aa+4]=N.y,ha[aa+5]=N.z,ha[aa+6]=O.x,ha[aa+7]=O.y,ha[aa+8]=O.z,aa+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=fa[I.a].position,N=fa[I.b].position,O=fa[I.c].position,I=fa[I.d].position,ha[aa]=P.x,ha[aa+
+1]=P.y,ha[aa+2]=P.z,ha[aa+3]=N.x,ha[aa+4]=N.y,ha[aa+5]=N.z,ha[aa+6]=O.x,ha[aa+7]=O.y,ha[aa+8]=O.z,ha[aa+9]=I.x,ha[aa+10]=I.y,ha[aa+11]=I.z,aa+=12;l.bindBuffer(l.ARRAY_BUFFER,r.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,ha,y)}if(va){aa=0;for(va=Ha.length;aa<va;aa++){C=ha=0;for(v=F.length;C<v;C++)I=ka[F[C]],P=Ha[aa].vertices[I.a].position,N=Ha[aa].vertices[I.b].position,O=Ha[aa].vertices[I.c].position,fa=ea[aa],fa[ha]=P.x,fa[ha+1]=P.y,fa[ha+2]=P.z,fa[ha+3]=N.x,fa[ha+4]=N.y,fa[ha+5]=N.z,fa[ha+
+6]=O.x,fa[ha+7]=O.y,fa[ha+8]=O.z,ha+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=Ha[aa].vertices[I.a].position,N=Ha[aa].vertices[I.b].position,O=Ha[aa].vertices[I.c].position,I=Ha[aa].vertices[I.d].position,fa=ea[aa],fa[ha]=P.x,fa[ha+1]=P.y,fa[ha+2]=P.z,fa[ha+3]=N.x,fa[ha+4]=N.y,fa[ha+5]=N.z,fa[ha+6]=O.x,fa[ha+7]=O.y,fa[ha+8]=O.z,fa[ha+9]=I.x,fa[ha+10]=I.y,fa[ha+11]=I.z,ha+=12;l.bindBuffer(l.ARRAY_BUFFER,r.__webglMorphTargetsBuffers[aa]);l.bufferData(l.ARRAY_BUFFER,ea[aa],y)}}if(Ga.length){C=0;for(v=
+F.length;C<v;C++)I=ka[F[C]],P=Ga[I.a],N=Ga[I.b],O=Ga[I.c],oa[J]=P.x,oa[J+1]=P.y,oa[J+2]=P.z,oa[J+3]=P.w,oa[J+4]=N.x,oa[J+5]=N.y,oa[J+6]=N.z,oa[J+7]=N.w,oa[J+8]=O.x,oa[J+9]=O.y,oa[J+10]=O.z,oa[J+11]=O.w,P=Aa[I.a],N=Aa[I.b],O=Aa[I.c],D[J]=P.x,D[J+1]=P.y,D[J+2]=P.z,D[J+3]=P.w,D[J+4]=N.x,D[J+5]=N.y,D[J+6]=N.z,D[J+7]=N.w,D[J+8]=O.x,D[J+9]=O.y,D[J+10]=O.z,D[J+11]=O.w,P=wa[I.a],N=wa[I.b],O=wa[I.c],W[J]=P.x,W[J+1]=P.y,W[J+2]=P.z,W[J+3]=1,W[J+4]=N.x,W[J+5]=N.y,W[J+6]=N.z,W[J+7]=1,W[J+8]=O.x,W[J+9]=O.y,W[J+
+10]=O.z,W[J+11]=1,P=xa[I.a],N=xa[I.b],O=xa[I.c],V[J]=P.x,V[J+1]=P.y,V[J+2]=P.z,V[J+3]=1,V[J+4]=N.x,V[J+5]=N.y,V[J+6]=N.z,V[J+7]=1,V[J+8]=O.x,V[J+9]=O.y,V[J+10]=O.z,V[J+11]=1,J+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=Ga[I.a],N=Ga[I.b],O=Ga[I.c],ea=Ga[I.d],oa[J]=P.x,oa[J+1]=P.y,oa[J+2]=P.z,oa[J+3]=P.w,oa[J+4]=N.x,oa[J+5]=N.y,oa[J+6]=N.z,oa[J+7]=N.w,oa[J+8]=O.x,oa[J+9]=O.y,oa[J+10]=O.z,oa[J+11]=O.w,oa[J+12]=ea.x,oa[J+13]=ea.y,oa[J+14]=ea.z,oa[J+15]=ea.w,P=Aa[I.a],N=Aa[I.b],O=Aa[I.c],ea=Aa[I.d],
+D[J]=P.x,D[J+1]=P.y,D[J+2]=P.z,D[J+3]=P.w,D[J+4]=N.x,D[J+5]=N.y,D[J+6]=N.z,D[J+7]=N.w,D[J+8]=O.x,D[J+9]=O.y,D[J+10]=O.z,D[J+11]=O.w,D[J+12]=ea.x,D[J+13]=ea.y,D[J+14]=ea.z,D[J+15]=ea.w,P=wa[I.a],N=wa[I.b],O=wa[I.c],ea=wa[I.d],W[J]=P.x,W[J+1]=P.y,W[J+2]=P.z,W[J+3]=1,W[J+4]=N.x,W[J+5]=N.y,W[J+6]=N.z,W[J+7]=1,W[J+8]=O.x,W[J+9]=O.y,W[J+10]=O.z,W[J+11]=1,W[J+12]=ea.x,W[J+13]=ea.y,W[J+14]=ea.z,W[J+15]=1,P=xa[I.a],N=xa[I.b],O=xa[I.c],I=xa[I.d],V[J]=P.x,V[J+1]=P.y,V[J+2]=P.z,V[J+3]=1,V[J+4]=N.x,V[J+5]=N.y,
+V[J+6]=N.z,V[J+7]=1,V[J+8]=O.x,V[J+9]=O.y,V[J+10]=O.z,V[J+11]=1,V[J+12]=I.x,V[J+13]=I.y,V[J+14]=I.z,V[J+15]=1,J+=16;J>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinVertexABuffer),l.bufferData(l.ARRAY_BUFFER,W,y),l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinVertexBBuffer),l.bufferData(l.ARRAY_BUFFER,V,y),l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,D,y),l.bindBuffer(l.ARRAY_BUFFER,r.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,oa,y))}if(za&&w){C=0;for(v=F.length;C<
+v;C++)I=ka[F[C]],J=I.vertexColors,D=I.color,J.length===3&&w===THREE.VertexColors?(I=J[0],W=J[1],V=J[2]):V=W=I=D,U[T]=I.r,U[T+1]=I.g,U[T+2]=I.b,U[T+3]=W.r,U[T+4]=W.g,U[T+5]=W.b,U[T+6]=V.r,U[T+7]=V.g,U[T+8]=V.b,T+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],J=I.vertexColors,D=I.color,J.length===4&&w===THREE.VertexColors?(I=J[0],W=J[1],V=J[2],J=J[3]):J=V=W=I=D,U[T]=I.r,U[T+1]=I.g,U[T+2]=I.b,U[T+3]=W.r,U[T+4]=W.g,U[T+5]=W.b,U[T+6]=V.r,U[T+7]=V.g,U[T+8]=V.b,U[T+9]=J.r,U[T+10]=J.g,U[T+11]=J.b,T+=12;T>0&&
+(l.bindBuffer(l.ARRAY_BUFFER,r.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,U,y))}if($&&X.hasTangents){C=0;for(v=F.length;C<v;C++)I=ka[F[C]],$=I.vertexTangents,T=$[0],U=$[1],X=$[2],M[L]=T.x,M[L+1]=T.y,M[L+2]=T.z,M[L+3]=T.w,M[L+4]=U.x,M[L+5]=U.y,M[L+6]=U.z,M[L+7]=U.w,M[L+8]=X.x,M[L+9]=X.y,M[L+10]=X.z,M[L+11]=X.w,L+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],$=I.vertexTangents,T=$[0],U=$[1],X=$[2],$=$[3],M[L]=T.x,M[L+1]=T.y,M[L+2]=T.z,M[L+3]=T.w,M[L+4]=U.x,M[L+5]=U.y,M[L+6]=U.z,M[L+7]=U.w,M[L+8]=
+X.x,M[L+9]=X.y,M[L+10]=X.z,M[L+11]=X.w,M[L+12]=$.x,M[L+13]=$.y,M[L+14]=$.z,M[L+15]=$.w,L+=16;l.bindBuffer(l.ARRAY_BUFFER,r.__webglTangentBuffer);l.bufferData(l.ARRAY_BUFFER,M,y)}if(Q&&t){C=0;for(v=F.length;C<v;C++)if(I=ka[F[C]],M=I.vertexNormals,Q=I.normal,M.length===3&&H)for(L=0;L<3;L++)Q=M[L],ba[B]=Q.x,ba[B+1]=Q.y,ba[B+2]=Q.z,B+=3;else for(L=0;L<3;L++)ba[B]=Q.x,ba[B+1]=Q.y,ba[B+2]=Q.z,B+=3;C=0;for(v=ia.length;C<v;C++)if(I=ka[ia[C]],M=I.vertexNormals,Q=I.normal,M.length===4&&H)for(L=0;L<4;L++)Q=
+M[L],ba[B]=Q.x,ba[B+1]=Q.y,ba[B+2]=Q.z,B+=3;else for(L=0;L<4;L++)ba[B]=Q.x,ba[B+1]=Q.y,ba[B+2]=Q.z,B+=3;l.bindBuffer(l.ARRAY_BUFFER,r.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER,ba,y)}if(sa&&ya&&z){C=0;for(v=F.length;C<v;C++)if(B=F[C],B=ya[B],B!==void 0)for(L=0;L<3;L++)ba=B[L],ga[Z]=ba.u,ga[Z+1]=ba.v,Z+=2;C=0;for(v=ia.length;C<v;C++)if(B=ia[C],B=ya[B],B!==void 0)for(L=0;L<4;L++)ba=B[L],ga[Z]=ba.u,ga[Z+1]=ba.v,Z+=2;Z>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,
+ga,y))}if(sa&&Ba&&z){C=0;for(v=F.length;C<v;C++)if(B=F[C],Z=Ba[B],Z!==void 0)for(L=0;L<3;L++)ga=Z[L],E[na]=ga.u,E[na+1]=ga.v,na+=2;C=0;for(v=ia.length;C<v;C++)if(B=ia[C],Z=Ba[B],Z!==void 0)for(L=0;L<4;L++)ga=Z[L],E[na]=ga.u,E[na+1]=ga.v,na+=2;na>0&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,E,y))}if(qa){C=0;for(v=F.length;C<v;C++)x[la]=S,x[la+1]=S+1,x[la+2]=S+2,la+=3,ma[ja]=S,ma[ja+1]=S+1,ma[ja+2]=S,ma[ja+3]=S+2,ma[ja+4]=S+1,ma[ja+5]=S+2,ja+=6,S+=3;C=0;for(v=ia.length;C<
+v;C++)x[la]=S,x[la+1]=S+1,x[la+2]=S+3,x[la+3]=S+1,x[la+4]=S+2,x[la+5]=S+3,la+=6,ma[ja]=S,ma[ja+1]=S+1,ma[ja+2]=S,ma[ja+3]=S+3,ma[ja+4]=S+1,ma[ja+5]=S+2,ma[ja+6]=S+2,ma[ja+7]=S+3,ja+=8,S+=4;l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,r.__webglFaceBuffer);l.bufferData(l.ELEMENT_ARRAY_BUFFER,x,y);l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,r.__webglLineBuffer);l.bufferData(l.ELEMENT_ARRAY_BUFFER,ma,y)}if(A){L=0;for(S=A.length;L<S;L++)if(x=A[L],x.__original.needsUpdate){E=0;if(x.size===1)if(x.boundTo===void 0||x.boundTo===
+"vertices"){C=0;for(v=F.length;C<v;C++)I=ka[F[C]],x.array[E]=x.value[I.a],x.array[E+1]=x.value[I.b],x.array[E+2]=x.value[I.c],E+=3;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],x.array[E]=x.value[I.a],x.array[E+1]=x.value[I.b],x.array[E+2]=x.value[I.c],x.array[E+3]=x.value[I.d],E+=4}else{if(x.boundTo==="faces"){C=0;for(v=F.length;C<v;C++)ma=x.value[F[C]],x.array[E]=ma,x.array[E+1]=ma,x.array[E+2]=ma,E+=3;C=0;for(v=ia.length;C<v;C++)ma=x.value[ia[C]],x.array[E]=ma,x.array[E+1]=ma,x.array[E+2]=ma,x.array[E+
+3]=ma,E+=4}}else if(x.size===2)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=F.length;C<v;C++)I=ka[F[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=N.x,x.array[E+3]=N.y,x.array[E+4]=O.x,x.array[E+5]=O.y,E+=6;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],I=x.value[I.d],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=N.x,x.array[E+3]=N.y,x.array[E+4]=O.x,x.array[E+5]=O.y,x.array[E+6]=I.x,x.array[E+7]=I.y,E+=
+8}else{if(x.boundTo==="faces"){C=0;for(v=F.length;C<v;C++)O=N=P=ma=x.value[F[C]],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=N.x,x.array[E+3]=N.y,x.array[E+4]=O.x,x.array[E+5]=O.y,E+=6;C=0;for(v=ia.length;C<v;C++)I=O=N=P=ma=x.value[ia[C]],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=N.x,x.array[E+3]=N.y,x.array[E+4]=O.x,x.array[E+5]=O.y,x.array[E+6]=I.x,x.array[E+7]=I.y,E+=8}}else if(x.size===3)if(t=x.type==="c"?["r","g","b"]:["x","y","z"],x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=F.length;C<
+v;C++)I=ka[F[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],x.array[E]=P[t[0]],x.array[E+1]=P[t[1]],x.array[E+2]=P[t[2]],x.array[E+3]=N[t[0]],x.array[E+4]=N[t[1]],x.array[E+5]=N[t[2]],x.array[E+6]=O[t[0]],x.array[E+7]=O[t[1]],x.array[E+8]=O[t[2]],E+=9;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],I=x.value[I.d],x.array[E]=P[t[0]],x.array[E+1]=P[t[1]],x.array[E+2]=P[t[2]],x.array[E+3]=N[t[0]],x.array[E+4]=N[t[1]],x.array[E+5]=N[t[2]],x.array[E+6]=O[t[0]],x.array[E+
+7]=O[t[1]],x.array[E+8]=O[t[2]],x.array[E+9]=I[t[0]],x.array[E+10]=I[t[1]],x.array[E+11]=I[t[2]],E+=12}else{if(x.boundTo==="faces"){C=0;for(v=F.length;C<v;C++)O=N=P=ma=x.value[F[C]],x.array[E]=P[t[0]],x.array[E+1]=P[t[1]],x.array[E+2]=P[t[2]],x.array[E+3]=N[t[0]],x.array[E+4]=N[t[1]],x.array[E+5]=N[t[2]],x.array[E+6]=O[t[0]],x.array[E+7]=O[t[1]],x.array[E+8]=O[t[2]],E+=9;C=0;for(v=ia.length;C<v;C++)I=O=N=P=ma=x.value[ia[C]],x.array[E]=P[t[0]],x.array[E+1]=P[t[1]],x.array[E+2]=P[t[2]],x.array[E+3]=
+N[t[0]],x.array[E+4]=N[t[1]],x.array[E+5]=N[t[2]],x.array[E+6]=O[t[0]],x.array[E+7]=O[t[1]],x.array[E+8]=O[t[2]],x.array[E+9]=I[t[0]],x.array[E+10]=I[t[1]],x.array[E+11]=I[t[2]],E+=12}}else if(x.size===4)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(v=F.length;C<v;C++)I=ka[F[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=P.z,x.array[E+3]=P.w,x.array[E+4]=N.x,x.array[E+5]=N.y,x.array[E+6]=N.z,x.array[E+7]=N.w,x.array[E+8]=O.x,x.array[E+9]=O.y,
+x.array[E+10]=O.z,x.array[E+11]=O.w,E+=12;C=0;for(v=ia.length;C<v;C++)I=ka[ia[C]],P=x.value[I.a],N=x.value[I.b],O=x.value[I.c],I=x.value[I.d],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=P.z,x.array[E+3]=P.w,x.array[E+4]=N.x,x.array[E+5]=N.y,x.array[E+6]=N.z,x.array[E+7]=N.w,x.array[E+8]=O.x,x.array[E+9]=O.y,x.array[E+10]=O.z,x.array[E+11]=O.w,x.array[E+12]=I.x,x.array[E+13]=I.y,x.array[E+14]=I.z,x.array[E+15]=I.w,E+=16}else if(x.boundTo==="faces"){C=0;for(v=F.length;C<v;C++)O=N=P=ma=x.value[F[C]],
+x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=P.z,x.array[E+3]=P.w,x.array[E+4]=N.x,x.array[E+5]=N.y,x.array[E+6]=N.z,x.array[E+7]=N.w,x.array[E+8]=O.x,x.array[E+9]=O.y,x.array[E+10]=O.z,x.array[E+11]=O.w,E+=12;C=0;for(v=ia.length;C<v;C++)I=O=N=P=ma=x.value[ia[C]],x.array[E]=P.x,x.array[E+1]=P.y,x.array[E+2]=P.z,x.array[E+3]=P.w,x.array[E+4]=N.x,x.array[E+5]=N.y,x.array[E+6]=N.z,x.array[E+7]=N.w,x.array[E+8]=O.x,x.array[E+9]=O.y,x.array[E+10]=O.z,x.array[E+11]=O.w,x.array[E+12]=I.x,x.array[E+13]=I.y,
+x.array[E+14]=I.z,x.array[E+15]=I.w,E+=16}l.bindBuffer(l.ARRAY_BUFFER,x.buffer);l.bufferData(l.ARRAY_BUFFER,x.array,y)}}u&&(delete r.__inittedArrays,delete r.__colorArray,delete r.__normalArray,delete r.__tangentArray,delete r.__uvArray,delete r.__uv2Array,delete r.__faceArray,delete r.__vertexArray,delete r.__lineArray,delete r.__skinVertexAArray,delete r.__skinVertexBArray,delete r.__skinIndexArray,delete r.__skinWeightArray)}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=
+!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=!1;j.attributes&&m(j)}else if(K instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){j=k;K=l.DYNAMIC_DRAW;t=G=t=u=u=void 0;w=j.vertices;s=j.colors;C=w.length;r=s.length;v=j.__vertexArray;y=j.__colorArray;A=j.__dirtyColors;if(j.__dirtyVertices){for(u=0;u<C;u++)t=w[u].position,G=u*3,v[G]=t.x,v[G+1]=t.y,v[G+2]=t.z;l.bindBuffer(l.ARRAY_BUFFER,j.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,v,K)}if(A){for(u=0;u<r;u++)t=s[u],G=u*
+3,y[G]=t.r,y[G+1]=t.g,y[G+2]=t.b;l.bindBuffer(l.ARRAY_BUFFER,j.__webglColorBuffer);l.bufferData(l.ARRAY_BUFFER,y,K)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(K instanceof THREE.Line){j=c(K,r);y=j.attributes&&p(j);if(k.__dirtyVertices||k.__dirtyColors||y){K=k;G=l.DYNAMIC_DRAW;C=s=H=w=z=void 0;w=K.vertices;r=K.colors;C=w.length;y=r.length;v=K.__vertexArray;u=K.__colorArray;A=K.__dirtyColors;t=K.__webglCustomAttributesList;S=ka=ia=F=H=z=void 0;if(K.__dirtyVertices){for(z=0;z<C;z++)H=w[z].position,
+s=z*3,v[s]=H.x,v[s+1]=H.y,v[s+2]=H.z;l.bindBuffer(l.ARRAY_BUFFER,K.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,v,G)}if(A){for(w=0;w<y;w++)C=r[w],s=w*3,u[s]=C.r,u[s+1]=C.g,u[s+2]=C.b;l.bindBuffer(l.ARRAY_BUFFER,K.__webglColorBuffer);l.bufferData(l.ARRAY_BUFFER,u,G)}if(t){z=0;for(H=t.length;z<H;z++)if(S=t[z],S.needsUpdate&&(S.boundTo===void 0||S.boundTo==="vertices")){s=0;ia=S.value.length;if(S.size===1)for(F=0;F<ia;F++)S.array[F]=S.value[F];else if(S.size===2)for(F=0;F<ia;F++)ka=S.value[F],S.array[s]=
+ka.x,S.array[s+1]=ka.y,s+=2;else if(S.size===3)if(S.type==="c")for(F=0;F<ia;F++)ka=S.value[F],S.array[s]=ka.r,S.array[s+1]=ka.g,S.array[s+2]=ka.b,s+=3;else for(F=0;F<ia;F++)ka=S.value[F],S.array[s]=ka.x,S.array[s+1]=ka.y,S.array[s+2]=ka.z,s+=3;else if(S.size===4)for(F=0;F<ia;F++)ka=S.value[F],S.array[s]=ka.x,S.array[s+1]=ka.y,S.array[s+2]=ka.z,S.array[s+3]=ka.w,s+=4;l.bindBuffer(l.ARRAY_BUFFER,S.buffer);l.bufferData(l.ARRAY_BUFFER,S.array,G)}}}k.__dirtyVertices=!1;k.__dirtyColors=!1;j.attributes&&
+m(j)}else if(K instanceof THREE.ParticleSystem)j=c(K,r),y=j.attributes&&p(j),(k.__dirtyVertices||k.__dirtyColors||K.sortParticles||y)&&g(k,l.DYNAMIC_DRAW,K),k.__dirtyVertices=!1,k.__dirtyColors=!1,j.attributes&&m(j)};this.initMaterial=function(a,b,c,d){var e,f,g,h;a instanceof THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":
+a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,m;j=m=i=0;for(k=b.length;j<k;j++)g=b[j],g instanceof THREE.SpotLight&&m++,g instanceof THREE.DirectionalLight&&m++,g instanceof THREE.PointLight&&i++;i+m<=T?j=m:(j=Math.ceil(T*m/(i+m)),i=T-j);g={directional:j,point:i};i=m=0;for(j=b.length;i<
+j;i++)k=b[i],k instanceof THREE.SpotLight&&k.castShadow&&m++;var n=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)n=d.bones.length;var o;a:{j=a.fragmentShader;k=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:n,shadowMapEnabled:this.shadowMapEnabled&&
+d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},p,d=[];h?d.push(h):(d.push(j),d.push(k));for(p in c)d.push(p),d.push(c[p]);h=d.join();p=0;for(d=S.length;p<d;p++)if(S[p].code===h){o=S[p].program;break a}p=l.createProgram();d=[la?"#define VERTEX_TEXTURES":"",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?
+"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?
+"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+g=["precision "+F+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
+"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");l.attachShader(p,A("fragment",g+j));l.attachShader(p,A("vertex",
 d+k));l.linkProgram(p);l.getProgramParameter(p,l.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+l.getProgramParameter(p,l.VALIDATE_STATUS)+", gl error ["+l.getError()+"]");p.uniforms={};p.attributes={};var q,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in i)d.push(q);q=d;d=0;for(i=q.length;d<i;d++)j=q[d],p.uniforms[j]=l.getUniformLocation(p,
 d+k));l.linkProgram(p);l.getProgramParameter(p,l.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+l.getProgramParameter(p,l.VALIDATE_STATUS)+", gl error ["+l.getError()+"]");p.uniforms={};p.attributes={};var q,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in i)d.push(q);q=d;d=0;for(i=q.length;d<i;d++)j=q[d],p.uniforms[j]=l.getUniformLocation(p,
-j);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(q=0;q<c.maxMorphTargets;q++)d.push("morphTarget"+q);for(o in b)d.push(o);o=d;q=0;for(b=o.length;q<b;q++)c=o[q],p.attributes[c]=l.getAttribLocation(p,c);p.id=W.length;W.push({program:p,code:h});R.info.memory.programs=W.length;o=p}a.program=o;o=a.program.attributes;o.position>=0&&l.enableVertexAttribArray(o.position);o.color>=0&&l.enableVertexAttribArray(o.color);o.normal>=0&&l.enableVertexAttribArray(o.normal);
+j);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(q=0;q<c.maxMorphTargets;q++)d.push("morphTarget"+q);for(o in b)d.push(o);o=d;q=0;for(b=o.length;q<b;q++)c=o[q],p.attributes[c]=l.getAttribLocation(p,c);p.id=S.length;S.push({program:p,code:h});R.info.memory.programs=S.length;o=p}a.program=o;o=a.program.attributes;o.position>=0&&l.enableVertexAttribArray(o.position);o.color>=0&&l.enableVertexAttribArray(o.color);o.normal>=0&&l.enableVertexAttribArray(o.normal);
 o.tangent>=0&&l.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(l.enableVertexAttribArray(o.skinVertexA),l.enableVertexAttribArray(o.skinVertexB),l.enableVertexAttribArray(o.skinIndex),l.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&l.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f<this.maxMorphTargets;f++)q="morphTarget"+f,o[q]>=0&&(l.enableVertexAttribArray(o[q]),
 o.tangent>=0&&l.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(l.enableVertexAttribArray(o.skinVertexA),l.enableVertexAttribArray(o.skinVertexB),l.enableVertexAttribArray(o.skinIndex),l.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&l.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f<this.maxMorphTargets;f++)q="morphTarget"+f,o[q]>=0&&(l.enableVertexAttribArray(o[q]),
-a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?l.frontFace(l.CCW):l.frontFace(l.CW),a==="back"?l.cullFace(l.BACK):a==="front"?l.cullFace(l.FRONT):l.cullFace(l.FRONT_AND_BACK),l.enable(l.CULL_FACE)):l.disable(l.CULL_FACE)};this.setObjectFaces=function(a){if(ba!==a.doubleSided)a.doubleSided?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE),ba=a.doubleSided;if(T!==a.flipSided)a.flipSided?l.frontFace(l.CW):
-l.frontFace(l.CCW),T=a.flipSided};this.setDepthTest=function(a){O!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),O=a)};this.setBlending=function(a){if(a!==U){switch(a){case THREE.AdditiveBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE);break;case THREE.SubtractiveBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.SRC_COLOR);break;default:l.blendEquationSeparate(l.FUNC_ADD,
-l.FUNC_ADD),l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA)}U=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),R.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture);var c=A(l.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,B(a.format),a.image.width,a.image.height,0,B(a.format),l.UNSIGNED_BYTE,a.image.data):l.texImage2D(l.TEXTURE_2D,
+a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?l.frontFace(l.CCW):l.frontFace(l.CW),a==="back"?l.cullFace(l.BACK):a==="front"?l.cullFace(l.FRONT):l.cullFace(l.FRONT_AND_BACK),l.enable(l.CULL_FACE)):l.disable(l.CULL_FACE)};this.setObjectFaces=function(a){if(aa!==a.doubleSided)a.doubleSided?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE),aa=a.doubleSided;if(ea!==a.flipSided)a.flipSided?l.frontFace(l.CW):
+l.frontFace(l.CCW),ea=a.flipSided};this.setDepthTest=function(a){L!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),L=a)};this.setBlending=function(a){if(a!==U){switch(a){case THREE.AdditiveBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE);break;case THREE.SubtractiveBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.SRC_COLOR);break;default:l.blendEquationSeparate(l.FUNC_ADD,
+l.FUNC_ADD),l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA)}U=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),R.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture);var c=B(l.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,H(a.format),a.image.width,a.image.height,0,H(a.format),l.UNSIGNED_BYTE,a.image.data):l.texImage2D(l.TEXTURE_2D,
 0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,a.image);c&&l.generateMipmap(l.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else l.activeTexture(l.TEXTURE0+b),l.bindTexture(l.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=l.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];l.bindTexture(l.TEXTURE_CUBE_MAP,
 0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,a.image);c&&l.generateMipmap(l.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else l.activeTexture(l.TEXTURE0+b),l.bindTexture(l.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=l.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];l.bindTexture(l.TEXTURE_CUBE_MAP,
-a.__webglTexture);A(l.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=l.createFramebuffer();a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,B(a.format),a.width,a.height,0,B(a.format),B(a.type),null);var d=a,e=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,e,d.__webglTexture,0);E(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),
-a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),A(l.TEXTURE_2D,a,a),l.texImage2D(l.TEXTURE_2D,0,B(a.format),a.width,a.height,0,B(a.format),B(a.type),null),c=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,c,a.__webglTexture,0),E(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,
-null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=sa,a=qa,d=na,e=ja);b!==X&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),X=b);Ba=c;wa=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
+a.__webglTexture);B(l.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=l.createFramebuffer();a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,H(a.format),a.width,a.height,0,H(a.format),H(a.type),null);var d=a,e=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,e,d.__webglTexture,0);z(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),
+a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),B(l.TEXTURE_2D,a,a),l.texImage2D(l.TEXTURE_2D,0,H(a.format),a.width,a.height,0,H(a.format),H(a.type),null),c=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,c,a.__webglTexture,0),z(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,
+null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=sa,a=qa,d=na,e=ja);b!==W&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),W=b);Ba=c;wa=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type:
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type:
 THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0};
 THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};
@@ -344,20 +348,20 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}};
 THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,k=f.faces,j=a.faceVertexUvs[0],o=f.faceVertexUvs[0],p={},m=0;m<a.materials.length;m++)p[a.materials[m].id]=m;if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale);for(var m=0,q=h.length;m<q;m++){var n=new THREE.Vertex(h[m].position.clone());c&&c.multiplyVector3(n.position);g.push(n)}m=
-0;for(q=k.length;m<q;m++){var g=k[m],s,r,u=g.vertexNormals,t=g.vertexColors;g instanceof THREE.Face3?s=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(s=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));s.normal.copy(g.normal);d&&d.multiplyVector3(s.normal);h=0;for(n=u.length;h<n;h++)r=u[h].clone(),d&&d.multiplyVector3(r),s.vertexNormals.push(r);s.color.copy(g.color);h=0;for(n=t.length;h<n;h++)r=t[h],s.vertexColors.push(r.clone());if(g.materialIndex!==void 0){h=f.materials[g.materialIndex];
-n=h.id;t=p[n];if(t===void 0)t=a.materials.length,p[n]=t,a.materials.push(h);s.materialIndex=t}s.centroid.copy(g.centroid);c&&c.multiplyVector3(s.centroid);i.push(s)}m=0;for(q=o.length;m<q;m++){c=o[m];d=[];h=0;for(n=c.length;h<n;h++)d.push(new THREE.UV(c[h].u,c[h].v));j.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();a=0;for(c=d.length;a<c;a++){var g=new THREE.Vertex(d[a].position.clone());b.vertices.push(g)}a=
-0;for(c=e.length;a<c;a++){var h=e[a],i,k,j=h.vertexNormals,o=h.vertexColors;h instanceof THREE.Face3?i=new THREE.Face3(h.a,h.b,h.c):h instanceof THREE.Face4&&(i=new THREE.Face4(h.a,h.b,h.c,h.d));i.normal.copy(h.normal);d=0;for(g=j.length;d<g;d++)k=j[d],i.vertexNormals.push(k.clone());i.color.copy(h.color);d=0;for(g=o.length;d<g;d++)k=o[d],i.vertexColors.push(k.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);b.faces.push(i)}a=0;for(c=f.length;a<c;a++){e=f[a];i=[];d=0;for(g=e.length;d<
+THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,j=f.faces,k=a.faceVertexUvs[0],o=f.faceVertexUvs[0],p={},m=0;m<a.materials.length;m++)p[a.materials[m].id]=m;if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale);for(var m=0,q=h.length;m<q;m++){var n=new THREE.Vertex(h[m].position.clone());c&&c.multiplyVector3(n.position);g.push(n)}m=
+0;for(q=j.length;m<q;m++){var g=j[m],s,r,u=g.vertexNormals,t=g.vertexColors;g instanceof THREE.Face3?s=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(s=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));s.normal.copy(g.normal);d&&d.multiplyVector3(s.normal);h=0;for(n=u.length;h<n;h++)r=u[h].clone(),d&&d.multiplyVector3(r),s.vertexNormals.push(r);s.color.copy(g.color);h=0;for(n=t.length;h<n;h++)r=t[h],s.vertexColors.push(r.clone());if(g.materialIndex!==void 0){h=f.materials[g.materialIndex];
+n=h.id;t=p[n];if(t===void 0)t=a.materials.length,p[n]=t,a.materials.push(h);s.materialIndex=t}s.centroid.copy(g.centroid);c&&c.multiplyVector3(s.centroid);i.push(s)}m=0;for(q=o.length;m<q;m++){c=o[m];d=[];h=0;for(n=c.length;h<n;h++)d.push(new THREE.UV(c[h].u,c[h].v));k.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();a=0;for(c=d.length;a<c;a++){var g=new THREE.Vertex(d[a].position.clone());b.vertices.push(g)}a=
+0;for(c=e.length;a<c;a++){var h=e[a],i,j,k=h.vertexNormals,o=h.vertexColors;h instanceof THREE.Face3?i=new THREE.Face3(h.a,h.b,h.c):h instanceof THREE.Face4&&(i=new THREE.Face4(h.a,h.b,h.c,h.d));i.normal.copy(h.normal);d=0;for(g=k.length;d<g;d++)j=k[d],i.vertexNormals.push(j.clone());i.color.copy(h.color);d=0;for(g=o.length;d<g;d++)j=o[d],i.vertexColors.push(j.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);b.faces.push(i)}a=0;for(c=f.length;a<c;a++){e=f[a];i=[];d=0;for(g=e.length;d<
 g;d++)i.push(new THREE.UV(e[d].u,e[d].v));b.faceVertexUvs[0].push(i)}return b},randomPointInTriangle:function(a,b,c){var d,e,f,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();d+e>1&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position,
 g;d++)i.push(new THREE.UV(e[d].u,e[d].v));b.faceVertexUvs[0].push(i)}return b},randomPointInTriangle:function(a,b,c){var d,e,f,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();d+e>1&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position,
 f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+
 f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+
-g)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,k=[],j,o,p,m;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)j=g[d.a].position,o=g[d.b].position,p=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(j,o,p);else if(d instanceof
-THREE.Face4)j=g[d.a].position,o=g[d.b].position,p=g[d.c].position,m=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(j,o,m),d._area2=THREE.GeometryUtils.triangleArea(o,p,m),d._area=d._area1+d._area2;i+=d._area;k[e]=i}d=[];g={};for(e=0;e<b;e++)h=THREE.GeometryUtils.random()*i,h=c(h),d[e]=THREE.GeometryUtils.randomPointInFace(f[h],a,!0),g[h]?g[h]+=1:g[h]=1;return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();
+g)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return j[e]>a?b(c,e-1):j[e]<a?b(e+1,d):e}return b(0,j.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,j=[],k,o,p,m;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)k=g[d.a].position,o=g[d.b].position,p=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(k,o,p);else if(d instanceof
+THREE.Face4)k=g[d.a].position,o=g[d.b].position,p=g[d.c].position,m=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(k,o,m),d._area2=THREE.GeometryUtils.triangleArea(o,p,m),d._area=d._area1+d._area2;i+=d._area;j[e]=i}d=[];g={};for(e=0;e<b;e++)h=THREE.GeometryUtils.random()*i,h=c(h),d[e]=THREE.GeometryUtils.randomPointInFace(f[h],a,!0),g[h]?g[h]+=1:g[h]=1;return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();
 b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
 b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
 THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(e.loadCount===6)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
 THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(e.loadCount===6)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
-Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};b|=1;var d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),k=i.data,j=0;j<d;j++)for(var o=1;o<e;o++){var p=o-1<0?e-1:o-1,m=(o+1)%e,q=j-1<0?d-1:j-1,n=(j+1)%d,s=[],r=[0,0,h[(o*d+j)*4]/255*b];s.push([-1,0,h[(o*d+q)*4]/255*b]);s.push([-1,-1,h[(p*d+q)*4]/255*b]);s.push([0,-1,h[(p*d+j)*4]/255*b]);s.push([1,
--1,h[(p*d+n)*4]/255*b]);s.push([1,0,h[(o*d+n)*4]/255*b]);s.push([1,1,h[(m*d+n)*4]/255*b]);s.push([0,1,h[(m*d+j)*4]/255*b]);s.push([-1,1,h[(m*d+q)*4]/255*b]);p=[];q=s.length;for(m=0;m<q;m++){var n=s[m],u=s[(m+1)%q],n=[n[0]-r[0],n[1]-r[1],n[2]-r[2]],u=[u[0]-r[0],u[1]-r[1],u[2]-r[2]];p.push(c([n[1]*u[2]-n[2]*u[1],n[2]*u[0]-n[0]*u[2],n[0]*u[1]-n[1]*u[0]]))}s=[0,0,0];for(m=0;m<p.length;m++)s[0]+=p[m][0],s[1]+=p[m][1],s[2]+=p[m][2];s[0]/=p.length;s[1]/=p.length;s[2]/=p.length;r=(o*d+j)*4;k[r]=(s[0]+1)/
-2*255|0;k[r+1]=(s[1]+0.5)*255|0;k[r+2]=s[2]*255|0;k[r+3]=255}g.putImageData(i,0,0);return f}};
+Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};b|=1;var d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,k=0;k<d;k++)for(var o=1;o<e;o++){var p=o-1<0?e-1:o-1,m=(o+1)%e,q=k-1<0?d-1:k-1,n=(k+1)%d,s=[],r=[0,0,h[(o*d+k)*4]/255*b];s.push([-1,0,h[(o*d+q)*4]/255*b]);s.push([-1,-1,h[(p*d+q)*4]/255*b]);s.push([0,-1,h[(p*d+k)*4]/255*b]);s.push([1,
+-1,h[(p*d+n)*4]/255*b]);s.push([1,0,h[(o*d+n)*4]/255*b]);s.push([1,1,h[(m*d+n)*4]/255*b]);s.push([0,1,h[(m*d+k)*4]/255*b]);s.push([-1,1,h[(m*d+q)*4]/255*b]);p=[];q=s.length;for(m=0;m<q;m++){var n=s[m],u=s[(m+1)%q],n=[n[0]-r[0],n[1]-r[1],n[2]-r[2]],u=[u[0]-r[0],u[1]-r[1],u[2]-r[2]];p.push(c([n[1]*u[2]-n[2]*u[1],n[2]*u[0]-n[0]*u[2],n[0]*u[1]-n[1]*u[0]]))}s=[0,0,0];for(m=0;m<p.length;m++)s[0]+=p[m][0],s[1]+=p[m][1],s[2]+=p[m][2];s[0]/=p.length;s[1]/=p.length;s[2]/=p.length;r=(o*d+k)*4;j[r]=(s[0]+1)/
+2*255|0;j[r+1]=(s[1]+0.5)*255|0;j[r+2]=s[2]*255|0;j[r+3]=255}g.putImageData(i,0,0);return f}};
 THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,e=a.children.length;for(d=0;d<e;d++)c=a.children[d],b(c),THREE.SceneUtils.traverseHierarchy(c,b)},createMultiMaterialObject:function(a,b){var c,d=b.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(a,b[c]);e.add(f)}return e},cloneObject:function(a){var b;a instanceof THREE.MorphAnimMesh?(b=new THREE.MorphAnimMesh(a.geometry,a.material),
 THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,e=a.children.length;for(d=0;d<e;d++)c=a.children[d],b(c),THREE.SceneUtils.traverseHierarchy(c,b)},createMultiMaterialObject:function(a,b){var c,d=b.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(a,b[c]);e.add(f)}return e},cloneObject:function(a){var b;a instanceof THREE.MorphAnimMesh?(b=new THREE.MorphAnimMesh(a.geometry,a.material),
 b.duration=a.duration,b.mirroredLoop=a.mirroredLoop,b.time=a.time,b.lastKeyframe=a.lastKeyframe,b.currentKeyframe=a.currentKeyframe,b.direction=a.direction,b.directionBackwards=a.directionBackwards):a instanceof THREE.SkinnedMesh?b=new THREE.SkinnedMesh(a.geometry,a.material):a instanceof THREE.Mesh?b=new THREE.Mesh(a.geometry,a.material):a instanceof THREE.Line?b=new THREE.Line(a.geometry,a.material,a.type):a instanceof THREE.Ribbon?b=new THREE.Ribbon(a.geometry,a.material):a instanceof THREE.ParticleSystem?
 b.duration=a.duration,b.mirroredLoop=a.mirroredLoop,b.time=a.time,b.lastKeyframe=a.lastKeyframe,b.currentKeyframe=a.currentKeyframe,b.direction=a.direction,b.directionBackwards=a.directionBackwards):a instanceof THREE.SkinnedMesh?b=new THREE.SkinnedMesh(a.geometry,a.material):a instanceof THREE.Mesh?b=new THREE.Mesh(a.geometry,a.material):a instanceof THREE.Line?b=new THREE.Line(a.geometry,a.material,a.type):a instanceof THREE.Ribbon?b=new THREE.Ribbon(a.geometry,a.material):a instanceof THREE.ParticleSystem?
 (b=new THREE.ParticleSystem(a.geometry,a.material),b.sortParticles=a.sortParticles):a instanceof THREE.Particle?b=new THREE.Particle(a.material):a instanceof THREE.Sprite?(b=new THREE.Sprite({}),b.color.copy(a.color),b.map=a.map,b.blending=a.blending,b.useScreenCoordinates=a.useScreenCoordinates,b.mergeWith3D=a.mergeWith3D,b.affectedByDistance=a.affectedByDistance,b.scaleByViewport=a.scaleByViewport,b.alignment=a.alignment,b.rotation3d.copy(a.rotation3d),b.rotation=a.rotation,b.opacity=a.opacity,
 (b=new THREE.ParticleSystem(a.geometry,a.material),b.sortParticles=a.sortParticles):a instanceof THREE.Particle?b=new THREE.Particle(a.material):a instanceof THREE.Sprite?(b=new THREE.Sprite({}),b.color.copy(a.color),b.map=a.map,b.blending=a.blending,b.useScreenCoordinates=a.useScreenCoordinates,b.mergeWith3D=a.mergeWith3D,b.affectedByDistance=a.affectedByDistance,b.scaleByViewport=a.scaleByViewport,b.alignment=a.alignment,b.rotation3d.copy(a.rotation3d),b.rotation=a.rotation,b.opacity=a.opacity,
@@ -372,6 +376,7 @@ THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"v
 THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
 THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
 THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
 THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
+THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
 THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
 THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
 THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b};
 THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b};
 THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,i;g<=h;)if(d=Math.floor(g+(h-g)/2),i=c[d]-f,i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
 THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,i;g<=h;)if(d=Math.floor(g+(h-g)/2),i=c[d]-f,i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
@@ -402,37 +407,37 @@ THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=Array.prototype.sl
 THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
 THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
 THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};
 THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};
 THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,b,c,d,e,f));this.actions.push({action:THREE.PathActions.ARC,args:g})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
 THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,b,c,d,e,f));this.actions.push({action:THREE.PathActions.ARC,args:g})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
-THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],d,e,f,g,h,i,k,j,o,p,m,q,n;d=0;for(e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];i=f[3];o=f[0];p=f[1];c.length>0?(g=c[c.length-1],m=g.x,q=g.y):(g=this.actions[d-1].args,m=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)n=g/a,f=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,q,p,
-i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];p=f[1];k=f[2];j=f[3];c.length>0?(g=c[c.length-1],m=g.x,q=g.y):(g=this.actions[d-1].args,m=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)n=g/a,f=THREE.Shape.Utils.b3(n,m,o,k,h),n=THREE.Shape.Utils.b3(n,q,p,j,i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];n=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g);
-for(g=1;g<=n;g++)c.push(f.getPointAt(g/n));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];k=f[2];o=f[3];n=f[4];p=!!f[5];j=g[g.length-2];m=g[g.length-1];g.length==0&&(j=m=0);q=n-o;var s=a*2;for(g=1;g<=s;g++)n=g/s,p||(n=1-n),n=o+n*q,f=j+h+k*Math.cos(n),n=m+i+k*Math.sin(n),c.push(new THREE.Vector2(f,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
-THREE.Path.prototype.nltransform=function(a,b,c,d,e,f){var g=this.getPoints(),h,i,k,j,o;h=0;for(i=g.length;h<i;h++)k=g[h],j=k.x,o=k.y,k.x=a*j+b*o+c,k.y=d*o+e*j+f;return g};
+THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],d,e,f,g,h,i,j,k,o,p,m,q,n;d=0;for(e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];i=f[3];o=f[0];p=f[1];c.length>0?(g=c[c.length-1],m=g.x,q=g.y):(g=this.actions[d-1].args,m=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)n=g/a,f=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,q,p,
+i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];p=f[1];j=f[2];k=f[3];c.length>0?(g=c[c.length-1],m=g.x,q=g.y):(g=this.actions[d-1].args,m=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)n=g/a,f=THREE.Shape.Utils.b3(n,m,o,j,h),n=THREE.Shape.Utils.b3(n,q,p,k,i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];n=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g);
+for(g=1;g<=n;g++)c.push(f.getPointAt(g/n));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];j=f[2];o=f[3];n=f[4];p=!!f[5];k=g[g.length-2];m=g[g.length-1];g.length==0&&(k=m=0);q=n-o;var s=a*2;for(g=1;g<=s;g++)n=g/s,p||(n=1-n),n=o+n*q,f=k+h+j*Math.cos(n),n=m+i+j*Math.sin(n),c.push(new THREE.Vector2(f,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
+THREE.Path.prototype.nltransform=function(a,b,c,d,e,f){var g=this.getPoints(),h,i,j,k,o;h=0;for(i=g.length;h<i;h++)j=g[h],k=j.x,o=j.y,j.x=a*k+b*o+c,j.y=d*o+e*k+f;return g};
 THREE.Path.prototype.debug=function(a){var b=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,d,e,a=0;for(c=this.actions.length;a<c;a++)d=this.actions[a],e=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&b[d].apply(b,e);b.stroke();b.closePath();b.strokeStyle="red";d=
 THREE.Path.prototype.debug=function(a){var b=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,d,e,a=0;for(c=this.actions.length;a<c;a++)d=this.actions[a],e=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&b[d].apply(b,e);b.stroke();b.closePath();b.strokeStyle="red";d=
 this.getPoints();a=0;for(c=d.length;a<c;a++)e=d[a],b.beginPath(),b.arc(e.x,e.y,1.5,0,Math.PI*2,!1),b.stroke(),b.closePath()};
 this.getPoints();a=0;for(c=d.length;a<c;a++)e=d[a],b.beginPath(),b.arc(e.x,e.y,1.5,0,Math.PI*2,!1),b.stroke(),b.closePath()};
 THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a<b;a++)c=this.actions[a],d=c.args,c=c.action,c==THREE.PathActions.MOVE_TO&&f.actions.length!=0&&(e.push(f),f=new THREE.Path),f[c].apply(f,d);f.actions.length!=0&&e.push(f);if(e.length==0)return[];var g,f=[];if(THREE.Shape.Utils.isClockWise(e[0].getPoints())){a=0;for(b=e.length;a<b;a++)d=e[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(g&&f.push(g),g=new THREE.Shape,g.actions=d.actions,g.curves=
 THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a<b;a++)c=this.actions[a],d=c.args,c=c.action,c==THREE.PathActions.MOVE_TO&&f.actions.length!=0&&(e.push(f),f=new THREE.Path),f[c].apply(f,d);f.actions.length!=0&&e.push(f);if(e.length==0)return[];var g,f=[];if(THREE.Shape.Utils.isClockWise(e[0].getPoints())){a=0;for(b=e.length;a<b;a++)d=e[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(g&&f.push(g),g=new THREE.Shape,g.actions=d.actions,g.curves=
 d.curves):g.holes.push(d);f.push(g)}else{g=new THREE.Shape;a=0;for(b=e.length;a<b;a++)d=e[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(g.actions=d.actions,g.curves=d.curves,f.push(g),g=new THREE.Shape):g.holes.push(d)}return f};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};
 d.curves):g.holes.push(d);f.push(g)}else{g=new THREE.Shape;a=0;for(b=e.length;a<b;a++)d=e[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(g.actions=d.actions,g.curves=d.curves,f.push(g),g=new THREE.Shape):g.holes.push(d)}return f};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};
 THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
 THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
 THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
 THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
-THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,k,j,o,p,m,q=[];for(i=0;i<b.length;i++){k=b[i];Array.prototype.push.apply(d,k);f=Number.POSITIVE_INFINITY;for(e=0;e<k.length;e++){p=k[e];m=[];for(o=0;o<c.length;o++)j=c[o],j=p.distanceToSquared(j),m.push(j),j<f&&(f=j,g=e,h=o)}e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;var n=[k[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var s=[k[g],k[f],c[h]];p=THREE.FontUtils.Triangulate.area(s);m=h;j=g;h+=1;g+=-1;h<
-0&&(h+=c.length);h%=c.length;g<0&&(g+=k.length);g%=k.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;n=[k[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);s=[k[g],k[f],c[h]];s=THREE.FontUtils.Triangulate.area(s);o+p>n+s&&(h=m,g=j,h<0&&(h+=c.length),h%=c.length,g<0&&(g+=k.length),g%=k.length,e=h-1>=0?h-1:c.length-1,f=g-1>=0?g-1:k.length-1);o=c.slice(0,h);p=c.slice(h);m=k.slice(g);j=k.slice(0,g);f=[k[g],k[f],c[h]];q.push([k[g],c[h],c[e]]);q.push(f);c=o.concat(m).concat(j).concat(p)}return{shape:c,
-isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),f,g,h,i,k={};f=0;for(g=d.length;f<g;f++)i=d[f].x+":"+d[f].y,k[i]!==void 0&&console.log("Duplicate point",i),k[i]=f;f=0;for(g=c.length;f<g;f++){h=c[f];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=k[i],i!==void 0&&(h[d]=i)}f=0;for(g=e.length;f<g;f++){h=e[f];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=k[i],i!==void 0&&(h[d]=i)}return c.concat(e)},
+THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,j,k,o,p,m,q=[];for(i=0;i<b.length;i++){j=b[i];Array.prototype.push.apply(d,j);f=Number.POSITIVE_INFINITY;for(e=0;e<j.length;e++){p=j[e];m=[];for(o=0;o<c.length;o++)k=c[o],k=p.distanceToSquared(k),m.push(k),k<f&&(f=k,g=e,h=o)}e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var n=[j[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var s=[j[g],j[f],c[h]];p=THREE.FontUtils.Triangulate.area(s);m=h;k=g;h+=1;g+=-1;h<
+0&&(h+=c.length);h%=c.length;g<0&&(g+=j.length);g%=j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;n=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);s=[j[g],j[f],c[h]];s=THREE.FontUtils.Triangulate.area(s);o+p>n+s&&(h=m,g=k,h<0&&(h+=c.length),h%=c.length,g<0&&(g+=j.length),g%=j.length,e=h-1>=0?h-1:c.length-1,f=g-1>=0?g-1:j.length-1);o=c.slice(0,h);p=c.slice(h);m=j.slice(g);k=j.slice(0,g);f=[j[g],j[f],c[h]];q.push([j[g],c[h],c[e]]);q.push(f);c=o.concat(m).concat(k).concat(p)}return{shape:c,
+isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),f,g,h,i,j={};f=0;for(g=d.length;f<g;f++)i=d[f].x+":"+d[f].y,j[i]!==void 0&&console.log("Duplicate point",i),j[i]=f;f=0;for(g=c.length;f<g;f++){h=c[f];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=j[i],i!==void 0&&(h[d]=i)}f=0;for(g=e.length;f<g;f++){h=e[f];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=j[i],i!==void 0&&(h[d]=i)}return c.concat(e)},
 isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
 isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
 this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){this.text=a;var b=b||this.parameters,c=b.curveSegments!==void 0?b.curveSegments:4,d=b.font!==void 0?b.font:"helvetiker",e=b.weight!==void 0?b.weight:"normal",f=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f};
 this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){this.text=a;var b=b||this.parameters,c=b.curveSegments!==void 0?b.curveSegments:4,d=b.font!==void 0?b.font:"helvetiker",e=b.weight!==void 0?b.weight:"normal",f=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f};
 THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,a[c].toShapes());return b};
 THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,a[c].toShapes());return b};
 THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<
 THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<
-0)a.hierarchy[c].keys[d].time=0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var k=a.hierarchy[c].keys[d].morphTargets[i];h[k]=-1}a.hierarchy[c].usedMorphTargets=
-h;for(d=0;d<a.hierarchy[c].keys.length;d++){var j={};for(k in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===k){j[k]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(j[k]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=j}}for(d=1;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time&&(a.hierarchy[c].keys.splice(d,1),d--);for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=
+0)a.hierarchy[c].keys[d].time=0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var j=a.hierarchy[c].keys[d].morphTargets[i];h[j]=-1}a.hierarchy[c].usedMorphTargets=
+h;for(d=0;d<a.hierarchy[c].keys.length;d++){var k={};for(j in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===j){k[j]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(k[j]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=k}}for(d=1;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time&&(a.hierarchy[c].keys.splice(d,1),d--);for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=
 d}d=parseInt(a.length*a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=
 d}d=parseInt(a.length*a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,d){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==void 0?d:!0;this.points=[];this.target=new THREE.Vector3};
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,d){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==void 0?d:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,e;for(c=0;c<d;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===void 0)e.animationCache={},e.animationCache.prevKey={pos:0,rot:0,scl:0},e.animationCache.nextKey={pos:0,rot:0,scl:0},e.animationCache.originalMatrix=e instanceof
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,e;for(c=0;c<d;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===void 0)e.animationCache={},e.animationCache.prevKey={pos:0,rot:0,scl:0},e.animationCache.nextKey={pos:0,rot:0,scl:0},e.animationCache.originalMatrix=e instanceof
 THREE.Bone?e.skinMatrix:e.matrix;var f=e.animationCache.prevKey;e=e.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Bone?e.skinMatrix:e.matrix;var f=e.animationCache.prevKey;e=e.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,k,j=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;k=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var m=0,q=this.hierarchy.length;m<q;m++)if(a=this.hierarchy[m],i=a.animationCache,this.JITCompile&&j[m][k]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=j[m][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
-!1):(a.matrix=j[m][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var n=0;n<3;n++){c=b[n];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=p){if(o<p)if(this.loop){g=this.data.hierarchy[m].keys[0];for(h=this.getNextKeyWith(c,m,1);h.time<o;)g=h,h=this.getNextKeyWith(c,m,h.index+1)}else{this.stop();return}else{do g=h,h=this.getNextKeyWith(c,m,h.index+1);while(h.time<
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,j,k=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;j=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var m=0,q=this.hierarchy.length;m<q;m++)if(a=this.hierarchy[m],i=a.animationCache,this.JITCompile&&k[m][j]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=k[m][j],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
+!1):(a.matrix=k[m][j],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var n=0;n<3;n++){c=b[n];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=p){if(o<p)if(this.loop){g=this.data.hierarchy[m].keys[0];for(h=this.getNextKeyWith(c,m,1);h.time<o;)g=h,h=this.getNextKeyWith(c,m,h.index+1)}else{this.stop();return}else{do g=h,h=this.getNextKeyWith(c,m,h.index+1);while(h.time<
 o)}i.prevKey[c]=g;i.nextKey[c]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(o-g.time)/(h.time-g.time);e=g[c];f=h[c];if(d<0||d>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 o)}i.prevKey[c]=g;i.nextKey[c]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(o-g.time)/(h.time-g.time);e=g[c];f=h[c];if(d<0||d>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 this.getPrevKeyWith("pos",m,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c===
 this.getPrevKeyWith("pos",m,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c===
-"rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(m=0;m<this.hierarchy.length;m++)j[m][k]=this.hierarchy[m]instanceof THREE.Bone?this.hierarchy[m].skinMatrix.clone():this.hierarchy[m].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,k;e=(a.length-1)*b;f=Math.floor(e);e-=f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],k[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],k[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],k[2],e,c,g);return d};
+"rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&k[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(m=0;m<this.hierarchy.length;m++)k[m][j]=this.hierarchy[m]instanceof THREE.Bone?this.hierarchy[m].skinMatrix.clone():this.hierarchy[m].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,j;e=(a.length-1)*b;f=Math.floor(e);e-=f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c<d.length-1?c:d.length-1:c%=d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c<d.length-1?c:d.length-1:c%=d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
 THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=c!==void 0?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
 THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=c!==void 0?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
@@ -440,9 +445,9 @@ d.matrixWorldNeedsUpdate=!0}}};
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=!0;if(f.animationCache===void 0)f.animationCache={},f.animationCache.prevKey=null,f.animationCache.nextKey=null,f.animationCache.originalMatrix=e instanceof THREE.Bone?e.skinMatrix:
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=!0;if(f.animationCache===void 0)f.animationCache={},f.animationCache.prevKey=null,f.animationCache.nextKey=null,f.animationCache.originalMatrix=e instanceof THREE.Bone?e.skinMatrix:
 e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0],f.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0],f.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++){var b=this.hierarchy[a];if(b.animationCache!==void 0){var c=b.animationCache.originalMatrix;b instanceof THREE.Bone?(c.copy(b.skinMatrix),b.skinMatrix=c):(c.copy(b.matrix),b.matrix=c);delete b.animationCache}}};
 THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++){var b=this.hierarchy[a];if(b.animationCache!==void 0){var c=b.animationCache.originalMatrix;b instanceof THREE.Bone?(c.copy(b.skinMatrix),b.skinMatrix=c):(c.copy(b.matrix),b.matrix=c);delete b.animationCache}}};
-THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,i;this.currentTime+=a*this.timeScale;h=this.currentTime;g=this.currentTime%=this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;e=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,k=this.hierarchy.length;a<k;a++){var j=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=j.length-1;e=this.hierarchy[a];
-if(j.length){for(j=0;j<f.length;j++)g=f[j],(h=this.getPrevKeyWith(g,a,d))&&h.apply(g);this.data.hierarchy[a].node.updateMatrix();e.matrixWorldNeedsUpdate=!0}}this.stop()}else if(!(g<this.startTime)){a=0;for(k=this.hierarchy.length;a<k;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var j=b.keys,o=b.animationCache;if(this.JITCompile&&f[a][e]!==void 0)d instanceof THREE.Bone?(d.skinMatrix=f[a][e],d.matrixWorldNeedsUpdate=!1):(d.matrix=f[a][e],d.matrixWorldNeedsUpdate=!0);else if(j.length){if(this.JITCompile&&
-o)d instanceof THREE.Bone?d.skinMatrix=o.originalMatrix:d.matrix=o.originalMatrix;b=o.prevKey;c=o.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=j[0];for(c=j[1];c.time<g;)b=c,c=j[b.index+1]}else if(!i)for(var p=j.length-1;c.time<g&&c.index!==p;)b=c,c=j[b.index+1];o.prevKey=b;o.nextKey=c}b.interpolate(c,g)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a<this.hierarchy.length;a++)f[a][e]=
+THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,i;this.currentTime+=a*this.timeScale;h=this.currentTime;g=this.currentTime%=this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;e=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,j=this.hierarchy.length;a<j;a++){var k=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=k.length-1;e=this.hierarchy[a];
+if(k.length){for(k=0;k<f.length;k++)g=f[k],(h=this.getPrevKeyWith(g,a,d))&&h.apply(g);this.data.hierarchy[a].node.updateMatrix();e.matrixWorldNeedsUpdate=!0}}this.stop()}else if(!(g<this.startTime)){a=0;for(j=this.hierarchy.length;a<j;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var k=b.keys,o=b.animationCache;if(this.JITCompile&&f[a][e]!==void 0)d instanceof THREE.Bone?(d.skinMatrix=f[a][e],d.matrixWorldNeedsUpdate=!1):(d.matrix=f[a][e],d.matrixWorldNeedsUpdate=!0);else if(k.length){if(this.JITCompile&&
+o)d instanceof THREE.Bone?d.skinMatrix=o.originalMatrix:d.matrix=o.originalMatrix;b=o.prevKey;c=o.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=k[0];for(c=k[1];c.time<g;)b=c,c=k[b.index+1]}else if(!i)for(var p=k.length-1;c.time<g&&c.index!==p;)b=c,c=k[b.index+1];o.prevKey=b;o.nextKey=c}b.interpolate(c,g)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a<this.hierarchy.length;a++)f[a][e]=
 this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c>=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
 this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c>=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
 THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
 THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
 this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
 this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
@@ -481,42 +486,42 @@ THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,argu
 this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
 this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
 -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,
 -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,
 this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
 this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
-THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=!1,h=1,i=0,k=0,j=0,o=0,p=0,m=window.innerWidth/2,q=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed;
-this.rotateHorizontally(b*o);this.rotateVertically(b*p)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*k);this.object.translateY(b*j);g&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();e.copy(this.forward);d.set(0,1,0);c.cross(d,
+THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=!1,h=1,i=0,j=0,k=0,o=0,p=0,m=window.innerWidth/2,q=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed;
+this.rotateHorizontally(b*o);this.rotateVertically(b*p)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*j);this.object.translateY(b*k);g&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();e.copy(this.forward);d.set(0,1,0);c.cross(d,
 e).normalize();d.cross(e,c).normalize();this.object.matrix.n11=c.x;this.object.matrix.n12=d.x;this.object.matrix.n13=e.x;this.object.matrix.n21=c.y;this.object.matrix.n22=d.y;this.object.matrix.n23=e.y;this.object.matrix.n31=c.z;this.object.matrix.n32=d.z;this.object.matrix.n33=e.z;f.identity();f.n11=Math.cos(this.roll);f.n12=-Math.sin(this.roll);f.n21=Math.sin(this.roll);f.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(f);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
 e).normalize();d.cross(e,c).normalize();this.object.matrix.n11=c.x;this.object.matrix.n12=d.x;this.object.matrix.n13=e.x;this.object.matrix.n21=c.y;this.object.matrix.n22=d.y;this.object.matrix.n23=e.y;this.object.matrix.n31=c.z;this.object.matrix.n32=d.z;this.object.matrix.n33=e.z;f.identity();f.n11=Math.cos(this.roll);f.n12=-Math.sin(this.roll);f.n21=Math.sin(this.roll);f.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(f);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
 this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
 this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
 a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
 a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
 function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){o=(a.clientX-m)/window.innerWidth;p=(a.clientY-q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
 function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){o=(a.clientX-m)/window.innerWidth;p=(a.clientY-q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
-function(a){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:k=-1;break;case 40:case 83:i=-1;break;case 39:case 68:k=1;break;case 81:g=!0;h=1;break;case 69:g=!0;h=-1;break;case 82:j=1;break;case 70:j=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:k=0;break;case 40:case 83:i=0;break;case 39:case 68:k=0;break;case 81:g=!1;break;case 69:g=!1;break;case 82:j=0;break;case 70:j=0}},!1)};
+function(a){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:j=-1;break;case 40:case 83:i=-1;break;case 39:case 68:j=1;break;case 81:g=!0;h=1;break;case 69:g=!0;h=-1;break;case 82:k=1;break;case 70:k=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:j=0;break;case 40:case 83:i=0;break;case 39:case 68:j=0;break;case 81:g=!1;break;case 69:g=!1;break;case 82:k=0;break;case 70:k=0}},!1)};
 THREE.TrackballControls=function(a,b){var c=this,d={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};this.object=a;this.domElement=b!==void 0?b:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=this.noRotate=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];
 THREE.TrackballControls=function(a,b){var c=this,d={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};this.object=a;this.domElement=b!==void 0?b:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=this.noRotate=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];
-this.target=new THREE.Vector3(0,0,0);var e=!1,f=d.NONE,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector2,j=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-c.screen.offsetLeft)/c.radius*0.5,(b-c.screen.offsetTop)/c.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-c.screen.width*0.5-
+this.target=new THREE.Vector3(0,0,0);var e=!1,f=d.NONE,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-c.screen.offsetLeft)/c.radius*0.5,(b-c.screen.offsetTop)/c.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-c.screen.width*0.5-
 c.screen.offsetLeft)/c.radius,(c.screen.height*0.5+c.screen.offsetTop-b)/c.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b,
 c.screen.offsetLeft)/c.radius,(c.screen.height*0.5+c.screen.offsetTop-b)/c.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b,
--a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*c.zoomSpeed;a!==1&&a>0&&(g.multiplyScalar(a),c.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y));
+-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*c.zoomSpeed;a!==1&&a>0&&(g.multiplyScalar(a),c.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y));
 c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=p:o.addSelf(a.sub(p,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),g.lengthSq()<c.minDistance*c.minDistance&&c.object.position.add(c.target,g.setLength(c.minDistance))};this.update=function(){g.copy(c.object.position).subSelf(this.target);c.noRotate||c.rotateCamera();c.noZoom||c.zoomCamera();
 c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=p:o.addSelf(a.sub(p,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),g.lengthSq()<c.minDistance*c.minDistance&&c.object.position.add(c.target,g.setLength(c.minDistance))};this.update=function(){g.copy(c.object.position).subSelf(this.target);c.noRotate||c.rotateCamera();c.noZoom||c.zoomCamera();
-c.noPan||c.panCamera();c.object.position.add(c.target,g);c.checkDistances();c.object.lookAt(c.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){c.enabled&&(e&&(h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY),k=j=c.getMouseOnScreen(a.clientX,a.clientY),o=p=c.getMouseOnScreen(a.clientX,a.clientY),e=!1),f!==d.NONE&&(f===d.ROTATE&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===d.ZOOM&&
-!c.noZoom?j=c.getMouseOnScreen(a.clientX,a.clientY):f===d.PAN&&!c.noPan&&(p=c.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(c.enabled&&(a.preventDefault(),a.stopPropagation(),f===d.NONE))f=a.button,f===d.ROTATE&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===d.ZOOM&&!c.noZoom?k=j=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=p=c.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",
+c.noPan||c.panCamera();c.object.position.add(c.target,g);c.checkDistances();c.object.lookAt(c.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){c.enabled&&(e&&(h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY),j=k=c.getMouseOnScreen(a.clientX,a.clientY),o=p=c.getMouseOnScreen(a.clientX,a.clientY),e=!1),f!==d.NONE&&(f===d.ROTATE&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===d.ZOOM&&
+!c.noZoom?k=c.getMouseOnScreen(a.clientX,a.clientY):f===d.PAN&&!c.noPan&&(p=c.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(c.enabled&&(a.preventDefault(),a.stopPropagation(),f===d.NONE))f=a.button,f===d.ROTATE&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===d.ZOOM&&!c.noZoom?j=k=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=p=c.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",
 function(a){if(c.enabled)a.preventDefault(),a.stopPropagation(),f=d.NONE},!1);window.addEventListener("keydown",function(a){if(c.enabled&&f===d.NONE){if(a.keyCode===c.keys[d.ROTATE]&&!c.noRotate)f=d.ROTATE;else if(a.keyCode===c.keys[d.ZOOM]&&!c.noZoom)f=d.ZOOM;else if(a.keyCode===c.keys[d.PAN]&&!c.noPan)f=d.PAN;f!==d.NONE&&(e=!0)}},!1);window.addEventListener("keyup",function(){if(c.enabled&&f!==d.NONE)f=d.NONE},!1)};
 function(a){if(c.enabled)a.preventDefault(),a.stopPropagation(),f=d.NONE},!1);window.addEventListener("keydown",function(a){if(c.enabled&&f===d.NONE){if(a.keyCode===c.keys[d.ROTATE]&&!c.noRotate)f=d.ROTATE;else if(a.keyCode===c.keys[d.ZOOM]&&!c.noZoom)f=d.ZOOM;else if(a.keyCode===c.keys[d.PAN]&&!c.noPan)f=d.PAN;f!==d.NONE&&(e=!0)}},!1);window.addEventListener("keyup",function(){if(c.enabled&&f!==d.NONE)f=d.NONE},!1)};
-THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,j,m){var n,o=d||1,p=e||1,q=h/2,s=i/2,r=k.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")n="y",p=f||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")n="x",o=f||1;var l=o+1,t=p+1,v=h/o,u=i/p,L=new THREE.Vector3;L[n]=j>0?1:-1;for(h=0;h<t;h++)for(i=0;i<l;i++){var Z=new THREE.Vector3;Z[a]=(i*v-q)*c;Z[b]=(h*u-s)*g;Z[n]=j;k.vertices.push(new THREE.Vertex(Z))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
-new THREE.Face4(i+l*h+r,i+l*(h+1)+r,i+1+l*(h+1)+r,i+1+l*h+r),a.normal.copy(L),a.vertexNormals.push(L.clone(),L.clone(),L.clone(),L.clone()),a.materialIndex=m,k.faces.push(a),k.faceVertexUvs[0].push([new THREE.UV(i/o,h/p),new THREE.UV(i/o,(h+1)/p),new THREE.UV((i+1)/o,(h+1)/p),new THREE.UV((i+1)/o,h/p)])}THREE.Geometry.call(this);var k=this,j=a/2,o=b/2,p=c/2,m,q,n,s,r,u;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(m=0;m<6;m++)this.materials.push(g)}m=0;s=1;q=2;r=
-3;n=4;u=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=void 0)for(var t in h)this.sides[t]!==void 0&&(this.sides[t]=h[t]);this.sides.px&&i("z","y",-1,-1,c,b,j,m);this.sides.nx&&i("z","y",1,-1,c,b,-j,s);this.sides.py&&i("x","z",1,1,a,c,o,q);this.sides.ny&&i("x","z",1,-1,a,c,-o,r);this.sides.pz&&i("x","y",1,-1,a,b,p,n);this.sides.nz&&i("x","y",-1,-1,a,b,-p,u);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
+THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,k,m){var n,o=d||1,p=e||1,q=h/2,s=i/2,r=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")n="y",p=f||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")n="x",o=f||1;var l=o+1,t=p+1,v=h/o,u=i/p,M=new THREE.Vector3;M[n]=k>0?1:-1;for(h=0;h<t;h++)for(i=0;i<l;i++){var Z=new THREE.Vector3;Z[a]=(i*v-q)*c;Z[b]=(h*u-s)*g;Z[n]=k;j.vertices.push(new THREE.Vertex(Z))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
+new THREE.Face4(i+l*h+r,i+l*(h+1)+r,i+1+l*(h+1)+r,i+1+l*h+r),a.normal.copy(M),a.vertexNormals.push(M.clone(),M.clone(),M.clone(),M.clone()),a.materialIndex=m,j.faces.push(a),j.faceVertexUvs[0].push([new THREE.UV(i/o,h/p),new THREE.UV(i/o,(h+1)/p),new THREE.UV((i+1)/o,(h+1)/p),new THREE.UV((i+1)/o,h/p)])}THREE.Geometry.call(this);var j=this,k=a/2,o=b/2,p=c/2,m,q,n,s,r,u;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(m=0;m<6;m++)this.materials.push(g)}m=0;s=1;q=2;r=
+3;n=4;u=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=void 0)for(var t in h)this.sides[t]!==void 0&&(this.sides[t]=h[t]);this.sides.px&&i("z","y",-1,-1,c,b,k,m);this.sides.nx&&i("z","y",1,-1,c,b,-k,s);this.sides.py&&i("x","z",1,1,a,c,o,q);this.sides.ny&&i("x","z",1,-1,a,c,-o,r);this.sides.pz&&i("x","y",1,-1,a,b,p,n);this.sides.nz&&i("x","y",-1,-1,a,b,-p,u);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
 THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
 THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=a!=null?a:20,b=b!=null?b:20,c=c||100,g=c/2,d=d||8,e=e||1,h,i,k=[],j=[];for(i=0;i<=e;i++){var o=[],p=[],m=i/e,q=m*(b-a)+a;for(h=0;h<=d;h++){var n=h/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(q*Math.sin(n*Math.PI*2),-m*c+g,q*Math.cos(n*Math.PI*2))));o.push(this.vertices.length-1);p.push(new THREE.UV(n,m))}k.push(o);j.push(p)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=k[i][h],o=k[i+1][h],p=k[i+1][h+1],m=k[i][h+1],q=
-this.vertices[c].position.clone().setY(0).normalize(),n=this.vertices[o].position.clone().setY(0).normalize(),s=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[m].position.clone().setY(0).normalize(),u=j[i][h].clone(),t=j[i+1][h].clone(),z=j[i+1][h+1].clone(),A=j[i][h+1].clone();this.faces.push(new THREE.Face4(c,o,p,m,[q,n,s,r]));this.faceVertexUvs[0].push([u,t,z,A])}if(!f&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=0;h<d;h++)c=k[0][h],o=k[0][h+
-1],p=this.vertices.length-1,q=new THREE.Vector3(0,1,0),n=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,1,0),u=j[0][h].clone(),t=j[0][h+1].clone(),z=new THREE.UV(t.u,0),this.faces.push(new THREE.Face3(c,o,p,[q,n,s])),this.faceVertexUvs[0].push([u,t,z])}if(!f&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=k[i][h+1],o=k[i][h],p=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,-1,0),s=new THREE.Vector3(0,-1,0),u=j[i][h+1].clone(),t=j[i][h].clone(),
-z=new THREE.UV(t.u,1),this.faces.push(new THREE.Face3(c,o,p,[q,n,s])),this.faceVertexUvs[0].push([u,t,z])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=a!=null?a:20,b=b!=null?b:20,c=c||100,g=c/2,d=d||8,e=e||1,h,i,j=[],k=[];for(i=0;i<=e;i++){var o=[],p=[],m=i/e,q=m*(b-a)+a;for(h=0;h<=d;h++){var n=h/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(q*Math.sin(n*Math.PI*2),-m*c+g,q*Math.cos(n*Math.PI*2))));o.push(this.vertices.length-1);p.push(new THREE.UV(n,m))}j.push(o);k.push(p)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=j[i][h],o=j[i+1][h],p=j[i+1][h+1],m=j[i][h+1],q=
+this.vertices[c].position.clone().setY(0).normalize(),n=this.vertices[o].position.clone().setY(0).normalize(),s=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[m].position.clone().setY(0).normalize(),u=k[i][h].clone(),t=k[i+1][h].clone(),A=k[i+1][h+1].clone(),B=k[i][h+1].clone();this.faces.push(new THREE.Face4(c,o,p,m,[q,n,s,r]));this.faceVertexUvs[0].push([u,t,A,B])}if(!f&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=0;h<d;h++)c=j[0][h],o=j[0][h+
+1],p=this.vertices.length-1,q=new THREE.Vector3(0,1,0),n=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,1,0),u=k[0][h].clone(),t=k[0][h+1].clone(),A=new THREE.UV(t.u,0),this.faces.push(new THREE.Face3(c,o,p,[q,n,s])),this.faceVertexUvs[0].push([u,t,A])}if(!f&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=j[i][h+1],o=j[i][h],p=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,-1,0),s=new THREE.Vector3(0,-1,0),u=k[i][h+1].clone(),t=k[i][h].clone(),
+A=new THREE.UV(t.u,1),this.faces.push(new THREE.Face3(c,o,p,[q,n,s])),this.faceVertexUvs[0].push([u,t,A])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],c,d=a.length,e;this.shapebb=a[d-1].getBoundingBox();for(c=0;c<d;c++)e=a[c],this.addShape(e,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
 THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],c,d=a.length,e;this.shapebb=a[d-1].getBoundingBox();for(c=0;c<d;c++)e=a[c],this.addShape(e,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
 THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
 THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
-h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);f===0&&(console.log("Either infinite or no solutions!"),g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;if(g<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(y=a.length;--y>=0;){Z=y;da=y-1;da<0&&(da=a.length-1);for(var b=
-0,c=m+j*2,b=0;b<c;b++){var d=R*b,e=R*(b+1),f=ba+Z+d,g=ba+Z+e,k=f,d=ba+da+d,e=ba+da+e,l=g;k+=G;d+=G;e+=G;l+=G;w.faces.push(new THREE.Face4(k,d,e,l,null,null,z));z!==void 0&&(k=b/c,d=(b+1)/c,e=h+i*2,f=(w.vertices[f].position.z+i)/e,g=(w.vertices[g].position.z+i)/e,w.faceVertexUvs[0].push([new THREE.UV(f,k),new THREE.UV(g,k),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){w.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=G;b+=G;c+=G;w.faces.push(new THREE.Face3(a,
-b,c,null,null,t));if(t!==void 0){var d=A.minX,e=A.minY,f=A.maxY,g=A.maxX,h=w.vertices[b].position.x-d,b=w.vertices[b].position.y-e,i=w.vertices[c].position.x-d,c=w.vertices[c].position.y-e;w.faceVertexUvs[0].push([new THREE.UV((w.vertices[a].position.x-d)/g,(w.vertices[a].position.y-e)/f),new THREE.UV(h/g,b/f),new THREE.UV(i/g,c/f)])}}var h=b.amount!==void 0?b.amount:100,i=b.bevelThickness!==void 0?b.bevelThickness:6,k=b.bevelSize!==void 0?b.bevelSize:i-2,j=b.bevelSegments!==void 0?b.bevelSegments:
-3,o=b.bevelEnabled!==void 0?b.bevelEnabled:!0,p=b.curveSegments!==void 0?b.curveSegments:12,m=b.steps!==void 0?b.steps:1,q=b.bendPath,n=b.extrudePath,s,r=!1,u=b.useSpacedPoints!==void 0?b.useSpacedPoints:!1,t=b.material,z=b.extrudeMaterial,A=this.shapebb;if(n)s=n.getPoints(p),m=s.length,r=!0,o=!1;o||(k=i=j=0);var E,D,B,w=this,G=this.vertices.length;q&&a.addWrapPath(q);p=u?a.extractAllSpacedPoints(p):a.extractAllPoints(p);q=p.shape;p=p.holes;if(n=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();D=
-0;for(B=p.length;D<B;D++)E=p[D],THREE.Shape.Utils.isClockWise(E)&&(p[D]=E.reverse());n=!1}n=THREE.Shape.Utils.triangulateShape(q,p);u=q;D=0;for(B=p.length;D<B;D++)E=p[D],q=q.concat(E);var y,K,$,Q,Y,S,R=q.length,l=n.length,W=[];y=0;K=u.length;Z=K-1;for(da=y+1;y<K;y++,Z++,da++)Z===K&&(Z=0),da===K&&(da=0),W[y]=d(u[y],u[Z],u[da]);var v=[],X,L=W.concat();D=0;for(B=p.length;D<B;D++){E=p[D];X=[];y=0;K=E.length;Z=K-1;for(da=y+1;y<K;y++,Z++,da++)Z===K&&(Z=0),da===K&&(da=0),X[y]=d(E[y],E[Z],E[da]);v.push(X);
-L=L.concat(X)}for($=0;$<j;$++){Q=$/j;Y=i*(1-Q);Q=k*Math.sin(Q*Math.PI/2);y=0;for(K=u.length;y<K;y++)S=c(u[y],W[y],Q),f(S.x,S.y,-Y);D=0;for(B=p.length;D<B;D++){E=p[D];X=v[D];y=0;for(K=E.length;y<K;y++)S=c(E[y],X[y],Q),f(S.x,S.y,-Y)}}Q=k;for(y=0;y<R;y++)S=o?c(q[y],L[y],Q):q[y],r?f(S.x,S.y+s[0].y,s[0].x):f(S.x,S.y,0);for($=1;$<=m;$++)for(y=0;y<R;y++)S=o?c(q[y],L[y],Q):q[y],r?f(S.x,S.y+s[$-1].y,s[$-1].x):f(S.x,S.y,h/m*$);for($=j-1;$>=0;$--){Q=$/j;Y=i*(1-Q);Q=k*Math.sin(Q*Math.PI/2);y=0;for(K=u.length;y<
-K;y++)S=c(u[y],W[y],Q),f(S.x,S.y,h+Y);D=0;for(B=p.length;D<B;D++){E=p[D];X=v[D];y=0;for(K=E.length;y<K;y++)S=c(E[y],X[y],Q),r?f(S.x,S.y+s[m-1].y,s[m-1].x+Y):f(S.x,S.y,h+Y)}}if(o){o=R*0;for(y=0;y<l;y++)k=n[y],g(k[2]+o,k[1]+o,k[0]+o);o=R*(m+j*2);for(y=0;y<l;y++)k=n[y],g(k[0]+o,k[1]+o,k[2]+o)}else{for(y=0;y<l;y++)k=n[y],g(k[2],k[1],k[0]);for(y=0;y<l;y++)k=n[y],g(k[0]+R*m,k[1]+R*m,k[2]+R*m)}var Z,da,ba=0;e(u);ba+=u.length;D=0;for(B=p.length;D<B;D++)E=p[D],e(E),ba+=E.length};
+h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);f===0&&(console.log("Either infinite or no solutions!"),g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;if(g<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(y=a.length;--y>=0;){Z=y;ca=y-1;ca<0&&(ca=a.length-1);for(var b=
+0,c=m+k*2,b=0;b<c;b++){var d=R*b,e=R*(b+1),f=aa+Z+d,g=aa+Z+e,j=f,d=aa+ca+d,e=aa+ca+e,l=g;j+=F;d+=F;e+=F;l+=F;w.faces.push(new THREE.Face4(j,d,e,l,null,null,A));A!==void 0&&(j=b/c,d=(b+1)/c,e=h+i*2,f=(w.vertices[f].position.z+i)/e,g=(w.vertices[g].position.z+i)/e,w.faceVertexUvs[0].push([new THREE.UV(f,j),new THREE.UV(g,j),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){w.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=F;b+=F;c+=F;w.faces.push(new THREE.Face3(a,
+b,c,null,null,t));if(t!==void 0){var d=B.minX,e=B.minY,f=B.maxY,g=B.maxX,h=w.vertices[b].position.x-d,b=w.vertices[b].position.y-e,i=w.vertices[c].position.x-d,c=w.vertices[c].position.y-e;w.faceVertexUvs[0].push([new THREE.UV((w.vertices[a].position.x-d)/g,(w.vertices[a].position.y-e)/f),new THREE.UV(h/g,b/f),new THREE.UV(i/g,c/f)])}}var h=b.amount!==void 0?b.amount:100,i=b.bevelThickness!==void 0?b.bevelThickness:6,j=b.bevelSize!==void 0?b.bevelSize:i-2,k=b.bevelSegments!==void 0?b.bevelSegments:
+3,o=b.bevelEnabled!==void 0?b.bevelEnabled:!0,p=b.curveSegments!==void 0?b.curveSegments:12,m=b.steps!==void 0?b.steps:1,q=b.bendPath,n=b.extrudePath,s,r=!1,u=b.useSpacedPoints!==void 0?b.useSpacedPoints:!1,t=b.material,A=b.extrudeMaterial,B=this.shapebb;if(n)s=n.getPoints(p),m=s.length,r=!0,o=!1;o||(j=i=k=0);var z,D,H,w=this,F=this.vertices.length;q&&a.addWrapPath(q);p=u?a.extractAllSpacedPoints(p):a.extractAllPoints(p);q=p.shape;p=p.holes;if(n=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();D=
+0;for(H=p.length;D<H;D++)z=p[D],THREE.Shape.Utils.isClockWise(z)&&(p[D]=z.reverse());n=!1}n=THREE.Shape.Utils.triangulateShape(q,p);u=q;D=0;for(H=p.length;D<H;D++)z=p[D],q=q.concat(z);var y,K,$,Q,X,T,R=q.length,l=n.length,S=[];y=0;K=u.length;Z=K-1;for(ca=y+1;y<K;y++,Z++,ca++)Z===K&&(Z=0),ca===K&&(ca=0),S[y]=d(u[y],u[Z],u[ca]);var v=[],W,M=S.concat();D=0;for(H=p.length;D<H;D++){z=p[D];W=[];y=0;K=z.length;Z=K-1;for(ca=y+1;y<K;y++,Z++,ca++)Z===K&&(Z=0),ca===K&&(ca=0),W[y]=d(z[y],z[Z],z[ca]);v.push(W);
+M=M.concat(W)}for($=0;$<k;$++){Q=$/k;X=i*(1-Q);Q=j*Math.sin(Q*Math.PI/2);y=0;for(K=u.length;y<K;y++)T=c(u[y],S[y],Q),f(T.x,T.y,-X);D=0;for(H=p.length;D<H;D++){z=p[D];W=v[D];y=0;for(K=z.length;y<K;y++)T=c(z[y],W[y],Q),f(T.x,T.y,-X)}}Q=j;for(y=0;y<R;y++)T=o?c(q[y],M[y],Q):q[y],r?f(T.x,T.y+s[0].y,s[0].x):f(T.x,T.y,0);for($=1;$<=m;$++)for(y=0;y<R;y++)T=o?c(q[y],M[y],Q):q[y],r?f(T.x,T.y+s[$-1].y,s[$-1].x):f(T.x,T.y,h/m*$);for($=k-1;$>=0;$--){Q=$/k;X=i*(1-Q);Q=j*Math.sin(Q*Math.PI/2);y=0;for(K=u.length;y<
+K;y++)T=c(u[y],S[y],Q),f(T.x,T.y,h+X);D=0;for(H=p.length;D<H;D++){z=p[D];W=v[D];y=0;for(K=z.length;y<K;y++)T=c(z[y],W[y],Q),r?f(T.x,T.y+s[m-1].y,s[m-1].x+X):f(T.x,T.y,h+X)}}if(o){o=R*0;for(y=0;y<l;y++)j=n[y],g(j[2]+o,j[1]+o,j[0]+o);o=R*(m+k*2);for(y=0;y<l;y++)j=n[y],g(j[0]+o,j[1]+o,j[2]+o)}else{for(y=0;y<l;y++)j=n[y],g(j[2],j[1],j[0]);for(y=0;y<l;y++)j=n[y],g(j[0]+R*m,j[1]+R*m,j[2]+R*m)}var Z,ca,aa=0;e(u);aa+=u.length;D=0;for(H=p.length;D<H;D++)z=p[D],e(z),aa+=z.length};
 THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
 THREE.IcosahedronGeometry=function(a){function b(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function c(a,b,c,d){var f=e.vertices[a].position,g=e.vertices[b].position,h=e.vertices[c].position,a=new THREE.Face3(a,b,c);a.vertexNormals.push(f.clone().normalize(),g.clone().normalize(),h.clone().normalize());d.faces.push(a);d.faceVertexUvs[0].push([new THREE.UV(1-(Math.atan2(f.z,f.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-f.y/2),new THREE.UV(1-
 THREE.IcosahedronGeometry=function(a){function b(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function c(a,b,c,d){var f=e.vertices[a].position,g=e.vertices[b].position,h=e.vertices[c].position,a=new THREE.Face3(a,b,c);a.vertexNormals.push(f.clone().normalize(),g.clone().normalize(),h.clone().normalize());d.faces.push(a);d.faceVertexUvs[0].push([new THREE.UV(1-(Math.atan2(f.z,f.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-f.y/2),new THREE.UV(1-
 (Math.atan2(g.z,g.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-g.y/2),new THREE.UV(1-(Math.atan2(h.z,h.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-h.y/2)])}function d(a,c){var d=e.vertices[a].position,f=e.vertices[c].position;return b((d.x+f.x)/2,(d.y+f.y)/2,(d.z+f.z)/2)}var e=this,f=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,
 (Math.atan2(g.z,g.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-g.y/2),new THREE.UV(1-(Math.atan2(h.z,h.x)+Math.PI)%Math.PI/Math.PI*0.5,0.5-h.y/2)])}function d(a,c){var d=e.vertices[a].position,f=e.vertices[c].position;return b((d.x+f.x)/2,(d.y+f.y)/2,(d.z+f.z)/2)}var e=this,f=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,
-1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(var g=0;g<this.subdivisions;g++){var a=new THREE.Geometry,h;for(h in f.faces){var i=d(f.faces[h].a,f.faces[h].b),k=d(f.faces[h].b,f.faces[h].c),j=d(f.faces[h].c,f.faces[h].a);c(f.faces[h].a,i,j,a);c(f.faces[h].b,k,i,a);c(f.faces[h].c,j,k,a);c(i,k,j,a)}f.faces=a.faces;f.faceVertexUvs[0]=a.faceVertexUvs[0]}e.faces=
+1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(var g=0;g<this.subdivisions;g++){var a=new THREE.Geometry,h;for(h in f.faces){var i=d(f.faces[h].a,f.faces[h].b),j=d(f.faces[h].b,f.faces[h].c),k=d(f.faces[h].c,f.faces[h].a);c(f.faces[h].a,i,k,a);c(f.faces[h].b,j,i,a);c(f.faces[h].c,k,j,a);c(i,j,k,a)}f.faces=a.faces;f.faceVertexUvs[0]=a.faceVertexUvs[0]}e.faces=
 f.faces;e.faceVertexUvs[0]=f.faceVertexUvs[0];this.computeCentroids();this.computeFaceNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
 f.faces;e.faceVertexUvs[0]=f.faceVertexUvs[0];this.computeCentroids();this.computeFaceNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
 THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;i==0&&(f=d);
 THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;i==0&&(f=d);
 for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,h/a.length)]);d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,h/a.length)]);d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
@@ -524,171 +529,171 @@ THREE.OctahedronGeometry=function(a,b){function c(b){var c=b.clone().normalize()
 g.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),g.faceVertexUvs[0].push([f(a.uv,a.position,h),f(b.uv,b.position,h),f(c.uv,c.position,h)])):(h-=1,d(a,e(a,b),e(a,c),h),d(e(a,b),b,e(b,c),h),d(e(a,c),e(b,c),c,h),d(e(a,b),e(b,c),e(a,c),h))}function e(a,b){h[a.index]||(h[a.index]=[]);h[b.index]||(h[b.index]=[]);var d=h[a.index][b.index];d===void 0&&(h[a.index][b.index]=h[b.index][a.index]=d=c((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return d}function f(a,b,c){c<0&&a.u===
 g.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),g.faceVertexUvs[0].push([f(a.uv,a.position,h),f(b.uv,b.position,h),f(c.uv,c.position,h)])):(h-=1,d(a,e(a,b),e(a,c),h),d(e(a,b),b,e(b,c),h),d(e(a,c),e(b,c),c,h),d(e(a,b),e(b,c),e(a,c),h))}function e(a,b){h[a.index]||(h[a.index]=[]);h[b.index]||(h[b.index]=[]);var d=h[a.index][b.index];d===void 0&&(h[a.index][b.index]=h[b.index][a.index]=d=c((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return d}function f(a,b,c){c<0&&a.u===
 1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);var b=b||0,g=this;c(new THREE.Vector3(1,0,0));c(new THREE.Vector3(-1,0,0));c(new THREE.Vector3(0,1,0));c(new THREE.Vector3(0,-1,0));c(new THREE.Vector3(0,0,1));c(new THREE.Vector3(0,0,-1));var h=[],i=this.vertices;d(i[0],i[2],i[4],b);d(i[0],i[4],i[3],b);d(i[0],i[3],i[5],b);d(i[0],i[5],i[2],b);d(i[1],i[2],i[5],b);d(i[1],i[5],i[3],b);d(i[1],i[3],i[4],b);d(i[1],i[4],i[2],b);this.boundingSphere=
 1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);var b=b||0,g=this;c(new THREE.Vector3(1,0,0));c(new THREE.Vector3(-1,0,0));c(new THREE.Vector3(0,1,0));c(new THREE.Vector3(0,-1,0));c(new THREE.Vector3(0,0,1));c(new THREE.Vector3(0,0,-1));var h=[],i=this.vertices;d(i[0],i[2],i[4],b);d(i[0],i[4],i[3],b);d(i[0],i[3],i[5],b);d(i[0],i[5],i[2],b);d(i[1],i[2],i[5],b);d(i[1],i[5],i[3],b);d(i[1],i[3],i[4],b);d(i[1],i[4],i[2],b);this.boundingSphere=
 {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
 {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
-THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,k=b/d,j=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-e,-(a*k-f),0)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a),e.normal.copy(j),e.vertexNormals.push(j.clone(),j.clone(),j.clone(),j.clone()),this.faces.push(e),this.faceVertexUvs[0].push([new THREE.UV(b/c,a/d),new THREE.UV(b/
+THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,j=b/d,k=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-e,-(a*j-f),0)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a),e.normal.copy(k),e.vertexNormals.push(k.clone(),k.clone(),k.clone(),k.clone()),this.faces.push(e),this.faceVertexUvs[0].push([new THREE.UV(b/c,a/d),new THREE.UV(b/
 c,(a+1)/d),new THREE.UV((b+1)/c,(a+1)/d),new THREE.UV((b+1)/c,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
 c,(a+1)/d),new THREE.UV((b+1)/c,(a+1)/d),new THREE.UV((b+1)/c,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);var a=a||50,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),d=d!=void 0?d:0,e=e!=void 0?e:Math.PI*2,f=f!=void 0?f:0,g=g!=void 0?g:Math.PI,h,i,k=[],j=[];for(i=0;i<=c;i++){var o=[],p=[];for(h=0;h<=b;h++){var m=h/b,q=i/c;this.vertices.push(new THREE.Vertex(new THREE.Vector3(-a*Math.cos(d+m*e)*Math.sin(f+q*g),a*Math.cos(f+q*g),a*Math.sin(d+m*e)*Math.sin(f+q*g))));o.push(this.vertices.length-1);p.push(new THREE.UV(m,q))}k.push(o);
-j.push(p)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=k[i][h+1],e=k[i][h],f=k[i+1][h],g=k[i+1][h+1],o=this.vertices[d].position.clone().normalize(),p=this.vertices[e].position.clone().normalize(),m=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),n=j[i][h+1].clone(),s=j[i][h].clone(),r=j[i+1][h].clone(),u=j[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[o,m,q])),this.faceVertexUvs[0].push([n,r,u])):Math.abs(this.vertices[f].position.y)==
+THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);var a=a||50,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),d=d!=void 0?d:0,e=e!=void 0?e:Math.PI*2,f=f!=void 0?f:0,g=g!=void 0?g:Math.PI,h,i,j=[],k=[];for(i=0;i<=c;i++){var o=[],p=[];for(h=0;h<=b;h++){var m=h/b,q=i/c;this.vertices.push(new THREE.Vertex(new THREE.Vector3(-a*Math.cos(d+m*e)*Math.sin(f+q*g),a*Math.cos(f+q*g),a*Math.sin(d+m*e)*Math.sin(f+q*g))));o.push(this.vertices.length-1);p.push(new THREE.UV(m,q))}j.push(o);
+k.push(p)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=j[i][h+1],e=j[i][h],f=j[i+1][h],g=j[i+1][h+1],o=this.vertices[d].position.clone().normalize(),p=this.vertices[e].position.clone().normalize(),m=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),n=k[i][h+1].clone(),s=k[i][h].clone(),r=k[i+1][h].clone(),u=k[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[o,m,q])),this.faceVertexUvs[0].push([n,r,u])):Math.abs(this.vertices[f].position.y)==
 a?(this.faces.push(new THREE.Face3(d,e,f,[o,p,m])),this.faceVertexUvs[0].push([n,s,r])):(this.faces.push(new THREE.Face4(d,e,f,g,[o,p,m,q])),this.faceVertexUvs[0].push([n,s,r,u]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
 a?(this.faces.push(new THREE.Face3(d,e,f,[o,p,m])),this.faceVertexUvs[0].push([n,s,r])):(this.faces.push(new THREE.Face4(d,e,f,g,[o,p,m,q])),this.faceVertexUvs[0].push([n,s,r,u]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
 THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var d=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
 THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var d=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
 THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
 THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
 THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
 THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
-0,e=String(a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h);d+=h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,i,k,j,o,p,m,q,n,s,r=b.glyphs[a]||b.glyphs["?"];if(r){if(r.o){b=r._cachedOutline||(r._cachedOutline=r.o.split(" "));k=b.length;for(a=0;a<k;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;j=b[a++]*c;f.push(new THREE.Vector2(i,j));e.moveTo(i,j);break;case "l":i=b[a++]*c+d;j=b[a++]*c;f.push(new THREE.Vector2(i,
-j));e.lineTo(i,j);break;case "q":i=b[a++]*c+d;j=b[a++]*c;m=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(m,q,i,j);if(g=f[f.length-1]){o=g.x;p=g.y;g=1;for(h=this.divisions;g<=h;g++){var u=g/h,t=THREE.Shape.Utils.b2(u,o,m,i),u=THREE.Shape.Utils.b2(u,p,q,j);f.push(new THREE.Vector2(t,u))}}break;case "b":if(i=b[a++]*c+d,j=b[a++]*c,m=b[a++]*c+d,q=b[a++]*-c,n=b[a++]*c+d,s=b[a++]*-c,e.bezierCurveTo(i,j,m,q,n,s),g=f[f.length-1]){o=g.x;p=g.y;g=1;for(h=this.divisions;g<=h;g++)u=g/h,t=THREE.Shape.Utils.b3(u,o,m,
-n,i),u=THREE.Shape.Utils.b3(u,p,q,s,j),f.push(new THREE.Vector2(t,u))}}}return{offset:r.ha*c,points:f,path:e}}}};
-(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return e*0.5};a.Triangulate=function(a,d){var e=a.length;if(e<3)return null;var f=[],g=[],h=[],i,k,j;if(b(a)>0)for(k=0;k<e;k++)g[k]=k;else for(k=0;k<e;k++)g[k]=e-1-k;var o=2*e;for(k=e-1;e>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);j=k+1;e<=j&&(j=0);var p;a:{p=a;var m=i,q=k,n=j,s=e,r=g,u=void 0,t=void 0,z=void 0,
-A=void 0,E=void 0,D=void 0,B=void 0,w=void 0,G=void 0,t=p[r[m]].x,z=p[r[m]].y,A=p[r[q]].x,E=p[r[q]].y,D=p[r[n]].x,B=p[r[n]].y;if(1.0E-10>(A-t)*(B-z)-(E-z)*(D-t))p=!1;else{for(u=0;u<s;u++)if(!(u==m||u==q||u==n)){var w=p[r[u]].x,G=p[r[u]].y,y=void 0,K=void 0,$=void 0,Q=void 0,Y=void 0,S=void 0,R=void 0,l=void 0,W=void 0,v=void 0,X=void 0,L=void 0,y=$=Y=void 0,y=D-A,K=B-E,$=t-D,Q=z-B,Y=A-t,S=E-z,R=w-t,l=G-z,W=w-A,v=G-E,X=w-D,L=G-B,y=y*v-K*W,Y=Y*l-S*R,$=$*L-Q*X;if(y>=0&&$>=0&&Y>=0){p=!1;break a}}p=!0}}if(p){f.push([a[g[i]],
-a[g[k]],a[g[j]]]);h.push([g[i],g[k],g[j]]);i=k;for(j=k+1;j<e;i++,j++)g[i]=g[j];e--;o=2*e}}if(d)return h;return f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
+0,e=String(a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h);d+=h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,i,j,k,o,p,m,q,n,s,r=b.glyphs[a]||b.glyphs["?"];if(r){if(r.o){b=r._cachedOutline||(r._cachedOutline=r.o.split(" "));j=b.length;for(a=0;a<j;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,k));e.moveTo(i,k);break;case "l":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,
+k));e.lineTo(i,k);break;case "q":i=b[a++]*c+d;k=b[a++]*c;m=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(m,q,i,k);if(g=f[f.length-1]){o=g.x;p=g.y;g=1;for(h=this.divisions;g<=h;g++){var u=g/h,t=THREE.Shape.Utils.b2(u,o,m,i),u=THREE.Shape.Utils.b2(u,p,q,k);f.push(new THREE.Vector2(t,u))}}break;case "b":if(i=b[a++]*c+d,k=b[a++]*c,m=b[a++]*c+d,q=b[a++]*-c,n=b[a++]*c+d,s=b[a++]*-c,e.bezierCurveTo(i,k,m,q,n,s),g=f[f.length-1]){o=g.x;p=g.y;g=1;for(h=this.divisions;g<=h;g++)u=g/h,t=THREE.Shape.Utils.b3(u,o,m,
+n,i),u=THREE.Shape.Utils.b3(u,p,q,s,k),f.push(new THREE.Vector2(t,u))}}}return{offset:r.ha*c,points:f,path:e}}}};
+(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return e*0.5};a.Triangulate=function(a,d){var e=a.length;if(e<3)return null;var f=[],g=[],h=[],i,j,k;if(b(a)>0)for(j=0;j<e;j++)g[j]=j;else for(j=0;j<e;j++)g[j]=e-1-j;var o=2*e;for(j=e-1;e>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);k=j+1;e<=k&&(k=0);var p;a:{p=a;var m=i,q=j,n=k,s=e,r=g,u=void 0,t=void 0,A=void 0,
+B=void 0,z=void 0,D=void 0,H=void 0,w=void 0,F=void 0,t=p[r[m]].x,A=p[r[m]].y,B=p[r[q]].x,z=p[r[q]].y,D=p[r[n]].x,H=p[r[n]].y;if(1.0E-10>(B-t)*(H-A)-(z-A)*(D-t))p=!1;else{for(u=0;u<s;u++)if(!(u==m||u==q||u==n)){var w=p[r[u]].x,F=p[r[u]].y,y=void 0,K=void 0,$=void 0,Q=void 0,X=void 0,T=void 0,R=void 0,l=void 0,S=void 0,v=void 0,W=void 0,M=void 0,y=$=X=void 0,y=D-B,K=H-z,$=t-D,Q=A-H,X=B-t,T=z-A,R=w-t,l=F-A,S=w-B,v=F-z,W=w-D,M=F-H,y=y*v-K*S,X=X*l-T*R,$=$*M-Q*W;if(y>=0&&$>=0&&X>=0){p=!1;break a}}p=!0}}if(p){f.push([a[g[i]],
+a[g[j]],a[g[k]]]);h.push([g[i],g[j],g[k]]);i=j;for(k=j+1;k<e;i++,k++)g[i]=g[k];e--;o=2*e}}if(d)return h;return f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=e||Math.PI*2;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var f=d/this.segmentsT*this.arc,g=c/this.segmentsR*Math.PI*2;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*Math.cos(g))*Math.sin(f);h.z=
 THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=e||Math.PI*2;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var f=d/this.segmentsT*this.arc,g=c/this.segmentsR*Math.PI*2;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*Math.cos(g))*Math.sin(f);h.z=
 this.tube*Math.sin(g);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var e=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[f]);i.normal.addSelf(b[g]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
 this.tube*Math.sin(g);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var e=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[f]);i.normal.addSelf(b[g]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
 this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
 this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
 THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){b=c/d*a;c=Math.cos(b);return new THREE.Vector3(e*(2+c)*0.5*Math.cos(a),e*(2+c)*Math.sin(a)*0.5,f*e*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(b=0;b<
 THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){b=c/d*a;c=Math.cos(b);return new THREE.Vector3(e*(2+c)*0.5*Math.cos(a),e*(2+c)*Math.sin(a)*0.5,f*e*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(b=0;b<
 this.segmentsT;++b){var i=a/this.segmentsR*2*this.p*Math.PI,g=b/this.segmentsT*2*Math.PI,e=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.x=i.x-e.x;c.y=i.y-e.y;c.z=i.z-e.z;d.x=i.x+e.x;d.y=i.y+e.y;d.z=i.z+e.z;f.cross(c,d);d.cross(f,c);f.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);e.x+=i*d.x+g*f.x;e.y+=i*d.y+g*f.y;e.z+=i*d.z+g*f.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,
 this.segmentsT;++b){var i=a/this.segmentsR*2*this.p*Math.PI,g=b/this.segmentsT*2*Math.PI,e=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.x=i.x-e.x;c.y=i.y-e.y;c.z=i.z-e.z;d.x=i.x+e.x;d.y=i.y+e.y;d.z=i.z+e.z;f.cross(c,d);d.cross(f,c);f.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);e.x+=i*d.x+g*f.x;e.y+=i*d.y+g*f.y;e.z+=i*d.z+g*f.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,
-e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var d=(a+1)%this.segmentsR,f=(b+1)%this.segmentsT,e=this.grid[a][b],c=this.grid[d][b],d=this.grid[d][f],f=this.grid[a][f],g=new THREE.UV(a/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),j=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(e,c,d,f));this.faceVertexUvs[0].push([g,i,k,j])}this.computeCentroids();
+e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var d=(a+1)%this.segmentsR,f=(b+1)%this.segmentsT,e=this.grid[a][b],c=this.grid[d][b],d=this.grid[d][f],f=this.grid[a][f],g=new THREE.UV(a/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(e,c,d,f));this.faceVertexUvs[0].push([g,i,j,k])}this.computeCentroids();
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};
 THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){j.vertexColors=[];for(var k,n,m,o=0;o<4;o++){m=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q<m.length;q++)n=h.vertexColors[m[q]-1],k.r+=n.r,k.g+=n.g,k.b+=n.b;k.r/=m.length;k.g/=m.length;k.b/=m.length;j.vertexColors[o]=k}}e.push(j);(!g.supportUVs||p.length!=0)&&f.push([p[a],p[b],p[c],p[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
 THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){j.vertexColors=[];for(var k,n,m,o=0;o<4;o++){m=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q<m.length;q++)n=h.vertexColors[m[q]-1],k.r+=n.r,k.g+=n.g,k.b+=n.b;k.r/=m.length;k.g/=m.length;k.b/=m.length;j.vertexColors[o]=k}}e.push(j);(!g.supportUVs||p.length!=0)&&f.push([p[a],p[b],p[c],p[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
-b)}var d=[],e=[],f=[],g=this,h=a.vertices,d=a.faces,i=h.concat(),k=[],j={},o={},p=[],m,q,n,s,r,u=a.faceVertexUvs[0];m=0;for(q=u.length;m<q;m++){n=0;for(s=u[m].length;n<s;n++)r=d[m]["abcd".charAt(n)],p[r]||(p[r]=u[m][n])}var t;m=0;for(q=d.length;m<q;m++)if(r=d[m],k.push(r.centroid),i.push(new THREE.Vertex(r.centroid)),g.supportUVs&&p.length!=0){t=new THREE.UV;if(r instanceof THREE.Face3)t.u=p[r.a].u+p[r.b].u+p[r.c].u,t.v=p[r.a].v+p[r.b].v+p[r.c].v,t.u/=3,t.v/=3;else if(r instanceof THREE.Face4)t.u=
-p[r.a].u+p[r.b].u+p[r.c].u+p[r.d].u,t.v=p[r.a].v+p[r.b].v+p[r.c].v+p[r.d].v,t.u/=4,t.v/=4;p.push(t)}q=function(a){function b(a,c,d){a[c]===void 0&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var z=0,u=h.length,A,E,D={},B={},w=function(a,
-b){D[a]===void 0&&(D[a]=[]);D[a].push(b)},G=function(a,b){B[a]===void 0&&(B[a]={});B[a][b]=null};for(m in q){t=q[m];A=m.split("_");E=A[0];A=A[1];w(E,[E,A]);w(A,[E,A]);n=0;for(s=t.length;n<s;n++)r=t[n],G(E,r,m),G(A,r,m);t.length<2&&(o[m]=!0)}for(m in q)if(t=q[m],r=t[0],t=t[1],A=m.split("_"),E=A[0],A=A[1],s=new THREE.Vector3,o[m]?(s.addSelf(h[E].position),s.addSelf(h[A].position),s.multiplyScalar(0.5)):(s.addSelf(k[r]),s.addSelf(k[t]),s.addSelf(h[E].position),s.addSelf(h[A].position),s.multiplyScalar(0.25)),
-j[m]=u+d.length+z,i.push(new THREE.Vertex(s)),z++,g.supportUVs&&p.length!=0)t=new THREE.UV,t.u=p[E].u+p[A].u,t.v=p[E].v+p[A].v,t.u/=2,t.v/=2,p.push(t);var y,K;A=["123","12","2","23"];s=["123","23","3","31"];var w=["123","31","1","12"],G=["1234","12","2","23"],$=["1234","23","3","34"],Q=["1234","34","4","41"],Y=["1234","41","1","12"];m=0;for(q=k.length;m<q;m++)r=d[m],t=u+m,r instanceof THREE.Face3?(z=c(r.a,r.b),E=c(r.b,r.c),y=c(r.c,r.a),b(t,j[z],r.b,j[E],r,A),b(t,j[E],r.c,j[y],r,s),b(t,j[y],r.a,j[z],
-r,w)):r instanceof THREE.Face4?(z=c(r.a,r.b),E=c(r.b,r.c),y=c(r.c,r.d),K=c(r.d,r.a),b(t,j[z],r.b,j[E],r,G),b(t,j[E],r.c,j[y],r,$),b(t,j[y],r.d,j[K],r,Q),b(t,j[K],r.a,j[z],r,Y)):console.log("face should be a face!",r);d=i;i=new THREE.Vector3;j=new THREE.Vector3;m=0;for(q=h.length;m<q;m++)if(D[m]!==void 0){i.set(0,0,0);j.set(0,0,0);r=new THREE.Vector3(0,0,0);t=0;for(n in B[m])i.addSelf(k[n]),t++;z=0;u=D[m].length;for(n=0;n<u;n++)o[c(D[m][n][0],D[m][n][1])]&&z++;if(z!=2){i.divideScalar(t);for(n=0;n<
-u;n++)t=D[m][n],t=h[t[0]].position.clone().addSelf(h[t[1]].position).divideScalar(2),j.addSelf(t);j.divideScalar(u);r.addSelf(h[m].position);r.multiplyScalar(u-3);r.addSelf(i);r.addSelf(j.multiplyScalar(2));r.divideScalar(u);d[m].position=r}}a.vertices=d;a.faces=e;a.faceVertexUvs[0]=f;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
+b)}var d=[],e=[],f=[],g=this,h=a.vertices,d=a.faces,i=h.concat(),j=[],k={},o={},p=[],m,q,n,s,r,u=a.faceVertexUvs[0];m=0;for(q=u.length;m<q;m++){n=0;for(s=u[m].length;n<s;n++)r=d[m]["abcd".charAt(n)],p[r]||(p[r]=u[m][n])}var t;m=0;for(q=d.length;m<q;m++)if(r=d[m],j.push(r.centroid),i.push(new THREE.Vertex(r.centroid)),g.supportUVs&&p.length!=0){t=new THREE.UV;if(r instanceof THREE.Face3)t.u=p[r.a].u+p[r.b].u+p[r.c].u,t.v=p[r.a].v+p[r.b].v+p[r.c].v,t.u/=3,t.v/=3;else if(r instanceof THREE.Face4)t.u=
+p[r.a].u+p[r.b].u+p[r.c].u+p[r.d].u,t.v=p[r.a].v+p[r.b].v+p[r.c].v+p[r.d].v,t.u/=4,t.v/=4;p.push(t)}q=function(a){function b(a,c,d){a[c]===void 0&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var A=0,u=h.length,B,z,D={},H={},w=function(a,
+b){D[a]===void 0&&(D[a]=[]);D[a].push(b)},F=function(a,b){H[a]===void 0&&(H[a]={});H[a][b]=null};for(m in q){t=q[m];B=m.split("_");z=B[0];B=B[1];w(z,[z,B]);w(B,[z,B]);n=0;for(s=t.length;n<s;n++)r=t[n],F(z,r,m),F(B,r,m);t.length<2&&(o[m]=!0)}for(m in q)if(t=q[m],r=t[0],t=t[1],B=m.split("_"),z=B[0],B=B[1],s=new THREE.Vector3,o[m]?(s.addSelf(h[z].position),s.addSelf(h[B].position),s.multiplyScalar(0.5)):(s.addSelf(j[r]),s.addSelf(j[t]),s.addSelf(h[z].position),s.addSelf(h[B].position),s.multiplyScalar(0.25)),
+k[m]=u+d.length+A,i.push(new THREE.Vertex(s)),A++,g.supportUVs&&p.length!=0)t=new THREE.UV,t.u=p[z].u+p[B].u,t.v=p[z].v+p[B].v,t.u/=2,t.v/=2,p.push(t);var y,K;B=["123","12","2","23"];s=["123","23","3","31"];var w=["123","31","1","12"],F=["1234","12","2","23"],$=["1234","23","3","34"],Q=["1234","34","4","41"],X=["1234","41","1","12"];m=0;for(q=j.length;m<q;m++)r=d[m],t=u+m,r instanceof THREE.Face3?(A=c(r.a,r.b),z=c(r.b,r.c),y=c(r.c,r.a),b(t,k[A],r.b,k[z],r,B),b(t,k[z],r.c,k[y],r,s),b(t,k[y],r.a,k[A],
+r,w)):r instanceof THREE.Face4?(A=c(r.a,r.b),z=c(r.b,r.c),y=c(r.c,r.d),K=c(r.d,r.a),b(t,k[A],r.b,k[z],r,F),b(t,k[z],r.c,k[y],r,$),b(t,k[y],r.d,k[K],r,Q),b(t,k[K],r.a,k[A],r,X)):console.log("face should be a face!",r);d=i;i=new THREE.Vector3;k=new THREE.Vector3;m=0;for(q=h.length;m<q;m++)if(D[m]!==void 0){i.set(0,0,0);k.set(0,0,0);r=new THREE.Vector3(0,0,0);t=0;for(n in H[m])i.addSelf(j[n]),t++;A=0;u=D[m].length;for(n=0;n<u;n++)o[c(D[m][n][0],D[m][n][1])]&&A++;if(A!=2){i.divideScalar(t);for(n=0;n<
+u;n++)t=D[m][n],t=h[t[0]].position.clone().addSelf(h[t[1]].position).divideScalar(2),k.addSelf(t);k.divideScalar(u);r.addSelf(h[m].position);r.multiplyScalar(u-3);r.addSelf(i);r.addSelf(k.multiplyScalar(2));r.divideScalar(u);d[m].position=r}}a.vertices=d;a.faces=e;a.faceVertexUvs[0]=f;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+
 THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+
 "%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.length<1?"":a.join("/")+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==
 "%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.length<1?"":a.join("/")+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==
 a}function d(a,b){var d=new Image;d.onload=function(){if(!c(this.width)||!c(this.height)){var b=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),d=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=b;a.image.height=d;a.image.getContext("2d").drawImage(this,0,0,b,d)}else a.image=this;a.needsUpdate=!0};d.crossOrigin=g.crossOrigin;d.src=b}function e(a,c,e,f,g,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=e;if(f){a[c].repeat.set(f[0],f[1]);
 a}function d(a,b){var d=new Image;d.onload=function(){if(!c(this.width)||!c(this.height)){var b=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),d=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=b;a.image.height=d;a.image.getContext("2d").drawImage(this,0,0,b,d)}else a.image=this;a.needsUpdate=!0};d.crossOrigin=g.crossOrigin;d.src=b}function e(a,c,e,f,g,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=e;if(f){a[c].repeat.set(f[0],f[1]);
-if(f[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[h[0]]!==void 0)a[c].wrapS=f[h[0]];if(f[h[1]]!==void 0)a[c].wrapT=f[h[1]]}d(a[c],b+"/"+e)}function f(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var g=this,h,i,k;i="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?
+if(f[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[h[0]]!==void 0)a[c].wrapS=f[h[0]];if(f[h[1]]!==void 0)a[c].wrapT=f[h[1]]}d(a[c],b+"/"+e)}function f(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var g=this,h,i,j;i="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?
 i="MeshPhongMaterial":a.shading=="Basic"&&(i="MeshBasicMaterial"));if(a.blending)if(a.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)h.transparent=a.transparent;if(a.depthTest!==void 0)h.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(a.vertexColors)h.vertexColors=
 i="MeshPhongMaterial":a.shading=="Basic"&&(i="MeshBasicMaterial"));if(a.blending)if(a.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)h.transparent=a.transparent;if(a.depthTest!==void 0)h.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(a.vertexColors)h.vertexColors=
 THREE.VertexColors;if(a.colorDiffuse)h.color=f(a.colorDiffuse);else if(a.DbgColor)h.color=a.DbgColor;if(a.colorSpecular)h.specular=f(a.colorSpecular);if(a.colorAmbient)h.ambient=f(a.colorAmbient);if(a.transparency)h.opacity=a.transparency;if(a.specularCoef)h.shininess=a.specularCoef;a.mapDiffuse&&b&&e(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(h,"normalMap",
 THREE.VertexColors;if(a.colorDiffuse)h.color=f(a.colorDiffuse);else if(a.DbgColor)h.color=a.DbgColor;if(a.colorSpecular)h.specular=f(a.colorSpecular);if(a.colorAmbient)h.ambient=f(a.colorAmbient);if(a.transparency)h.opacity=a.transparency;if(a.specularCoef)h.shininess=a.specularCoef;a.mapDiffuse&&b&&e(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(h,"normalMap",
-a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var j=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(j.uniforms),p=h.color;i=h.specular;k=h.ambient;var m=h.shininess;o.tNormal.texture=h.normalMap;if(a.mapNormalFactor)o.uNormalScale.value=a.mapNormalFactor;if(h.map)o.tDiffuse.texture=h.map,o.enableDiffuse.value=!0;if(h.specularMap)o.tSpecular.texture=
-h.specularMap,o.enableSpecular.value=!0;if(h.lightMap)o.tAO.texture=h.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(p);o.uSpecularColor.value.setHex(i);o.uAmbientColor.value.setHex(k);o.uShininess.value=m;if(h.opacity)o.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:o,lights:!0,fog:!0})}else h=new THREE[i](h);if(a.DbgName!==void 0)h.name=a.DbgName;return h}};
+a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var k=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(k.uniforms),p=h.color;i=h.specular;j=h.ambient;var m=h.shininess;o.tNormal.texture=h.normalMap;if(a.mapNormalFactor)o.uNormalScale.value=a.mapNormalFactor;if(h.map)o.tDiffuse.texture=h.map,o.enableDiffuse.value=!0;if(h.specularMap)o.tSpecular.texture=
+h.specularMap,o.enableSpecular.value=!0;if(h.lightMap)o.tAO.texture=h.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(p);o.uSpecularColor.value.setHex(i);o.uAmbientColor.value.setHex(j);o.uShininess.value=m;if(h.opacity)o.uOpacity.value=h.opacity;h=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:o,lights:!0,fog:!0})}else h=new THREE[i](h);if(a.DbgName!==void 0)h.name=a.DbgName;return h}};
 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=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,b,c,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,b=d.callback,c=d.texture_path,d=d.bin_path;var c=c?c:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
 THREE.BinaryLoader.prototype.load=function(a,b,c,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,b=d.callback,c=d.texture_path,d=d.bin_path;var c=c?c:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)};
 THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0)try{var h=JSON.parse(g.responseText);h.metadata===void 0||h.metadata.formatVersion===void 0||h.metadata.formatVersion!==3?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,e,d,f)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+
 THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0)try{var h=JSON.parse(g.responseText);h.metadata===void 0||h.metadata.formatVersion===void 0||h.metadata.formatVersion!==3?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,e,d,f)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+
 g.status+"]")};g.open("GET",b,!0);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
 g.status+"]")};g.open("GET",b,!0);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){f.readyState==4?f.status==200||f.status==0?THREE.BinaryLoader.prototype.createBinModel(f.response,b,d,a.materials):console.error("Couldn't load ["+g+"] ["+f.status+"]"):f.readyState==3?e&&(h==0&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):f.readyState==2&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0);
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){f.readyState==4?f.status==200||f.status==0?THREE.BinaryLoader.prototype.createBinModel(f.response,b,d,a.materials):console.error("Couldn't load ["+g+"] ["+f.status+"]"):f.readyState==3?e&&(h==0&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):f.readyState==2&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0);
 f.responseType="arraybuffer";f.send(null)};
 f.responseType="arraybuffer";f.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){function c(a){return a%4?4-a%4:0}function e(a,b){return(new Uint8Array(a,b,1))[0]}function i(a,b){return(new Uint32Array(a,b,1))[0]}function k(b,c){var d,e,f,g,h,i,j,k,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[d*3];f=m[d*3+1];g=m[d*3+2];h=t[e*2];e=t[e*2+1];i=t[f*2];j=t[f*2+1];f=t[g*2];k=t[g*2+1];g=n.faceVertexUvs[0];var o=[];o.push(new THREE.UV(h,e));o.push(new THREE.UV(i,j));o.push(new THREE.UV(f,k));g.push(o)}}
-function j(b,c){var d,e,f,g,h,i,j,k,m,o,p=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=p[d*4];f=p[d*4+1];g=p[d*4+2];h=p[d*4+3];i=t[e*2];e=t[e*2+1];j=t[f*2];m=t[f*2+1];k=t[g*2];o=t[g*2+1];g=t[h*2];f=t[h*2+1];h=n.faceVertexUvs[0];var q=[];q.push(new THREE.UV(i,e));q.push(new THREE.UV(j,m));q.push(new THREE.UV(k,o));q.push(new THREE.UV(g,f));h.push(q)}}function o(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[d*3],f=c[d*3+1],g=c[d*3+2],h=i[d],n.faces.push(new THREE.Face3(e,
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){function c(a){return a%4?4-a%4:0}function e(a,b){return(new Uint8Array(a,b,1))[0]}function i(a,b){return(new Uint32Array(a,b,1))[0]}function j(b,c){var d,e,f,g,h,i,l,j,k=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=k[d*3];f=k[d*3+1];g=k[d*3+2];h=t[e*2];e=t[e*2+1];i=t[f*2];l=t[f*2+1];f=t[g*2];j=t[g*2+1];g=n.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,e));m.push(new THREE.UV(i,l));m.push(new THREE.UV(f,j));g.push(m)}}
+function k(b,c){var d,e,f,g,h,i,l,j,k,m,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[d*4];f=o[d*4+1];g=o[d*4+2];h=o[d*4+3];i=t[e*2];e=t[e*2+1];l=t[f*2];k=t[f*2+1];j=t[g*2];m=t[g*2+1];g=t[h*2];f=t[h*2+1];h=n.faceVertexUvs[0];var p=[];p.push(new THREE.UV(i,e));p.push(new THREE.UV(l,k));p.push(new THREE.UV(j,m));p.push(new THREE.UV(g,f));h.push(p)}}function o(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[d*3],f=c[d*3+1],g=c[d*3+2],h=i[d],n.faces.push(new THREE.Face3(e,
 f,g,null,null,h))}function p(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[d*4],f=c[d*4+1],g=c[d*4+2],h=c[d*4+3],i=j[d],n.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function m(b,c,d,e){for(var f,g,h,i,j,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*3];g=c[e*3+1];h=c[e*3+2];j=d[e*3];k=d[e*3+1];m=d[e*3+2];i=o[e];var p=u[k*3],q=u[k*3+1];k=u[k*3+2];var s=u[m*3],r=u[m*3+1];m=u[m*3+2];n.faces.push(new THREE.Face3(f,
 f,g,null,null,h))}function p(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[d*4],f=c[d*4+1],g=c[d*4+2],h=c[d*4+3],i=j[d],n.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function m(b,c,d,e){for(var f,g,h,i,j,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*3];g=c[e*3+1];h=c[e*3+2];j=d[e*3];k=d[e*3+1];m=d[e*3+2];i=o[e];var p=u[k*3],q=u[k*3+1];k=u[k*3+2];var s=u[m*3],r=u[m*3+1];m=u[m*3+2];n.faces.push(new THREE.Face3(f,
 g,h,[new THREE.Vector3(u[j*3],u[j*3+1],u[j*3+2]),new THREE.Vector3(p,q,k),new THREE.Vector3(s,r,m)],null,i))}}function q(b,c,d,e){for(var f,g,h,i,j,k,m,o,p,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),q=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*4];g=c[e*4+1];h=c[e*4+2];i=c[e*4+3];k=d[e*4];m=d[e*4+1];o=d[e*4+2];p=d[e*4+3];j=q[e];var s=u[m*3],r=u[m*3+1];m=u[m*3+2];var t=u[o*3],w=u[o*3+1];o=u[o*3+2];var z=u[p*3],A=u[p*3+1];p=u[p*3+2];n.faces.push(new THREE.Face4(f,g,h,i,[new THREE.Vector3(u[k*
 g,h,[new THREE.Vector3(u[j*3],u[j*3+1],u[j*3+2]),new THREE.Vector3(p,q,k),new THREE.Vector3(s,r,m)],null,i))}}function q(b,c,d,e){for(var f,g,h,i,j,k,m,o,p,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),q=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*4];g=c[e*4+1];h=c[e*4+2];i=c[e*4+3];k=d[e*4];m=d[e*4+1];o=d[e*4+2];p=d[e*4+3];j=q[e];var s=u[m*3],r=u[m*3+1];m=u[m*3+2];var t=u[o*3],w=u[o*3+1];o=u[o*3+2];var z=u[p*3],A=u[p*3+1];p=u[p*3+2];n.faces.push(new THREE.Face4(f,g,h,i,[new THREE.Vector3(u[k*
-3],u[k*3+1],u[k*3+2]),new THREE.Vector3(s,r,m),new THREE.Vector3(t,w,o),new THREE.Vector3(z,A,p)],null,j))}}var n=this,s=0,r,u=[],t=[],z,A,E,D,B,w;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(n,d,b);r={signature:function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d}(a,s,12),header_bytes:e(a,s+12),vertex_coordinate_bytes:e(a,s+13),normal_coordinate_bytes:e(a,s+14),uv_coordinate_bytes:e(a,s+15),vertex_index_bytes:e(a,s+16),normal_index_bytes:e(a,
+3],u[k*3+1],u[k*3+2]),new THREE.Vector3(s,r,m),new THREE.Vector3(t,w,o),new THREE.Vector3(z,A,p)],null,j))}}var n=this,s=0,r,u=[],t=[],A,B,z,D,H,w;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(n,d,b);r={signature:function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d}(a,s,12),header_bytes:e(a,s+12),vertex_coordinate_bytes:e(a,s+13),normal_coordinate_bytes:e(a,s+14),uv_coordinate_bytes:e(a,s+15),vertex_index_bytes:e(a,s+16),normal_index_bytes:e(a,
 s+17),uv_index_bytes:e(a,s+18),material_index_bytes:e(a,s+19),nvertices:i(a,s+20),nnormals:i(a,s+20+4),nuvs:i(a,s+20+8),ntri_flat:i(a,s+20+12),ntri_smooth:i(a,s+20+16),ntri_flat_uv:i(a,s+20+20),ntri_smooth_uv:i(a,s+20+24),nquad_flat:i(a,s+20+28),nquad_smooth:i(a,s+20+32),nquad_flat_uv:i(a,s+20+36),nquad_smooth_uv:i(a,s+20+40)};r.signature!=="Three.js 003"&&console.warn("DEPRECATED: binary model seems to be using old format");s+=r.header_bytes;b=r.vertex_index_bytes*3+r.material_index_bytes;w=r.vertex_index_bytes*
 s+17),uv_index_bytes:e(a,s+18),material_index_bytes:e(a,s+19),nvertices:i(a,s+20),nnormals:i(a,s+20+4),nuvs:i(a,s+20+8),ntri_flat:i(a,s+20+12),ntri_smooth:i(a,s+20+16),ntri_flat_uv:i(a,s+20+20),ntri_smooth_uv:i(a,s+20+24),nquad_flat:i(a,s+20+28),nquad_smooth:i(a,s+20+32),nquad_flat_uv:i(a,s+20+36),nquad_smooth_uv:i(a,s+20+40)};r.signature!=="Three.js 003"&&console.warn("DEPRECATED: binary model seems to be using old format");s+=r.header_bytes;b=r.vertex_index_bytes*3+r.material_index_bytes;w=r.vertex_index_bytes*
-4+r.material_index_bytes;z=r.ntri_flat*b;A=r.ntri_smooth*(b+r.normal_index_bytes*3);E=r.ntri_flat_uv*(b+r.uv_index_bytes*3);D=r.ntri_smooth_uv*(b+r.normal_index_bytes*3+r.uv_index_bytes*3);B=r.nquad_flat*w;b=r.nquad_smooth*(w+r.normal_index_bytes*4);w=r.nquad_flat_uv*(w+r.uv_index_bytes*4);s+=function(b){var c=r.nvertices,b=new Float32Array(a,b,c*3),d,e,f,g;for(d=0;d<c;d++)e=b[d*3],f=b[d*3+1],g=b[d*3+2],n.vertices.push(new THREE.Vertex(new THREE.Vector3(e,f,g)));return c*3*Float32Array.BYTES_PER_ELEMENT}(s);
-s+=function(b){var c=r.nnormals;if(c){var b=new Int8Array(a,b,c*3),d,e,f,g;for(d=0;d<c;d++)e=b[d*3],f=b[d*3+1],g=b[d*3+2],u.push(e/127,f/127,g/127)}return c*3*Int8Array.BYTES_PER_ELEMENT}(s);s+=c(r.nnormals*3);s+=function(b){var c=r.nuvs;if(c){var b=new Float32Array(a,b,c*2),d,e,f;for(d=0;d<c;d++)e=b[d*2],f=b[d*2+1],t.push(e,f)}return c*2*Float32Array.BYTES_PER_ELEMENT}(s);z=s+z+c(r.ntri_flat*2);A=z+A+c(r.ntri_smooth*2);E=A+E+c(r.ntri_flat_uv*2);D=E+D+c(r.ntri_smooth_uv*2);B=D+B+c(r.nquad_flat*2);
-b=B+b+c(r.nquad_smooth*2);w=b+w+c(r.nquad_flat_uv*2);(function(a){var b=r.ntri_flat_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3;o(b,a,c+b*Uint32Array.BYTES_PER_ELEMENT*3);k(b,c)}})(A);(function(a){var b=r.ntri_smooth_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3,d=c+b*Uint32Array.BYTES_PER_ELEMENT*3;m(b,a,c,d+b*Uint32Array.BYTES_PER_ELEMENT*3);k(b,d)}})(E);(function(a){var b=r.nquad_flat_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4;p(b,a,c+b*Uint32Array.BYTES_PER_ELEMENT*4);j(b,
-c)}})(b);(function(a){var b=r.nquad_smooth_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4,d=c+b*Uint32Array.BYTES_PER_ELEMENT*4;q(b,a,c,d+b*Uint32Array.BYTES_PER_ELEMENT*4);j(b,d)}})(w);(function(a){var b=r.ntri_flat;b&&o(b,a,a+b*Uint32Array.BYTES_PER_ELEMENT*3)})(s);(function(a){var b=r.ntri_smooth;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3;m(b,a,c,c+b*Uint32Array.BYTES_PER_ELEMENT*3)}})(z);(function(a){var b=r.nquad_flat;b&&p(b,a,a+b*Uint32Array.BYTES_PER_ELEMENT*4)})(D);(function(a){var b=
-r.nquad_smooth;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4;q(b,a,c,c+b*Uint32Array.BYTES_PER_ELEMENT*4)}})(B);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
-THREE.ColladaLoader=function(){function a(a,d,e){U=a;d=d||ca;e!==void 0&&(a=e.split("/"),a.pop(),xa=a.length<1?"":a.join("/")+"/");if((a=U.evaluate("//dae:asset",U,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":ta=i.textContent.charAt(0)}}if(!la.convertUpAxis||ta===la.upAxis)pa=null;else switch(ta){case "X":pa=la.upAxis===
-"Y"?"XtoY":"XtoZ";break;case "Y":pa=la.upAxis==="X"?"YtoX":"YtoZ";break;case "Z":pa=la.upAxis==="X"?"ZtoX":"ZtoY"}va=b("//dae:library_images/dae:image",g,"image");sa=b("//dae:library_materials/dae:material",B,"material");qa=b("//dae:library_effects/dae:effect",$,"effect");ja=b("//dae:library_geometries/dae:geometry",s,"geometry");na=b("//dae:library_controllers/dae:controller",h,"controller");fa=b("//dae:library_animations/dae:animation",Y,"animation");wa=b(".//dae:library_visual_scenes/dae:visual_scene",
-j,"visual_scene");ya=[];za=[];(a=U.evaluate(".//dae:scene/dae:instance_visual_scene",U,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),aa=wa[a]):aa=null;O=new THREE.Object3D;for(a=0;a<aa.nodes.length;a++)O.add(f(aa.nodes[a]));Ba=[];c(O);a={scene:O,morphs:ya,skins:za,animations:Ba,dae:{images:va,materials:sa,effects:qa,geometries:ja,controllers:na,animations:fa,visualScenes:wa,scene:aa}};d&&d(a);return a}function b(a,b,c){for(var a=U.evaluate(a,
-U,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=aa.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};Ba.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=
+4+r.material_index_bytes;A=r.ntri_flat*b;B=r.ntri_smooth*(b+r.normal_index_bytes*3);z=r.ntri_flat_uv*(b+r.uv_index_bytes*3);D=r.ntri_smooth_uv*(b+r.normal_index_bytes*3+r.uv_index_bytes*3);H=r.nquad_flat*w;b=r.nquad_smooth*(w+r.normal_index_bytes*4);w=r.nquad_flat_uv*(w+r.uv_index_bytes*4);s+=function(b){var c=r.nvertices,b=new Float32Array(a,b,c*3),d,e,f,g;for(d=0;d<c;d++)e=b[d*3],f=b[d*3+1],g=b[d*3+2],n.vertices.push(new THREE.Vertex(new THREE.Vector3(e,f,g)));return c*3*Float32Array.BYTES_PER_ELEMENT}(s);
+s+=function(b){var c=r.nnormals;if(c){var b=new Int8Array(a,b,c*3),d,e,f,g;for(d=0;d<c;d++)e=b[d*3],f=b[d*3+1],g=b[d*3+2],u.push(e/127,f/127,g/127)}return c*3*Int8Array.BYTES_PER_ELEMENT}(s);s+=c(r.nnormals*3);s+=function(b){var c=r.nuvs;if(c){var b=new Float32Array(a,b,c*2),d,e,f;for(d=0;d<c;d++)e=b[d*2],f=b[d*2+1],t.push(e,f)}return c*2*Float32Array.BYTES_PER_ELEMENT}(s);A=s+A+c(r.ntri_flat*2);B=A+B+c(r.ntri_smooth*2);z=B+z+c(r.ntri_flat_uv*2);D=z+D+c(r.ntri_smooth_uv*2);H=D+H+c(r.nquad_flat*2);
+b=H+b+c(r.nquad_smooth*2);w=b+w+c(r.nquad_flat_uv*2);(function(a){var b=r.ntri_flat_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3;o(b,a,c+b*Uint32Array.BYTES_PER_ELEMENT*3);j(b,c)}})(B);(function(a){var b=r.ntri_smooth_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3,d=c+b*Uint32Array.BYTES_PER_ELEMENT*3;m(b,a,c,d+b*Uint32Array.BYTES_PER_ELEMENT*3);j(b,d)}})(z);(function(a){var b=r.nquad_flat_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4;p(b,a,c+b*Uint32Array.BYTES_PER_ELEMENT*4);k(b,
+c)}})(b);(function(a){var b=r.nquad_smooth_uv;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4,d=c+b*Uint32Array.BYTES_PER_ELEMENT*4;q(b,a,c,d+b*Uint32Array.BYTES_PER_ELEMENT*4);k(b,d)}})(w);(function(a){var b=r.ntri_flat;b&&o(b,a,a+b*Uint32Array.BYTES_PER_ELEMENT*3)})(s);(function(a){var b=r.ntri_smooth;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*3;m(b,a,c,c+b*Uint32Array.BYTES_PER_ELEMENT*3)}})(A);(function(a){var b=r.nquad_flat;b&&p(b,a,a+b*Uint32Array.BYTES_PER_ELEMENT*4)})(D);(function(a){var b=
+r.nquad_smooth;if(b){var c=a+b*Uint32Array.BYTES_PER_ELEMENT*4;q(b,a,c,c+b*Uint32Array.BYTES_PER_ELEMENT*4)}})(H);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
+THREE.ColladaLoader=function(){function a(a,d,e){U=a;d=d||ba;e!==void 0&&(a=e.split("/"),a.pop(),xa=a.length<1?"":a.join("/")+"/");if((a=U.evaluate("//dae:asset",U,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":ta=i.textContent.charAt(0)}}if(!la.convertUpAxis||ta===la.upAxis)pa=null;else switch(ta){case "X":pa=la.upAxis===
+"Y"?"XtoY":"XtoZ";break;case "Y":pa=la.upAxis==="X"?"YtoX":"YtoZ";break;case "Z":pa=la.upAxis==="X"?"ZtoX":"ZtoY"}va=b("//dae:library_images/dae:image",g,"image");sa=b("//dae:library_materials/dae:material",H,"material");qa=b("//dae:library_effects/dae:effect",$,"effect");ja=b("//dae:library_geometries/dae:geometry",s,"geometry");na=b("//dae:library_controllers/dae:controller",h,"controller");fa=b("//dae:library_animations/dae:animation",X,"animation");wa=b(".//dae:library_visual_scenes/dae:visual_scene",
+k,"visual_scene");ya=[];za=[];(a=U.evaluate(".//dae:scene/dae:instance_visual_scene",U,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),V=wa[a]):V=null;L=new THREE.Object3D;for(a=0;a<V.nodes.length;a++)L.add(f(V.nodes[a]));Ba=[];c(L);a={scene:L,morphs:ya,skins:za,animations:Ba,dae:{images:va,materials:sa,effects:qa,geometries:ja,controllers:na,animations:fa,visualScenes:wa,scene:V}};d&&d(a);return a}function b(a,b,c){for(var a=U.evaluate(a,U,
+S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=V.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};Ba.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=
 0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e=na[b.url];if(!e||!e.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||
 0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e=na[b.url];if(!e||!e.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||
-!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var f,c=1E6,g=-c,h=0;for(f in fa)for(var i=fa[f],j=0;j<i.sampler.length;j++){var k=i.sampler[j];k.create();c=Math.min(c,k.startTime);g=Math.max(g,k.endTime);h=Math.max(h,k.input.length)}f={start:c,end:g,frames:h};for(var b=aa.getChildById(b.skeleton[0],!0)||aa.getChildBySid(b.skeleton[0],!0),l,m,g=new THREE.Vector3,n,j=0;j<a.vertices.length;j++)e.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);
+!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var f,c=1E6,g=-c,h=0;for(f in fa)for(var i=fa[f],j=0;j<i.sampler.length;j++){var k=i.sampler[j];k.create();c=Math.min(c,k.startTime);g=Math.max(g,k.endTime);h=Math.max(h,k.input.length)}f={start:c,end:g,frames:h};for(var b=V.getChildById(b.skeleton[0],!0)||V.getChildBySid(b.skeleton[0],!0),l,m,g=new THREE.Vector3,n,j=0;j<a.vertices.length;j++)e.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);
 for(c=0;c<f.frames;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;k=e.skin;for(m=0;m<j.length;m++)if(l=j[m],n=-1,l.type=="JOINT"){for(var o=0;o<k.joints.length;o++)if(l.sid==k.joints[o]){n=o;break}if(n>=0){o=k.invBindMatrices[n];l.invBindMatrix=o;l.skinningMatrix=new THREE.Matrix4;l.skinningMatrix.multiply(l.world,o);l.weights=[];for(o=0;o<k.weights.length;o++)for(var p=0;p<k.weights[o].length;p++){var q=k.weights[o][p];q.joint==n&&l.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
 for(c=0;c<f.frames;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;k=e.skin;for(m=0;m<j.length;m++)if(l=j[m],n=-1,l.type=="JOINT"){for(var o=0;o<k.joints.length;o++)if(l.sid==k.joints[o]){n=o;break}if(n>=0){o=k.invBindMatrices[n];l.invBindMatrix=o;l.skinningMatrix=new THREE.Matrix4;l.skinningMatrix.multiply(l.world,o);l.weights=[];for(o=0;o<k.weights.length;o++)for(var p=0;p<k.weights[o].length;p++){var q=k.weights[o][p];q.joint==n&&l.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
 l.sid+"'.";}for(j=0;j<h.length;j++)if(h[j].type=="JOINT")for(k=0;k<h[j].weights.length;k++)l=h[j].weights[k],m=l.index,l=l.weight,n=a.vertices[m],m=i[m],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),m.position.x+=g.x*l,m.position.y+=g.y*l,m.position.z+=g.z*l;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var i=na[a.controllers[g].url];switch(i.type){case "skin":if(ja[i.skin.source]){var j=
 l.sid+"'.";}for(j=0;j<h.length;j++)if(h[j].type=="JOINT")for(k=0;k<h[j].weights.length;k++)l=h[j].weights[k],m=l.index,l=l.weight,n=a.vertices[m],m=i[m],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),m.position.x+=g.x*l,m.position.y+=g.y*l,m.position.z+=g.z*l;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var i=na[a.controllers[g].url];switch(i.type){case "skin":if(ja[i.skin.source]){var j=
 new n;j.url=i.skin.source;j.instance_material=a.controllers[g].instance_material;a.geometries.push(j);c=a.controllers[g]}else if(na[i.skin.source]&&(d=i=na[i.skin.source],i.morph&&ja[i.morph.source]))j=new n,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j);break;case "morph":if(ja[i.morph.source])j=new n,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j),d=a.controllers[g];console.log("ColladaLoader: Morph-controller partially supported.")}}for(g=
 new n;j.url=i.skin.source;j.instance_material=a.controllers[g].instance_material;a.geometries.push(j);c=a.controllers[g]}else if(na[i.skin.source]&&(d=i=na[i.skin.source],i.morph&&ja[i.morph.source]))j=new n,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j);break;case "morph":if(ja[i.morph.source])j=new n,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j),d=a.controllers[g];console.log("ColladaLoader: Morph-controller partially supported.")}}for(g=
 0;g<a.geometries.length;g++){var i=a.geometries[g],j=i.instance_material,i=ja[i.url],k={},l=[],o=0,p;if(i&&i.mesh&&i.mesh.primitives){if(b.name.length==0)b.name=i.id;if(j)for(h=0;h<j.length;h++){p=j[h];var q=qa[sa[p.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;k[p.symbol]=o;l.push(q.material);p=q.material;o++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(o>1){j=new THREE.MeshFaceMaterial;i.materials=
 0;g<a.geometries.length;g++){var i=a.geometries[g],j=i.instance_material,i=ja[i.url],k={},l=[],o=0,p;if(i&&i.mesh&&i.mesh.primitives){if(b.name.length==0)b.name=i.id;if(j)for(h=0;h<j.length;h++){p=j[h];var q=qa[sa[p.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;k[p.symbol]=o;l.push(q.material);p=q.material;o++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(o>1){j=new THREE.MeshFaceMaterial;i.materials=
 l;for(h=0;h<i.faces.length;h++)l=i.faces[h],l.materialIndex=k[l.daeMaterial]}if(c!==void 0)e(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=na[c.url],j.skinInstanceController=c,j.name="skin_"+za.length,za.push(j);else if(d!==void 0){h=i;k=d instanceof m?na[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(o=ja[k.targets[l]],o.mesh&&o.mesh.primitives&&o.mesh.primitives.length)o=o.mesh.primitives[0].geometry,
 l;for(h=0;h<i.faces.length;h++)l=i.faces[h],l.materialIndex=k[l.daeMaterial]}if(c!==void 0)e(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=na[c.url],j.skinInstanceController=c,j.name="skin_"+za.length,za.push(j);else if(d!==void 0){h=i;k=d instanceof m?na[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(o=ja[k.targets[l]],o.mesh&&o.mesh.primitives&&o.mesh.primitives.length)o=o.mesh.primitives[0].geometry,
 o.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:o.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+ya.length;ya.push(j)}else j=new THREE.Mesh(i,j);a.geometries.length>1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];la.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)),
 o.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:o.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+ya.length;ya.push(j)}else j=new THREE.Mesh(i,j);a.geometries.length>1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];la.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)),
-b.position.subSelf(c));for(g=0;g<a.nodes.length;g++)b.add(f(a.nodes[g],a));return b}function g(){this.init_from=this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=null}function i(){this.weights=this.targets=this.source=this.method=null}function k(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function j(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function o(){this.sid=this.name=this.id="";this.nodes=
+b.position.subSelf(c));for(g=0;g<a.nodes.length;g++)b.add(f(a.nodes[g],a));return b}function g(){this.init_from=this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=null}function i(){this.weights=this.targets=this.source=this.method=null}function j(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function k(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function o(){this.sid=this.name=this.id="";this.nodes=
 [];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function p(){this.type=this.sid="";this.data=[];this.obj=null}function m(){this.url="";this.skeleton=[];this.instance_material=[]}function q(){this.target=this.symbol=""}function n(){this.url="";this.instance_material=[]}function s(){this.id="";this.mesh=null}function r(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function u(){}function t(){this.material="";this.count=
 [];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function p(){this.type=this.sid="";this.data=[];this.obj=null}function m(){this.url="";this.skeleton=[];this.instance_material=[]}function q(){this.target=this.symbol=""}function n(){this.url="";this.instance_material=[]}function s(){this.id="";this.mesh=null}function r(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function u(){}function t(){this.material="";this.count=
-0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function z(){this.source="";this.stride=this.count=0;this.params=[]}function A(){this.input={}}function E(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function B(){this.name=this.id="";this.instance_effect=null}function w(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}
-function G(a,b){this.type=a;this.effect=b;this.material=null}function y(a){this.effect=a;this.format=this.init_from=null}function K(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function $(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function Q(){this.url=""}function Y(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function S(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=
-this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function R(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.strideOut=this.output=this.input=null;this.duration=0}function l(a){this.targets=[];this.time=a}function W(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function v(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function X(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],
-10));return b}function L(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function Z(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function da(a,b){if(la.convertUpAxis&&ta!==la.upAxis)switch(pa){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;break;case "XtoZ":c=a[2];a[2]=a[1];a[1]=a[0];a[0]=c;break;case "YtoX":c=a[0];a[0]=a[1];a[1]=b*c;break;case "YtoZ":c=a[1];a[1]=b*a[2];a[2]=c;break;case "ZtoX":c=a[0];a[0]=a[1];a[1]=a[2];a[2]=c;break;case "ZtoY":c=a[1],a[1]=a[2],a[2]=
-b*c}}function ba(a,b){var c=[a[b],a[b+1],a[b+2]];da(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function T(a){if(la.convertUpAxis){var b=[a[0],a[4],a[8]];da(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];da(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];da(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];da(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];da(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];da(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],
-a[11]];da(b,-1);a[3]=b[0];a[7]=b[1];a[11]=b[2]}return new THREE.Matrix4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}var U=null,O=null,aa,ca=null,ga={},va={},fa={},na={},ja={},sa={},qa={},Ba,wa,xa,ya,za,Aa=THREE.SmoothShading,la={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},ta="Y",pa=null,Ia=Math.PI/180;g.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName==
-"init_from")this.init_from=c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new k).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,
+0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function A(){this.source="";this.stride=this.count=0;this.params=[]}function B(){this.input={}}function z(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function H(){this.name=this.id="";this.instance_effect=null}function w(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}
+function F(a,b){this.type=a;this.effect=b;this.material=null}function y(a){this.effect=a;this.format=this.init_from=null}function K(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function $(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function Q(){this.url=""}function X(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function T(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=
+this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function R(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.strideOut=this.output=this.input=null;this.duration=0}function l(a){this.targets=[];this.time=a}function S(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function v(a){for(var a=M(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function W(a){for(var a=M(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],
+10));return b}function M(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function Z(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function ca(a,b){if(la.convertUpAxis&&ta!==la.upAxis)switch(pa){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;break;case "XtoZ":c=a[2];a[2]=a[1];a[1]=a[0];a[0]=c;break;case "YtoX":c=a[0];a[0]=a[1];a[1]=b*c;break;case "YtoZ":c=a[1];a[1]=b*a[2];a[2]=c;break;case "ZtoX":c=a[0];a[0]=a[1];a[1]=a[2];a[2]=c;break;case "ZtoY":c=a[1],a[1]=a[2],a[2]=
+b*c}}function aa(a,b){var c=[a[b],a[b+1],a[b+2]];ca(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function ea(a){if(la.convertUpAxis){var b=[a[0],a[4],a[8]];ca(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];ca(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];ca(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];ca(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];ca(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];ca(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],
+a[11]];ca(b,-1);a[3]=b[0];a[7]=b[1];a[11]=b[2]}return new THREE.Matrix4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}var U=null,L=null,V,ba=null,ga={},va={},fa={},na={},ja={},sa={},qa={},Ba,wa,xa,ya,za,Aa=THREE.SmoothShading,la={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},ta="Y",pa=null,Ia=Math.PI/180;g.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName==
+"init_from")this.init_from=c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new j).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,
 "");for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new D).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};i.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==
 "");for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new D).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};i.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==
-1)switch(d.nodeName){case "input":b.push((new E).parse(d))}}return b};k.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=v(f.textContent);this.bindShapeMatrix=T(f);break;case "source":f=(new D).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,
-b);this.parseWeights(d,b);return this};k.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=(new E).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};k.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=a.childNodes[f];if(g.nodeType==1)switch(g.nodeName){case "input":e.push((new E).parse(g));
-break;case "v":c=X(g.textContent);break;case "vcount":d=X(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],o=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=o;break;case "WEIGHT":k.weight=b[m.source].data[o]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};j.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};
-j.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};j.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new o).parse(c))}}return this};o.prototype.getChannelForTransform=function(a){for(var b=0;b<this.channels.length;b++){var c=this.channels[b],
-d=c.target.split("/");d.shift();var e=d.shift(),f=e.indexOf(".")>=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;d<h.length;d++)h[d]=parseInt(h[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:g,arrIndices:h},c}return null};o.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};o.prototype.getChildBySid=
-function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};o.prototype.getTransformBySid=function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};o.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");this.type=this.type=="JOINT"?this.type:
-"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],b.nodeType==1)switch(b.nodeName){case "node":this.nodes.push((new o).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new m).parse(b));break;case "instance_geometry":this.geometries.push((new n).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,
-"");(b=U.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",U,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new o).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new p).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in fa)for(var e=fa[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];if(d==this.id)h.create(),
-g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=[];a=[];c=0;for(e=this.channels.length;c<e;c++){b=this.channels[c];f=b.fullSid;g=b.member;if(la.convertUpAxis)switch(g){case "X":switch(pa){case "XtoY":case "XtoZ":case "YtoX":g="Y";break;case "ZtoX":g="Z"}break;case "Y":switch(pa){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(pa){case "XtoZ":g=
-"X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){a.indexOf(f)===-1&&a.push(f);b=0;for(var k=i.length;b<k;b++){var q=i[b],s=h.getData(j.type,b),r;r=null;for(var t=0,u=d.length;t<u&&r==null;t++){var v=d[t];if(v.time===q)r=v;else if(v.time>q)break}if(!r){r=new l(q);t=-1;u=0;for(v=d.length;u<v&&t==-1;u++)d[u].time>=q&&(t=u);q=t;d.splice(q==-1?d.length:q,0,r)}r.addTarget(f,j,g,s)}}else console.log('Could not find transform "'+b.sid+'" in node '+
-this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=i>=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))break a;k=null}if(i&&k){h=(f.time-i.time)/(k.time-i.time);i=i.getTarget(g);j=k.getTarget(g).data;k=i.data;s=void 0;if(k.length){s=[];for(q=0;q<k.length;++q)s[q]=k[q]+(j[q]-k[q])*h}else s=k+(j-k)*h;f.addTarget(g,i.transform,i.member,s)}}}this.keys=
-d;this.sids=a}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};p.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=v(a.textContent);this.convert();return this};p.prototype.convert=function(){switch(this.type){case "matrix":this.obj=T(this.data);break;case "rotate":this.angle=this.data[3]*Ia;case "translate":da(this.data,-1);this.obj=new THREE.Vector3(this.data[0],
-this.data[1],this.data[2]);break;case "scale":da(this.data,1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};p.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,this.angle);break;case "scale":a.scale(this.obj)}};p.prototype.update=function(a,b){switch(this.type){case "matrix":console.log("Currently not handling matrix transform updates");
-break;case "translate":case "scale":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case "rotate":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=a*Ia;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*Ia}}};m.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=
-[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=U.evaluate(".//dae:instance_material",c,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new q).parse(d)),d=c.iterateNext()}}return this};q.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,
-"");return this};n.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1&&c.nodeName=="bind_material"){if(a=U.evaluate(".//dae:instance_material",c,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new q).parse(b)),b=a.iterateNext();break}}return this};s.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<
-a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new r(this)).parse(c)}}return this};r.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "source":var d=c.getAttribute("id");ga[d]==void 0&&(ga[d]=(new D(d)).parse(c));break;case "vertices":this.vertices=(new A).parse(c);break;case "triangles":this.primitives.push((new t).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");
-case "polylist":this.primitives.push((new u).parse(c))}}this.geometry3js=new THREE.Geometry;a=ga[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(ba(a,b)));for(b=0;b<this.primitives.length;b++)a=this.primitives[b],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
-return this};r.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,l=0,m=3,o=[];for(d=0;d<g.length;d++)switch(h=g[d],h.semantic){case "TEXCOORD":o.push(h.set)}for(;c<f.length;){var n=[],p=[],q={},r=[];a.vcount&&(m=a.vcount[l++]);for(d=0;d<m;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=ga[h.source],i=f[c+d*g.length+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":n.push(i);break;case "NORMAL":p.push(ba(k.data,j));break;case "TEXCOORD":q[h.set]===void 0&&(q[h.set]=
-[]);q[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":r.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(m===3)d.push(new THREE.Face3(n[0],n[1],n[2],[p[0],p[1],p[2]],r.length?r:new THREE.Color));else if(m===4)d.push(new THREE.Face4(n[0],n[1],n[2],n[3],[p[0],p[1],p[2],p[3]],r.length?r:new THREE.Color));else if(m>4&&la.subdivideFaces){r=r.length?r:new THREE.Color;for(e=1;e<m-1;)d.push(new THREE.Face3(n[0],n[e],n[e+1],[p[0],p[e++],p[e]],r))}if(d.length){n=
-0;for(p=d.length;n<p;n++){e=d[n];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)r=q[o[e]],r=m>4?[r[0],r[n+1],r[n+2]]:m===4?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};u.prototype=new t;u.prototype.constructor=u;t.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=
-a.input.POSITION.source};t.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=Z(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new E).parse(a.childNodes[b]));break;case "vcount":this.vcount=X(c.textContent);break;case "p":this.p=X(c.textContent)}}return this};z.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=Z(a,"count",0);this.stride=
-Z(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};A.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="input"){var c=(new E).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};E.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,
-"");this.set=Z(a,"set",-1);this.offset=Z(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};D.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=L(c.textContent),e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=v(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
-X(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=L(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new z).parse(c.childNodes[d]);break}}}return this};D.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=
-this.data.slice(b,b+16),c=T(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};B.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new Q).parse(a.childNodes[b]);break}return this};w.prototype.isColor=function(){return this.texture==null};w.prototype.isTexture=function(){return this.texture!=
-null};w.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "color":c=v(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord"),this.texOpts={offsetU:0,offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(c)}}return this};w.prototype.parseTexture=function(a){if(!a.childNodes)return this;
-a.childNodes[1]&&a.childNodes[1].nodeName==="extra"&&(a=a.childNodes[1],a.childNodes[1]&&a.childNodes[1].nodeName==="technique"&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};G.prototype.parse=
-function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new w).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=U.evaluate(".//dae:float",c,W,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();
-return this};G.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof w)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=va[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(xa+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,
-e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Aa;return this.material=new THREE.MeshLambertMaterial(a)};y.prototype.parse=function(a){for(var b=
-0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+c.nodeName)}}return this};K.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=
-c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};$.prototype.create=function(){if(this.shader==null)return null};$.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
-$.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=(new y(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new K(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};$.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);
-break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};$.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new G(c.nodeName,this)).parse(c)}}};Q.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};Y.prototype.parse=function(a){this.id=a.getAttribute("id");
-this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":c=(new D).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new R(this)).parse(c));break;case "channel":this.channel.push((new S(this)).parse(c))}}return this};S.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");b.shift();var a=
-b.shift(),c=a.indexOf(".")>=0,d=a.indexOf("(")>=0;if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e<b.length;e++)b[e]=parseInt(b[e].replace(/\)/,""));this.arrIndices=b}else this.sid=a;this.fullSid=a;this.dotSyntax=c;this.arrSyntax=d;return this};R.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new E).parse(c))}}return this};
-R.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();this.strideOut=c.accessor.stride;break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=
-0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};R.prototype.getData=function(a,b){var c;if(this.strideOut>1){c=[];b*=this.strideOut;for(var d=0;d<this.strideOut;++d)c[d]=this.output[b+d];if(this.strideOut===3)switch(a){case "rotate":case "translate":da(c,-1);break;case "scale":da(c,1)}}else c=this.output[b];return c};l.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,
-member:c,transform:b,data:d})};l.prototype.apply=function(a){for(var b=0;b<this.targets.length;++b){var c=this.targets[b];(!a||c.sid===a)&&c.transform.update(c.data,c.member)}};l.prototype.getTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return this.targets[b];return null};l.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};l.prototype.interpolate=function(a,b){for(var c=0;c<this.targets.length;++c){var d=
-this.targets[c],e=a.getTarget(d.sid);if(e){var f=(b-this.time)/(a.time-this.time),g=e.data,h=d.data;if(f<0||f>1)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=f<0?0:1;if(h.length)for(var e=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;else e=h+(g-h)*f}else e=d.data;d.transform.update(e,d.member)}};return{load:function(b,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=
-function(){if(f.readyState==4){if(f.status==0||f.status==200)f.responseXML?(ca=c,a(f.responseXML,void 0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else f.readyState==3&&d&&(e==0&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){Aa=a},applySkin:e,geometries:ja,options:la}};
-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;
+1)switch(d.nodeName){case "input":b.push((new z).parse(d))}}return b};j.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=v(f.textContent);this.bindShapeMatrix=ea(f);break;case "source":f=(new D).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":d=f;break;
+default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,b);return this};j.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=(new z).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};j.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=a.childNodes[f];if(g.nodeType==
+1)switch(g.nodeName){case "input":e.push((new z).parse(g));break;case "v":c=W(g.textContent);break;case "vcount":d=W(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],o=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=o;break;case "WEIGHT":k.weight=b[m.source].data[o]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};k.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=
+this.nodes[c].getChildById(a,b);if(d)return d}return null};k.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};k.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new o).parse(c))}}return this};o.prototype.getChannelForTransform=function(a){for(var b=
+0;b<this.channels.length;b++){var c=this.channels[b],d=c.target.split("/");d.shift();var e=d.shift(),f=e.indexOf(".")>=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;d<h.length;d++)h[d]=parseInt(h[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:g,arrIndices:h},c}return null};o.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,
+b);if(d)return d}return null};o.prototype.getChildBySid=function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};o.prototype.getTransformBySid=function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};o.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");
+this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],b.nodeType==1)switch(b.nodeName){case "node":this.nodes.push((new o).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new m).parse(b));break;case "instance_geometry":this.geometries.push((new n).parse(b));break;case "instance_light":break;case "instance_node":b=
+b.getAttribute("url").replace(/^#/,"");(b=U.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",U,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new o).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new p).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in fa)for(var e=fa[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];
+if(d==this.id)h.create(),g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=[];a=[];c=0;for(e=this.channels.length;c<e;c++){b=this.channels[c];f=b.fullSid;g=b.member;if(la.convertUpAxis)switch(g){case "X":switch(pa){case "XtoY":case "XtoZ":case "YtoX":g="Y";break;case "ZtoX":g="Z"}break;case "Y":switch(pa){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g=
+"Z"}break;case "Z":switch(pa){case "XtoZ":g="X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){a.indexOf(f)===-1&&a.push(f);b=0;for(var k=i.length;b<k;b++){var q=i[b],s=h.getData(j.type,b),r;r=null;for(var t=0,u=d.length;t<u&&r==null;t++){var v=d[t];if(v.time===q)r=v;else if(v.time>q)break}if(!r){r=new l(q);t=-1;u=0;for(v=d.length;u<v&&t==-1;u++)d[u].time>=q&&(t=u);q=t;d.splice(q==-1?d.length:q,0,r)}r.addTarget(f,j,g,s)}}else console.log('Could not find transform "'+
+b.sid+'" in node '+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=i>=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))break a;k=null}if(i&&k){h=(f.time-i.time)/(k.time-i.time);i=i.getTarget(g);j=k.getTarget(g).data;k=i.data;s=void 0;if(k.length){s=[];for(q=0;q<k.length;++q)s[q]=k[q]+(j[q]-k[q])*h}else s=k+(j-k)*h;f.addTarget(g,i.transform,
+i.member,s)}}}this.keys=d;this.sids=a}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};p.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=v(a.textContent);this.convert();return this};p.prototype.convert=function(){switch(this.type){case "matrix":this.obj=ea(this.data);break;case "rotate":this.angle=this.data[3]*Ia;case "translate":ca(this.data,
+-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":ca(this.data,1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};p.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,this.angle);break;case "scale":a.scale(this.obj)}};p.prototype.update=function(a,
+b){switch(this.type){case "matrix":console.log("Currently not handling matrix transform updates");break;case "translate":case "scale":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case "rotate":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=a*Ia;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*
+Ia}}};m.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=U.evaluate(".//dae:instance_material",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new q).parse(d)),d=c.iterateNext()}}return this};
+q.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,"");return this};n.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1&&c.nodeName=="bind_material"){if(a=U.evaluate(".//dae:instance_material",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new q).parse(b)),
+b=a.iterateNext();break}}return this};s.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new r(this)).parse(c)}}return this};r.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "source":var d=c.getAttribute("id");ga[d]==void 0&&(ga[d]=(new D(d)).parse(c));break;case "vertices":this.vertices=(new B).parse(c);
+break;case "triangles":this.primitives.push((new t).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new u).parse(c))}}this.geometry3js=new THREE.Geometry;a=ga[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(aa(a,b)));for(b=0;b<this.primitives.length;b++)a=this.primitives[b],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js);this.geometry3js.computeCentroids();
+this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};r.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,l=0,m=3,o=[];for(d=0;d<g.length;d++)switch(h=g[d],h.semantic){case "TEXCOORD":o.push(h.set)}for(;c<f.length;){var n=[],p=[],q={},r=[];a.vcount&&(m=a.vcount[l++]);for(d=0;d<m;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=ga[h.source],i=f[c+d*g.length+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":n.push(i);
+break;case "NORMAL":p.push(aa(k.data,j));break;case "TEXCOORD":q[h.set]===void 0&&(q[h.set]=[]);q[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":r.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(m===3)d.push(new THREE.Face3(n[0],n[1],n[2],[p[0],p[1],p[2]],r.length?r:new THREE.Color));else if(m===4)d.push(new THREE.Face4(n[0],n[1],n[2],n[3],[p[0],p[1],p[2],p[3]],r.length?r:new THREE.Color));else if(m>4&&la.subdivideFaces){r=r.length?r:new THREE.Color;
+for(e=1;e<m-1;)d.push(new THREE.Face3(n[0],n[e],n[e+1],[p[0],p[e++],p[e]],r))}if(d.length){n=0;for(p=d.length;n<p;n++){e=d[n];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)r=q[o[e]],r=m>4?[r[0],r[n+1],r[n+2]]:m===4?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};u.prototype=new t;u.prototype.constructor=u;t.prototype.setVertices=
+function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=a.input.POSITION.source};t.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=Z(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new z).parse(a.childNodes[b]));break;case "vcount":this.vcount=W(c.textContent);break;case "p":this.p=W(c.textContent)}}return this};A.prototype.parse=
+function(a){this.params=[];this.source=a.getAttribute("source");this.count=Z(a,"count",0);this.stride=Z(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};B.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="input"){var c=(new z).parse(a.childNodes[b]);this.input[c.semantic]=
+c}return this};z.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=Z(a,"set",-1);this.offset=Z(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};D.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=M(c.textContent),e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!0:!1);
+this.data=e;this.type=c.nodeName;break;case "float_array":this.data=v(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=W(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=M(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new A).parse(c.childNodes[d]);break}}}return this};D.prototype.read=function(){var a=[],b=this.accessor.params[0];
+switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=this.data.slice(b,b+16),c=ea(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};H.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new Q).parse(a.childNodes[b]);
+break}return this};w.prototype.isColor=function(){return this.texture==null};w.prototype.isTexture=function(){return this.texture!=null};w.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "color":c=v(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord"),this.texOpts={offsetU:0,
+offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(c)}}return this};w.prototype.parseTexture=function(a){if(!a.childNodes)return this;a.childNodes[1]&&a.childNodes[1].nodeName==="extra"&&(a=a.childNodes[1],a.childNodes[1]&&a.childNodes[1].nodeName==="technique"&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=
+parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};F.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new w).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=U.evaluate(".//dae:float",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),
+f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof w)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=va[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(xa+
+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Aa;return this.material=
+new THREE.MeshLambertMaterial(a)};y.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+c.nodeName)}}return this};K.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;
+case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};$.prototype.create=function(){if(this.shader==null)return null};$.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=
+0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};$.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=(new y(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new K(this)).parse(d);this.sampler.sid=b;break;case "extra":break;
+default:console.log(d.nodeName)}}};$.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};$.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=
+(new F(c.nodeName,this)).parse(c)}}};Q.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};X.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":c=(new D).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new R(this)).parse(c));break;case "channel":this.channel.push((new T(this)).parse(c))}}return this};
+T.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");b.shift();var a=b.shift(),c=a.indexOf(".")>=0,d=a.indexOf("(")>=0;if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e<b.length;e++)b[e]=parseInt(b[e].replace(/\)/,""));this.arrIndices=b}else this.sid=a;this.fullSid=a;this.dotSyntax=c;this.arrSyntax=d;return this};R.prototype.parse=function(a){this.id=
+a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new z).parse(c))}}return this};R.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();this.strideOut=c.accessor.stride;break;case "INTERPOLATION":this.interpolation=c.read();break;
+case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};R.prototype.getData=function(a,b){var c;if(this.strideOut>1){c=[];b*=this.strideOut;for(var d=0;d<this.strideOut;++d)c[d]=this.output[b+
+d];if(this.strideOut===3)switch(a){case "rotate":case "translate":ca(c,-1);break;case "scale":ca(c,1)}}else c=this.output[b];return c};l.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,member:c,transform:b,data:d})};l.prototype.apply=function(a){for(var b=0;b<this.targets.length;++b){var c=this.targets[b];(!a||c.sid===a)&&c.transform.update(c.data,c.member)}};l.prototype.getTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return this.targets[b];return null};
+l.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};l.prototype.interpolate=function(a,b){for(var c=0;c<this.targets.length;++c){var d=this.targets[c],e=a.getTarget(d.sid);if(e){var f=(b-this.time)/(a.time-this.time),g=e.data,h=d.data;if(f<0||f>1)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=f<0?0:1;if(h.length)for(var e=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;else e=h+(g-h)*f}else e=d.data;d.transform.update(e,
+d.member)}};return{load:function(b,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=function(){if(f.readyState==4){if(f.status==0||f.status==200)f.responseXML?(ba=c,a(f.responseXML,void 0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else f.readyState==3&&d&&(e==0&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};
+f.open("GET",b,!0);f.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){Aa=a},applySkin:e,geometries:ja,options:la}};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,b,c){if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),c=a,a=c.model,b=c.callback,c=c.texture_path;c=c?c:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
 THREE.JSONLoader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),c=a,a=c.model,b=c.callback,c=c.texture_path;c=c?c:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState==4)if(f.status==200||f.status==0){try{var h=JSON.parse(f.responseText)}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}a.createModel(h,c,d);a.onLoadComplete()}else console.error("Couldn't load ["+b+"] ["+f.status+"]");else f.readyState==3?e&&(g==0&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState==4)if(f.status==200||f.status==0){try{var h=JSON.parse(f.responseText)}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}a.createModel(h,c,d);a.onLoadComplete()}else console.error("Couldn't load ["+b+"] ["+f.status+"]");else f.readyState==3?e&&(g==0&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):
 f.readyState==2&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
 f.readyState==2&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
-THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){if(a.metadata===void 0||a.metadata.formatVersion===void 0||a.metadata.formatVersion!==3)console.error("Deprecated file format.");else{var c,e,i,k,j,o,p,m,q,n,s,r,u,t,z=a.faces;o=a.vertices;var A=a.normals,E=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];k=0;for(j=o.length;k<
-j;)p=new THREE.Vertex,p.position.x=o[k++]*b,p.position.y=o[k++]*b,p.position.z=o[k++]*b,d.vertices.push(p);k=0;for(j=z.length;k<j;){b=z[k++];o=b&1;i=b&2;c=b&4;e=b&8;m=b&16;p=b&32;n=b&64;b&=128;o?(s=new THREE.Face4,s.a=z[k++],s.b=z[k++],s.c=z[k++],s.d=z[k++],o=4):(s=new THREE.Face3,s.a=z[k++],s.b=z[k++],s.c=z[k++],o=3);if(i)i=z[k++],s.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<D;c++)r=a.uvs[c],q=z[k++],t=r[q*2],q=r[q*2+1],d.faceUvs[c][i]=new THREE.UV(t,q);if(e)for(c=0;c<D;c++){r=a.uvs[c];u=[];
-for(e=0;e<o;e++)q=z[k++],t=r[q*2],q=r[q*2+1],u[e]=new THREE.UV(t,q);d.faceVertexUvs[c][i]=u}if(m)m=z[k++]*3,e=new THREE.Vector3,e.x=A[m++],e.y=A[m++],e.z=A[m],s.normal=e;if(p)for(c=0;c<o;c++)m=z[k++]*3,e=new THREE.Vector3,e.x=A[m++],e.y=A[m++],e.z=A[m],s.vertexNormals.push(e);if(n)p=z[k++],p=new THREE.Color(E[p]),s.color=p;if(b)for(c=0;c<o;c++)p=z[k++],p=new THREE.Color(E[p]),s.vertexColors.push(p);d.faces.push(s)}}})(e);(function(){var b,c,e,i;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=
-2)e=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(e,i,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)e=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(e,i,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,e,i,k,j,o,p,m,q;c=0;for(e=a.morphTargets.length;c<e;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];m=d.morphTargets[c].vertices;
-q=a.morphTargets[c].vertices;i=0;for(k=q.length;i<k;i+=3)j=q[i]*b,o=q[i+1]*b,p=q[i+2]*b,m.push(new THREE.Vertex(new THREE.Vector3(j,o,p)))}}if(a.morphColors!==void 0){c=0;for(e=a.morphColors.length;c<e;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];k=d.morphColors[c].colors;j=a.morphColors[c].colors;b=0;for(i=j.length;b<i;b+=3)o=new THREE.Color(16755200),o.setRGB(j[b],j[b+1],j[b+2]),k.push(o)}}})(e);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
+THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){if(a.metadata===void 0||a.metadata.formatVersion===void 0||a.metadata.formatVersion!==3)console.error("Deprecated file format.");else{var c,e,i,j,k,o,p,m,q,n,s,r,u,t,A=a.faces;o=a.vertices;var B=a.normals,z=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];j=0;for(k=o.length;j<
+k;)p=new THREE.Vertex,p.position.x=o[j++]*b,p.position.y=o[j++]*b,p.position.z=o[j++]*b,d.vertices.push(p);j=0;for(k=A.length;j<k;){b=A[j++];o=b&1;i=b&2;c=b&4;e=b&8;m=b&16;p=b&32;n=b&64;b&=128;o?(s=new THREE.Face4,s.a=A[j++],s.b=A[j++],s.c=A[j++],s.d=A[j++],o=4):(s=new THREE.Face3,s.a=A[j++],s.b=A[j++],s.c=A[j++],o=3);if(i)i=A[j++],s.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<D;c++)r=a.uvs[c],q=A[j++],t=r[q*2],q=r[q*2+1],d.faceUvs[c][i]=new THREE.UV(t,q);if(e)for(c=0;c<D;c++){r=a.uvs[c];u=[];
+for(e=0;e<o;e++)q=A[j++],t=r[q*2],q=r[q*2+1],u[e]=new THREE.UV(t,q);d.faceVertexUvs[c][i]=u}if(m)m=A[j++]*3,e=new THREE.Vector3,e.x=B[m++],e.y=B[m++],e.z=B[m],s.normal=e;if(p)for(c=0;c<o;c++)m=A[j++]*3,e=new THREE.Vector3,e.x=B[m++],e.y=B[m++],e.z=B[m],s.vertexNormals.push(e);if(n)p=A[j++],p=new THREE.Color(z[p]),s.color=p;if(b)for(c=0;c<o;c++)p=A[j++],p=new THREE.Color(z[p]),s.vertexColors.push(p);d.faces.push(s)}}})(e);(function(){var b,c,e,i;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=
+2)e=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(e,i,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)e=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(e,i,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,e,i,j,k,o,p,m,q;c=0;for(e=a.morphTargets.length;c<e;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];m=d.morphTargets[c].vertices;
+q=a.morphTargets[c].vertices;i=0;for(j=q.length;i<j;i+=3)k=q[i]*b,o=q[i+1]*b,p=q[i+2]*b,m.push(new THREE.Vertex(new THREE.Vector3(k,o,p)))}}if(a.morphColors!==void 0){c=0;for(e=a.morphColors.length;c<e;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];j=d.morphColors[c].colors;k=a.morphColors[c].colors;b=0;for(i=k.length;b<i;b+=3)o=new THREE.Color(16755200),o.setRGB(k[b],k[b+1],k[b+2]),j.push(o)}}})(e);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
 d.computeTangents();b(d)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
 d.computeTangents();b(d)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
 THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState==4)if(d.status==200||d.status==0)try{var e=JSON.parse(d.responseText);e.metadata===void 0||e.metadata.formatVersion===void 0||e.metadata.formatVersion!==3?console.error("Deprecated file format."):c.createScene(e,b,a)}catch(f){console.error(f),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}else console.error("Couldn't load ["+a+"] ["+d.status+"]")};
 THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState==4)if(d.status==200||d.status==0)try{var e=JSON.parse(d.responseText);e.metadata===void 0||e.metadata.formatVersion===void 0||e.metadata.formatVersion!==3?console.error("Deprecated file format."):c.createScene(e,b,a)}catch(f){console.error(f),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}else console.error("Couldn't load ["+a+"] ["+d.status+"]")};
 d.open("GET",a,!0);d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
 d.open("GET",a,!0);d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
-THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function e(){var a;for(p in Q.objects)if(!v.objects[p])if(r=Q.objects[p],r.geometry!==void 0){if(G=v.geometries[r.geometry]){a=!1;for(X=0;X<r.materials.length;X++)$=v.materials[r.materials[X]],a=$ instanceof THREE.ShaderMaterial;a&&G.computeTangents();z=r.position;A=r.rotation;E=r.quaternion;D=r.scale;E=0;$.length==0&&($=new THREE.MeshFaceMaterial);$.length>1&&($=new THREE.MeshFaceMaterial);
-a=new THREE.Mesh(G,$);a.name=p;a.position.set(z[0],z[1],z[2]);E?(a.quaternion.set(E[0],E[1],E[2],E[3]),a.useQuaternion=!0):a.rotation.set(A[0],A[1],A[2]);a.scale.set(D[0],D[1],D[2]);a.visible=r.visible;v.scene.add(a);v.objects[p]=a;if(r.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);v.scene.collisions.colliders.push(b)}if(r.castsShadow)b=new THREE.ShadowVolume(G),v.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;r.trigger&&r.trigger.toLowerCase()!="none"&&(b=
-{type:r.trigger,object:r},v.triggers[a.name]=b)}}else z=r.position,A=r.rotation,E=r.quaternion,D=r.scale,E=0,a=new THREE.Object3D,a.name=p,a.position.set(z[0],z[1],z[2]),E?(a.quaternion.set(E[0],E[1],E[2],E[3]),a.useQuaternion=!0):a.rotation.set(A[0],A[1],A[2]),a.scale.set(D[0],D[1],D[2]),a.visible=r.visible!==void 0?r.visible:!1,v.scene.add(a),v.objects[p]=a,v.empties[p]=a,r.trigger&&r.trigger.toLowerCase()!="none"&&(b={type:r.trigger,object:r},v.triggers[a.name]=b)}function f(a){return function(b){v.geometries[a]=
-b;e();S-=1;i.onLoadComplete();h()}}function g(a){return function(b){v.geometries[a]=b}}function h(){i.callbackProgress({totalModels:l,totalTextures:W,loadedModels:l-S,loadedTextures:W-R},v);i.onLoadProgress();S==0&&R==0&&b(v)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,o,p,m,q,n,s,r,u,t,z,A,E,D,B,w,G,y,K,$,Q,Y,S,R,l,W,v;Q=a;c=new THREE.BinaryLoader;Y=new THREE.JSONLoader;R=S=0;v={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
-empties:{}};a=!1;for(p in Q.objects)if(r=Q.objects[p],r.meshCollider){a=!0;break}if(a)v.scene.collisions=new THREE.CollisionSystem;if(Q.transform)a=Q.transform.position,u=Q.transform.rotation,B=Q.transform.scale,a&&v.scene.position.set(a[0],a[1],a[2]),u&&v.scene.rotation.set(u[0],u[1],u[2]),B&&v.scene.scale.set(B[0],B[1],B[2]),(a||u||B)&&v.scene.updateMatrix();a=function(){R-=1;h();i.onLoadComplete()};for(q in Q.cameras)B=Q.cameras[q],B.type=="perspective"?y=new THREE.PerspectiveCamera(B.fov,B.aspect,
-B.near,B.far):B.type=="ortho"&&(y=new THREE.OrthographicCamera(B.left,B.right,B.top,B.bottom,B.near,B.far)),z=B.position,u=B.target,B=B.up,y.position.set(z[0],z[1],z[2]),y.target=new THREE.Vector3(u[0],u[1],u[2]),B&&y.up.set(B[0],B[1],B[2]),v.cameras[q]=y;for(m in Q.lights)u=Q.lights[m],q=u.color!==void 0?u.color:16777215,y=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(z=u.direction,t=new THREE.DirectionalLight(q,y),t.position.set(z[0],z[1],z[2]),t.position.normalize()):u.type=="point"?
-(z=u.position,t=u.distance,t=new THREE.PointLight(q,y,t),t.position.set(z[0],z[1],z[2])):u.type=="ambient"&&(t=new THREE.AmbientLight(q)),v.scene.add(t),v.lights[m]=t;for(n in Q.fogs)m=Q.fogs[n],m.type=="linear"?K=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(K=new THREE.FogExp2(0,m.density)),B=m.color,K.color.setRGB(B[0],B[1],B[2]),v.fogs[n]=K;if(v.cameras&&Q.defaults.camera)v.currentCamera=v.cameras[Q.defaults.camera];if(v.fogs&&Q.defaults.fog)v.scene.fog=v.fogs[Q.defaults.fog];B=Q.defaults.bgcolor;
-v.bgColor=new THREE.Color;v.bgColor.setRGB(B[0],B[1],B[2]);v.bgColorAlpha=Q.defaults.bgalpha;for(j in Q.geometries)if(n=Q.geometries[j],n.type=="bin_mesh"||n.type=="ascii_mesh")S+=1,i.onLoadStart();l=S;for(j in Q.geometries)n=Q.geometries[j],n.type=="cube"?(G=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),v.geometries[j]=G):n.type=="plane"?(G=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),v.geometries[j]=
-G):n.type=="sphere"?(G=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),v.geometries[j]=G):n.type=="cylinder"?(G=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),v.geometries[j]=G):n.type=="torus"?(G=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),v.geometries[j]=G):n.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(n.subdivisions),v.geometries[j]=G):n.type=="bin_mesh"?c.load(d(n.url,Q.urlBaseType),f(j)):n.type=="ascii_mesh"?Y.load(d(n.url,
-Q.urlBaseType),f(j)):n.type=="embedded_mesh"&&(n=Q.embeds[n.id])&&Y.createModel(n,g(j),"");for(s in Q.textures)if(j=Q.textures[s],j.url instanceof Array){R+=j.url.length;for(n=0;n<j.url.length;n++)i.onLoadStart()}else R+=1,i.onLoadStart();W=R;for(s in Q.textures){j=Q.textures[s];if(j.mapping!=void 0&&THREE[j.mapping]!=void 0)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){n=[];for(var X=0;X<j.url.length;X++)n[X]=d(j.url[X],Q.urlBaseType);n=THREE.ImageUtils.loadTextureCube(n,j.mapping,a)}else{n=
-THREE.ImageUtils.loadTexture(d(j.url,Q.urlBaseType),j.mapping,a);if(THREE[j.minFilter]!=void 0)n.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=void 0)n.magFilter=THREE[j.magFilter];if(j.repeat){n.repeat.set(j.repeat[0],j.repeat[1]);if(j.repeat[0]!=1)n.wrapS=THREE.RepeatWrapping;if(j.repeat[1]!=1)n.wrapT=THREE.RepeatWrapping}j.offset&&n.offset.set(j.offset[0],j.offset[1]);if(j.wrap){K={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(K[j.wrap[0]]!==void 0)n.wrapS=K[j.wrap[0]];
-if(K[j.wrap[1]]!==void 0)n.wrapT=K[j.wrap[1]]}}v.textures[s]=n}for(o in Q.materials){s=Q.materials[o];for(w in s.parameters)if(w=="envMap"||w=="map"||w=="lightMap")s.parameters[w]=v.textures[s.parameters[w]];else if(w=="shading")s.parameters[w]=s.parameters[w]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(w=="blending")s.parameters[w]=THREE[s.parameters[w]]?THREE[s.parameters[w]]:THREE.NormalBlending;else if(w=="combine")s.parameters[w]=s.parameters[w]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-else if(w=="vertexColors")if(s.parameters[w]=="face")s.parameters[w]=THREE.FaceColors;else if(s.parameters[w])s.parameters[w]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=!0;if(s.parameters.normalMap){j=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(j.uniforms);n=s.parameters.color;K=s.parameters.specular;c=s.parameters.ambient;Y=s.parameters.shininess;a.tNormal.texture=v.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=
-s.parameters.normalMapFactor;if(s.parameters.map)a.tDiffuse.texture=s.parameters.map,a.enableDiffuse.value=!0;if(s.parameters.lightMap)a.tAO.texture=s.parameters.lightMap,a.enableAO.value=!0;if(s.parameters.specularMap)a.tSpecular.texture=v.textures[s.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(n);a.uSpecularColor.value.setHex(K);a.uAmbientColor.value.setHex(c);a.uShininess.value=Y;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;s=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,
-vertexShader:j.vertexShader,uniforms:a,lights:!0,fog:!0})}else s=new THREE[s.type](s.parameters);v.materials[o]=s}e();i.callbackSync(v);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:j+"/"+a}function e(){var a;for(p in Q.objects)if(!v.objects[p])if(r=Q.objects[p],r.geometry!==void 0){if(F=v.geometries[r.geometry]){a=!1;for(W=0;W<r.materials.length;W++)$=v.materials[r.materials[W]],a=$ instanceof THREE.ShaderMaterial;a&&F.computeTangents();A=r.position;B=r.rotation;z=r.quaternion;D=r.scale;z=0;$.length==0&&($=new THREE.MeshFaceMaterial);$.length>1&&($=new THREE.MeshFaceMaterial);
+a=new THREE.Mesh(F,$);a.name=p;a.position.set(A[0],A[1],A[2]);z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]);a.scale.set(D[0],D[1],D[2]);a.visible=r.visible;v.scene.add(a);v.objects[p]=a;if(r.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);v.scene.collisions.colliders.push(b)}if(r.castsShadow)b=new THREE.ShadowVolume(F),v.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;r.trigger&&r.trigger.toLowerCase()!="none"&&(b=
+{type:r.trigger,object:r},v.triggers[a.name]=b)}}else A=r.position,B=r.rotation,z=r.quaternion,D=r.scale,z=0,a=new THREE.Object3D,a.name=p,a.position.set(A[0],A[1],A[2]),z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]),a.scale.set(D[0],D[1],D[2]),a.visible=r.visible!==void 0?r.visible:!1,v.scene.add(a),v.objects[p]=a,v.empties[p]=a,r.trigger&&r.trigger.toLowerCase()!="none"&&(b={type:r.trigger,object:r},v.triggers[a.name]=b)}function f(a){return function(b){v.geometries[a]=
+b;e();T-=1;i.onLoadComplete();h()}}function g(a){return function(b){v.geometries[a]=b}}function h(){i.callbackProgress({totalModels:l,totalTextures:S,loadedModels:l-T,loadedTextures:S-R},v);i.onLoadProgress();T==0&&R==0&&b(v)}var i=this,j=THREE.Loader.prototype.extractUrlbase(c),k,o,p,m,q,n,s,r,u,t,A,B,z,D,H,w,F,y,K,$,Q,X,T,R,l,S,v;Q=a;c=new THREE.BinaryLoader;X=new THREE.JSONLoader;R=T=0;v={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(p in Q.objects)if(r=Q.objects[p],r.meshCollider){a=!0;break}if(a)v.scene.collisions=new THREE.CollisionSystem;if(Q.transform)a=Q.transform.position,u=Q.transform.rotation,H=Q.transform.scale,a&&v.scene.position.set(a[0],a[1],a[2]),u&&v.scene.rotation.set(u[0],u[1],u[2]),H&&v.scene.scale.set(H[0],H[1],H[2]),(a||u||H)&&v.scene.updateMatrix();a=function(){R-=1;h();i.onLoadComplete()};for(q in Q.cameras)H=Q.cameras[q],H.type=="perspective"?y=new THREE.PerspectiveCamera(H.fov,H.aspect,
+H.near,H.far):H.type=="ortho"&&(y=new THREE.OrthographicCamera(H.left,H.right,H.top,H.bottom,H.near,H.far)),A=H.position,u=H.target,H=H.up,y.position.set(A[0],A[1],A[2]),y.target=new THREE.Vector3(u[0],u[1],u[2]),H&&y.up.set(H[0],H[1],H[2]),v.cameras[q]=y;for(m in Q.lights)u=Q.lights[m],q=u.color!==void 0?u.color:16777215,y=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(A=u.direction,t=new THREE.DirectionalLight(q,y),t.position.set(A[0],A[1],A[2]),t.position.normalize()):u.type=="point"?
+(A=u.position,t=u.distance,t=new THREE.PointLight(q,y,t),t.position.set(A[0],A[1],A[2])):u.type=="ambient"&&(t=new THREE.AmbientLight(q)),v.scene.add(t),v.lights[m]=t;for(n in Q.fogs)m=Q.fogs[n],m.type=="linear"?K=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(K=new THREE.FogExp2(0,m.density)),H=m.color,K.color.setRGB(H[0],H[1],H[2]),v.fogs[n]=K;if(v.cameras&&Q.defaults.camera)v.currentCamera=v.cameras[Q.defaults.camera];if(v.fogs&&Q.defaults.fog)v.scene.fog=v.fogs[Q.defaults.fog];H=Q.defaults.bgcolor;
+v.bgColor=new THREE.Color;v.bgColor.setRGB(H[0],H[1],H[2]);v.bgColorAlpha=Q.defaults.bgalpha;for(k in Q.geometries)if(n=Q.geometries[k],n.type=="bin_mesh"||n.type=="ascii_mesh")T+=1,i.onLoadStart();l=T;for(k in Q.geometries)n=Q.geometries[k],n.type=="cube"?(F=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),v.geometries[k]=F):n.type=="plane"?(F=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),v.geometries[k]=
+F):n.type=="sphere"?(F=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),v.geometries[k]=F):n.type=="cylinder"?(F=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),v.geometries[k]=F):n.type=="torus"?(F=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),v.geometries[k]=F):n.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(n.subdivisions),v.geometries[k]=F):n.type=="bin_mesh"?c.load(d(n.url,Q.urlBaseType),f(k)):n.type=="ascii_mesh"?X.load(d(n.url,
+Q.urlBaseType),f(k)):n.type=="embedded_mesh"&&(n=Q.embeds[n.id])&&X.createModel(n,g(k),"");for(s in Q.textures)if(k=Q.textures[s],k.url instanceof Array){R+=k.url.length;for(n=0;n<k.url.length;n++)i.onLoadStart()}else R+=1,i.onLoadStart();S=R;for(s in Q.textures){k=Q.textures[s];if(k.mapping!=void 0&&THREE[k.mapping]!=void 0)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){n=[];for(var W=0;W<k.url.length;W++)n[W]=d(k.url[W],Q.urlBaseType);n=THREE.ImageUtils.loadTextureCube(n,k.mapping,a)}else{n=
+THREE.ImageUtils.loadTexture(d(k.url,Q.urlBaseType),k.mapping,a);if(THREE[k.minFilter]!=void 0)n.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=void 0)n.magFilter=THREE[k.magFilter];if(k.repeat){n.repeat.set(k.repeat[0],k.repeat[1]);if(k.repeat[0]!=1)n.wrapS=THREE.RepeatWrapping;if(k.repeat[1]!=1)n.wrapT=THREE.RepeatWrapping}k.offset&&n.offset.set(k.offset[0],k.offset[1]);if(k.wrap){K={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(K[k.wrap[0]]!==void 0)n.wrapS=K[k.wrap[0]];
+if(K[k.wrap[1]]!==void 0)n.wrapT=K[k.wrap[1]]}}v.textures[s]=n}for(o in Q.materials){s=Q.materials[o];for(w in s.parameters)if(w=="envMap"||w=="map"||w=="lightMap")s.parameters[w]=v.textures[s.parameters[w]];else if(w=="shading")s.parameters[w]=s.parameters[w]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(w=="blending")s.parameters[w]=THREE[s.parameters[w]]?THREE[s.parameters[w]]:THREE.NormalBlending;else if(w=="combine")s.parameters[w]=s.parameters[w]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+else if(w=="vertexColors")if(s.parameters[w]=="face")s.parameters[w]=THREE.FaceColors;else if(s.parameters[w])s.parameters[w]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=!0;if(s.parameters.normalMap){k=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(k.uniforms);n=s.parameters.color;K=s.parameters.specular;c=s.parameters.ambient;X=s.parameters.shininess;a.tNormal.texture=v.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=
+s.parameters.normalMapFactor;if(s.parameters.map)a.tDiffuse.texture=s.parameters.map,a.enableDiffuse.value=!0;if(s.parameters.lightMap)a.tAO.texture=s.parameters.lightMap,a.enableAO.value=!0;if(s.parameters.specularMap)a.tSpecular.texture=v.textures[s.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(n);a.uSpecularColor.value.setHex(K);a.uAmbientColor.value.setHex(c);a.uShininess.value=X;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;s=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,
+vertexShader:k.vertexShader,uniforms:a,lights:!0,fog:!0})}else s=new THREE[s.type](s.parameters);v.materials[o]=s}e();i.callbackSync(v);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),c=a,a=c.model,b=c.callback,c={scale:c.scale,offsetX:c.offsetX,offsetY:c.offsetY,offsetZ:c.offsetZ};var d=new XMLHttpRequest,e=c.scale!==void 0?c.scale:1,f=c.offsetX!==void 0?c.offsetX:0,g=c.offsetY!==void 0?c.offsetY:0,h=c.offsetZ!==void 0?c.offsetZ:0;d.onreadystatechange=function(){d.readyState==4?d.status==200||d.status==0?THREE.UTF8Loader.prototype.createModel(d.responseText,
 THREE.UTF8Loader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),c=a,a=c.model,b=c.callback,c={scale:c.scale,offsetX:c.offsetX,offsetY:c.offsetY,offsetZ:c.offsetZ};var d=new XMLHttpRequest,e=c.scale!==void 0?c.scale:1,f=c.offsetX!==void 0?c.offsetX:0,g=c.offsetY!==void 0?c.offsetY:0,h=c.offsetZ!==void 0?c.offsetZ:0;d.onreadystatechange=function(){d.readyState==4?d.status==200||d.status==0?THREE.UTF8Loader.prototype.createModel(d.responseText,
 b,e,f,g,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):d.readyState!=3&&d.readyState==2&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);b>=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var f=0,g=0;g<b;++g){var h=a.charCodeAt(g+d);f+=h>>1^-(h&1);c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=0;e<b;e++)h=a.charCodeAt(e+d),f[e]=g-h,h==0&&g++;return[c,f]};
 b,e,f,g,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):d.readyState!=3&&d.readyState==2&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);b>=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var f=0,g=0;g<b;++g){var h=a.charCodeAt(g+d);f+=h>>1^-(h&1);c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=0;e<b;e++)h=a.charCodeAt(e+d),f[e]=g-h,h==0&&g++;return[c,f]};
-THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,f){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],j=[];(function(a,g,i){for(var j,k,s,r=a.length;i<r;i+=g)j=a[i],k=a[i+1],s=a[i+2],j=j/16383*c,k=k/16383*c,s=s/16383*c,j+=d,k+=e,s+=f,b.vertices.push(new THREE.Vertex(new THREE.Vector3(j,k,s)))})(g[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,j.push(d,1-e)})(g[0],8,3);(function(a,
-b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,k.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,u,t,z,A=a.length;for(c=0;c<A;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;t=d;z=e;i=f;u=d;var E=e,D=f,B=k[E*3],w=k[E*3+1],E=k[E*3+2],G=k[D*3],y=k[D*3+1],D=k[D*3+2];u=new THREE.Vector3(k[u*3],k[u*3+1],k[u*3+2]);E=new THREE.Vector3(B,w,E);D=new THREE.Vector3(G,y,D);g.faces.push(new THREE.Face3(t,z,i,[u,E,D],null,0));g=j[d*2];d=j[d*2+1];i=j[e*2];u=j[e*
-2+1];t=j[f*2];z=j[f*2+1];f=b.faceVertexUvs[0];e=i;i=u;u=[];u.push(new THREE.UV(g,d));u.push(new THREE.UV(e,i));u.push(new THREE.UV(t,z));f.push(u)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};
+THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,f){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),j=[],k=[];(function(a,g,i){for(var j,k,s,r=a.length;i<r;i+=g)j=a[i],k=a[i+1],s=a[i+2],j=j/16383*c,k=k/16383*c,s=s/16383*c,j+=d,k+=e,s+=f,b.vertices.push(new THREE.Vertex(new THREE.Vector3(j,k,s)))})(g[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,k.push(d,1-e)})(g[0],8,3);(function(a,
+b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,j.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,u,t,A,B=a.length;for(c=0;c<B;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;t=d;A=e;i=f;u=d;var z=e,D=f,H=j[z*3],w=j[z*3+1],z=j[z*3+2],F=j[D*3],y=j[D*3+1],D=j[D*3+2];u=new THREE.Vector3(j[u*3],j[u*3+1],j[u*3+2]);z=new THREE.Vector3(H,w,z);D=new THREE.Vector3(F,y,D);g.faces.push(new THREE.Face3(t,A,i,[u,z,D],null,0));g=k[d*2];d=k[d*2+1];i=k[e*2];u=k[e*
+2+1];t=k[f*2];A=k[f*2+1];f=b.faceVertexUvs[0];e=i;i=u;u=[];u.push(new THREE.UV(g,d));u.push(new THREE.UV(e,i));u.push(new THREE.UV(t,A));f.push(u)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};
 THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var b=new THREE.CylinderGeometry(0,5,25,5,1),c=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(c);
 THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var b=new THREE.CylinderGeometry(0,5,25,5,1),c=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(c);
 c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
 c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=0;this.hasNormal=
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=0;this.hasNormal=
-this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,f,g,h,i,k,j,o){g=(g-j)/(o-j);j=this.normal_cache;b[f]=h+g*this.delta;b[f+1]=i;b[f+2]=k;e[f]=this.lerp(j[a],j[a+3],g);e[f+1]=this.lerp(j[a+1],j[a+4],g);e[f+2]=this.lerp(j[a+2],j[a+5],g)};this.VIntY=function(a,b,e,f,g,h,i,k,j,o){g=(g-j)/(o-j);j=this.normal_cache;b[f]=h;b[f+1]=i+g*this.delta;b[f+2]=k;b=a+this.yd*
-3;e[f]=this.lerp(j[a],j[b],g);e[f+1]=this.lerp(j[a+1],j[b+1],g);e[f+2]=this.lerp(j[a+2],j[b+2],g)};this.VIntZ=function(a,b,e,f,g,h,i,k,j,o){g=(g-j)/(o-j);j=this.normal_cache;b[f]=h;b[f+1]=i;b[f+2]=k+g*this.delta;b=a+this.zd*3;e[f]=this.lerp(j[a],j[b],g);e[f+1]=this.lerp(j[a+1],j[b+1],g);e[f+2]=this.lerp(j[a+2],j[b+2],g)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]===0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
-this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,f,g,h){var i=f+1,k=f+this.yd,j=f+this.zd,o=i+this.yd,p=i+this.zd,m=f+this.yd+this.zd,q=i+this.yd+this.zd,n=0,s=this.field[f],r=this.field[i],u=this.field[k],t=this.field[o],z=this.field[j],A=this.field[p],E=this.field[m],D=this.field[q];s<g&&(n|=1);r<g&&(n|=2);u<g&&(n|=8);t<g&&(n|=4);z<g&&(n|=16);A<g&&(n|=32);E<g&&(n|=128);D<g&&(n|=64);var B=THREE.edgeTable[n];if(B===0)return 0;var w=this.delta,G=a+
-w,y=b+w,w=e+w;B&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(f*3,this.vlist,this.nlist,0,g,a,b,e,s,r));B&2&&(this.compNorm(i),this.compNorm(o),this.VIntY(i*3,this.vlist,this.nlist,3,g,G,b,e,r,t));B&4&&(this.compNorm(k),this.compNorm(o),this.VIntX(k*3,this.vlist,this.nlist,6,g,a,y,e,u,t));B&8&&(this.compNorm(f),this.compNorm(k),this.VIntY(f*3,this.vlist,this.nlist,9,g,a,b,e,s,u));B&16&&(this.compNorm(j),this.compNorm(p),this.VIntX(j*3,this.vlist,this.nlist,12,g,a,b,w,z,A));B&32&&(this.compNorm(p),
-this.compNorm(q),this.VIntY(p*3,this.vlist,this.nlist,15,g,G,b,w,A,D));B&64&&(this.compNorm(m),this.compNorm(q),this.VIntX(m*3,this.vlist,this.nlist,18,g,a,y,w,E,D));B&128&&(this.compNorm(j),this.compNorm(m),this.VIntY(j*3,this.vlist,this.nlist,21,g,a,b,w,z,E));B&256&&(this.compNorm(f),this.compNorm(j),this.VIntZ(f*3,this.vlist,this.nlist,24,g,a,b,e,s,z));B&512&&(this.compNorm(i),this.compNorm(p),this.VIntZ(i*3,this.vlist,this.nlist,27,g,G,b,e,r,A));B&1024&&(this.compNorm(o),this.compNorm(q),this.VIntZ(o*
-3,this.vlist,this.nlist,30,g,G,y,e,t,D));B&2048&&(this.compNorm(k),this.compNorm(m),this.VIntZ(k*3,this.vlist,this.nlist,33,g,a,y,e,u,E));n<<=4;for(g=f=0;THREE.triTable[n+g]!=-1;)a=n+g,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],h),g+=3,f++;return f};this.posnormtriv=function(a,b,e,f,g,h){var i=this.count*3;this.positionArray[i]=a[e];this.positionArray[i+1]=a[e+1];this.positionArray[i+2]=a[e+2];this.positionArray[i+3]=a[f];this.positionArray[i+
+this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,f,g,h,i,j,k,o){g=(g-k)/(o-k);k=this.normal_cache;b[f]=h+g*this.delta;b[f+1]=i;b[f+2]=j;e[f]=this.lerp(k[a],k[a+3],g);e[f+1]=this.lerp(k[a+1],k[a+4],g);e[f+2]=this.lerp(k[a+2],k[a+5],g)};this.VIntY=function(a,b,e,f,g,h,i,j,k,o){g=(g-k)/(o-k);k=this.normal_cache;b[f]=h;b[f+1]=i+g*this.delta;b[f+2]=j;b=a+this.yd*
+3;e[f]=this.lerp(k[a],k[b],g);e[f+1]=this.lerp(k[a+1],k[b+1],g);e[f+2]=this.lerp(k[a+2],k[b+2],g)};this.VIntZ=function(a,b,e,f,g,h,i,j,k,o){g=(g-k)/(o-k);k=this.normal_cache;b[f]=h;b[f+1]=i;b[f+2]=j+g*this.delta;b=a+this.zd*3;e[f]=this.lerp(k[a],k[b],g);e[f+1]=this.lerp(k[a+1],k[b+1],g);e[f+2]=this.lerp(k[a+2],k[b+2],g)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]===0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,f,g,h){var i=f+1,j=f+this.yd,k=f+this.zd,o=i+this.yd,p=i+this.zd,m=f+this.yd+this.zd,q=i+this.yd+this.zd,n=0,s=this.field[f],r=this.field[i],u=this.field[j],t=this.field[o],A=this.field[k],B=this.field[p],z=this.field[m],D=this.field[q];s<g&&(n|=1);r<g&&(n|=2);u<g&&(n|=8);t<g&&(n|=4);A<g&&(n|=16);B<g&&(n|=32);z<g&&(n|=128);D<g&&(n|=64);var H=THREE.edgeTable[n];if(H===0)return 0;var w=this.delta,F=a+
+w,y=b+w,w=e+w;H&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(f*3,this.vlist,this.nlist,0,g,a,b,e,s,r));H&2&&(this.compNorm(i),this.compNorm(o),this.VIntY(i*3,this.vlist,this.nlist,3,g,F,b,e,r,t));H&4&&(this.compNorm(j),this.compNorm(o),this.VIntX(j*3,this.vlist,this.nlist,6,g,a,y,e,u,t));H&8&&(this.compNorm(f),this.compNorm(j),this.VIntY(f*3,this.vlist,this.nlist,9,g,a,b,e,s,u));H&16&&(this.compNorm(k),this.compNorm(p),this.VIntX(k*3,this.vlist,this.nlist,12,g,a,b,w,A,B));H&32&&(this.compNorm(p),
+this.compNorm(q),this.VIntY(p*3,this.vlist,this.nlist,15,g,F,b,w,B,D));H&64&&(this.compNorm(m),this.compNorm(q),this.VIntX(m*3,this.vlist,this.nlist,18,g,a,y,w,z,D));H&128&&(this.compNorm(k),this.compNorm(m),this.VIntY(k*3,this.vlist,this.nlist,21,g,a,b,w,A,z));H&256&&(this.compNorm(f),this.compNorm(k),this.VIntZ(f*3,this.vlist,this.nlist,24,g,a,b,e,s,A));H&512&&(this.compNorm(i),this.compNorm(p),this.VIntZ(i*3,this.vlist,this.nlist,27,g,F,b,e,r,B));H&1024&&(this.compNorm(o),this.compNorm(q),this.VIntZ(o*
+3,this.vlist,this.nlist,30,g,F,y,e,t,D));H&2048&&(this.compNorm(j),this.compNorm(m),this.VIntZ(j*3,this.vlist,this.nlist,33,g,a,y,e,u,z));n<<=4;for(g=f=0;THREE.triTable[n+g]!=-1;)a=n+g,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],h),g+=3,f++;return f};this.posnormtriv=function(a,b,e,f,g,h){var i=this.count*3;this.positionArray[i]=a[e];this.positionArray[i+1]=a[e+1];this.positionArray[i+2]=a[e+2];this.positionArray[i+3]=a[f];this.positionArray[i+
 4]=a[f+1];this.positionArray[i+5]=a[f+2];this.positionArray[i+6]=a[g];this.positionArray[i+7]=a[g+1];this.positionArray[i+8]=a[g+2];this.normalArray[i]=b[e];this.normalArray[i+1]=b[e+1];this.normalArray[i+2]=b[e+2];this.normalArray[i+3]=b[f];this.normalArray[i+4]=b[f+1];this.normalArray[i+5]=b[f+2];this.normalArray[i+6]=b[g];this.normalArray[i+7]=b[g+1];this.normalArray[i+8]=b[g+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=function(){this.count=0;
 4]=a[f+1];this.positionArray[i+5]=a[f+2];this.positionArray[i+6]=a[g];this.positionArray[i+7]=a[g+1];this.positionArray[i+8]=a[g+2];this.normalArray[i]=b[e];this.normalArray[i+1]=b[e+1];this.normalArray[i+2]=b[e+2];this.normalArray[i+3]=b[f];this.normalArray[i+4]=b[f+1];this.normalArray[i+5]=b[f+2];this.normalArray[i+6]=b[g];this.normalArray[i+7]=b[g+1];this.normalArray[i+8]=b[g+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=function(){this.count=0;
-this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,f,g){var h=this.size*Math.sqrt(f/g),i=e*this.size,k=b*this.size,j=a*this.size,o=Math.floor(i-h);o<1&&(o=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(j-h);m<1&&(m=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size-
-1);for(var q,n,s,r,u,t;o<i;o++){j=this.size2*o;n=o/this.size-e;u=n*n;for(n=p;n<k;n++){s=j+this.size*n;q=n/this.size-b;t=q*q;for(q=m;q<h;q++)r=q/this.size-a,r=f/(1.0E-6+r*r+t+u)-g,r>0&&(this.field[s+q]+=r)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,k=this.size,j=this.yd,o=this.zd,p=this.field,m=k*Math.sqrt(a/b);m>k&&(m=k);for(e=0;e<m;e++)if(f=e/k,f*=f,h=a/(1.0E-4+f)-b,h>0)for(f=0;f<k;f++){i=e+f*j;for(g=0;g<k;g++)p[o*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,k,j=this.size,o=this.yd,p=
-this.zd,m=this.field,q=j*Math.sqrt(a/b);q>j&&(q=j);for(f=0;f<q;f++)if(e=f/j,e*=e,h=a/(1.0E-4+e)-b,h>0){i=f*o;for(e=0;e<j;e++){k=i+e;for(g=0;g<j;g++)m[p*g+k]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,k,j=this.size,o=this.yd,p=this.zd,m=this.field,q=j*Math.sqrt(a/b);q>j&&(q=j);for(g=0;g<q;g++)if(e=g/j,e*=e,h=a/(1.0E-4+e)-b,h>0){i=p*g;for(f=0;f<j;f++){k=i+f*o;for(e=0;e<j;e++)m[k+e]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,this.field[a]=0};this.render=
-function(a){this.begin();var b,e,f,g,h,i,k,j,o,p=this.size-2;for(g=1;g<p;g++){o=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){j=o+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<p;e++)h=(e-this.halfsize)/this.halfsize,b=j+e,this.polygonize(h,i,k,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(f){var g,h,i,k,j,o,p,m;for(g=0;g<f.count;g++)p=g*3,j=p+1,m=p+2,h=f.positionArray[p],i=f.positionArray[j],k=
-f.positionArray[m],o=new THREE.Vector3(h,i,k),h=f.normalArray[p],i=f.normalArray[j],k=f.normalArray[m],p=new THREE.Vector3(h,i,k),p.normalize(),j=new THREE.Vertex(o),b.vertices.push(j),e.push(p);o=f.count/3;for(g=0;g<o;g++)p=(a+g)*3,j=p+1,m=p+2,h=e[p],i=e[j],k=e[m],p=new THREE.Face3(p,j,m,[h,i,k]),b.faces.push(p);a+=o;f.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,f,g){var h=this.size*Math.sqrt(f/g),i=e*this.size,j=b*this.size,k=a*this.size,o=Math.floor(i-h);o<1&&(o=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var p=Math.floor(j-h);p<1&&(p=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size-
+1);for(var q,n,s,r,u,t;o<i;o++){k=this.size2*o;n=o/this.size-e;u=n*n;for(n=p;n<j;n++){s=k+this.size*n;q=n/this.size-b;t=q*q;for(q=m;q<h;q++)r=q/this.size-a,r=f/(1.0E-6+r*r+t+u)-g,r>0&&(this.field[s+q]+=r)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,j=this.size,k=this.yd,o=this.zd,p=this.field,m=j*Math.sqrt(a/b);m>j&&(m=j);for(e=0;e<m;e++)if(f=e/j,f*=f,h=a/(1.0E-4+f)-b,h>0)for(f=0;f<j;f++){i=e+f*k;for(g=0;g<j;g++)p[o*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,j,k=this.size,o=this.yd,p=
+this.zd,m=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(f=0;f<q;f++)if(e=f/k,e*=e,h=a/(1.0E-4+e)-b,h>0){i=f*o;for(e=0;e<k;e++){j=i+e;for(g=0;g<k;g++)m[p*g+j]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,j,k=this.size,o=this.yd,p=this.zd,m=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(g=0;g<q;g++)if(e=g/k,e*=e,h=a/(1.0E-4+e)-b,h>0){i=p*g;for(f=0;f<k;f++){j=i+f*o;for(e=0;e<k;e++)m[j+e]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,this.field[a]=0};this.render=
+function(a){this.begin();var b,e,f,g,h,i,j,k,o,p=this.size-2;for(g=1;g<p;g++){o=this.size2*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){k=o+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<p;e++)h=(e-this.halfsize)/this.halfsize,b=k+e,this.polygonize(h,i,j,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(f){var g,h,i,j,k,o,p,m;for(g=0;g<f.count;g++)p=g*3,k=p+1,m=p+2,h=f.positionArray[p],i=f.positionArray[k],j=
+f.positionArray[m],o=new THREE.Vector3(h,i,j),h=f.normalArray[p],i=f.normalArray[k],j=f.normalArray[m],p=new THREE.Vector3(h,i,j),p.normalize(),k=new THREE.Vertex(o),b.vertices.push(k),e.push(p);o=f.count/3;for(g=0;g<o;g++)p=(a+g)*3,k=p+1,m=p+2,h=e[p],i=e[k],j=e[m],p=new THREE.Face3(p,k,m,[h,i,j]),b.faces.push(p);a+=o;f.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -720,29 +725,29 @@ d.vertices[e++]=1;d.vertices[e++]=-1;d.vertices[e++]=1;d.vertices[e++]=0;d.verti
 d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);d.tempTexture=b.createTexture();d.occlusionTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);
 d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);d.tempTexture=b.createTexture();d.occlusionTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);
 b.bindTexture(b.TEXTURE_2D,d.occlusionTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(d.hasVertexTexture=!1,d.program=a(THREE.ShaderFlares.lensFlare)):(d.hasVertexTexture=
 b.bindTexture(b.TEXTURE_2D,d.occlusionTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(d.hasVertexTexture=!1,d.program=a(THREE.ShaderFlares.lensFlare)):(d.hasVertexTexture=
 !0,d.program=a(THREE.ShaderFlares.lensFlareVertexTexture));d.attributes={};d.uniforms={};d.attributes.vertex=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.renderType=b.getUniformLocation(d.program,"renderType");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.occlusionMap=b.getUniformLocation(d.program,"occlusionMap");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.color=b.getUniformLocation(d.program,
 !0,d.program=a(THREE.ShaderFlares.lensFlareVertexTexture));d.attributes={};d.uniforms={};d.attributes.vertex=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.renderType=b.getUniformLocation(d.program,"renderType");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.occlusionMap=b.getUniformLocation(d.program,"occlusionMap");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.color=b.getUniformLocation(d.program,
-"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,f,g,h){var a=a.__webglFlares,i=a.length;if(i){var k=new THREE.Vector3,j=h/g,o=g*0.5,p=h*0.5,m=16/h,q=new THREE.Vector2(m*j,m),n=new THREE.Vector3(1,1,0),s=new THREE.Vector2(1,1),r=d.uniforms,m=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex),
-b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(r.occlusionMap,0);b.uniform1i(r.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(m.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(m.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var u,t,z,A,E;for(u=0;u<i;u++)if(m=16/h,q.set(m*j,m),A=a[u],k.set(A.matrixWorld.n14,A.matrixWorld.n24,A.matrixWorld.n34),f.matrixWorldInverse.multiplyVector3(k),
-f.projectionMatrix.multiplyVector3(k),n.copy(k),s.x=n.x*o+o,s.y=n.y*p+p,d.hasVertexTexture||s.x>0&&s.x<g&&s.y>0&&s.y<h){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,s.x-8,s.y-8,16,16,0);b.uniform1i(r.renderType,0);b.uniform2f(r.scale,q.x,q.y);b.uniform3f(r.screenPosition,n.x,n.y,n.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,d.occlusionTexture);
-b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,s.x-8,s.y-8,16,16,0);b.uniform1i(r.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);A.positionScreen.copy(n);A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares();b.uniform1i(r.renderType,2);b.enable(b.BLEND);t=0;for(z=A.lensFlares.length;t<z;t++)if(E=A.lensFlares[t],E.opacity>0.0010&&E.scale>0.0010)n.x=E.x,n.y=E.y,n.z=E.z,m=E.size*E.scale/
-h,q.x=m*j,q.y=m,b.uniform3f(r.screenPosition,n.x,n.y,n.z),b.uniform2f(r.scale,q.x,q.y),b.uniform1f(r.rotation,E.rotation),b.uniform1f(r.opacity,E.opacity),b.uniform3f(r.color,E.color.r,E.color.g,E.color.b),c.setBlending(E.blending),c.setTexture(E.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,f,g,h){var a=a.__webglFlares,i=a.length;if(i){var j=new THREE.Vector3,k=h/g,o=g*0.5,p=h*0.5,m=16/h,q=new THREE.Vector2(m*k,m),n=new THREE.Vector3(1,1,0),s=new THREE.Vector2(1,1),r=d.uniforms,m=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex),
+b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(r.occlusionMap,0);b.uniform1i(r.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(m.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(m.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var u,t,A,B,z;for(u=0;u<i;u++)if(m=16/h,q.set(m*k,m),B=a[u],j.set(B.matrixWorld.n14,B.matrixWorld.n24,B.matrixWorld.n34),f.matrixWorldInverse.multiplyVector3(j),
+f.projectionMatrix.multiplyVector3(j),n.copy(j),s.x=n.x*o+o,s.y=n.y*p+p,d.hasVertexTexture||s.x>0&&s.x<g&&s.y>0&&s.y<h){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,s.x-8,s.y-8,16,16,0);b.uniform1i(r.renderType,0);b.uniform2f(r.scale,q.x,q.y);b.uniform3f(r.screenPosition,n.x,n.y,n.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,d.occlusionTexture);
+b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,s.x-8,s.y-8,16,16,0);b.uniform1i(r.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,d.tempTexture);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);B.positionScreen.copy(n);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();b.uniform1i(r.renderType,2);b.enable(b.BLEND);t=0;for(A=B.lensFlares.length;t<A;t++)if(z=B.lensFlares[t],z.opacity>0.0010&&z.scale>0.0010)n.x=z.x,n.y=z.y,n.z=z.z,m=z.size*z.scale/
+h,q.x=m*k,q.y=m,b.uniform3f(r.screenPosition,n.x,n.y,n.z),b.uniform2f(r.scale,q.x,q.y),b.uniform1f(r.rotation,z.rotation),b.uniform1f(r.opacity,z.opacity),b.uniform3f(r.color,z.color.r,z.color.g,z.color.b),c.setBlending(z.blending),c.setTexture(z.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f=new THREE.Frustum,g=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f=new THREE.Frustum,g=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=
-function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,k,j,o,p,m,q,n,s=0,r=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(k=r.length;i<k;i++)if(q=r[i],q.castShadow&&q instanceof THREE.SpotLight){this.shadowMap[s]||(this.shadowMap[s]=new THREE.WebGLRenderTarget(b.shadowMapWidth,b.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
-format:THREE.RGBAFormat}),this.shadowMatrix[s]=new THREE.Matrix4);j=this.shadowMap[s];o=this.shadowMatrix[s];e.position.copy(q.position);e.lookAt(q.target.position);e.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),h.add(e),b.autoUpdateScene&&h.updateMatrixWorld());e.matrixWorldInverse.getInverse(e.matrixWorld);o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(e.projectionMatrix);o.multiplySelf(e.matrixWorldInverse);if(!e._viewMatrixArray)e._viewMatrixArray=
-new Float32Array(16);e.matrixWorldInverse.flattenToArray(e._viewMatrixArray);if(!e._projectionMatrixArray)e._projectionMatrixArray=new Float32Array(16);e.projectionMatrix.flattenToArray(e._projectionMatrixArray);g.multiply(e.projectionMatrix,e.matrixWorldInverse);f.setFromMatrix(g);b.setRenderTarget(j);a.clearColor(1,0,1,1);b.clear();j=b.getClearColor();o=b.getClearAlpha();a.clearColor(j.r,j.g,j.b,o);n=h.__webglObjects;j=0;for(o=n.length;j<o;j++)if(p=n[j],q=p.object,p.render=!1,q.visible&&q.castShadow&&
-(!(q instanceof THREE.Mesh)||!q.frustumCulled||f.contains(q)))q.matrixWorld.flattenToArray(q._objectMatrixArray),q._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),p.render=!0;b.setDepthTest(!0);b.setBlending(THREE.NormalBlending);j=0;for(o=n.length;j<o;j++)if(p=n[j],p.render)q=p.object,p=p.buffer,b.setObjectFaces(q),m=q.customDepthMaterial?q.customDepthMaterial:q.geometry.morphTargets.length?d:c,b.renderBuffer(e,r,null,m,p,q);n=h.__webglObjectsImmediate;
-j=0;for(o=n.length;j<o;j++)p=n[j],q=p.object,q.visible&&q.castShadow&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),q._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),b.renderImmediateObject(e,r,null,c,q));s++}}};
+function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,j,k,o,p,m,q,n,s=0,r=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(j=r.length;i<j;i++)if(q=r[i],q.castShadow&&q instanceof THREE.SpotLight){this.shadowMap[s]||(this.shadowMap[s]=new THREE.WebGLRenderTarget(b.shadowMapWidth,b.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+format:THREE.RGBAFormat}),this.shadowMatrix[s]=new THREE.Matrix4);k=this.shadowMap[s];o=this.shadowMatrix[s];e.position.copy(q.position);e.lookAt(q.target.position);e.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),h.add(e),b.autoUpdateScene&&h.updateMatrixWorld());e.matrixWorldInverse.getInverse(e.matrixWorld);o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(e.projectionMatrix);o.multiplySelf(e.matrixWorldInverse);if(!e._viewMatrixArray)e._viewMatrixArray=
+new Float32Array(16);e.matrixWorldInverse.flattenToArray(e._viewMatrixArray);if(!e._projectionMatrixArray)e._projectionMatrixArray=new Float32Array(16);e.projectionMatrix.flattenToArray(e._projectionMatrixArray);g.multiply(e.projectionMatrix,e.matrixWorldInverse);f.setFromMatrix(g);b.setRenderTarget(k);a.clearColor(1,0,1,1);b.clear();k=b.getClearColor();o=b.getClearAlpha();a.clearColor(k.r,k.g,k.b,o);n=h.__webglObjects;k=0;for(o=n.length;k<o;k++)if(p=n[k],q=p.object,p.render=!1,q.visible&&q.castShadow&&
+(!(q instanceof THREE.Mesh)||!q.frustumCulled||f.contains(q)))q.matrixWorld.flattenToArray(q._objectMatrixArray),q._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),p.render=!0;b.setDepthTest(!0);b.setBlending(THREE.NormalBlending);k=0;for(o=n.length;k<o;k++)if(p=n[k],p.render)q=p.object,p=p.buffer,b.setObjectFaces(q),m=q.customDepthMaterial?q.customDepthMaterial:q.geometry.morphTargets.length?d:c,b.renderBuffer(e,r,null,m,p,q);n=h.__webglObjectsImmediate;
+k=0;for(o=n.length;k<o;k++)p=n[k],q=p.object,q.visible&&q.castShadow&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),q._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),b.renderImmediateObject(e,r,null,c,q));s++}}};
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d={};this.init=function(a){b=a.context;c=a;d.vertices=new Float32Array(16);d.faces=new Uint16Array(6);a=0;d.vertices[a++]=-1;d.vertices[a++]=-1;d.vertices[a++]=0;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=0;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=0;a=d.vertices[a++]=0;d.faces[a++]=0;d.faces[a++]=1;d.faces[a++]=
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d={};this.init=function(a){b=a.context;c=a;d.vertices=new Float32Array(16);d.faces=new Uint16Array(6);a=0;d.vertices[a++]=-1;d.vertices[a++]=-1;d.vertices[a++]=0;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=0;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=0;a=d.vertices[a++]=0;d.faces[a++]=0;d.faces[a++]=1;d.faces[a++]=
 2;d.faces[a++]=0;d.faces[a++]=2;d.faces[a++]=3;d.vertexBuffer=b.createBuffer();d.elementBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.vertices,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,f=b.createProgram(),g=b.createShader(b.FRAGMENT_SHADER),h=b.createShader(b.VERTEX_SHADER);b.shaderSource(g,a.fragmentShader);b.shaderSource(h,a.vertexShader);
 2;d.faces[a++]=0;d.faces[a++]=2;d.faces[a++]=3;d.vertexBuffer=b.createBuffer();d.elementBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.vertices,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,f=b.createProgram(),g=b.createShader(b.FRAGMENT_SHADER),h=b.createShader(b.VERTEX_SHADER);b.shaderSource(g,a.fragmentShader);b.shaderSource(h,a.vertexShader);
 b.compileShader(g);b.compileShader(h);b.attachShader(f,g);b.attachShader(f,h);b.linkProgram(f);d.program=f;d.attributes={};d.uniforms={};d.attributes.position=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.uvOffset=b.getUniformLocation(d.program,"uvOffset");d.uniforms.uvScale=b.getUniformLocation(d.program,"uvScale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.alignment=
 b.compileShader(g);b.compileShader(h);b.attachShader(f,g);b.attachShader(f,h);b.linkProgram(f);d.program=f;d.attributes={};d.uniforms={};d.attributes.position=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.uvOffset=b.getUniformLocation(d.program,"uvOffset");d.uniforms.uvScale=b.getUniformLocation(d.program,"uvScale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.alignment=
 b.getUniformLocation(d.program,"alignment");d.uniforms.color=b.getUniformLocation(d.program,"color");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.useScreenCoordinates=b.getUniformLocation(d.program,"useScreenCoordinates");d.uniforms.affectedByDistance=b.getUniformLocation(d.program,"affectedByDistance");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.uniforms.modelViewMatrix=b.getUniformLocation(d.program,
 b.getUniformLocation(d.program,"alignment");d.uniforms.color=b.getUniformLocation(d.program,"color");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.useScreenCoordinates=b.getUniformLocation(d.program,"useScreenCoordinates");d.uniforms.affectedByDistance=b.getUniformLocation(d.program,"affectedByDistance");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.uniforms.modelViewMatrix=b.getUniformLocation(d.program,
-"modelViewMatrix");d.uniforms.projectionMatrix=b.getUniformLocation(d.program,"projectionMatrix");d.attributesEnabled=!1};this.render=function(e,f,g,h){var e=e.__webglSprites,i=e.length;if(i){var k=d.attributes,j=d.uniforms,o=h/g;g*=0.5;var p=h*0.5,m=!0;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(k.position),b.enableVertexAttribArray(k.uv),d.attributesEnabled=!0;b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(k.position,
-2,b.FLOAT,!1,16,0);b.vertexAttribPointer(k.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.uniformMatrix4fv(j.projectionMatrix,!1,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(j.map,0);for(var q,n=[],k=0;k<i;k++)if(q=e[k],q.visible&&q.opacity!==0)q.useScreenCoordinates?q.z=-q.position.z:(q._modelViewMatrix.multiplyToArray(f.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),q.z=-q._modelViewMatrix.n34);e.sort(a);for(k=0;k<i;k++)q=e[k],q.visible&&
-q.opacity!==0&&q.map&&q.map.image&&q.map.image.width&&(q.useScreenCoordinates?(b.uniform1i(j.useScreenCoordinates,1),b.uniform3f(j.screenPosition,(q.position.x-g)/g,(p-q.position.y)/p,Math.max(0,Math.min(1,q.position.z)))):(b.uniform1i(j.useScreenCoordinates,0),b.uniform1i(j.affectedByDistance,q.affectedByDistance?1:0),b.uniformMatrix4fv(j.modelViewMatrix,!1,q._modelViewMatrixArray)),f=q.map.image.width/(q.scaleByViewport?h:1),n[0]=f*o*q.scale.x,n[1]=f*q.scale.y,b.uniform2f(j.uvScale,q.uvScale.x,
-q.uvScale.y),b.uniform2f(j.uvOffset,q.uvOffset.x,q.uvOffset.y),b.uniform2f(j.alignment,q.alignment.x,q.alignment.y),b.uniform1f(j.opacity,q.opacity),b.uniform3f(j.color,q.color.r,q.color.g,q.color.b),b.uniform1f(j.rotation,q.rotation),b.uniform2fv(j.scale,n),q.mergeWith3D&&!m?(b.enable(b.DEPTH_TEST),m=!0):!q.mergeWith3D&&m&&(b.disable(b.DEPTH_TEST),m=!1),c.setBlending(q.blending),c.setTexture(q.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
-if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,g=new THREE.Matrix4,h=new THREE.Matrix4,i,k,j,o;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),m=new THREE.WebGLRenderTarget(512,512,a),q=new THREE.PerspectiveCamera(53,
+"modelViewMatrix");d.uniforms.projectionMatrix=b.getUniformLocation(d.program,"projectionMatrix");d.attributesEnabled=!1};this.render=function(e,f,g,h){var e=e.__webglSprites,i=e.length;if(i){var j=d.attributes,k=d.uniforms,o=h/g;g*=0.5;var p=h*0.5,m=!0;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(j.position),b.enableVertexAttribArray(j.uv),d.attributesEnabled=!0;b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(j.position,
+2,b.FLOAT,!1,16,0);b.vertexAttribPointer(j.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.uniformMatrix4fv(k.projectionMatrix,!1,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(k.map,0);for(var q,n=[],j=0;j<i;j++)if(q=e[j],q.visible&&q.opacity!==0)q.useScreenCoordinates?q.z=-q.position.z:(q._modelViewMatrix.multiplyToArray(f.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),q.z=-q._modelViewMatrix.n34);e.sort(a);for(j=0;j<i;j++)q=e[j],q.visible&&
+q.opacity!==0&&q.map&&q.map.image&&q.map.image.width&&(q.useScreenCoordinates?(b.uniform1i(k.useScreenCoordinates,1),b.uniform3f(k.screenPosition,(q.position.x-g)/g,(p-q.position.y)/p,Math.max(0,Math.min(1,q.position.z)))):(b.uniform1i(k.useScreenCoordinates,0),b.uniform1i(k.affectedByDistance,q.affectedByDistance?1:0),b.uniformMatrix4fv(k.modelViewMatrix,!1,q._modelViewMatrixArray)),f=q.map.image.width/(q.scaleByViewport?h:1),n[0]=f*o*q.scale.x,n[1]=f*q.scale.y,b.uniform2f(k.uvScale,q.uvScale.x,
+q.uvScale.y),b.uniform2f(k.uvOffset,q.uvOffset.x,q.uvOffset.y),b.uniform2f(k.alignment,q.alignment.x,q.alignment.y),b.uniform1f(k.opacity,q.opacity),b.uniform3f(k.color,q.color.r,q.color.g,q.color.b),b.uniform1f(k.rotation,q.rotation),b.uniform2fv(k.scale,n),q.mergeWith3D&&!m?(b.enable(b.DEPTH_TEST),m=!0):!q.mergeWith3D&&m&&(b.disable(b.DEPTH_TEST),m=!1),c.setBlending(q.blending),c.setTexture(q.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,g=new THREE.Matrix4,h=new THREE.Matrix4,i,j,k,o;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),m=new THREE.WebGLRenderTarget(512,512,a),q=new THREE.PerspectiveCamera(53,
 1,1,1E4);q.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},mapRight:{type:"t",value:1,texture:m}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}),
 1,1,1E4);q.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},mapRight:{type:"t",value:1,texture:m}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}),
-n=new THREE.Scene;n.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));n.add(q);this.setSize=function(a,d){c.call(b,a,d);p.width=a;p.height=d;m.width=a;m.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||k!==c.near||j!==c.far||o!==c.fov){i=c.aspect;k=c.near;j=c.far;o=c.fov;var u=c.projectionMatrix.clone(),t=125/30*0.5,z=t*k/125,A=k*Math.tan(o*Math.PI/360),E;g.n14=t;h.n14=-t;t=-A*i+z;E=A*i+z;u.n11=2*k/(E-t);u.n13=(E+t)/(E-t);e.projectionMatrix.copy(u);t=-A*i-z;E=A*i-z;u.n11=
-2*k/(E-t);u.n13=(E+t)/(E-t);f.projectionMatrix.copy(u)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,p,!0);f.matrixWorld.copy(c.matrixWorld).multiplySelf(g);f.position.copy(c.position);f.near=c.near;f.far=c.far;d.call(b,a,f,m,!0);n.updateMatrixWorld();d.call(b,n,q)}};
+n=new THREE.Scene;n.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));n.add(q);this.setSize=function(a,d){c.call(b,a,d);p.width=a;p.height=d;m.width=a;m.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||j!==c.near||k!==c.far||o!==c.fov){i=c.aspect;j=c.near;k=c.far;o=c.fov;var u=c.projectionMatrix.clone(),t=125/30*0.5,A=t*j/125,B=j*Math.tan(o*Math.PI/360),z;g.n14=t;h.n14=-t;t=-B*i+A;z=B*i+A;u.n11=2*j/(z-t);u.n13=(z+t)/(z-t);e.projectionMatrix.copy(u);t=-B*i-A;z=B*i-A;u.n11=
+2*j/(z-t);u.n13=(z+t)/(z-t);f.projectionMatrix.copy(u)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,p,!0);f.matrixWorld.copy(c.matrixWorld).multiplySelf(g);f.position.copy(c.position);f.near=c.near;f.far=c.far;d.call(b,a,f,m,!0);n.updateMatrixWorld();d.call(b,n,q)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,d=this.render,e,f,g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;this.setSize=function(a,d){c.call(b,a,d);e=a/2;f=d};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,d=this.render,e,f,g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;this.setSize=function(a,d){c.call(b,a,d);e=a/2;f=d};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=
 c.far;g.updateProjectionMatrix();g.position.copy(c.position);g.target.copy(c.target);g.translateX(b.separation);g.lookAt(g.target);h.projectionMatrix=g.projectionMatrix;h.position.copy(c.position);h.target.copy(c.target);h.translateX(-b.separation);h.lookAt(h.target);this.setViewport(0,0,e,f);d.call(b,a,g);this.setViewport(e,0,e,f);d.call(b,a,h,!1)}};
 c.far;g.updateProjectionMatrix();g.position.copy(c.position);g.target.copy(c.target);g.translateX(b.separation);g.lookAt(g.target);h.projectionMatrix=g.projectionMatrix;h.position.copy(c.position);h.target.copy(c.target);h.translateX(-b.separation);h.lookAt(h.target);this.setViewport(0,0,e,f);d.call(b,a,g);this.setViewport(e,0,e,f);d.call(b,a,h,!1)}};
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},

+ 1 - 1
build/custom/ThreeCanvas.js

@@ -89,7 +89,7 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;
 b,c,d,e,f,D){j=a.vertices[b].position;n=a.vertices[c].position;k=a.vertices[d].position;l=g[e];h=g[f];m=g[D];o=n.x-j.x;p=k.x-j.x;i=n.y-j.y;q=k.y-j.y;F=n.z-j.z;x=k.z-j.z;I=h.u-l.u;G=m.u-l.u;r=h.v-l.v;C=m.v-l.v;y=1/(I*C-G*r);E.set((C*o-r*p)*y,(C*i-r*q)*y,(C*F-r*x)*y);O.set((I*p-G*o)*y,(I*q-G*i)*y,(I*x-G*F)*y);t[b].addSelf(E);t[c].addSelf(E);t[d].addSelf(E);A[b].addSelf(O);A[c].addSelf(O);A[d].addSelf(O)}var b,c,d,e,f,g,j,n,k,l,h,m,o,p,i,q,F,x,I,G,r,C,y,D,t=[],A=[],E=new THREE.Vector3,O=new THREE.Vector3,
 b,c,d,e,f,D){j=a.vertices[b].position;n=a.vertices[c].position;k=a.vertices[d].position;l=g[e];h=g[f];m=g[D];o=n.x-j.x;p=k.x-j.x;i=n.y-j.y;q=k.y-j.y;F=n.z-j.z;x=k.z-j.z;I=h.u-l.u;G=m.u-l.u;r=h.v-l.v;C=m.v-l.v;y=1/(I*C-G*r);E.set((C*o-r*p)*y,(C*i-r*q)*y,(C*F-r*x)*y);O.set((I*p-G*o)*y,(I*q-G*i)*y,(I*x-G*F)*y);t[b].addSelf(E);t[c].addSelf(E);t[d].addSelf(E);A[b].addSelf(O);A[c].addSelf(O);A[d].addSelf(O)}var b,c,d,e,f,g,j,n,k,l,h,m,o,p,i,q,F,x,I,G,r,C,y,D,t=[],A=[],E=new THREE.Vector3,O=new THREE.Vector3,
 $=new THREE.Vector3,U=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)t[b]=new THREE.Vector3,A[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var K=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)J.copy(f.vertexNormals[d]),e=f[K[d]],
 $=new THREE.Vector3,U=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)t[b]=new THREE.Vector3,A[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var K=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)J.copy(f.vertexNormals[d]),e=f[K[d]],
 D=t[e],$.copy(D),$.subSelf(J.multiplyScalar(J.dot(D))).normalize(),U.cross(f.vertexNormals[d],D),e=U.dot(A[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
 D=t[e],$.copy(D),$.subSelf(J.multiplyScalar(J.dot(D))).normalize(),U.cross(f.vertexNormals[d],D),e=U.dot(A[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
-this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
+this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
 THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;

+ 1 - 0
build/custom/ThreeExtras.js

@@ -29,6 +29,7 @@ THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"v
 THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
 THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
 THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
 THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
+THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
 THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
 THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
 THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,d=this.getPoint(0),e,g=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),g+=c.distanceTo(d),b.push(g),d=c;return this.cacheArcLengths=b};
 THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,d=this.getPoint(0),e,g=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),g+=c.distanceTo(d),b.push(g),d=c;return this.cacheArcLengths=b};
 THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,g;g=b?b:a*c[e-1];for(var f=0,h=e-1,i;f<=h;)if(d=Math.floor(f+(h-f)/2),i=c[d]-g,i<0)f=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(c[d]==g)return d/(e-1);f=c[d];return c=(d+(g-f)/(c[d+1]-f))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
 THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,g;g=b?b:a*c[e-1];for(var f=0,h=e-1,i;f<=h;)if(d=Math.floor(f+(h-f)/2),i=c[d]-g,i<0)f=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(c[d]==g)return d/(e-1);f=c[d];return c=(d+(g-f)/(c[d+1]-f))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};

+ 1 - 1
build/custom/ThreeSVG.js

@@ -89,7 +89,7 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;
 b,c,d,e,f,A){h=a.vertices[b].position;l=a.vertices[c].position;i=a.vertices[d].position;k=g[e];j=g[f];n=g[A];m=l.x-h.x;o=i.x-h.x;p=l.y-h.y;u=i.y-h.y;F=l.z-h.z;v=i.z-h.z;D=j.u-k.u;s=n.u-k.u;t=j.v-k.v;B=n.v-k.v;x=1/(D*B-s*t);I.set((B*m-t*o)*x,(B*p-t*u)*x,(B*F-t*v)*x);z.set((D*o-s*m)*x,(D*u-s*p)*x,(D*v-s*F)*x);H[b].addSelf(I);H[c].addSelf(I);H[d].addSelf(I);C[b].addSelf(z);C[c].addSelf(z);C[d].addSelf(z)}var b,c,d,e,f,g,h,l,i,k,j,n,m,o,p,u,F,v,D,s,t,B,x,y,H=[],C=[],I=new THREE.Vector3,z=new THREE.Vector3,
 b,c,d,e,f,A){h=a.vertices[b].position;l=a.vertices[c].position;i=a.vertices[d].position;k=g[e];j=g[f];n=g[A];m=l.x-h.x;o=i.x-h.x;p=l.y-h.y;u=i.y-h.y;F=l.z-h.z;v=i.z-h.z;D=j.u-k.u;s=n.u-k.u;t=j.v-k.v;B=n.v-k.v;x=1/(D*B-s*t);I.set((B*m-t*o)*x,(B*p-t*u)*x,(B*F-t*v)*x);z.set((D*o-s*m)*x,(D*u-s*p)*x,(D*v-s*F)*x);H[b].addSelf(I);H[c].addSelf(I);H[d].addSelf(I);C[b].addSelf(z);C[c].addSelf(z);C[d].addSelf(z)}var b,c,d,e,f,g,h,l,i,k,j,n,m,o,p,u,F,v,D,s,t,B,x,y,H=[],C=[],I=new THREE.Vector3,z=new THREE.Vector3,
 L=new THREE.Vector3,J=new THREE.Vector3,M=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)H[b]=new THREE.Vector3,C[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var N=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)M.copy(f.vertexNormals[d]),e=f[N[d]],
 L=new THREE.Vector3,J=new THREE.Vector3,M=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)H[b]=new THREE.Vector3,C[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var N=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)M.copy(f.vertexNormals[d]),e=f[N[d]],
 y=H[e],L.copy(y),L.subSelf(M.multiplyScalar(M.dot(y))).normalize(),J.cross(f.vertexNormals[d],y),e=J.dot(C[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
 y=H[e],L.copy(y),L.subSelf(M.multiplyScalar(M.dot(y))).normalize(),J.cross(f.vertexNormals[d],y),e=J.dot(C[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
-this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
+this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
 THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;

+ 113 - 107
build/custom/ThreeWebGL.js

@@ -18,8 +18,8 @@ b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};
 THREE.Ray=function(a,b){function d(a,b,d){p.sub(d,a);n=p.dot(b);if(n<=0)return null;E=s.add(a,w.copy(b).multiplyScalar(n));return y=d.distanceTo(E)}function c(a,b,d,c){p.sub(c,b);s.sub(d,b);w.sub(a,b);J=p.dot(p);P=p.dot(s);Q=p.dot(w);V=s.dot(s);C=s.dot(w);D=1/(J*V-P*P);N=(V*Q-P*C)*D;O=(J*C-P*Q)*D;return N>=0&&O>=0&&N+O<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 THREE.Ray=function(a,b){function d(a,b,d){p.sub(d,a);n=p.dot(b);if(n<=0)return null;E=s.add(a,w.copy(b).multiplyScalar(n));return y=d.distanceTo(E)}function c(a,b,d,c){p.sub(c,b);s.sub(d,b);w.sub(a,b);J=p.dot(p);P=p.dot(s);Q=p.dot(w);V=s.dot(s);C=s.dot(w);D=1/(J*V-P*P);N=(V*Q-P*C)*D;O=(J*C-P*Q)*D;return N>=0&&O>=0&&N+O<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
 d,c=[];b=0;for(d=a.length;b<d;b++)Array.prototype.push.apply(c,this.intersectObject(a[b]));c.sort(function(a,b){return a.distance-b.distance});return c};var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3;this.intersectObject=function(n){for(var w,p=[],s=0,E=n.children.length;s<E;s++)Array.prototype.push.apply(p,this.intersectObject(n.children[s]));if(n instanceof THREE.Particle){s=
 d,c=[];b=0;for(d=a.length;b<d;b++)Array.prototype.push.apply(c,this.intersectObject(a[b]));c.sort(function(a,b){return a.distance-b.distance});return c};var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,a=new THREE.Vector3,b=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3;this.intersectObject=function(n){for(var w,p=[],s=0,E=n.children.length;s<E;s++)Array.prototype.push.apply(p,this.intersectObject(n.children[s]));if(n instanceof THREE.Particle){s=
-d(this.origin,this.direction,n.matrixWorld.getPosition());if(s===null||s>n.scale.x)return[];w={distance:s,point:n.position,face:null,object:n};p.push(w)}else if(n instanceof THREE.Mesh){s=d(this.origin,this.direction,n.matrixWorld.getPosition());if(s===null||s>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return p;var y,C=n.geometry,J=C.vertices,I;n.matrixRotationWorld.extractRotation(n.matrixWorld);s=0;for(E=C.faces.length;s<E;s++)if(w=C.faces[s],a.copy(this.origin),
-b.copy(this.direction),I=n.matrixWorld,l=I.multiplyVector3(l.copy(w.centroid)).subSelf(a),y=l.dot(b),!(y<=0)&&(f=I.multiplyVector3(f.copy(J[w.a].position)),g=I.multiplyVector3(g.copy(J[w.b].position)),h=I.multiplyVector3(h.copy(J[w.c].position)),w instanceof THREE.Face4&&(i=I.multiplyVector3(i.copy(J[w.d].position))),k=n.matrixRotationWorld.multiplyVector3(k.copy(w.normal)),y=b.dot(k),n.doubleSided||(n.flipSided?y>0:y<0)))if(y=k.dot(l.sub(f,a))/y,j.add(a,b.multiplyScalar(y)),w instanceof THREE.Face3)c(j,
+d(this.origin,this.direction,n.matrixWorld.getPosition());if(s===null||s>n.scale.x)return[];w={distance:s,point:n.position,face:null,object:n};p.push(w)}else if(n instanceof THREE.Mesh){s=d(this.origin,this.direction,n.matrixWorld.getPosition());if(s===null||s>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return p;var y,C=n.geometry,J=C.vertices,H;n.matrixRotationWorld.extractRotation(n.matrixWorld);s=0;for(E=C.faces.length;s<E;s++)if(w=C.faces[s],a.copy(this.origin),
+b.copy(this.direction),H=n.matrixWorld,l=H.multiplyVector3(l.copy(w.centroid)).subSelf(a),y=l.dot(b),!(y<=0)&&(f=H.multiplyVector3(f.copy(J[w.a].position)),g=H.multiplyVector3(g.copy(J[w.b].position)),h=H.multiplyVector3(h.copy(J[w.c].position)),w instanceof THREE.Face4&&(i=H.multiplyVector3(i.copy(J[w.d].position))),k=n.matrixRotationWorld.multiplyVector3(k.copy(w.normal)),y=b.dot(k),n.doubleSided||(n.flipSided?y>0:y<0)))if(y=k.dot(l.sub(f,a))/y,j.add(a,b.multiplyScalar(y)),w instanceof THREE.Face3)c(j,
 f,g,h)&&(w={distance:a.distanceTo(j),point:j.clone(),face:w,object:n},p.push(w));else if(w instanceof THREE.Face4&&(c(j,f,g,i)||c(j,g,h,i)))w={distance:a.distanceTo(j),point:j.clone(),face:w,object:n},p.push(w)}return p};var p=new THREE.Vector3,s=new THREE.Vector3,w=new THREE.Vector3,n,E,y,J,P,Q,V,C,D,N,O};
 f,g,h)&&(w={distance:a.distanceTo(j),point:j.clone(),face:w,object:n},p.push(w));else if(w instanceof THREE.Face4&&(c(j,f,g,i)||c(j,g,h,i)))w={distance:a.distanceTo(j),point:j.clone(),face:w,object:n},p.push(w)}return p};var p=new THREE.Vector3,s=new THREE.Vector3,w=new THREE.Vector3,n,E,y,J,P,Q,V,C,D,N,O};
 THREE.Rectangle=function(){function a(){g=c-b;h=f-d}var b,d,c,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return c};this.getBottom=function(){return f};this.set=function(g,h,j,p){i=!1;b=g;d=h;c=j;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,d=h,c=g,f=h):(b=b<g?b:g,d=d<h?d:h,c=c>g?c:g,f=f>h?f:h);a()};this.add3Points=
 THREE.Rectangle=function(){function a(){g=c-b;h=f-d}var b,d,c,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return c};this.getBottom=function(){return f};this.set=function(g,h,j,p){i=!1;b=g;d=h;c=j;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,d=h,c=g,f=h):(b=b<g?b:g,d=d<h?d:h,c=c>g?c:g,f=f>h?f:h);a()};this.add3Points=
 function(g,h,j,p,s,w){i?(i=!1,b=g<j?g<s?g:s:j<s?j:s,d=h<p?h<w?h:w:p<w?p:w,c=g>j?g>s?g:s:j>s?j:s,f=h>p?h>w?h:w:p>w?p:w):(b=g<j?g<s?g<b?g:b:s<b?s:b:j<s?j<b?j:b:s<b?s:b,d=h<p?h<w?h<d?h:d:w<d?w:d:p<w?p<d?p:d:w<d?w:d,c=g>j?g>s?g>c?g:c:s>c?s:c:j>s?j>c?j:c:s>c?s:c,f=h>p?h>w?h>f?h:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),d=g.getTop(),c=g.getRight(),f=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),d=d<g.getTop()?d:g.getTop(),c=c>g.getRight()?c:g.getRight(),f=f>
 function(g,h,j,p,s,w){i?(i=!1,b=g<j?g<s?g:s:j<s?j:s,d=h<p?h<w?h:w:p<w?p:w,c=g>j?g>s?g:s:j>s?j:s,f=h>p?h>w?h:w:p>w?p:w):(b=g<j?g<s?g<b?g:b:s<b?s:b:j<s?j<b?j:b:s<b?s:b,d=h<p?h<w?h<d?h:d:w<d?w:d:p<w?p<d?p:d:w<d?w:d,c=g>j?g>s?g>c?g:c:s>c?s:c:j>s?j>c?j:c:s>c?s:c,f=h>p?h>w?h>f?h:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),d=g.getTop(),c=g.getRight(),f=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),d=d<g.getTop()?d:g.getTop(),c=c>g.getRight()?c:g.getRight(),f=f>
@@ -29,8 +29,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.set(a!==void 0?a:1,b||0,d||0,c||0,f||0,g!==void 0?g:1,h||0,i||0,l||0,k||0,j!==void 0?j:1,p||0,s||0,w||0,n||0,E!==void 0?E:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4=function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.set(a!==void 0?a:1,b||0,d||0,c||0,f||0,g!==void 0?g:1,h||0,i||0,l||0,k||0,j!==void 0?j:1,p||0,s||0,w||0,n||0,E!==void 0?E:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.n11=a;this.n12=b;this.n13=d;this.n14=c;this.n21=f;this.n22=g;this.n23=h;this.n24=i;this.n31=l;this.n32=k;this.n33=j;this.n34=p;this.n41=s;this.n42=w;this.n43=n;this.n44=E;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,
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,d,c,f,g,h,i,l,k,j,p,s,w,n,E){this.n11=a;this.n12=b;this.n13=d;this.n14=c;this.n21=f;this.n22=g;this.n23=h;this.n24=i;this.n31=l;this.n32=k;this.n33=j;this.n34=p;this.n41=s;this.n42=w;this.n43=n;this.n44=E;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,d){var c=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;c.cross(d,g).normalize();c.length()===0&&(g.x+=1.0E-4,c.cross(d,g).normalize());f.cross(g,c).normalize();this.n11=c.x;this.n12=f.x;this.n13=g.x;this.n21=c.y;this.n22=f.y;this.n23=g.y;this.n31=c.z;this.n32=f.z;this.n33=g.z;return this},multiply:function(a,b){var d=a.n11,c=a.n12,f=a.n13,g=a.n14,h=a.n21,i=a.n22,l=a.n23,k=a.n24,j=a.n31,p=a.n32,s=a.n33,w=a.n34,n=a.n41,E=a.n42,y=a.n43,
 b,d){var c=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;c.cross(d,g).normalize();c.length()===0&&(g.x+=1.0E-4,c.cross(d,g).normalize());f.cross(g,c).normalize();this.n11=c.x;this.n12=f.x;this.n13=g.x;this.n21=c.y;this.n22=f.y;this.n23=g.y;this.n31=c.z;this.n32=f.z;this.n33=g.z;return this},multiply:function(a,b){var d=a.n11,c=a.n12,f=a.n13,g=a.n14,h=a.n21,i=a.n22,l=a.n23,k=a.n24,j=a.n31,p=a.n32,s=a.n33,w=a.n34,n=a.n41,E=a.n42,y=a.n43,
-J=a.n44,P=b.n11,Q=b.n12,V=b.n13,C=b.n14,D=b.n21,N=b.n22,O=b.n23,ma=b.n24,ua=b.n31,ha=b.n32,ca=b.n33,pa=b.n34,ja=b.n41,xa=b.n42,va=b.n43,I=b.n44;this.n11=d*P+c*D+f*ua+g*ja;this.n12=d*Q+c*N+f*ha+g*xa;this.n13=d*V+c*O+f*ca+g*va;this.n14=d*C+c*ma+f*pa+g*I;this.n21=h*P+i*D+l*ua+k*ja;this.n22=h*Q+i*N+l*ha+k*xa;this.n23=h*V+i*O+l*ca+k*va;this.n24=h*C+i*ma+l*pa+k*I;this.n31=j*P+p*D+s*ua+w*ja;this.n32=j*Q+p*N+s*ha+w*xa;this.n33=j*V+p*O+s*ca+w*va;this.n34=j*C+p*ma+s*pa+w*I;this.n41=n*P+E*D+y*ua+J*ja;this.n42=
-n*Q+E*N+y*ha+J*xa;this.n43=n*V+E*O+y*ca+J*va;this.n44=n*C+E*ma+y*pa+J*I;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,d){this.multiply(a,b);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=
+J=a.n44,P=b.n11,Q=b.n12,V=b.n13,C=b.n14,D=b.n21,N=b.n22,O=b.n23,ma=b.n24,ua=b.n31,ha=b.n32,ca=b.n33,pa=b.n34,ja=b.n41,xa=b.n42,va=b.n43,H=b.n44;this.n11=d*P+c*D+f*ua+g*ja;this.n12=d*Q+c*N+f*ha+g*xa;this.n13=d*V+c*O+f*ca+g*va;this.n14=d*C+c*ma+f*pa+g*H;this.n21=h*P+i*D+l*ua+k*ja;this.n22=h*Q+i*N+l*ha+k*xa;this.n23=h*V+i*O+l*ca+k*va;this.n24=h*C+i*ma+l*pa+k*H;this.n31=j*P+p*D+s*ua+w*ja;this.n32=j*Q+p*N+s*ha+w*xa;this.n33=j*V+p*O+s*ca+w*va;this.n34=j*C+p*ma+s*pa+w*H;this.n41=n*P+E*D+y*ua+J*ja;this.n42=
+n*Q+E*N+y*ha+J*xa;this.n43=n*V+E*O+y*ca+J*va;this.n44=n*C+E*ma+y*pa+J*H;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,d){this.multiply(a,b);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},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},multiplyVector3:function(a){var b=a.x,d=a.y,c=a.z,f=1/(this.n41*b+this.n42*d+this.n43*c+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*c+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*c+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*c+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,c=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*
 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},multiplyVector3:function(a){var b=a.x,d=a.y,c=a.z,f=1/(this.n41*b+this.n42*d+this.n43*c+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*c+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*c+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*c+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,c=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*
 c+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*c+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*c+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*c+this.n44*f;return a},rotateAxis:function(a){var b=a.x,d=a.y,c=a.z;a.x=b*this.n11+d*this.n12+c*this.n13;a.y=b*this.n21+d*this.n22+c*this.n23;a.z=b*this.n31+d*this.n32+c*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*
 c+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*c+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*c+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*c+this.n44*f;return a},rotateAxis:function(a){var b=a.x,d=a.y,c=a.z;a.x=b*this.n11+d*this.n12+c*this.n13;a.y=b*this.n21+d*this.n22+c*this.n23;a.z=b*this.n31+d*this.n32+c*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},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,c=this.n14,f=this.n21,g=this.n22,h=this.n23,i=this.n24,l=this.n31,k=this.n32,j=this.n33,p=this.n34,s=this.n41,w=this.n42,n=this.n43,E=this.n44;return c*h*k*s-d*i*k*s-c*g*j*s+b*i*j*s+d*g*p*s-b*h*p*s-c*h*l*w+d*i*l*w+c*f*j*w-a*i*j*w-d*f*p*w+a*h*p*w+c*g*l*n-b*i*l*n-c*f*k*n+a*i*k*n+b*f*p*n-a*g*p*n-d*g*l*E+b*h*l*E+
 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},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,c=this.n14,f=this.n21,g=this.n22,h=this.n23,i=this.n24,l=this.n31,k=this.n32,j=this.n33,p=this.n34,s=this.n41,w=this.n42,n=this.n43,E=this.n44;return c*h*k*s-d*i*k*s-c*g*j*s+b*i*j*s+d*g*p*s-b*h*p*s-c*h*l*w+d*i*l*w+c*f*j*w-a*i*j*w-d*f*p*w+a*h*p*w+c*g*l*n-b*i*l*n-c*f*k*n+a*i*k*n+b*f*p*n-a*g*p*n-d*g*l*E+b*h*l*E+
@@ -63,13 +63,13 @@ this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWor
 THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=k[l]=k[l]||new THREE.RenderableVertex;l++;return a}function d(a,b){return b.z-a.z}function c(a,b){var d=0,c=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?d=Math.max(d,f/(f-e)):e<0&&(c=Math.min(c,f/(f-e))),g<0?d=Math.max(d,g/(g-h)):h<0&&(c=Math.min(c,g/(g-h))),c<d?!1:(a.lerpSelf(b,d),b.lerpSelf(a,1-c),!0))}var f,g,h=[],i,l,k=[],
 THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=k[l]=k[l]||new THREE.RenderableVertex;l++;return a}function d(a,b){return b.z-a.z}function c(a,b){var d=0,c=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?d=Math.max(d,f/(f-e)):e<0&&(c=Math.min(c,f/(f-e))),g<0?d=Math.max(d,g/(g-h)):h<0&&(c=Math.min(c,g/(g-h))),c<d?!1:(a.lerpSelf(b,d),b.lerpSelf(a,1-c),!0))}var f,g,h=[],i,l,k=[],
 j,p,s=[],w,n=[],E,y,J=[],P,Q,V=[],C={objects:[],sprites:[],lights:[],elements:[]},D=new THREE.Vector3,N=new THREE.Vector4,O=new THREE.Matrix4,ma=new THREE.Matrix4,ua=new THREE.Frustum,ha=new THREE.Vector4,ca=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);O.multiply(b.projectionMatrix,b.matrixWorldInverse);O.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);O.multiply(b.matrixWorld,
 j,p,s=[],w,n=[],E,y,J=[],P,Q,V=[],C={objects:[],sprites:[],lights:[],elements:[]},D=new THREE.Vector3,N=new THREE.Vector4,O=new THREE.Matrix4,ma=new THREE.Matrix4,ua=new THREE.Frustum,ha=new THREE.Vector4,ca=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);O.multiply(b.projectionMatrix,b.matrixWorldInverse);O.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);O.multiply(b.matrixWorld,
 b.projectionMatrixInverse);O.multiplyVector3(a);return a};this.pickingRay=function(a,b){var d;a.z=-1;d=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(d,b);d.subSelf(a).normalize();return new THREE.Ray(a,d)};this.projectGraph=function(b,c){g=0;C.objects.length=0;C.sprites.length=0;C.lights.length=0;var h=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||ua.contains(b))?(O.multiplyVector3(D.copy(b.position)),f=a(),
 b.projectionMatrixInverse);O.multiplyVector3(a);return a};this.pickingRay=function(a,b){var d;a.z=-1;d=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(d,b);d.subSelf(a).normalize();return new THREE.Ray(a,d)};this.projectGraph=function(b,c){g=0;C.objects.length=0;C.sprites.length=0;C.lights.length=0;var h=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||ua.contains(b))?(O.multiplyVector3(D.copy(b.position)),f=a(),
-f.object=b,f.z=D.z,C.objects.push(f)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(O.multiplyVector3(D.copy(b.position)),f=a(),f.object=b,f.z=D.z,C.sprites.push(f)):b instanceof THREE.Light&&C.lights.push(b);for(var d=0,e=b.children.length;d<e;d++)h(b.children[d])}};h(b);c&&C.objects.sort(d);return C};this.projectScene=function(a,f,g){var h=f.near,I=f.far,e,D,S,qa,H,T,na,ra,Z,sa,oa,wa,Ca,za,Aa,ta;Q=y=w=p=0;C.elements.length=0;f.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(f));a.updateMatrixWorld();f.matrixWorldInverse.getInverse(f.matrixWorld);O.multiply(f.projectionMatrix,f.matrixWorldInverse);ua.setFromMatrix(O);C=this.projectGraph(a,!1);a=0;for(e=C.objects.length;a<e;a++)if(Z=C.objects[a].object,sa=Z.matrixWorld,wa=Z.material,l=0,Z instanceof THREE.Mesh){oa=Z.geometry;Ca=Z.geometry.materials;qa=oa.vertices;za=oa.faces;Aa=oa.faceVertexUvs;oa=Z.matrixRotationWorld.extractRotation(sa);D=0;for(S=qa.length;D<S;D++)i=b(),i.positionWorld.copy(qa[D].position),sa.multiplyVector3(i.positionWorld),
-i.positionScreen.copy(i.positionWorld),O.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<I;qa=0;for(D=za.length;qa<D;qa++){S=za[qa];if(S instanceof THREE.Face3)if(H=k[S.a],T=k[S.b],na=k[S.c],H.visible&&T.visible&&na.visible&&(Z.doubleSided||Z.flipSided!=(na.positionScreen.x-H.positionScreen.x)*(T.positionScreen.y-H.positionScreen.y)-(na.positionScreen.y-H.positionScreen.y)*(T.positionScreen.x-
-H.positionScreen.x)<0))ra=s[p]=s[p]||new THREE.RenderableFace3,p++,j=ra,j.v1.copy(H),j.v2.copy(T),j.v3.copy(na);else continue;else if(S instanceof THREE.Face4)if(H=k[S.a],T=k[S.b],na=k[S.c],ra=k[S.d],H.visible&&T.visible&&na.visible&&ra.visible&&(Z.doubleSided||Z.flipSided!=((ra.positionScreen.x-H.positionScreen.x)*(T.positionScreen.y-H.positionScreen.y)-(ra.positionScreen.y-H.positionScreen.y)*(T.positionScreen.x-H.positionScreen.x)<0||(T.positionScreen.x-na.positionScreen.x)*(ra.positionScreen.y-
-na.positionScreen.y)-(T.positionScreen.y-na.positionScreen.y)*(ra.positionScreen.x-na.positionScreen.x)<0)))ta=n[w]=n[w]||new THREE.RenderableFace4,w++,j=ta,j.v1.copy(H),j.v2.copy(T),j.v3.copy(na),j.v4.copy(ra);else continue;j.normalWorld.copy(S.normal);oa.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);sa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);O.multiplyVector3(j.centroidScreen);na=S.vertexNormals;H=0;for(T=na.length;H<T;H++)ra=j.vertexNormalsWorld[H],
-ra.copy(na[H]),oa.multiplyVector3(ra);H=0;for(T=Aa.length;H<T;H++)if(ta=Aa[H][qa]){na=0;for(ra=ta.length;na<ra;na++)j.uvs[H][na]=ta[na]}j.material=wa;j.faceMaterial=S.materialIndex!==null?Ca[S.materialIndex]:null;j.z=j.centroidScreen.z;C.elements.push(j)}}else if(Z instanceof THREE.Line){ma.multiply(O,sa);qa=Z.geometry.vertices;H=b();H.positionScreen.copy(qa[0].position);ma.multiplyVector4(H.positionScreen);D=1;for(S=qa.length;D<S;D++)if(H=b(),H.positionScreen.copy(qa[D].position),ma.multiplyVector4(H.positionScreen),
-T=k[l-2],ha.copy(H.positionScreen),ca.copy(T.positionScreen),c(ha,ca))ha.multiplyScalar(1/ha.w),ca.multiplyScalar(1/ca.w),Z=J[y]=J[y]||new THREE.RenderableLine,y++,E=Z,E.v1.positionScreen.copy(ha),E.v2.positionScreen.copy(ca),E.z=Math.max(ha.z,ca.z),E.material=wa,C.elements.push(E)}a=0;for(e=C.sprites.length;a<e;a++)if(Z=C.sprites[a].object,sa=Z.matrixWorld,Z instanceof THREE.Particle&&(N.set(sa.n14,sa.n24,sa.n34,1),O.multiplyVector4(N),N.z/=N.w,N.z>0&&N.z<1))h=V[Q]=V[Q]||new THREE.RenderableParticle,
+f.object=b,f.z=D.z,C.objects.push(f)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(O.multiplyVector3(D.copy(b.position)),f=a(),f.object=b,f.z=D.z,C.sprites.push(f)):b instanceof THREE.Light&&C.lights.push(b);for(var d=0,e=b.children.length;d<e;d++)h(b.children[d])}};h(b);c&&C.objects.sort(d);return C};this.projectScene=function(a,f,g){var h=f.near,H=f.far,e,D,T,qa,I,R,na,ra,Z,sa,oa,wa,Ca,za,Aa,ta;Q=y=w=p=0;C.elements.length=0;f.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(f));a.updateMatrixWorld();f.matrixWorldInverse.getInverse(f.matrixWorld);O.multiply(f.projectionMatrix,f.matrixWorldInverse);ua.setFromMatrix(O);C=this.projectGraph(a,!1);a=0;for(e=C.objects.length;a<e;a++)if(Z=C.objects[a].object,sa=Z.matrixWorld,wa=Z.material,l=0,Z instanceof THREE.Mesh){oa=Z.geometry;Ca=Z.geometry.materials;qa=oa.vertices;za=oa.faces;Aa=oa.faceVertexUvs;oa=Z.matrixRotationWorld.extractRotation(sa);D=0;for(T=qa.length;D<T;D++)i=b(),i.positionWorld.copy(qa[D].position),sa.multiplyVector3(i.positionWorld),
+i.positionScreen.copy(i.positionWorld),O.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<H;qa=0;for(D=za.length;qa<D;qa++){T=za[qa];if(T instanceof THREE.Face3)if(I=k[T.a],R=k[T.b],na=k[T.c],I.visible&&R.visible&&na.visible&&(Z.doubleSided||Z.flipSided!=(na.positionScreen.x-I.positionScreen.x)*(R.positionScreen.y-I.positionScreen.y)-(na.positionScreen.y-I.positionScreen.y)*(R.positionScreen.x-
+I.positionScreen.x)<0))ra=s[p]=s[p]||new THREE.RenderableFace3,p++,j=ra,j.v1.copy(I),j.v2.copy(R),j.v3.copy(na);else continue;else if(T instanceof THREE.Face4)if(I=k[T.a],R=k[T.b],na=k[T.c],ra=k[T.d],I.visible&&R.visible&&na.visible&&ra.visible&&(Z.doubleSided||Z.flipSided!=((ra.positionScreen.x-I.positionScreen.x)*(R.positionScreen.y-I.positionScreen.y)-(ra.positionScreen.y-I.positionScreen.y)*(R.positionScreen.x-I.positionScreen.x)<0||(R.positionScreen.x-na.positionScreen.x)*(ra.positionScreen.y-
+na.positionScreen.y)-(R.positionScreen.y-na.positionScreen.y)*(ra.positionScreen.x-na.positionScreen.x)<0)))ta=n[w]=n[w]||new THREE.RenderableFace4,w++,j=ta,j.v1.copy(I),j.v2.copy(R),j.v3.copy(na),j.v4.copy(ra);else continue;j.normalWorld.copy(T.normal);oa.multiplyVector3(j.normalWorld);j.centroidWorld.copy(T.centroid);sa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);O.multiplyVector3(j.centroidScreen);na=T.vertexNormals;I=0;for(R=na.length;I<R;I++)ra=j.vertexNormalsWorld[I],
+ra.copy(na[I]),oa.multiplyVector3(ra);I=0;for(R=Aa.length;I<R;I++)if(ta=Aa[I][qa]){na=0;for(ra=ta.length;na<ra;na++)j.uvs[I][na]=ta[na]}j.material=wa;j.faceMaterial=T.materialIndex!==null?Ca[T.materialIndex]:null;j.z=j.centroidScreen.z;C.elements.push(j)}}else if(Z instanceof THREE.Line){ma.multiply(O,sa);qa=Z.geometry.vertices;I=b();I.positionScreen.copy(qa[0].position);ma.multiplyVector4(I.positionScreen);D=1;for(T=qa.length;D<T;D++)if(I=b(),I.positionScreen.copy(qa[D].position),ma.multiplyVector4(I.positionScreen),
+R=k[l-2],ha.copy(I.positionScreen),ca.copy(R.positionScreen),c(ha,ca))ha.multiplyScalar(1/ha.w),ca.multiplyScalar(1/ca.w),Z=J[y]=J[y]||new THREE.RenderableLine,y++,E=Z,E.v1.positionScreen.copy(ha),E.v2.positionScreen.copy(ca),E.z=Math.max(ha.z,ca.z),E.material=wa,C.elements.push(E)}a=0;for(e=C.sprites.length;a<e;a++)if(Z=C.sprites[a].object,sa=Z.matrixWorld,Z instanceof THREE.Particle&&(N.set(sa.n14,sa.n24,sa.n34,1),O.multiplyVector4(N),N.z/=N.w,N.z>0&&N.z<1))h=V[Q]=V[Q]||new THREE.RenderableParticle,
 Q++,P=h,P.x=N.x/N.w,P.y=N.y/N.w,P.z=N.z,P.rotation=Z.rotation.z,P.scale.x=Z.scale.x*Math.abs(P.x-(N.x+f.projectionMatrix.n11)/(N.w+f.projectionMatrix.n14)),P.scale.y=Z.scale.y*Math.abs(P.y-(N.y+f.projectionMatrix.n22)/(N.w+f.projectionMatrix.n24)),P.material=Z.material,C.elements.push(P);g&&C.elements.sort(d);return C}};THREE.Quaternion=function(a,b,d,c){this.set(a||0,b||0,d||0,c!==void 0?c:1)};
 Q++,P=h,P.x=N.x/N.w,P.y=N.y/N.w,P.z=N.z,P.rotation=Z.rotation.z,P.scale.x=Z.scale.x*Math.abs(P.x-(N.x+f.projectionMatrix.n11)/(N.w+f.projectionMatrix.n14)),P.scale.y=Z.scale.y*Math.abs(P.y-(N.y+f.projectionMatrix.n22)/(N.w+f.projectionMatrix.n24)),P.material=Z.material,C.elements.push(P);g&&C.elements.sort(d);return C}};THREE.Quaternion=function(a,b,d,c){this.set(a||0,b||0,d||0,c!==void 0?c:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,d,c){this.x=a;this.y=b;this.z=d;this.w=c;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=Math.PI/360,d=a.x*b,c=a.y*b,f=a.z*b,a=Math.cos(c),c=Math.sin(c),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(d),d=Math.sin(d),h=a*b,i=c*f;this.w=h*g-i*d;this.x=h*d+i*g;this.y=c*b*g+a*f*d;this.z=a*f*g-c*b*d;return this},setFromAxisAngle:function(a,b){var d=b/2,c=Math.sin(d);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,d,c){this.x=a;this.y=b;this.z=d;this.w=c;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=Math.PI/360,d=a.x*b,c=a.y*b,f=a.z*b,a=Math.cos(c),c=Math.sin(c),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(d),d=Math.sin(d),h=a*b,i=c*f;this.w=h*g-i*d;this.x=h*d+i*g;this.y=c*b*g+a*f*d;this.z=a*f*g-c*b*d;return this},setFromAxisAngle:function(a,b){var d=b/2,c=Math.sin(d);
 this.x=a.x*c;this.y=a.y*c;this.z=a.z*c;this.w=Math.cos(d);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*c;this.y=a.y*c;this.z=a.z*c;this.w=Math.cos(d);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
@@ -89,7 +89,7 @@ c[d.b].addSelf(d.normal),c[d.c].addSelf(d.normal),c[d.d].addSelf(d.normal));a=0;
 b,d,c,f,g,O){i=a.vertices[b].position;l=a.vertices[d].position;k=a.vertices[c].position;j=h[f];p=h[g];s=h[O];w=l.x-i.x;n=k.x-i.x;E=l.y-i.y;y=k.y-i.y;J=l.z-i.z;P=k.z-i.z;Q=p.u-j.u;V=s.u-j.u;C=p.v-j.v;D=s.v-j.v;N=1/(Q*D-V*C);ha.set((D*w-C*n)*N,(D*E-C*y)*N,(D*J-C*P)*N);ca.set((Q*n-V*w)*N,(Q*y-V*E)*N,(Q*P-V*J)*N);ma[b].addSelf(ha);ma[d].addSelf(ha);ma[c].addSelf(ha);ua[b].addSelf(ca);ua[d].addSelf(ca);ua[c].addSelf(ca)}var b,d,c,f,g,h,i,l,k,j,p,s,w,n,E,y,J,P,Q,V,C,D,N,O,ma=[],ua=[],ha=new THREE.Vector3,
 b,d,c,f,g,O){i=a.vertices[b].position;l=a.vertices[d].position;k=a.vertices[c].position;j=h[f];p=h[g];s=h[O];w=l.x-i.x;n=k.x-i.x;E=l.y-i.y;y=k.y-i.y;J=l.z-i.z;P=k.z-i.z;Q=p.u-j.u;V=s.u-j.u;C=p.v-j.v;D=s.v-j.v;N=1/(Q*D-V*C);ha.set((D*w-C*n)*N,(D*E-C*y)*N,(D*J-C*P)*N);ca.set((Q*n-V*w)*N,(Q*y-V*E)*N,(Q*P-V*J)*N);ma[b].addSelf(ha);ma[d].addSelf(ha);ma[c].addSelf(ha);ua[b].addSelf(ca);ua[d].addSelf(ca);ua[c].addSelf(ca)}var b,d,c,f,g,h,i,l,k,j,p,s,w,n,E,y,J,P,Q,V,C,D,N,O,ma=[],ua=[],ha=new THREE.Vector3,
 ca=new THREE.Vector3,pa=new THREE.Vector3,ja=new THREE.Vector3,xa=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++)ma[b]=new THREE.Vector3,ua[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):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 va=["a","b","c","d"];b=0;for(d=this.faces.length;b<d;b++){g=this.faces[b];for(c=0;c<g.vertexNormals.length;c++)xa.copy(g.vertexNormals[c]),
 ca=new THREE.Vector3,pa=new THREE.Vector3,ja=new THREE.Vector3,xa=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++)ma[b]=new THREE.Vector3,ua[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):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 va=["a","b","c","d"];b=0;for(d=this.faces.length;b<d;b++){g=this.faces[b];for(c=0;c<g.vertexNormals.length;c++)xa.copy(g.vertexNormals[c]),
 f=g[va[c]],O=ma[f],pa.copy(O),pa.subSelf(xa.multiplyScalar(xa.dot(O))).normalize(),ja.cross(g.vertexNormals[c],O),f=ja.dot(ua[f]),f=f<0?-1:1,g.vertexTangents[c]=new THREE.Vector4(pa.x,pa.y,pa.z,f)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,d=this.boundingBox.max,c=1,f=this.vertices.length;c<
 f=g[va[c]],O=ma[f],pa.copy(O),pa.subSelf(xa.multiplyScalar(xa.dot(O))).normalize(),ja.cross(g.vertexNormals[c],O),f=ja.dot(ua[f]),f=f<0?-1:1,g.vertexTangents[c]=new THREE.Vector4(pa.x,pa.y,pa.z,f)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,d=this.boundingBox.max,c=1,f=this.vertices.length;c<
-f;c++){a=this.vertices[c].position;if(a.x<b.x)b.x=a.x;else if(a.x>d.x)d.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>d.y)d.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>d.z)d.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],d=[],c,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++)c=this.vertices[g].position,c=[Math.round(c.x*f),Math.round(c.y*f),
+f;c++){a=this.vertices[c].position;if(a.x<b.x)b.x=a.x;else if(a.x>d.x)d.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>d.y)d.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>d.z)d.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,d=0,c=this.vertices.length;d<c;d++)a=this.vertices[d].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],d=[],c,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++)c=this.vertices[g].position,c=[Math.round(c.x*f),Math.round(c.y*f),
 Math.round(c.z*f)].join("_"),a[c]===void 0?(a[c]=g,b.push(this.vertices[g]),d[g]=b.length-1):d[g]=d[a[c]];g=0;for(h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c];else if(a instanceof THREE.Face4)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c],a.d=d[a.d];this.vertices=b}};THREE.GeometryCount=0;
 Math.round(c.z*f)].join("_"),a[c]===void 0?(a[c]=g,b.push(this.vertices[g]),d[g]=b.length-1):d[g]=d[a[c]];g=0;for(h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c];else if(a instanceof THREE.Face4)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c],a.d=d[a.d];this.vertices=b}};THREE.GeometryCount=0;
 THREE.Spline=function(a){function b(a,b,d,c,f,g,h){a=(d-a)*0.5;c=(c-b)*0.5;return(2*(b-d)+a+c)*h+(-3*(b-d)-2*a-c)*g+a*f+b}this.points=a;var d=[],c={x:0,y:0,z:0},f,g,h,i,l,k,j,p,s;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;g=Math.floor(f);h=f-g;d[0]=g===0?g:g-1;d[1]=g;d[2]=g>this.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;k=this.points[d[0]];j=this.points[d[1]];
 THREE.Spline=function(a){function b(a,b,d,c,f,g,h){a=(d-a)*0.5;c=(c-b)*0.5;return(2*(b-d)+a+c)*h+(-3*(b-d)-2*a-c)*g+a*f+b}this.points=a;var d=[],c={x:0,y:0,z:0},f,g,h,i,l,k,j,p,s;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;g=Math.floor(f);h=f-g;d[0]=g===0?g:g-1;d[1]=g;d[2]=g>this.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;k=this.points[d[0]];j=this.points[d[1]];
 p=this.points[d[2]];s=this.points[d[3]];i=h*h;l=h*i;c.x=b(k.x,j.x,p.x,s.x,h,i,l);c.y=b(k.y,j.y,p.y,s.y,h,i,l);c.z=b(k.z,j.z,p.z,s.z,h,i,l);return c};this.getControlPointsArray=function(){var a,b,d=this.points.length,c=[];for(a=0;a<d;a++)b=this.points[a],c[a]=[b.x,b.y,b.z];return c};this.getLength=function(a){var b,d,c,f=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);d=this.points.length*a;g.copy(this.points[0]);for(a=1;a<d;a++)b=a/d,c=this.getPoint(b),h.copy(c),j+=h.distanceTo(g),
 p=this.points[d[2]];s=this.points[d[3]];i=h*h;l=h*i;c.x=b(k.x,j.x,p.x,s.x,h,i,l);c.y=b(k.y,j.y,p.y,s.y,h,i,l);c.z=b(k.z,j.z,p.z,s.z,h,i,l);return c};this.getControlPointsArray=function(){var a,b,d=this.points.length,c=[];for(a=0;a<d;a++)b=this.points[a],c[a]=[b.x,b.y,b.z];return c};this.getLength=function(a){var b,d,c,f=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);d=this.points.length*a;g.copy(this.points[0]);for(a=1;a<d;a++)b=a/d,c=this.getPoint(b),h.copy(c),j+=h.distanceTo(g),
@@ -185,105 +185,109 @@ return!1}function h(a,b,d){var c,f,g,h,v=a.vertices;h=v.length;var i=a.colors,j=
 1]=f.g,k[g+2]=f.b;if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.boundTo===void 0||v.boundTo==="vertices")if(g=0,f=v.value.length,v.size===1)for(c=0;c<f;c++)h=m[c][1],v.array[c]=v.value[h];else if(v.size===2)for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,g+=2;else if(v.size===3)if(v.type==="c")for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.r,v.array[g+1]=h.g,v.array[g+2]=h.b,g+=3;else for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,
 1]=f.g,k[g+2]=f.b;if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.boundTo===void 0||v.boundTo==="vertices")if(g=0,f=v.value.length,v.size===1)for(c=0;c<f;c++)h=m[c][1],v.array[c]=v.value[h];else if(v.size===2)for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,g+=2;else if(v.size===3)if(v.type==="c")for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.r,v.array[g+1]=h.g,v.array[g+2]=h.b,g+=3;else for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,
 g+=3;else if(v.size===4)for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,v.array[g+3]=h.w,g+=4}}else{if(q)for(c=0;c<h;c++)f=v[c].position,g=c*3,t[g]=f.x,t[g+1]=f.y,t[g+2]=f.z;if(n)for(c=0;c<j;c++)f=i[c],g=c*3,k[g]=f.r,k[g+1]=f.g,k[g+2]=f.b;if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.needsUpdate&&(v.boundTo===void 0||v.boundTo==="vertices"))if(f=v.value.length,g=0,v.size===1)for(c=0;c<f;c++)v.array[c]=v.value[c];else if(v.size===2)for(c=0;c<f;c++)h=v.value[c],
 g+=3;else if(v.size===4)for(c=0;c<f;c++)h=m[c][1],h=v.value[h],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,v.array[g+3]=h.w,g+=4}}else{if(q)for(c=0;c<h;c++)f=v[c].position,g=c*3,t[g]=f.x,t[g+1]=f.y,t[g+2]=f.z;if(n)for(c=0;c<j;c++)f=i[c],g=c*3,k[g]=f.r,k[g+1]=f.g,k[g+2]=f.b;if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.needsUpdate&&(v.boundTo===void 0||v.boundTo==="vertices"))if(f=v.value.length,g=0,v.size===1)for(c=0;c<f;c++)v.array[c]=v.value[c];else if(v.size===2)for(c=0;c<f;c++)h=v.value[c],
 v.array[g]=h.x,v.array[g+1]=h.y,g+=2;else if(v.size===3)if(v.type==="c")for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.r,v.array[g+1]=h.g,v.array[g+2]=h.b,g+=3;else for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,g+=3;else if(v.size===4)for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,v.array[g+3]=h.w,g+=4}}if(q||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,t,b);if(n||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,
 v.array[g]=h.x,v.array[g+1]=h.y,g+=2;else if(v.size===3)if(v.type==="c")for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.r,v.array[g+1]=h.g,v.array[g+2]=h.b,g+=3;else for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,g+=3;else if(v.size===4)for(c=0;c<f;c++)h=v.value[c],v.array[g]=h.x,v.array[g+1]=h.y,v.array[g+2]=h.z,v.array[g+3]=h.w,g+=4}}if(q||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,t,b);if(n||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,
-a.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,k,b);if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.needsUpdate||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,v.buffer),e.bufferData(e.ARRAY_BUFFER,v.array,b)}}function i(a,b){return b.z-a.z}function l(a,b,d){if(a.length)for(var c=0,e=a.length;c<e;c++)S=null,H=T=wa=oa=sa=-1,a[c].render(b,d,Ja,Ka),S=null,H=T=wa=oa=sa=-1}function k(a,b,d,c,e,f,g,h){var i,j,t,k;b?(j=a.length-1,k=b=-1):(j=0,b=a.length,k=1);for(var m=j;m!==b;m+=k)if(i=a[m],i.render){j=i.object;
-t=i.buffer;if(h)i=h;else{i=i[d];if(!i)continue;g&&I.setBlending(i.blending);I.setDepthTest(i.depthTest);P(i.depthWrite);Q(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}I.setObjectFaces(j);I.renderBuffer(c,e,f,i,t,j)}}function j(a,b,d,c,e,f,g){for(var h,i,j=0,k=a.length;j<k;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&I.setBlending(h.blending);I.setDepthTest(h.depthTest);P(h.depthWrite);Q(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}I.renderImmediateObject(d,
-c,e,h,i)}}function p(a,b,d){a.push({buffer:b,object:d,opaque:null,transparent:null})}function s(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function w(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function n(a,b){for(var d=a.length-1;d>=0;d--)a[d].object===b&&a.splice(d,1)}function E(a,b){for(var d=a.length-1;d>=0;d--)a[d]===b&&a.splice(d,1)}function y(a,b,d,c,f){c.program||I.initMaterial(c,b,d,f);if(c.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=
-new Float32Array(I.maxMorphTargets);for(var g=0,h=I.maxMorphTargets;g<h;g++)f.__webglMorphTargetInfluences[g]=0}var i=!1,g=c.program,h=g.uniforms,j=c.uniforms;g!==S&&(e.useProgram(g),S=g,i=!0);if(c.id!==H)H=c.id,i=!0;if(i){e.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray);if(d&&c.fog)if(j.fogColor.value=d.color,d instanceof THREE.Fog)j.fogNear.value=d.near,j.fogFar.value=d.far;else if(d instanceof THREE.FogExp2)j.fogDensity.value=d.density;if(c instanceof THREE.MeshPhongMaterial||
-c instanceof THREE.MeshLambertMaterial||c.lights){for(var k,t,n=0,m=0,q=0,l,p,s=La,w=s.directional.colors,E=s.directional.positions,y=s.point.colors,u=s.point.positions,D=s.point.distances,J=0,x=0,U=p=0,d=0,i=b.length;d<i;d++)if(k=b[d],t=k.color,l=k.intensity,p=k.distance,k instanceof THREE.AmbientLight)I.gammaInput?(n+=t.r*t.r,m+=t.g*t.g,q+=t.b*t.b):(n+=t.r,m+=t.g,q+=t.b);else if(k instanceof THREE.DirectionalLight)p=J*3,I.gammaInput?(w[p]=t.r*t.r*l*l,w[p+1]=t.g*t.g*l*l,w[p+2]=t.b*t.b*l*l):(w[p]=
-t.r*l,w[p+1]=t.g*l,w[p+2]=t.b*l),k=k.matrixWorld.getPosition(),t=1/k.length(),E[p]=k.x*t,E[p+1]=k.y*t,E[p+2]=k.z*t,J+=1;else if(k instanceof THREE.SpotLight)p=J*3,I.gammaInput?(w[p]=t.r*t.r*l*l,w[p+1]=t.g*t.g*l*l,w[p+2]=t.b*t.b*l*l):(w[p]=t.r*l,w[p+1]=t.g*l,w[p+2]=t.b*l),k=k.matrixWorld.getPosition(),t=1/k.length(),E[p]=k.x*t,E[p+1]=k.y*t,E[p+2]=k.z*t,J+=1;else if(k instanceof THREE.PointLight)U=x*3,I.gammaInput?(y[U]=t.r*t.r*l*l,y[U+1]=t.g*t.g*l*l,y[U+2]=t.b*t.b*l*l):(y[U]=t.r*l,y[U+1]=t.g*l,y[U+
-2]=t.b*l),k=k.matrixWorld.getPosition(),u[U]=k.x,u[U+1]=k.y,u[U+2]=k.z,D[x]=p,x+=1;d=J*3;for(i=w.length;d<i;d++)w[d]=0;d=x*3;for(i=y.length;d<i;d++)y[d]=0;s.point.length=x;s.directional.length=J;s.ambient[0]=n;s.ambient[1]=m;s.ambient[2]=q;b=La;j.ambientLightColor.value=b.ambient;j.directionalLightColor.value=b.directional.colors;j.directionalLightDirection.value=b.directional.positions;j.pointLightColor.value=b.point.colors;j.pointLightPosition.value=b.point.positions;j.pointLightDistance.value=
-b.point.distances}if(c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial)j.opacity.value=c.opacity,I.gammaInput?j.diffuse.value.copyGammaToLinear(c.color):j.diffuse.value=c.color,(j.map.texture=c.map)&&j.offsetRepeat.value.set(c.map.offset.x,c.map.offset.y,c.map.repeat.x,c.map.repeat.y),j.lightMap.texture=c.lightMap,j.envMap.texture=c.envMap,j.flipEnvMap.value=c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,j.reflectivity.value=c.reflectivity,
-j.refractionRatio.value=c.refractionRatio,j.combine.value=c.combine,j.useRefract.value=c.envMap&&c.envMap.mapping instanceof THREE.CubeRefractionMapping;if(c instanceof THREE.LineBasicMaterial)j.diffuse.value=c.color,j.opacity.value=c.opacity;else if(c instanceof THREE.ParticleBasicMaterial)j.psColor.value=c.color,j.opacity.value=c.opacity,j.size.value=c.size,j.scale.value=ma.height/2,j.map.texture=c.map;else if(c instanceof THREE.MeshPhongMaterial)j.shininess.value=c.shininess,I.gammaInput?(j.ambient.value.copyGammaToLinear(c.ambient),
-j.specular.value.copyGammaToLinear(c.specular)):(j.ambient.value=c.ambient,j.specular.value=c.specular);else if(c instanceof THREE.MeshLambertMaterial)I.gammaInput?j.ambient.value.copyGammaToLinear(c.ambient):j.ambient.value=c.ambient;else if(c instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=c.opacity;else if(c instanceof THREE.MeshNormalMaterial)j.opacity.value=c.opacity;if(f.receiveShadow&&!c._shadowPass&&j.shadowMatrix){for(b=0;b<I.shadowMapPlugin.shadowMatrix.length;b++)j.shadowMatrix.value[b]=
-I.shadowMapPlugin.shadowMatrix[b],j.shadowMap.texture[b]=I.shadowMapPlugin.shadowMap[b];j.shadowDarkness.value=I.shadowMapDarkness;j.shadowBias.value=I.shadowMapBias}b=c.uniformsList;j=0;for(d=b.length;j<d;j++)if(m=g.uniforms[b[j][1]])if(n=b[j][0],q=n.type,i=n.value,q==="i")e.uniform1i(m,i);else if(q==="f")e.uniform1f(m,i);else if(q==="v2")e.uniform2f(m,i.x,i.y);else if(q==="v3")e.uniform3f(m,i.x,i.y,i.z);else if(q==="v4")e.uniform4f(m,i.x,i.y,i.z,i.w);else if(q==="c")e.uniform3f(m,i.r,i.g,i.b);else if(q===
-"fv1")e.uniform1fv(m,i);else if(q==="fv")e.uniform3fv(m,i);else if(q==="v3v"){if(!n._array)n._array=new Float32Array(3*i.length);q=0;for(s=i.length;q<s;q++)w=q*3,n._array[w]=i[q].x,n._array[w+1]=i[q].y,n._array[w+2]=i[q].z;e.uniform3fv(m,n._array)}else if(q==="m4"){if(!n._array)n._array=new Float32Array(16);i.flattenToArray(n._array);e.uniformMatrix4fv(m,!1,n._array)}else if(q==="m4v"){if(!n._array)n._array=new Float32Array(16*i.length);q=0;for(s=i.length;q<s;q++)i[q].flattenToArrayOffset(n._array,
-q*16);e.uniformMatrix4fv(m,!1,n._array)}else if(q==="t"){if(e.uniform1i(m,i),m=n.texture)if(m.image instanceof Array&&m.image.length===6){if(n=m,n.image.length===6)if(n.needsUpdate){if(!n.image.__webglTextureCube)n.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+i);e.bindTexture(e.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);i=C(e.TEXTURE_CUBE_MAP,n,n.image[0]);for(m=0;m<6;m++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image[m]);i&&e.generateMipmap(e.TEXTURE_CUBE_MAP);
-n.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(n=m,e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture)):I.setTexture(m,i)}else if(q==="tv"){if(!n._array){n._array=[];q=0;for(s=n.texture.length;q<s;q++)n._array[q]=i+q}e.uniform1iv(m,n._array);q=0;for(s=n.texture.length;q<s;q++)(m=n.texture[q])&&I.setTexture(m,n._array[q])}(c instanceof THREE.ShaderMaterial||
-c instanceof THREE.MeshPhongMaterial||c.envMap)&&h.cameraPosition!==null&&e.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.ShaderMaterial||c.skinning)&&h.viewMatrix!==null&&e.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);c.skinning&&(e.uniformMatrix4fv(h.cameraInverseMatrix,!1,a._viewMatrixArray),e.uniformMatrix4fv(h.boneGlobalMatrices,!1,f.boneMatrices))}e.uniformMatrix4fv(h.modelViewMatrix,
-!1,f._modelViewMatrixArray);h.normalMatrix&&e.uniformMatrix3fv(h.normalMatrix,!1,f._normalMatrixArray);(c instanceof THREE.ShaderMaterial||c.envMap||c.skinning||f.receiveShadow)&&h.objectMatrix!==null&&e.uniformMatrix4fv(h.objectMatrix,!1,f._objectMatrixArray);return g}function J(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function P(a){wa!==a&&
-(e.depthMask(a),wa=a)}function Q(a,b,c){Ca!==a&&(a?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),Ca=a);if(a&&(za!==b||Aa!==c))e.polygonOffset(b,c),za=b,Aa=c}function V(a,b){var c;a==="fragment"?c=e.createShader(e.FRAGMENT_SHADER):a==="vertex"&&(c=e.createShader(e.VERTEX_SHADER));e.shaderSource(c,b);e.compileShader(c);if(!e.getShaderParameter(c,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(c)),console.error(b),null;return c}function C(a,b,c){return(c.width&c.width-1)===
-0&&(c.height&c.height-1)===0?(e.texParameteri(a,e.TEXTURE_WRAP_S,O(b.wrapS)),e.texParameteri(a,e.TEXTURE_WRAP_T,O(b.wrapT)),e.texParameteri(a,e.TEXTURE_MAG_FILTER,O(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,O(b.minFilter)),!0):(e.texParameteri(a,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_MAG_FILTER,N(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,N(b.minFilter)),!1)}function D(a,b){e.bindRenderbuffer(e.RENDERBUFFER,
-a);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,a)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height)}function N(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;
-default:return e.LINEAR}}function O(a){switch(a){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}
-var a=a||{},ma=a.canvas!==void 0?a.canvas:document.createElement("canvas"),ua=a.precision!==void 0?a.precision:"mediump",ha=a.antialias!==void 0?a.antialias:!1,ca=a.stencil!==void 0?a.stencil:!0,pa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ja=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),xa=a.clearAlpha!==void 0?a.clearAlpha:0,va=a.maxLights!==void 0?a.maxLights:4;this.domElement=ma;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=
-this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,
-textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var I=this,e,ya=[],S=null,qa=null,H=-1,T=null,na=0,ra=null,Z=null,sa=null,oa=null,wa=null,Ca=null,za=null,Aa=null,ta=null,Ea=0,Fa=0,Ga=0,Ha=0,Ja=0,Ka=0,Ia=new THREE.Frustum,Da=new THREE.Matrix4,Ba=new THREE.Vector4,La={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};e=function(){var a;try{if(!(a=ma.getContext("experimental-webgl",{antialias:ha,stencil:ca,preserveDrawingBuffer:pa})))throw"Error creating WebGL context.";
-console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();e.clearColor(0,0,0,1);e.clearDepth(1);e.clearStencil(0);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(ja.r,ja.g,ja.b,xa);
-this.context=e;var Ma=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return e};this.supportsVertexTextures=function(){return Ma};this.setSize=function(a,b){ma.width=a;ma.height=b;this.setViewport(0,0,ma.width,ma.height)};this.setViewport=function(a,b,c,d){Ea=a;Fa=b;Ga=c;Ha=d;e.viewport(Ea,Fa,Ga,Ha)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,
-b){ja.setHex(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.setClearColor=function(a,b){ja.copy(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.getClearColor=function(){return ja};this.getClearAlpha=function(){return xa};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=e.COLOR_BUFFER_BIT;if(b===void 0||b)d|=e.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);
-this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);
-e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d<f;d++)e.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=
-void 0,c.__webglCustomAttributesList)e.deleteBuffer(c.__webglCustomAttributesList[d].buffer);I.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),I.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),I.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),
-e.deleteBuffer(a.__webglColorBuffer),I.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,e.deleteTexture(a.__webglTexture),I.info.memory.textures--};this.updateShadowMap=function(a,b){S=null;H=T=wa=oa=sa=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=e.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=e.createBuffer();a.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),
-e.bufferData(e.ARRAY_BUFFER,a.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(b.attributes.position),e.vertexAttribPointer(b.attributes.position,3,e.FLOAT,!1,0,0));if(a.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,f,g,h,i,j,n,k,l,m,q=a.count*3;for(m=0;m<q;m+=9)c=a.normalArray,d=c[m],f=c[m+1],g=c[m+2],h=c[m+3],j=c[m+4],k=c[m+5],i=c[m+6],n=c[m+7],l=c[m+8],d=(d+h+i)/3,f=(f+j+n)/3,g=(g+k+l)/3,c[m]=d,c[m+1]=f,c[m+2]=g,c[m+3]=d,c[m+4]=f,c[m+5]=g,
-c[m+6]=d,c[m+7]=f,c[m+8]=g}e.bufferData(e.ARRAY_BUFFER,a.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(b.attributes.normal);e.vertexAttribPointer(b.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,a.count);a.count=0};this.renderBuffer=function(a,b,c,d,f,g){if(d.opacity!==0){var h,i,c=y(a,b,c,d,g),b=c.attributes,a=!1,c=f.id*16777215+c.id*2+(d.wireframe?1:0);c!==T&&(T=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,
-3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)e.bindBuffer(e.ARRAY_BUFFER,
-f.__webglMorphTargetsBuffers[j[h]]),e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],n=-1,k=0;i=g.morphTargetInfluences;var l,m=i.length;h=0;for(g.morphTargetBase!==-1&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(l=0;l<m;l++)!j[l]&&i[l]>n&&(k=l,n=i[k]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=n;j[k]=
-1;n=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h=0;for(i=f.__webglCustomAttributesList.length;h<i;h++)c=f.__webglCustomAttributesList[h],b[c.buffer.belongsToAttribute]>=0&&(e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0))}b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,
-3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),
-e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,
-4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ta&&(e.lineWidth(d),ta=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),I.info.render.calls++,I.info.render.vertices+=
-f.__webglFaceCount,I.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==ta&&(e.lineWidth(d),ta=d),e.drawArrays(g,0,f.__webglLineCount),I.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),I.info.render.calls++,I.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),I.info.render.calls++)}};this.render=
-function(a,b,c,d){var f,g,h,n,p=a.lights,s=a.fog;H=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();l(this.renderPluginsPre,a,b);I.info.render.calls=0;I.info.render.vertices=0;I.info.render.faces=0;I.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);
-if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Da.multiply(b.projectionMatrix,b.matrixWorldInverse);Ia.setFromMatrix(Da);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(f=n.length;d<f;d++)if(g=n[d],h=g.object,g.render=!1,h.visible&&(!(h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem)||!h.frustumCulled||Ia.contains(h))){h.matrixWorld.flattenToArray(h._objectMatrixArray);
-J(h,b);var t=g,w=t.object,m=t.buffer,q=void 0,q=q=void 0,q=w.material;if(q instanceof THREE.MeshFaceMaterial){if(q=m.materialIndex,q>=0)q=w.geometry.materials[q],q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null)}else if(q)q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Ba.copy(h.position),Da.multiplyVector3(Ba),g.z=Ba.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;
-d=0;for(f=n.length;d<f;d++)if(g=n[d],h=g.object,h.visible)h.matrixAutoUpdate&&h.matrixWorld.flattenToArray(h._objectMatrixArray),J(h,b),h=g.object.material,h.transparent?(g.transparent=h,g.opaque=null):(g.opaque=h,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),P(a.overrideMaterial.depthWrite),Q(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,
-!1,"",b,p,s,!0,a.overrideMaterial),j(a.__webglObjectsImmediate,"",b,p,s,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,p,s,!1),j(a.__webglObjectsImmediate,"opaque",b,p,s,!1),k(a.__webglObjects,!1,"transparent",b,p,s,!0),j(a.__webglObjectsImmediate,"transparent",b,p,s,!0));l(this.renderPluginsPost,a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,
-c.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,c.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,f){var g=y(a,b,c,d,f);T=-1;I.setObjectFaces(f);f.immediateRenderCallback?f.immediateRenderCallback(g,e,Ia):f.render(function(a){I.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=
-[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var i=a.__objectsAdded[0],j=a,k=void 0,l=void 0,F=void 0;if(!i.__webglInit)if(i.__webglInit=!0,i._modelViewMatrix=new THREE.Matrix4,i._normalMatrixArray=new Float32Array(9),i._modelViewMatrixArray=new Float32Array(16),i._objectMatrixArray=new Float32Array(16),i.matrixWorld.flattenToArray(i._objectMatrixArray),i instanceof THREE.Mesh){l=i.geometry;if(l.geometryGroups===void 0){var F=l,G=void 0,v=void 0,y=void 0,C=void 0,t=void 0,
-D=void 0,m=void 0,q={},J=F.morphTargets.length;F.geometryGroups={};G=0;for(v=F.faces.length;G<v;G++)y=F.faces[G],C=y.materialIndex,D=C!==void 0?C:-1,q[D]===void 0&&(q[D]={hash:D,counter:0}),m=q[D].hash+"_"+q[D].counter,F.geometryGroups[m]===void 0&&(F.geometryGroups[m]={faces3:[],faces4:[],materialIndex:C,vertices:0,numMorphTargets:J}),t=y instanceof THREE.Face3?3:4,F.geometryGroups[m].vertices+t>65535&&(q[D].counter+=1,m=q[D].hash+"_"+q[D].counter,F.geometryGroups[m]===void 0&&(F.geometryGroups[m]=
-{faces3:[],faces4:[],materialIndex:C,vertices:0,numMorphTargets:J})),y instanceof THREE.Face3?F.geometryGroups[m].faces3.push(G):F.geometryGroups[m].faces4.push(G),F.geometryGroups[m].vertices+=t;F.geometryGroupsList=[];G=void 0;for(G in F.geometryGroups)F.geometryGroups[G].id=na++,F.geometryGroupsList.push(F.geometryGroups[G])}for(k in l.geometryGroups)if(F=l.geometryGroups[k],!F.__webglVertexBuffer){G=F;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer();G.__webglTangentBuffer=
-e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();G.__webglUV2Buffer=e.createBuffer();G.__webglSkinVertexABuffer=e.createBuffer();G.__webglSkinVertexBBuffer=e.createBuffer();G.__webglSkinIndicesBuffer=e.createBuffer();G.__webglSkinWeightsBuffer=e.createBuffer();G.__webglFaceBuffer=e.createBuffer();G.__webglLineBuffer=e.createBuffer();if(G.numMorphTargets){y=v=void 0;G.__webglMorphTargetsBuffers=[];v=0;for(y=G.numMorphTargets;v<y;v++)G.__webglMorphTargetsBuffers.push(e.createBuffer())}I.info.memory.geometries++;
-C=i;t=C.geometry;v=F.faces3;D=F.faces4;G=v.length*3+D.length*4;y=v.length*1+D.length*2;D=v.length*3+D.length*4;v=d(C,F);m=g(v);q=c(v);J=f(v);F.__vertexArray=new Float32Array(G*3);if(q)F.__normalArray=new Float32Array(G*3);if(t.hasTangents)F.__tangentArray=new Float32Array(G*4);if(J)F.__colorArray=new Float32Array(G*3);if(m){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)F.__uvArray=new Float32Array(G*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)F.__uv2Array=new Float32Array(G*2)}if(C.geometry.skinWeights.length&&
-C.geometry.skinIndices.length)F.__skinVertexAArray=new Float32Array(G*4),F.__skinVertexBArray=new Float32Array(G*4),F.__skinIndexArray=new Float32Array(G*4),F.__skinWeightArray=new Float32Array(G*4);F.__faceArray=new Uint16Array(y*3);F.__lineArray=new Uint16Array(D*2);if(F.numMorphTargets){F.__morphTargetsArrays=[];C=0;for(t=F.numMorphTargets;C<t;C++)F.__morphTargetsArrays.push(new Float32Array(G*3))}F.__webglFaceCount=y*3;F.__webglLineCount=D*2;if(v.attributes){if(F.__webglCustomAttributesList===
-void 0)F.__webglCustomAttributesList=[];y=void 0;for(y in v.attributes){var C=v.attributes[y],t={},ka;for(ka in C)t[ka]=C[ka];if(!t.__webglInitialized||t.createUniqueBuffers)t.__webglInitialized=!0,D=1,t.type==="v2"?D=2:t.type==="v3"?D=3:t.type==="v4"?D=4:t.type==="c"&&(D=3),t.size=D,t.array=new Float32Array(G*D),t.buffer=e.createBuffer(),t.buffer.belongsToAttribute=y,C.needsUpdate=!0,t.__original=C;F.__webglCustomAttributesList.push(t)}}F.__inittedArrays=!0;l.__dirtyVertices=!0;l.__dirtyMorphTargets=
-!0;l.__dirtyElements=!0;l.__dirtyUvs=!0;l.__dirtyNormals=!0;l.__dirtyTangents=!0;l.__dirtyColors=!0}}else if(i instanceof THREE.Ribbon){if(l=i.geometry,!l.__webglVertexBuffer)F=l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=e.createBuffer(),I.info.memory.geometries++,F=l,G=F.vertices.length,F.__vertexArray=new Float32Array(G*3),F.__colorArray=new Float32Array(G*3),F.__webglVertexCount=G,l.__dirtyVertices=!0,l.__dirtyColors=!0}else if(i instanceof THREE.Line){if(l=i.geometry,!l.__webglVertexBuffer)F=
-l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=e.createBuffer(),I.info.memory.geometries++,F=l,G=i,v=F.vertices.length,F.__vertexArray=new Float32Array(v*3),F.__colorArray=new Float32Array(v*3),F.__webglLineCount=v,b(F,G),l.__dirtyVertices=!0,l.__dirtyColors=!0}else if(i instanceof THREE.ParticleSystem&&(l=i.geometry,!l.__webglVertexBuffer))F=l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=e.createBuffer(),I.info.geometries++,F=l,G=i,v=F.vertices.length,F.__vertexArray=
-new Float32Array(v*3),F.__colorArray=new Float32Array(v*3),F.__sortArray=[],F.__webglParticleCount=v,b(F,G),l.__dirtyVertices=!0,l.__dirtyColors=!0;if(!i.__webglActive){if(i instanceof THREE.Mesh)for(k in l=i.geometry,l.geometryGroups)F=l.geometryGroups[k],p(j.__webglObjects,F,i);else i instanceof THREE.Ribbon||i instanceof THREE.Line||i instanceof THREE.ParticleSystem?(l=i.geometry,p(j.__webglObjects,l,i)):THREE.MarchingCubes!==void 0&&i instanceof THREE.MarchingCubes||i.immediateRenderCallback?
-j.__webglObjectsImmediate.push({object:i,opaque:null,transparent:null}):i instanceof THREE.Sprite?j.__webglSprites.push(i):i instanceof THREE.LensFlare&&j.__webglFlares.push(i);i.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;)i=a.__objectsRemoved[0],j=a,i instanceof THREE.Mesh||i instanceof THREE.ParticleSystem||i instanceof THREE.Ribbon||i instanceof THREE.Line?n(j.__webglObjects,i):i instanceof THREE.Sprite?E(j.__webglSprites,i):i instanceof THREE.LensFlare?E(j.__webglFlares,
-i):(i instanceof THREE.MarchingCubes||i.immediateRenderCallback)&&n(j.__webglObjectsImmediate,i),i.__webglActive=!1,a.__objectsRemoved.splice(0,1);i=0;for(j=a.__webglObjects.length;i<j;i++)if(ka=a.__webglObjects[i].object,k=ka.geometry,l=y=v=void 0,ka instanceof THREE.Mesh){F=0;for(G=k.geometryGroupsList.length;F<G;F++)if(v=k.geometryGroupsList[F],l=d(ka,v),y=l.attributes&&s(l),k.__dirtyVertices||k.__dirtyMorphTargets||k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||
-y){var M=ka,y=e.DYNAMIC_DRAW,C=!k.dynamic,m=l;if(v.__inittedArrays){var t=c(m),D=f(m),O=g(m),P=t===THREE.SmoothShading,H=q=m=void 0,u=void 0,ba=void 0,N=void 0,x=void 0,U=void 0,Q=void 0,V=H=void 0,z=void 0,A=void 0,B=void 0,da=u=void 0,ea=void 0,la=void 0,W=u=Q=void 0,X=void 0,S=B=A=z=x=void 0,K=u=B=A=z=S=B=A=z=S=B=A=z=void 0,L=void 0,T=N=void 0,Z=void 0,$=void 0,ma=void 0,fa=void 0,ja=V=$=L=0,ha=0,ca=K=H=0,R=x=da=0,r=0,ga=void 0,R=v.__vertexArray,Z=v.__uvArray,r=v.__uv2Array,T=v.__normalArray,ba=
-v.__tangentArray,ea=v.__colorArray,W=v.__skinVertexAArray,X=v.__skinVertexBArray,U=v.__skinIndexArray,ia=v.__skinWeightArray,S=v.__morphTargetsArrays,J=v.__webglCustomAttributesList,o=void 0,o=v.__faceArray,ga=v.__lineArray,la=M.geometry,ra=la.__dirtyElements,ua=la.__dirtyUvs,N=la.__dirtyNormals,Q=la.__dirtyTangents,xa=la.__dirtyColors,ma=la.__dirtyMorphTargets,fa=la.vertices,M=v.faces3,Y=v.faces4,aa=la.faces,qa=la.faceVertexUvs[0],sa=la.faceVertexUvs[1],oa=la.skinVerticesA,pa=la.skinVerticesB,va=
-la.skinIndices,ta=la.skinWeights,wa=la.morphTargets;if(la.__dirtyVertices){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=fa[u.a].position,A=fa[u.b].position,B=fa[u.c].position,R[$]=z.x,R[$+1]=z.y,R[$+2]=z.z,R[$+3]=A.x,R[$+4]=A.y,R[$+5]=A.z,R[$+6]=B.x,R[$+7]=B.y,R[$+8]=B.z,$+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=fa[u.a].position,A=fa[u.b].position,B=fa[u.c].position,u=fa[u.d].position,R[$]=z.x,R[$+1]=z.y,R[$+2]=z.z,R[$+3]=A.x,R[$+4]=A.y,R[$+5]=A.z,R[$+6]=B.x,R[$+7]=B.y,R[$+8]=B.z,R[$+9]=u.x,R[$+10]=
-u.y,R[$+11]=u.z,$+=12;e.bindBuffer(e.ARRAY_BUFFER,v.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,R,y)}if(ma){$=0;for(ma=wa.length;$<ma;$++){m=R=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=wa[$].vertices[u.a].position,A=wa[$].vertices[u.b].position,B=wa[$].vertices[u.c].position,fa=S[$],fa[R]=z.x,fa[R+1]=z.y,fa[R+2]=z.z,fa[R+3]=A.x,fa[R+4]=A.y,fa[R+5]=A.z,fa[R+6]=B.x,fa[R+7]=B.y,fa[R+8]=B.z,R+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=wa[$].vertices[u.a].position,A=wa[$].vertices[u.b].position,B=wa[$].vertices[u.c].position,
-u=wa[$].vertices[u.d].position,fa=S[$],fa[R]=z.x,fa[R+1]=z.y,fa[R+2]=z.z,fa[R+3]=A.x,fa[R+4]=A.y,fa[R+5]=A.z,fa[R+6]=B.x,fa[R+7]=B.y,fa[R+8]=B.z,fa[R+9]=u.x,fa[R+10]=u.y,fa[R+11]=u.z,R+=12;e.bindBuffer(e.ARRAY_BUFFER,v.__webglMorphTargetsBuffers[$]);e.bufferData(e.ARRAY_BUFFER,S[$],y)}}if(ta.length){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=ta[u.a],A=ta[u.b],B=ta[u.c],ia[x]=z.x,ia[x+1]=z.y,ia[x+2]=z.z,ia[x+3]=z.w,ia[x+4]=A.x,ia[x+5]=A.y,ia[x+6]=A.z,ia[x+7]=A.w,ia[x+8]=B.x,ia[x+9]=B.y,ia[x+10]=B.z,ia[x+
-11]=B.w,z=va[u.a],A=va[u.b],B=va[u.c],U[x]=z.x,U[x+1]=z.y,U[x+2]=z.z,U[x+3]=z.w,U[x+4]=A.x,U[x+5]=A.y,U[x+6]=A.z,U[x+7]=A.w,U[x+8]=B.x,U[x+9]=B.y,U[x+10]=B.z,U[x+11]=B.w,z=oa[u.a],A=oa[u.b],B=oa[u.c],W[x]=z.x,W[x+1]=z.y,W[x+2]=z.z,W[x+3]=1,W[x+4]=A.x,W[x+5]=A.y,W[x+6]=A.z,W[x+7]=1,W[x+8]=B.x,W[x+9]=B.y,W[x+10]=B.z,W[x+11]=1,z=pa[u.a],A=pa[u.b],B=pa[u.c],X[x]=z.x,X[x+1]=z.y,X[x+2]=z.z,X[x+3]=1,X[x+4]=A.x,X[x+5]=A.y,X[x+6]=A.z,X[x+7]=1,X[x+8]=B.x,X[x+9]=B.y,X[x+10]=B.z,X[x+11]=1,x+=12;m=0;for(q=Y.length;m<
-q;m++)u=aa[Y[m]],z=ta[u.a],A=ta[u.b],B=ta[u.c],S=ta[u.d],ia[x]=z.x,ia[x+1]=z.y,ia[x+2]=z.z,ia[x+3]=z.w,ia[x+4]=A.x,ia[x+5]=A.y,ia[x+6]=A.z,ia[x+7]=A.w,ia[x+8]=B.x,ia[x+9]=B.y,ia[x+10]=B.z,ia[x+11]=B.w,ia[x+12]=S.x,ia[x+13]=S.y,ia[x+14]=S.z,ia[x+15]=S.w,z=va[u.a],A=va[u.b],B=va[u.c],S=va[u.d],U[x]=z.x,U[x+1]=z.y,U[x+2]=z.z,U[x+3]=z.w,U[x+4]=A.x,U[x+5]=A.y,U[x+6]=A.z,U[x+7]=A.w,U[x+8]=B.x,U[x+9]=B.y,U[x+10]=B.z,U[x+11]=B.w,U[x+12]=S.x,U[x+13]=S.y,U[x+14]=S.z,U[x+15]=S.w,z=oa[u.a],A=oa[u.b],B=oa[u.c],
-S=oa[u.d],W[x]=z.x,W[x+1]=z.y,W[x+2]=z.z,W[x+3]=1,W[x+4]=A.x,W[x+5]=A.y,W[x+6]=A.z,W[x+7]=1,W[x+8]=B.x,W[x+9]=B.y,W[x+10]=B.z,W[x+11]=1,W[x+12]=S.x,W[x+13]=S.y,W[x+14]=S.z,W[x+15]=1,z=pa[u.a],A=pa[u.b],B=pa[u.c],u=pa[u.d],X[x]=z.x,X[x+1]=z.y,X[x+2]=z.z,X[x+3]=1,X[x+4]=A.x,X[x+5]=A.y,X[x+6]=A.z,X[x+7]=1,X[x+8]=B.x,X[x+9]=B.y,X[x+10]=B.z,X[x+11]=1,X[x+12]=u.x,X[x+13]=u.y,X[x+14]=u.z,X[x+15]=1,x+=16;x>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,W,y),e.bindBuffer(e.ARRAY_BUFFER,
-v.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,X,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,U,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ia,y))}if(xa&&D){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],x=u.vertexColors,U=u.color,x.length===3&&D===THREE.VertexColors?(u=x[0],W=x[1],X=x[2]):X=W=u=U,ea[da]=u.r,ea[da+1]=u.g,ea[da+2]=u.b,ea[da+3]=W.r,ea[da+4]=W.g,ea[da+5]=W.b,ea[da+6]=X.r,ea[da+7]=X.g,ea[da+8]=X.b,da+=
-9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],x=u.vertexColors,U=u.color,x.length===4&&D===THREE.VertexColors?(u=x[0],W=x[1],X=x[2],x=x[3]):x=X=W=u=U,ea[da]=u.r,ea[da+1]=u.g,ea[da+2]=u.b,ea[da+3]=W.r,ea[da+4]=W.g,ea[da+5]=W.b,ea[da+6]=X.r,ea[da+7]=X.g,ea[da+8]=X.b,ea[da+9]=x.r,ea[da+10]=x.g,ea[da+11]=x.b,da+=12;da>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,ea,y))}if(Q&&la.hasTangents){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],Q=u.vertexTangents,da=Q[0],ea=Q[1],la=Q[2],
-ba[K]=da.x,ba[K+1]=da.y,ba[K+2]=da.z,ba[K+3]=da.w,ba[K+4]=ea.x,ba[K+5]=ea.y,ba[K+6]=ea.z,ba[K+7]=ea.w,ba[K+8]=la.x,ba[K+9]=la.y,ba[K+10]=la.z,ba[K+11]=la.w,K+=12;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],Q=u.vertexTangents,da=Q[0],ea=Q[1],la=Q[2],Q=Q[3],ba[K]=da.x,ba[K+1]=da.y,ba[K+2]=da.z,ba[K+3]=da.w,ba[K+4]=ea.x,ba[K+5]=ea.y,ba[K+6]=ea.z,ba[K+7]=ea.w,ba[K+8]=la.x,ba[K+9]=la.y,ba[K+10]=la.z,ba[K+11]=la.w,ba[K+12]=Q.x,ba[K+13]=Q.y,ba[K+14]=Q.z,ba[K+15]=Q.w,K+=16;e.bindBuffer(e.ARRAY_BUFFER,v.__webglTangentBuffer);
-e.bufferData(e.ARRAY_BUFFER,ba,y)}if(N&&t){m=0;for(q=M.length;m<q;m++)if(u=aa[M[m]],ba=u.vertexNormals,N=u.normal,ba.length===3&&P)for(K=0;K<3;K++)N=ba[K],T[H]=N.x,T[H+1]=N.y,T[H+2]=N.z,H+=3;else for(K=0;K<3;K++)T[H]=N.x,T[H+1]=N.y,T[H+2]=N.z,H+=3;m=0;for(q=Y.length;m<q;m++)if(u=aa[Y[m]],ba=u.vertexNormals,N=u.normal,ba.length===4&&P)for(K=0;K<4;K++)N=ba[K],T[H]=N.x,T[H+1]=N.y,T[H+2]=N.z,H+=3;else for(K=0;K<4;K++)T[H]=N.x,T[H+1]=N.y,T[H+2]=N.z,H+=3;e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);
-e.bufferData(e.ARRAY_BUFFER,T,y)}if(ua&&qa&&O){m=0;for(q=M.length;m<q;m++)if(H=M[m],H=qa[H],H!==void 0)for(K=0;K<3;K++)T=H[K],Z[V]=T.u,Z[V+1]=T.v,V+=2;m=0;for(q=Y.length;m<q;m++)if(H=Y[m],H=qa[H],H!==void 0)for(K=0;K<4;K++)T=H[K],Z[V]=T.u,Z[V+1]=T.v,V+=2;V>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Z,y))}if(ua&&sa&&O){m=0;for(q=M.length;m<q;m++)if(H=M[m],V=sa[H],V!==void 0)for(K=0;K<3;K++)Z=V[K],r[ja]=Z.u,r[ja+1]=Z.v,ja+=2;m=0;for(q=Y.length;m<q;m++)if(H=Y[m],V=
-sa[H],V!==void 0)for(K=0;K<4;K++)Z=V[K],r[ja]=Z.u,r[ja+1]=Z.v,ja+=2;ja>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,r,y))}if(ra){m=0;for(q=M.length;m<q;m++)o[ha]=L,o[ha+1]=L+1,o[ha+2]=L+2,ha+=3,ga[ca]=L,ga[ca+1]=L+1,ga[ca+2]=L,ga[ca+3]=L+2,ga[ca+4]=L+1,ga[ca+5]=L+2,ca+=6,L+=3;m=0;for(q=Y.length;m<q;m++)o[ha]=L,o[ha+1]=L+1,o[ha+2]=L+3,o[ha+3]=L+1,o[ha+4]=L+2,o[ha+5]=L+3,ha+=6,ga[ca]=L,ga[ca+1]=L+1,ga[ca+2]=L,ga[ca+3]=L+3,ga[ca+4]=L+1,ga[ca+5]=L+2,ga[ca+6]=L+2,ga[ca+
-7]=L+3,ca+=8,L+=4;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,o,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ga,y)}if(J){K=0;for(L=J.length;K<L;K++)if(o=J[K],o.__original.needsUpdate){r=0;if(o.size===1)if(o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],o.array[r]=o.value[u.a],o.array[r+1]=o.value[u.b],o.array[r+2]=o.value[u.c],r+=3;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],
-o.array[r]=o.value[u.a],o.array[r+1]=o.value[u.b],o.array[r+2]=o.value[u.c],o.array[r+3]=o.value[u.d],r+=4}else{if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)ga=o.value[M[m]],o.array[r]=ga,o.array[r+1]=ga,o.array[r+2]=ga,r+=3;m=0;for(q=Y.length;m<q;m++)ga=o.value[Y[m]],o.array[r]=ga,o.array[r+1]=ga,o.array[r+2]=ga,o.array[r+3]=ga,r+=4}}else if(o.size===2)if(o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],o.array[r]=
-z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,r+=6;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,o.array[r+6]=u.x,o.array[r+7]=u.y,r+=8}else{if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+
-5]=B.y,r+=6;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,o.array[r+6]=u.x,o.array[r+7]=u.y,r+=8}}else if(o.size===3)if(t=o.type==="c"?["r","g","b"]:["x","y","z"],o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+
-5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],r+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],o.array[r+9]=u[t[0]],o.array[r+10]=u[t[1]],o.array[r+11]=u[t[2]],r+=12}else{if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],
-o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],r+=9;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],o.array[r+9]=u[t[0]],o.array[r+10]=u[t[1]],o.array[r+11]=u[t[2]],r+=12}}else if(o.size===
-4)if(o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,r+=12;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=
-z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,o.array[r+12]=u.x,o.array[r+13]=u.y,o.array[r+14]=u.z,o.array[r+15]=u.w,r+=16}else if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,
-r+=12;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,o.array[r+12]=u.x,o.array[r+13]=u.y,o.array[r+14]=u.z,o.array[r+15]=u.w,r+=16}e.bindBuffer(e.ARRAY_BUFFER,o.buffer);e.bufferData(e.ARRAY_BUFFER,o.array,y)}}C&&(delete v.__inittedArrays,delete v.__colorArray,delete v.__normalArray,delete v.__tangentArray,
-delete v.__uvArray,delete v.__uv2Array,delete v.__faceArray,delete v.__vertexArray,delete v.__lineArray,delete v.__skinVertexAArray,delete v.__skinVertexBArray,delete v.__skinIndexArray,delete v.__skinWeightArray)}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=!1;l.attributes&&w(l)}else if(ka instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){l=k;ka=e.DYNAMIC_DRAW;t=F=t=C=C=void 0;D=l.vertices;
-G=l.colors;m=D.length;v=G.length;q=l.__vertexArray;y=l.__colorArray;J=l.__dirtyColors;if(l.__dirtyVertices){for(C=0;C<m;C++)t=D[C].position,F=C*3,q[F]=t.x,q[F+1]=t.y,q[F+2]=t.z;e.bindBuffer(e.ARRAY_BUFFER,l.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,q,ka)}if(J){for(C=0;C<v;C++)t=G[C],F=C*3,y[F]=t.r,y[F+1]=t.g,y[F+2]=t.b;e.bindBuffer(e.ARRAY_BUFFER,l.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,y,ka)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(ka instanceof THREE.Line){l=d(ka,v);y=l.attributes&&
-s(l);if(k.__dirtyVertices||k.__dirtyColors||y){ka=k;F=e.DYNAMIC_DRAW;m=G=P=D=O=void 0;D=ka.vertices;v=ka.colors;m=D.length;y=v.length;q=ka.__vertexArray;C=ka.__colorArray;J=ka.__dirtyColors;t=ka.__webglCustomAttributesList;L=aa=Y=M=P=O=void 0;if(ka.__dirtyVertices){for(O=0;O<m;O++)P=D[O].position,G=O*3,q[G]=P.x,q[G+1]=P.y,q[G+2]=P.z;e.bindBuffer(e.ARRAY_BUFFER,ka.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,q,F)}if(J){for(D=0;D<y;D++)m=v[D],G=D*3,C[G]=m.r,C[G+1]=m.g,C[G+2]=m.b;e.bindBuffer(e.ARRAY_BUFFER,
-ka.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,C,F)}if(t){O=0;for(P=t.length;O<P;O++)if(L=t[O],L.needsUpdate&&(L.boundTo===void 0||L.boundTo==="vertices")){G=0;Y=L.value.length;if(L.size===1)for(M=0;M<Y;M++)L.array[M]=L.value[M];else if(L.size===2)for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+1]=aa.y,G+=2;else if(L.size===3)if(L.type==="c")for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.r,L.array[G+1]=aa.g,L.array[G+2]=aa.b,G+=3;else for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+
-1]=aa.y,L.array[G+2]=aa.z,G+=3;else if(L.size===4)for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+1]=aa.y,L.array[G+2]=aa.z,L.array[G+3]=aa.w,G+=4;e.bindBuffer(e.ARRAY_BUFFER,L.buffer);e.bufferData(e.ARRAY_BUFFER,L.array,F)}}}k.__dirtyVertices=!1;k.__dirtyColors=!1;l.attributes&&w(l)}else if(ka instanceof THREE.ParticleSystem)l=d(ka,v),y=l.attributes&&s(l),(k.__dirtyVertices||k.__dirtyColors||ka.sortParticles||y)&&h(k,e.DYNAMIC_DRAW,ka),k.__dirtyVertices=!1,k.__dirtyColors=!1,l.attributes&&
-w(l)};this.initMaterial=function(a,b,c,d){var f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(j.uniforms);a.vertexShader=j.vertexShader;
-a.fragmentShader=j.fragmentShader}var k,l,n;k=n=j=0;for(l=b.length;k<l;k++)h=b[k],h instanceof THREE.SpotLight&&n++,h instanceof THREE.DirectionalLight&&n++,h instanceof THREE.PointLight&&j++;j+n<=va?k=n:(k=Math.ceil(va*n/(j+n)),j=va-k);h={directional:k,point:j};j=n=0;for(k=b.length;j<k;j++)l=b[j],l instanceof THREE.SpotLight&&l.castShadow&&n++;var m=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)m=d.bones.length;var q;a:{k=a.fragmentShader;l=a.vertexShader;var j=a.uniforms,b=a.attributes,c={map:!!a.map,
-envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:m,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},p,d=
-[];i?d.push(i):(d.push(k),d.push(l));for(p in c)d.push(p),d.push(c[p]);i=d.join();p=0;for(d=ya.length;p<d;p++)if(ya[p].code===i){q=ya[p].program;break a}p=e.createProgram();d=[Ma?"#define VERTEX_TEXTURES":"",I.gammaInput?"#define GAMMA_INPUT":"",I.gammaOutput?"#define GAMMA_OUTPUT":"",I.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,
-c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-h=["precision "+ua+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",I.gammaInput?"#define GAMMA_INPUT":"",I.gammaOutput?"#define GAMMA_OUTPUT":"",I.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
+a.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,k,b);if(l){i=0;for(j=l.length;i<j;i++)if(v=l[i],v.needsUpdate||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,v.buffer),e.bufferData(e.ARRAY_BUFFER,v.array,b)}}function i(a,b){return b.z-a.z}function l(a,b,d){if(a.length)for(var c=0,e=a.length;c<e;c++)T=null,I=R=wa=oa=sa=-1,a[c].render(b,d,Ja,Ka),T=null,I=R=wa=oa=sa=-1}function k(a,b,d,c,e,f,g,h){var i,j,t,k;b?(j=a.length-1,k=b=-1):(j=0,b=a.length,k=1);for(var m=j;m!==b;m+=k)if(i=a[m],i.render){j=i.object;
+t=i.buffer;if(h)i=h;else{i=i[d];if(!i)continue;g&&H.setBlending(i.blending);H.setDepthTest(i.depthTest);P(i.depthWrite);Q(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}H.setObjectFaces(j);t instanceof THREE.BufferGeometry?H.renderBufferDirect(c,e,f,i,t,j):H.renderBuffer(c,e,f,i,t,j)}}function j(a,b,d,c,e,f,g){for(var h,i,j=0,k=a.length;j<k;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&H.setBlending(h.blending);H.setDepthTest(h.depthTest);P(h.depthWrite);
+Q(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}H.renderImmediateObject(d,c,e,h,i)}}function p(a,b,d){a.push({buffer:b,object:d,opaque:null,transparent:null})}function s(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function w(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function n(a,b){for(var d=a.length-1;d>=0;d--)a[d].object===b&&a.splice(d,1)}function E(a,b){for(var d=a.length-1;d>=0;d--)a[d]===b&&a.splice(d,1)}function y(a,b,d,c,f){c.program||
+H.initMaterial(c,b,d,f);if(c.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(H.maxMorphTargets);for(var g=0,h=H.maxMorphTargets;g<h;g++)f.__webglMorphTargetInfluences[g]=0}var i=!1,g=c.program,h=g.uniforms,j=c.uniforms;g!==T&&(e.useProgram(g),T=g,i=!0);if(c.id!==I)I=c.id,i=!0;if(i){e.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray);if(d&&c.fog)if(j.fogColor.value=d.color,d instanceof THREE.Fog)j.fogNear.value=d.near,j.fogFar.value=d.far;
+else if(d instanceof THREE.FogExp2)j.fogDensity.value=d.density;if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c.lights){for(var k,t,n=0,m=0,q=0,l,p,s=La,w=s.directional.colors,E=s.directional.positions,y=s.point.colors,u=s.point.positions,D=s.point.distances,J=0,x=0,U=p=0,d=0,i=b.length;d<i;d++)if(k=b[d],t=k.color,l=k.intensity,p=k.distance,k instanceof THREE.AmbientLight)H.gammaInput?(n+=t.r*t.r,m+=t.g*t.g,q+=t.b*t.b):(n+=t.r,m+=t.g,q+=t.b);else if(k instanceof
+THREE.DirectionalLight)p=J*3,H.gammaInput?(w[p]=t.r*t.r*l*l,w[p+1]=t.g*t.g*l*l,w[p+2]=t.b*t.b*l*l):(w[p]=t.r*l,w[p+1]=t.g*l,w[p+2]=t.b*l),k=k.matrixWorld.getPosition(),t=1/k.length(),E[p]=k.x*t,E[p+1]=k.y*t,E[p+2]=k.z*t,J+=1;else if(k instanceof THREE.SpotLight)p=J*3,H.gammaInput?(w[p]=t.r*t.r*l*l,w[p+1]=t.g*t.g*l*l,w[p+2]=t.b*t.b*l*l):(w[p]=t.r*l,w[p+1]=t.g*l,w[p+2]=t.b*l),k=k.matrixWorld.getPosition(),t=1/k.length(),E[p]=k.x*t,E[p+1]=k.y*t,E[p+2]=k.z*t,J+=1;else if(k instanceof THREE.PointLight)U=
+x*3,H.gammaInput?(y[U]=t.r*t.r*l*l,y[U+1]=t.g*t.g*l*l,y[U+2]=t.b*t.b*l*l):(y[U]=t.r*l,y[U+1]=t.g*l,y[U+2]=t.b*l),k=k.matrixWorld.getPosition(),u[U]=k.x,u[U+1]=k.y,u[U+2]=k.z,D[x]=p,x+=1;d=J*3;for(i=w.length;d<i;d++)w[d]=0;d=x*3;for(i=y.length;d<i;d++)y[d]=0;s.point.length=x;s.directional.length=J;s.ambient[0]=n;s.ambient[1]=m;s.ambient[2]=q;b=La;j.ambientLightColor.value=b.ambient;j.directionalLightColor.value=b.directional.colors;j.directionalLightDirection.value=b.directional.positions;j.pointLightColor.value=
+b.point.colors;j.pointLightPosition.value=b.point.positions;j.pointLightDistance.value=b.point.distances}if(c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial)j.opacity.value=c.opacity,H.gammaInput?j.diffuse.value.copyGammaToLinear(c.color):j.diffuse.value=c.color,(j.map.texture=c.map)&&j.offsetRepeat.value.set(c.map.offset.x,c.map.offset.y,c.map.repeat.x,c.map.repeat.y),j.lightMap.texture=c.lightMap,j.envMap.texture=c.envMap,j.flipEnvMap.value=
+c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,j.reflectivity.value=c.reflectivity,j.refractionRatio.value=c.refractionRatio,j.combine.value=c.combine,j.useRefract.value=c.envMap&&c.envMap.mapping instanceof THREE.CubeRefractionMapping;if(c instanceof THREE.LineBasicMaterial)j.diffuse.value=c.color,j.opacity.value=c.opacity;else if(c instanceof THREE.ParticleBasicMaterial)j.psColor.value=c.color,j.opacity.value=c.opacity,j.size.value=c.size,j.scale.value=ma.height/2,j.map.texture=c.map;else if(c instanceof
+THREE.MeshPhongMaterial)j.shininess.value=c.shininess,H.gammaInput?(j.ambient.value.copyGammaToLinear(c.ambient),j.specular.value.copyGammaToLinear(c.specular)):(j.ambient.value=c.ambient,j.specular.value=c.specular);else if(c instanceof THREE.MeshLambertMaterial)H.gammaInput?j.ambient.value.copyGammaToLinear(c.ambient):j.ambient.value=c.ambient;else if(c instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=c.opacity;else if(c instanceof THREE.MeshNormalMaterial)j.opacity.value=
+c.opacity;if(f.receiveShadow&&!c._shadowPass&&j.shadowMatrix){for(b=0;b<H.shadowMapPlugin.shadowMatrix.length;b++)j.shadowMatrix.value[b]=H.shadowMapPlugin.shadowMatrix[b],j.shadowMap.texture[b]=H.shadowMapPlugin.shadowMap[b];j.shadowDarkness.value=H.shadowMapDarkness;j.shadowBias.value=H.shadowMapBias}b=c.uniformsList;j=0;for(d=b.length;j<d;j++)if(m=g.uniforms[b[j][1]])if(n=b[j][0],q=n.type,i=n.value,q==="i")e.uniform1i(m,i);else if(q==="f")e.uniform1f(m,i);else if(q==="v2")e.uniform2f(m,i.x,i.y);
+else if(q==="v3")e.uniform3f(m,i.x,i.y,i.z);else if(q==="v4")e.uniform4f(m,i.x,i.y,i.z,i.w);else if(q==="c")e.uniform3f(m,i.r,i.g,i.b);else if(q==="fv1")e.uniform1fv(m,i);else if(q==="fv")e.uniform3fv(m,i);else if(q==="v3v"){if(!n._array)n._array=new Float32Array(3*i.length);q=0;for(s=i.length;q<s;q++)w=q*3,n._array[w]=i[q].x,n._array[w+1]=i[q].y,n._array[w+2]=i[q].z;e.uniform3fv(m,n._array)}else if(q==="m4"){if(!n._array)n._array=new Float32Array(16);i.flattenToArray(n._array);e.uniformMatrix4fv(m,
+!1,n._array)}else if(q==="m4v"){if(!n._array)n._array=new Float32Array(16*i.length);q=0;for(s=i.length;q<s;q++)i[q].flattenToArrayOffset(n._array,q*16);e.uniformMatrix4fv(m,!1,n._array)}else if(q==="t"){if(e.uniform1i(m,i),m=n.texture)if(m.image instanceof Array&&m.image.length===6){if(n=m,n.image.length===6)if(n.needsUpdate){if(!n.image.__webglTextureCube)n.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+i);e.bindTexture(e.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);i=C(e.TEXTURE_CUBE_MAP,
+n,n.image[0]);for(m=0;m<6;m++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image[m]);i&&e.generateMipmap(e.TEXTURE_CUBE_MAP);n.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(n=m,e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture)):H.setTexture(m,i)}else if(q==="tv"){if(!n._array){n._array=[];q=0;for(s=n.texture.length;q<s;q++)n._array[q]=
+i+q}e.uniform1iv(m,n._array);q=0;for(s=n.texture.length;q<s;q++)(m=n.texture[q])&&H.setTexture(m,n._array[q])}(c instanceof THREE.ShaderMaterial||c instanceof THREE.MeshPhongMaterial||c.envMap)&&h.cameraPosition!==null&&e.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.ShaderMaterial||c.skinning)&&h.viewMatrix!==null&&e.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);c.skinning&&
+(e.uniformMatrix4fv(h.cameraInverseMatrix,!1,a._viewMatrixArray),e.uniformMatrix4fv(h.boneGlobalMatrices,!1,f.boneMatrices))}e.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray);h.normalMatrix&&e.uniformMatrix3fv(h.normalMatrix,!1,f._normalMatrixArray);(c instanceof THREE.ShaderMaterial||c.envMap||c.skinning||f.receiveShadow)&&h.objectMatrix!==null&&e.uniformMatrix4fv(h.objectMatrix,!1,f._objectMatrixArray);return g}function J(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,
+a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function P(a){wa!==a&&(e.depthMask(a),wa=a)}function Q(a,b,c){Ca!==a&&(a?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),Ca=a);if(a&&(za!==b||Aa!==c))e.polygonOffset(b,c),za=b,Aa=c}function V(a,b){var c;a==="fragment"?c=e.createShader(e.FRAGMENT_SHADER):a==="vertex"&&(c=e.createShader(e.VERTEX_SHADER));e.shaderSource(c,b);e.compileShader(c);if(!e.getShaderParameter(c,
+e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(c)),console.error(b),null;return c}function C(a,b,c){return(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(e.texParameteri(a,e.TEXTURE_WRAP_S,O(b.wrapS)),e.texParameteri(a,e.TEXTURE_WRAP_T,O(b.wrapT)),e.texParameteri(a,e.TEXTURE_MAG_FILTER,O(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,O(b.minFilter)),!0):(e.texParameteri(a,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_MAG_FILTER,
+N(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,N(b.minFilter)),!1)}function D(a,b){e.bindRenderbuffer(e.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,a)):
+e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height)}function N(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function O(a){switch(a){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;
+case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;
+case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var a=a||{},ma=a.canvas!==void 0?a.canvas:document.createElement("canvas"),ua=a.precision!==void 0?a.precision:"mediump",ha=a.antialias!==void 0?a.antialias:!1,ca=a.stencil!==void 0?a.stencil:!0,pa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ja=a.clearColor!==void 0?
+new THREE.Color(a.clearColor):new THREE.Color(0),xa=a.clearAlpha!==void 0?a.clearAlpha:0,va=a.maxLights!==void 0?a.maxLights:4;this.domElement=ma;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=
+5E3;this.shadowCameraFov=50;this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var H=this,e,ya=[],T=null,qa=null,I=-1,R=null,na=0,ra=null,Z=null,sa=null,oa=null,wa=null,Ca=null,za=null,Aa=null,ta=null,Ea=0,Fa=0,Ga=0,Ha=0,Ja=0,Ka=0,Ia=new THREE.Frustum,Da=new THREE.Matrix4,Ba=new THREE.Vector4,La={ambient:[0,
+0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};e=function(){var a;try{if(!(a=ma.getContext("experimental-webgl",{antialias:ha,stencil:ca,preserveDrawingBuffer:pa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();e.clearColor(0,0,0,1);e.clearDepth(1);
+e.clearStencil(0);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(ja.r,ja.g,ja.b,xa);this.context=e;var Ma=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return e};this.supportsVertexTextures=function(){return Ma};this.setSize=function(a,b){ma.width=a;ma.height=b;this.setViewport(0,0,ma.width,ma.height)};this.setViewport=
+function(a,b,c,d){Ea=a;Fa=b;Ga=c;Ha=d;e.viewport(Ea,Fa,Ga,Ha)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){ja.setHex(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.setClearColor=function(a,b){ja.copy(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.getClearColor=function(){return ja};this.getClearAlpha=function(){return xa};this.clear=function(a,b,c){var d=0;if(a===void 0||
+a)d|=e.COLOR_BUFFER_BIT;if(b===void 0||b)d|=e.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,
+a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);
+e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d<f;d++)e.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)e.deleteBuffer(c.__webglCustomAttributesList[d].buffer);H.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,
+e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,e.deleteTexture(a.__webglTexture),H.info.memory.textures--};this.updateShadowMap=function(a,b){T=null;I=R=wa=oa=sa=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=
+function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=e.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=e.createBuffer();a.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,a.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(b.attributes.position),e.vertexAttribPointer(b.attributes.position,3,e.FLOAT,!1,0,0));if(a.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,f,g,h,i,j,n,k,l,m,q=a.count*
+3;for(m=0;m<q;m+=9)c=a.normalArray,d=c[m],f=c[m+1],g=c[m+2],h=c[m+3],j=c[m+4],k=c[m+5],i=c[m+6],n=c[m+7],l=c[m+8],d=(d+h+i)/3,f=(f+j+n)/3,g=(g+k+l)/3,c[m]=d,c[m+1]=f,c[m+2]=g,c[m+3]=d,c[m+4]=f,c[m+5]=g,c[m+6]=d,c[m+7]=f,c[m+8]=g}e.bufferData(e.ARRAY_BUFFER,a.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(b.attributes.normal);e.vertexAttribPointer(b.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,f,g){if(d.opacity!==
+0&&(c=y(a,b,c,d,g),a=c.attributes,b=!1,d=f.id*16777215+c.id*2+(d.wireframe?1:0),d!==R&&(R=d,b=!0),g instanceof THREE.Mesh)){d=f.offsets;for(g=0;g<d.length;++g)b&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexPositionBuffer),e.vertexAttribPointer(a.position,f.vertexPositionBuffer.itemSize,e.FLOAT,!1,0,d[g].index*12),a.normal>=0&&f.vertexNormalBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexNormalBuffer),e.vertexAttribPointer(a.normal,f.vertexNormalBuffer.itemSize,e.FLOAT,!1,0,d[g].index*12)),a.uv>=0&&f.vertexUvBuffer&&
+(f.vertexUvBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.vertexUvBuffer),e.vertexAttribPointer(a.uv,f.vertexUvBuffer.itemSize,e.FLOAT,!1,0,d[g].index*8),e.enableVertexAttribArray(a.uv)):e.disableVertexAttribArray(a.uv)),a.color>=0&&f.vertexColorBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexColorBuffer),e.vertexAttribPointer(a.color,f.vertexColorBuffer.itemSize,e.FLOAT,!1,0,d[g].index*16)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.vertexIndexBuffer)),e.drawElements(e.TRIANGLES,d[g].count,e.UNSIGNED_SHORT,d[g].start*
+2),H.info.render.calls++,H.info.render.vertices+=d[g].count,H.info.render.faces+=d[g].count/3}};this.renderBuffer=function(a,b,c,d,f,g){if(d.opacity!==0){var h,i,c=y(a,b,c,d,g),b=c.attributes,a=!1,c=f.id*16777215+c.id*2+(d.wireframe?1:0);c!==R&&(R=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),
+e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j[h]]),e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],n=-1,
+k=0;i=g.morphTargetInfluences;var l,m=i.length;h=0;for(g.morphTargetBase!==-1&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(l=0;l<m;l++)!j[l]&&i[l]>n&&(k=l,n=i[k]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=n;j[k]=1;n=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h=
+0;for(i=f.__webglCustomAttributesList.length;h<i;h++)c=f.__webglCustomAttributesList[h],b[c.buffer.belongsToAttribute]>=0&&(e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0))}b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER,
+f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=
+0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?
+(d=d.wireframeLinewidth,d!==ta&&(e.lineWidth(d),ta=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),H.info.render.calls++,H.info.render.vertices+=f.__webglFaceCount,H.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==
+ta&&(e.lineWidth(d),ta=d),e.drawArrays(g,0,f.__webglLineCount),H.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),H.info.render.calls++,H.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),H.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,h,n,p=a.lights,s=a.fog;I=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();l(this.renderPluginsPre,a,b);H.info.render.calls=0;H.info.render.vertices=0;H.info.render.faces=0;H.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Da.multiply(b.projectionMatrix,
+b.matrixWorldInverse);Ia.setFromMatrix(Da);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(f=n.length;d<f;d++)if(g=n[d],h=g.object,g.render=!1,h.visible&&(!(h instanceof THREE.Mesh||h instanceof THREE.ParticleSystem)||!h.frustumCulled||Ia.contains(h))){h.matrixWorld.flattenToArray(h._objectMatrixArray);J(h,b);var t=g,w=t.object,m=t.buffer,q=void 0,q=q=void 0,q=w.material;if(q instanceof THREE.MeshFaceMaterial){if(q=
+m.materialIndex,q>=0)q=w.geometry.materials[q],q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null)}else if(q)q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Ba.copy(h.position),Da.multiplyVector3(Ba),g.z=Ba.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(f=n.length;d<f;d++)if(g=n[d],h=g.object,h.visible)h.matrixAutoUpdate&&h.matrixWorld.flattenToArray(h._objectMatrixArray),
+J(h,b),h=g.object.material,h.transparent?(g.transparent=h,g.opaque=null):(g.opaque=h,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),P(a.overrideMaterial.depthWrite),Q(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,p,s,!0,a.overrideMaterial),j(a.__webglObjectsImmediate,"",b,p,s,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
+k(a.__webglObjects,!0,"opaque",b,p,s,!1),j(a.__webglObjectsImmediate,"opaque",b,p,s,!1),k(a.__webglObjects,!1,"transparent",b,p,s,!0),j(a.__webglObjectsImmediate,"transparent",b,p,s,!0));l(this.renderPluginsPost,a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,c.__webglTexture),
+e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,f){var g=y(a,b,c,d,f);R=-1;H.setObjectFaces(f);f.immediateRenderCallback?f.immediateRenderCallback(g,e,Ia):f.render(function(a){H.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var i=a.__objectsAdded[0],j=a,k=void 0,l=void 0,
+F=void 0;if(!i.__webglInit)if(i.__webglInit=!0,i._modelViewMatrix=new THREE.Matrix4,i._normalMatrixArray=new Float32Array(9),i._modelViewMatrixArray=new Float32Array(16),i._objectMatrixArray=new Float32Array(16),i.matrixWorld.flattenToArray(i._objectMatrixArray),i instanceof THREE.Mesh){if(l=i.geometry,l instanceof THREE.Geometry){if(l.geometryGroups===void 0){var F=l,G=void 0,v=void 0,y=void 0,C=void 0,t=void 0,D=void 0,m=void 0,q={},J=F.morphTargets.length;F.geometryGroups={};G=0;for(v=F.faces.length;G<
+v;G++)y=F.faces[G],C=y.materialIndex,D=C!==void 0?C:-1,q[D]===void 0&&(q[D]={hash:D,counter:0}),m=q[D].hash+"_"+q[D].counter,F.geometryGroups[m]===void 0&&(F.geometryGroups[m]={faces3:[],faces4:[],materialIndex:C,vertices:0,numMorphTargets:J}),t=y instanceof THREE.Face3?3:4,F.geometryGroups[m].vertices+t>65535&&(q[D].counter+=1,m=q[D].hash+"_"+q[D].counter,F.geometryGroups[m]===void 0&&(F.geometryGroups[m]={faces3:[],faces4:[],materialIndex:C,vertices:0,numMorphTargets:J})),y instanceof THREE.Face3?
+F.geometryGroups[m].faces3.push(G):F.geometryGroups[m].faces4.push(G),F.geometryGroups[m].vertices+=t;F.geometryGroupsList=[];G=void 0;for(G in F.geometryGroups)F.geometryGroups[G].id=na++,F.geometryGroupsList.push(F.geometryGroups[G])}for(k in l.geometryGroups)if(F=l.geometryGroups[k],!F.__webglVertexBuffer){G=F;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer();G.__webglTangentBuffer=e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();
+G.__webglUV2Buffer=e.createBuffer();G.__webglSkinVertexABuffer=e.createBuffer();G.__webglSkinVertexBBuffer=e.createBuffer();G.__webglSkinIndicesBuffer=e.createBuffer();G.__webglSkinWeightsBuffer=e.createBuffer();G.__webglFaceBuffer=e.createBuffer();G.__webglLineBuffer=e.createBuffer();if(G.numMorphTargets){y=v=void 0;G.__webglMorphTargetsBuffers=[];v=0;for(y=G.numMorphTargets;v<y;v++)G.__webglMorphTargetsBuffers.push(e.createBuffer())}H.info.memory.geometries++;C=i;t=C.geometry;v=F.faces3;D=F.faces4;
+G=v.length*3+D.length*4;y=v.length*1+D.length*2;D=v.length*3+D.length*4;v=d(C,F);m=g(v);q=c(v);J=f(v);F.__vertexArray=new Float32Array(G*3);if(q)F.__normalArray=new Float32Array(G*3);if(t.hasTangents)F.__tangentArray=new Float32Array(G*4);if(J)F.__colorArray=new Float32Array(G*3);if(m){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)F.__uvArray=new Float32Array(G*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)F.__uv2Array=new Float32Array(G*2)}if(C.geometry.skinWeights.length&&C.geometry.skinIndices.length)F.__skinVertexAArray=
+new Float32Array(G*4),F.__skinVertexBArray=new Float32Array(G*4),F.__skinIndexArray=new Float32Array(G*4),F.__skinWeightArray=new Float32Array(G*4);F.__faceArray=new Uint16Array(y*3);F.__lineArray=new Uint16Array(D*2);if(F.numMorphTargets){F.__morphTargetsArrays=[];C=0;for(t=F.numMorphTargets;C<t;C++)F.__morphTargetsArrays.push(new Float32Array(G*3))}F.__webglFaceCount=y*3;F.__webglLineCount=D*2;if(v.attributes){if(F.__webglCustomAttributesList===void 0)F.__webglCustomAttributesList=[];y=void 0;for(y in v.attributes){var C=
+v.attributes[y],t={},ka;for(ka in C)t[ka]=C[ka];if(!t.__webglInitialized||t.createUniqueBuffers)t.__webglInitialized=!0,D=1,t.type==="v2"?D=2:t.type==="v3"?D=3:t.type==="v4"?D=4:t.type==="c"&&(D=3),t.size=D,t.array=new Float32Array(G*D),t.buffer=e.createBuffer(),t.buffer.belongsToAttribute=y,C.needsUpdate=!0,t.__original=C;F.__webglCustomAttributesList.push(t)}}F.__inittedArrays=!0;l.__dirtyVertices=!0;l.__dirtyMorphTargets=!0;l.__dirtyElements=!0;l.__dirtyUvs=!0;l.__dirtyNormals=!0;l.__dirtyTangents=
+!0;l.__dirtyColors=!0}}}else if(i instanceof THREE.Ribbon){if(l=i.geometry,!l.__webglVertexBuffer)F=l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=e.createBuffer(),H.info.memory.geometries++,F=l,G=F.vertices.length,F.__vertexArray=new Float32Array(G*3),F.__colorArray=new Float32Array(G*3),F.__webglVertexCount=G,l.__dirtyVertices=!0,l.__dirtyColors=!0}else if(i instanceof THREE.Line){if(l=i.geometry,!l.__webglVertexBuffer)F=l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=
+e.createBuffer(),H.info.memory.geometries++,F=l,G=i,v=F.vertices.length,F.__vertexArray=new Float32Array(v*3),F.__colorArray=new Float32Array(v*3),F.__webglLineCount=v,b(F,G),l.__dirtyVertices=!0,l.__dirtyColors=!0}else if(i instanceof THREE.ParticleSystem&&(l=i.geometry,!l.__webglVertexBuffer))F=l,F.__webglVertexBuffer=e.createBuffer(),F.__webglColorBuffer=e.createBuffer(),H.info.geometries++,F=l,G=i,v=F.vertices.length,F.__vertexArray=new Float32Array(v*3),F.__colorArray=new Float32Array(v*3),F.__sortArray=
+[],F.__webglParticleCount=v,b(F,G),l.__dirtyVertices=!0,l.__dirtyColors=!0;if(!i.__webglActive){if(i instanceof THREE.Mesh)if(l=i.geometry,l instanceof THREE.BufferGeometry)p(j.__webglObjects,l,i);else for(k in l.geometryGroups)F=l.geometryGroups[k],p(j.__webglObjects,F,i);else i instanceof THREE.Ribbon||i instanceof THREE.Line||i instanceof THREE.ParticleSystem?(l=i.geometry,p(j.__webglObjects,l,i)):THREE.MarchingCubes!==void 0&&i instanceof THREE.MarchingCubes||i.immediateRenderCallback?j.__webglObjectsImmediate.push({object:i,
+opaque:null,transparent:null}):i instanceof THREE.Sprite?j.__webglSprites.push(i):i instanceof THREE.LensFlare&&j.__webglFlares.push(i);i.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;)i=a.__objectsRemoved[0],j=a,i instanceof THREE.Mesh||i instanceof THREE.ParticleSystem||i instanceof THREE.Ribbon||i instanceof THREE.Line?n(j.__webglObjects,i):i instanceof THREE.Sprite?E(j.__webglSprites,i):i instanceof THREE.LensFlare?E(j.__webglFlares,i):(i instanceof THREE.MarchingCubes||
+i.immediateRenderCallback)&&n(j.__webglObjectsImmediate,i),i.__webglActive=!1,a.__objectsRemoved.splice(0,1);i=0;for(j=a.__webglObjects.length;i<j;i++)if(ka=a.__webglObjects[i].object,k=ka.geometry,l=y=v=void 0,ka instanceof THREE.Mesh)if(k instanceof THREE.BufferGeometry)k.__dirtyVertices=!1,k.__dirtyElements=!1,k.__dirtyUvs=!1,k.__dirtyNormals=!1,k.__dirtyColors=!1;else{F=0;for(G=k.geometryGroupsList.length;F<G;F++)if(v=k.geometryGroupsList[F],l=d(ka,v),y=l.attributes&&s(l),k.__dirtyVertices||k.__dirtyMorphTargets||
+k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||y){var M=ka,y=e.DYNAMIC_DRAW,C=!k.dynamic,m=l;if(v.__inittedArrays){var t=c(m),D=f(m),O=g(m),P=t===THREE.SmoothShading,I=q=m=void 0,u=void 0,ba=void 0,N=void 0,x=void 0,U=void 0,Q=void 0,V=I=void 0,z=void 0,A=void 0,B=void 0,da=u=void 0,ea=void 0,la=void 0,W=u=Q=void 0,X=void 0,R=B=A=z=x=void 0,K=u=B=A=z=R=B=A=z=R=B=A=z=void 0,L=void 0,T=N=void 0,Z=void 0,$=void 0,ma=void 0,fa=void 0,ja=V=$=L=0,ha=0,ca=K=I=0,S=
+x=da=0,r=0,ga=void 0,S=v.__vertexArray,Z=v.__uvArray,r=v.__uv2Array,T=v.__normalArray,ba=v.__tangentArray,ea=v.__colorArray,W=v.__skinVertexAArray,X=v.__skinVertexBArray,U=v.__skinIndexArray,ia=v.__skinWeightArray,R=v.__morphTargetsArrays,J=v.__webglCustomAttributesList,o=void 0,o=v.__faceArray,ga=v.__lineArray,la=M.geometry,ra=la.__dirtyElements,ua=la.__dirtyUvs,N=la.__dirtyNormals,Q=la.__dirtyTangents,xa=la.__dirtyColors,ma=la.__dirtyMorphTargets,fa=la.vertices,M=v.faces3,Y=v.faces4,aa=la.faces,
+qa=la.faceVertexUvs[0],sa=la.faceVertexUvs[1],oa=la.skinVerticesA,pa=la.skinVerticesB,va=la.skinIndices,ta=la.skinWeights,wa=la.morphTargets;if(la.__dirtyVertices){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=fa[u.a].position,A=fa[u.b].position,B=fa[u.c].position,S[$]=z.x,S[$+1]=z.y,S[$+2]=z.z,S[$+3]=A.x,S[$+4]=A.y,S[$+5]=A.z,S[$+6]=B.x,S[$+7]=B.y,S[$+8]=B.z,$+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=fa[u.a].position,A=fa[u.b].position,B=fa[u.c].position,u=fa[u.d].position,S[$]=z.x,S[$+1]=z.y,S[$+2]=
+z.z,S[$+3]=A.x,S[$+4]=A.y,S[$+5]=A.z,S[$+6]=B.x,S[$+7]=B.y,S[$+8]=B.z,S[$+9]=u.x,S[$+10]=u.y,S[$+11]=u.z,$+=12;e.bindBuffer(e.ARRAY_BUFFER,v.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,S,y)}if(ma){$=0;for(ma=wa.length;$<ma;$++){m=S=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=wa[$].vertices[u.a].position,A=wa[$].vertices[u.b].position,B=wa[$].vertices[u.c].position,fa=R[$],fa[S]=z.x,fa[S+1]=z.y,fa[S+2]=z.z,fa[S+3]=A.x,fa[S+4]=A.y,fa[S+5]=A.z,fa[S+6]=B.x,fa[S+7]=B.y,fa[S+8]=B.z,S+=9;m=0;for(q=Y.length;m<
+q;m++)u=aa[Y[m]],z=wa[$].vertices[u.a].position,A=wa[$].vertices[u.b].position,B=wa[$].vertices[u.c].position,u=wa[$].vertices[u.d].position,fa=R[$],fa[S]=z.x,fa[S+1]=z.y,fa[S+2]=z.z,fa[S+3]=A.x,fa[S+4]=A.y,fa[S+5]=A.z,fa[S+6]=B.x,fa[S+7]=B.y,fa[S+8]=B.z,fa[S+9]=u.x,fa[S+10]=u.y,fa[S+11]=u.z,S+=12;e.bindBuffer(e.ARRAY_BUFFER,v.__webglMorphTargetsBuffers[$]);e.bufferData(e.ARRAY_BUFFER,R[$],y)}}if(ta.length){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=ta[u.a],A=ta[u.b],B=ta[u.c],ia[x]=z.x,ia[x+1]=z.y,
+ia[x+2]=z.z,ia[x+3]=z.w,ia[x+4]=A.x,ia[x+5]=A.y,ia[x+6]=A.z,ia[x+7]=A.w,ia[x+8]=B.x,ia[x+9]=B.y,ia[x+10]=B.z,ia[x+11]=B.w,z=va[u.a],A=va[u.b],B=va[u.c],U[x]=z.x,U[x+1]=z.y,U[x+2]=z.z,U[x+3]=z.w,U[x+4]=A.x,U[x+5]=A.y,U[x+6]=A.z,U[x+7]=A.w,U[x+8]=B.x,U[x+9]=B.y,U[x+10]=B.z,U[x+11]=B.w,z=oa[u.a],A=oa[u.b],B=oa[u.c],W[x]=z.x,W[x+1]=z.y,W[x+2]=z.z,W[x+3]=1,W[x+4]=A.x,W[x+5]=A.y,W[x+6]=A.z,W[x+7]=1,W[x+8]=B.x,W[x+9]=B.y,W[x+10]=B.z,W[x+11]=1,z=pa[u.a],A=pa[u.b],B=pa[u.c],X[x]=z.x,X[x+1]=z.y,X[x+2]=z.z,
+X[x+3]=1,X[x+4]=A.x,X[x+5]=A.y,X[x+6]=A.z,X[x+7]=1,X[x+8]=B.x,X[x+9]=B.y,X[x+10]=B.z,X[x+11]=1,x+=12;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=ta[u.a],A=ta[u.b],B=ta[u.c],R=ta[u.d],ia[x]=z.x,ia[x+1]=z.y,ia[x+2]=z.z,ia[x+3]=z.w,ia[x+4]=A.x,ia[x+5]=A.y,ia[x+6]=A.z,ia[x+7]=A.w,ia[x+8]=B.x,ia[x+9]=B.y,ia[x+10]=B.z,ia[x+11]=B.w,ia[x+12]=R.x,ia[x+13]=R.y,ia[x+14]=R.z,ia[x+15]=R.w,z=va[u.a],A=va[u.b],B=va[u.c],R=va[u.d],U[x]=z.x,U[x+1]=z.y,U[x+2]=z.z,U[x+3]=z.w,U[x+4]=A.x,U[x+5]=A.y,U[x+6]=A.z,U[x+7]=A.w,
+U[x+8]=B.x,U[x+9]=B.y,U[x+10]=B.z,U[x+11]=B.w,U[x+12]=R.x,U[x+13]=R.y,U[x+14]=R.z,U[x+15]=R.w,z=oa[u.a],A=oa[u.b],B=oa[u.c],R=oa[u.d],W[x]=z.x,W[x+1]=z.y,W[x+2]=z.z,W[x+3]=1,W[x+4]=A.x,W[x+5]=A.y,W[x+6]=A.z,W[x+7]=1,W[x+8]=B.x,W[x+9]=B.y,W[x+10]=B.z,W[x+11]=1,W[x+12]=R.x,W[x+13]=R.y,W[x+14]=R.z,W[x+15]=1,z=pa[u.a],A=pa[u.b],B=pa[u.c],u=pa[u.d],X[x]=z.x,X[x+1]=z.y,X[x+2]=z.z,X[x+3]=1,X[x+4]=A.x,X[x+5]=A.y,X[x+6]=A.z,X[x+7]=1,X[x+8]=B.x,X[x+9]=B.y,X[x+10]=B.z,X[x+11]=1,X[x+12]=u.x,X[x+13]=u.y,X[x+14]=
+u.z,X[x+15]=1,x+=16;x>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,W,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,X,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,U,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ia,y))}if(xa&&D){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],x=u.vertexColors,U=u.color,x.length===3&&D===THREE.VertexColors?(u=x[0],
+W=x[1],X=x[2]):X=W=u=U,ea[da]=u.r,ea[da+1]=u.g,ea[da+2]=u.b,ea[da+3]=W.r,ea[da+4]=W.g,ea[da+5]=W.b,ea[da+6]=X.r,ea[da+7]=X.g,ea[da+8]=X.b,da+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],x=u.vertexColors,U=u.color,x.length===4&&D===THREE.VertexColors?(u=x[0],W=x[1],X=x[2],x=x[3]):x=X=W=u=U,ea[da]=u.r,ea[da+1]=u.g,ea[da+2]=u.b,ea[da+3]=W.r,ea[da+4]=W.g,ea[da+5]=W.b,ea[da+6]=X.r,ea[da+7]=X.g,ea[da+8]=X.b,ea[da+9]=x.r,ea[da+10]=x.g,ea[da+11]=x.b,da+=12;da>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer),
+e.bufferData(e.ARRAY_BUFFER,ea,y))}if(Q&&la.hasTangents){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],Q=u.vertexTangents,da=Q[0],ea=Q[1],la=Q[2],ba[K]=da.x,ba[K+1]=da.y,ba[K+2]=da.z,ba[K+3]=da.w,ba[K+4]=ea.x,ba[K+5]=ea.y,ba[K+6]=ea.z,ba[K+7]=ea.w,ba[K+8]=la.x,ba[K+9]=la.y,ba[K+10]=la.z,ba[K+11]=la.w,K+=12;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],Q=u.vertexTangents,da=Q[0],ea=Q[1],la=Q[2],Q=Q[3],ba[K]=da.x,ba[K+1]=da.y,ba[K+2]=da.z,ba[K+3]=da.w,ba[K+4]=ea.x,ba[K+5]=ea.y,ba[K+6]=ea.z,ba[K+7]=ea.w,ba[K+8]=la.x,
+ba[K+9]=la.y,ba[K+10]=la.z,ba[K+11]=la.w,ba[K+12]=Q.x,ba[K+13]=Q.y,ba[K+14]=Q.z,ba[K+15]=Q.w,K+=16;e.bindBuffer(e.ARRAY_BUFFER,v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ba,y)}if(N&&t){m=0;for(q=M.length;m<q;m++)if(u=aa[M[m]],ba=u.vertexNormals,N=u.normal,ba.length===3&&P)for(K=0;K<3;K++)N=ba[K],T[I]=N.x,T[I+1]=N.y,T[I+2]=N.z,I+=3;else for(K=0;K<3;K++)T[I]=N.x,T[I+1]=N.y,T[I+2]=N.z,I+=3;m=0;for(q=Y.length;m<q;m++)if(u=aa[Y[m]],ba=u.vertexNormals,N=u.normal,ba.length===4&&P)for(K=0;K<4;K++)N=
+ba[K],T[I]=N.x,T[I+1]=N.y,T[I+2]=N.z,I+=3;else for(K=0;K<4;K++)T[I]=N.x,T[I+1]=N.y,T[I+2]=N.z,I+=3;e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,T,y)}if(ua&&qa&&O){m=0;for(q=M.length;m<q;m++)if(I=M[m],I=qa[I],I!==void 0)for(K=0;K<3;K++)T=I[K],Z[V]=T.u,Z[V+1]=T.v,V+=2;m=0;for(q=Y.length;m<q;m++)if(I=Y[m],I=qa[I],I!==void 0)for(K=0;K<4;K++)T=I[K],Z[V]=T.u,Z[V+1]=T.v,V+=2;V>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Z,y))}if(ua&&sa&&
+O){m=0;for(q=M.length;m<q;m++)if(I=M[m],V=sa[I],V!==void 0)for(K=0;K<3;K++)Z=V[K],r[ja]=Z.u,r[ja+1]=Z.v,ja+=2;m=0;for(q=Y.length;m<q;m++)if(I=Y[m],V=sa[I],V!==void 0)for(K=0;K<4;K++)Z=V[K],r[ja]=Z.u,r[ja+1]=Z.v,ja+=2;ja>0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,r,y))}if(ra){m=0;for(q=M.length;m<q;m++)o[ha]=L,o[ha+1]=L+1,o[ha+2]=L+2,ha+=3,ga[ca]=L,ga[ca+1]=L+1,ga[ca+2]=L,ga[ca+3]=L+2,ga[ca+4]=L+1,ga[ca+5]=L+2,ca+=6,L+=3;m=0;for(q=Y.length;m<q;m++)o[ha]=L,o[ha+
+1]=L+1,o[ha+2]=L+3,o[ha+3]=L+1,o[ha+4]=L+2,o[ha+5]=L+3,ha+=6,ga[ca]=L,ga[ca+1]=L+1,ga[ca+2]=L,ga[ca+3]=L+3,ga[ca+4]=L+1,ga[ca+5]=L+2,ga[ca+6]=L+2,ga[ca+7]=L+3,ca+=8,L+=4;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,o,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ga,y)}if(J){K=0;for(L=J.length;K<L;K++)if(o=J[K],o.__original.needsUpdate){r=0;if(o.size===1)if(o.boundTo===void 0||o.boundTo==="vertices"){m=
+0;for(q=M.length;m<q;m++)u=aa[M[m]],o.array[r]=o.value[u.a],o.array[r+1]=o.value[u.b],o.array[r+2]=o.value[u.c],r+=3;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],o.array[r]=o.value[u.a],o.array[r+1]=o.value[u.b],o.array[r+2]=o.value[u.c],o.array[r+3]=o.value[u.d],r+=4}else{if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)ga=o.value[M[m]],o.array[r]=ga,o.array[r+1]=ga,o.array[r+2]=ga,r+=3;m=0;for(q=Y.length;m<q;m++)ga=o.value[Y[m]],o.array[r]=ga,o.array[r+1]=ga,o.array[r+2]=ga,o.array[r+3]=ga,r+=4}}else if(o.size===
+2)if(o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,r+=6;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,o.array[r+6]=u.x,o.array[r+7]=u.y,r+=8}else{if(o.boundTo==="faces"){m=
+0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,r+=6;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=A.x,o.array[r+3]=A.y,o.array[r+4]=B.x,o.array[r+5]=B.y,o.array[r+6]=u.x,o.array[r+7]=u.y,r+=8}}else if(o.size===3)if(t=o.type==="c"?["r","g","b"]:["x","y","z"],o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],
+A=o.value[u.b],B=o.value[u.c],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],r+=9;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],
+o.array[r+9]=u[t[0]],o.array[r+10]=u[t[1]],o.array[r+11]=u[t[2]],r+=12}else{if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],r+=9;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z[t[0]],o.array[r+1]=z[t[1]],o.array[r+2]=z[t[2]],o.array[r+3]=A[t[0]],o.array[r+4]=A[t[1]],o.array[r+
+5]=A[t[2]],o.array[r+6]=B[t[0]],o.array[r+7]=B[t[1]],o.array[r+8]=B[t[2]],o.array[r+9]=u[t[0]],o.array[r+10]=u[t[1]],o.array[r+11]=u[t[2]],r+=12}}else if(o.size===4)if(o.boundTo===void 0||o.boundTo==="vertices"){m=0;for(q=M.length;m<q;m++)u=aa[M[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,r+=
+12;m=0;for(q=Y.length;m<q;m++)u=aa[Y[m]],z=o.value[u.a],A=o.value[u.b],B=o.value[u.c],u=o.value[u.d],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,o.array[r+12]=u.x,o.array[r+13]=u.y,o.array[r+14]=u.z,o.array[r+15]=u.w,r+=16}else if(o.boundTo==="faces"){m=0;for(q=M.length;m<q;m++)B=A=z=ga=o.value[M[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+
+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,r+=12;m=0;for(q=Y.length;m<q;m++)u=B=A=z=ga=o.value[Y[m]],o.array[r]=z.x,o.array[r+1]=z.y,o.array[r+2]=z.z,o.array[r+3]=z.w,o.array[r+4]=A.x,o.array[r+5]=A.y,o.array[r+6]=A.z,o.array[r+7]=A.w,o.array[r+8]=B.x,o.array[r+9]=B.y,o.array[r+10]=B.z,o.array[r+11]=B.w,o.array[r+12]=u.x,o.array[r+13]=u.y,o.array[r+14]=u.z,o.array[r+15]=u.w,r+=16}e.bindBuffer(e.ARRAY_BUFFER,
+o.buffer);e.bufferData(e.ARRAY_BUFFER,o.array,y)}}C&&(delete v.__inittedArrays,delete v.__colorArray,delete v.__normalArray,delete v.__tangentArray,delete v.__uvArray,delete v.__uv2Array,delete v.__faceArray,delete v.__vertexArray,delete v.__lineArray,delete v.__skinVertexAArray,delete v.__skinVertexBArray,delete v.__skinIndexArray,delete v.__skinWeightArray)}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=
+!1;l.attributes&&w(l)}else if(ka instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){l=k;ka=e.DYNAMIC_DRAW;t=F=t=C=C=void 0;D=l.vertices;G=l.colors;m=D.length;v=G.length;q=l.__vertexArray;y=l.__colorArray;J=l.__dirtyColors;if(l.__dirtyVertices){for(C=0;C<m;C++)t=D[C].position,F=C*3,q[F]=t.x,q[F+1]=t.y,q[F+2]=t.z;e.bindBuffer(e.ARRAY_BUFFER,l.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,q,ka)}if(J){for(C=0;C<v;C++)t=G[C],F=C*3,y[F]=t.r,y[F+1]=t.g,y[F+2]=t.b;e.bindBuffer(e.ARRAY_BUFFER,
+l.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,y,ka)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(ka instanceof THREE.Line){l=d(ka,v);y=l.attributes&&s(l);if(k.__dirtyVertices||k.__dirtyColors||y){ka=k;F=e.DYNAMIC_DRAW;m=G=P=D=O=void 0;D=ka.vertices;v=ka.colors;m=D.length;y=v.length;q=ka.__vertexArray;C=ka.__colorArray;J=ka.__dirtyColors;t=ka.__webglCustomAttributesList;L=aa=Y=M=P=O=void 0;if(ka.__dirtyVertices){for(O=0;O<m;O++)P=D[O].position,G=O*3,q[G]=P.x,q[G+1]=P.y,q[G+2]=P.z;e.bindBuffer(e.ARRAY_BUFFER,
+ka.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,q,F)}if(J){for(D=0;D<y;D++)m=v[D],G=D*3,C[G]=m.r,C[G+1]=m.g,C[G+2]=m.b;e.bindBuffer(e.ARRAY_BUFFER,ka.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,C,F)}if(t){O=0;for(P=t.length;O<P;O++)if(L=t[O],L.needsUpdate&&(L.boundTo===void 0||L.boundTo==="vertices")){G=0;Y=L.value.length;if(L.size===1)for(M=0;M<Y;M++)L.array[M]=L.value[M];else if(L.size===2)for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+1]=aa.y,G+=2;else if(L.size===3)if(L.type===
+"c")for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.r,L.array[G+1]=aa.g,L.array[G+2]=aa.b,G+=3;else for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+1]=aa.y,L.array[G+2]=aa.z,G+=3;else if(L.size===4)for(M=0;M<Y;M++)aa=L.value[M],L.array[G]=aa.x,L.array[G+1]=aa.y,L.array[G+2]=aa.z,L.array[G+3]=aa.w,G+=4;e.bindBuffer(e.ARRAY_BUFFER,L.buffer);e.bufferData(e.ARRAY_BUFFER,L.array,F)}}}k.__dirtyVertices=!1;k.__dirtyColors=!1;l.attributes&&w(l)}else if(ka instanceof THREE.ParticleSystem)l=d(ka,v),y=l.attributes&&
+s(l),(k.__dirtyVertices||k.__dirtyColors||ka.sortParticles||y)&&h(k,e.DYNAMIC_DRAW,ka),k.__dirtyVertices=!1,k.__dirtyColors=!1,l.attributes&&w(l)};this.initMaterial=function(a,b,c,d){var f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&
+(i="particle_basic");if(i){var j=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(j.uniforms);a.vertexShader=j.vertexShader;a.fragmentShader=j.fragmentShader}var k,l,n;k=n=j=0;for(l=b.length;k<l;k++)h=b[k],h instanceof THREE.SpotLight&&n++,h instanceof THREE.DirectionalLight&&n++,h instanceof THREE.PointLight&&j++;j+n<=va?k=n:(k=Math.ceil(va*n/(j+n)),j=va-k);h={directional:k,point:j};j=n=0;for(k=b.length;j<k;j++)l=b[j],l instanceof THREE.SpotLight&&l.castShadow&&n++;var m=50;if(d!==void 0&&
+d instanceof THREE.SkinnedMesh)m=d.bones.length;var q;a:{k=a.fragmentShader;l=a.vertexShader;var j=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:m,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,
+shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},p,d=[];i?d.push(i):(d.push(k),d.push(l));for(p in c)d.push(p),d.push(c[p]);i=d.join();p=0;for(d=ya.length;p<d;p++)if(ya[p].code===i){q=ya[p].program;break a}p=e.createProgram();d=[Ma?"#define VERTEX_TEXTURES":"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,
+"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":
+"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+h=["precision "+ua+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
 "#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");e.attachShader(p,V("fragment",h+k));e.attachShader(p,V("vertex",
 "#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");e.attachShader(p,V("fragment",h+k));e.attachShader(p,V("vertex",
 d+l));e.linkProgram(p);e.getProgramParameter(p,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(p,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");p.uniforms={};p.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(s in j)d.push(s);s=d;d=0;for(j=s.length;d<j;d++)k=s[d],p.uniforms[k]=e.getUniformLocation(p,
 d+l));e.linkProgram(p);e.getProgramParameter(p,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(p,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");p.uniforms={};p.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(s in j)d.push(s);s=d;d=0;for(j=s.length;d<j;d++)k=s[d],p.uniforms[k]=e.getUniformLocation(p,
-k);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(q in b)d.push(q);q=d;s=0;for(b=q.length;s<b;s++)c=q[s],p.attributes[c]=e.getAttribLocation(p,c);p.id=ya.length;ya.push({program:p,code:i});I.info.memory.programs=ya.length;q=p}a.program=q;q=a.program.attributes;q.position>=0&&e.enableVertexAttribArray(q.position);q.color>=0&&e.enableVertexAttribArray(q.color);q.normal>=0&&e.enableVertexAttribArray(q.normal);
+k);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(q in b)d.push(q);q=d;s=0;for(b=q.length;s<b;s++)c=q[s],p.attributes[c]=e.getAttribLocation(p,c);p.id=ya.length;ya.push({program:p,code:i});H.info.memory.programs=ya.length;q=p}a.program=q;q=a.program.attributes;q.position>=0&&e.enableVertexAttribArray(q.position);q.color>=0&&e.enableVertexAttribArray(q.color);q.normal>=0&&e.enableVertexAttribArray(q.normal);
 q.tangent>=0&&e.enableVertexAttribArray(q.tangent);a.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(e.enableVertexAttribArray(q.skinVertexA),e.enableVertexAttribArray(q.skinVertexB),e.enableVertexAttribArray(q.skinIndex),e.enableVertexAttribArray(q.skinWeight));if(a.attributes)for(g in a.attributes)q[g]!==void 0&&q[g]>=0&&e.enableVertexAttribArray(q[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g<this.maxMorphTargets;g++)s="morphTarget"+g,q[s]>=0&&(e.enableVertexAttribArray(q[s]),
 q.tangent>=0&&e.enableVertexAttribArray(q.tangent);a.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(e.enableVertexAttribArray(q.skinVertexA),e.enableVertexAttribArray(q.skinVertexB),e.enableVertexAttribArray(q.skinIndex),e.enableVertexAttribArray(q.skinWeight));if(a.attributes)for(g in a.attributes)q[g]!==void 0&&q[g]>=0&&e.enableVertexAttribArray(q[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g<this.maxMorphTargets;g++)s="morphTarget"+g,q[s]>=0&&(e.enableVertexAttribArray(q[s]),
 a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),a==="back"?e.cullFace(e.BACK):a==="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(ra!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),ra=a.doubleSided;if(Z!==a.flipSided)a.flipSided?e.frontFace(e.CW):
 a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),a==="back"?e.cullFace(e.BACK):a==="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(ra!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),ra=a.doubleSided;if(Z!==a.flipSided)a.flipSided?e.frontFace(e.CW):
 e.frontFace(e.CCW),Z=a.flipSided};this.setDepthTest=function(a){oa!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),oa=a)};this.setBlending=function(a){if(a!==sa){switch(a){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,
 e.frontFace(e.CCW),Z=a.flipSided};this.setDepthTest=function(a){oa!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),oa=a)};this.setBlending=function(a){if(a!==sa){switch(a){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,
-e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}sa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),I.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=C(e.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.image.width,a.image.height,0,O(a.format),e.UNSIGNED_BYTE,a.image.data):e.texImage2D(e.TEXTURE_2D,
+e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}sa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),H.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=C(e.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.image.width,a.image.height,0,O(a.format),e.UNSIGNED_BYTE,a.image.data):e.texImage2D(e.TEXTURE_2D,
 0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a.image);c&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,
 0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a.image);c&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,
 a.__webglTexture);C(e.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null);var d=a,f=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,f,d.__webglTexture,0);D(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=e.createFramebuffer(),
 a.__webglTexture);C(e.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null);var d=a,f=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,f,d.__webglTexture,0);D(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=e.createFramebuffer(),
 a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),C(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),D(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,
 a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),C(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),D(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,
@@ -291,7 +295,9 @@ null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.wid
 THREE.WebGLRenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
 THREE.WebGLRenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
 THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
 THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,d){THREE.WebGLRenderTarget.call(this,a,b,d);this.activeCubeFace=0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,d){THREE.WebGLRenderTarget.call(this,a,b,d);this.activeCubeFace=0};
-THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.LensFlare=function(a,b,d,c,f){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;a!==void 0&&this.add(a,b,d,c,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
+THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;
+THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
+THREE.LensFlare=function(a,b,d,c,f){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;a!==void 0&&this.add(a,b,d,c,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
 THREE.LensFlare.prototype.add=function(a,b,d,c,f,g){b===void 0&&(b=-1);d===void 0&&(d=0);g===void 0&&(g=1);f===void 0&&(f=new THREE.Color(16777215));if(c===void 0)c=THREE.BillboardBlending;d=Math.min(d,Math.max(0,d));this.lensFlares.push({texture:a,size:b,distance:d,x:0,y:0,z:0,scale:1,rotation:1,opacity:g,color:f,blending:c})};
 THREE.LensFlare.prototype.add=function(a,b,d,c,f,g){b===void 0&&(b=-1);d===void 0&&(d=0);g===void 0&&(g=1);f===void 0&&(f=new THREE.Color(16777215));if(c===void 0)c=THREE.BillboardBlending;d=Math.min(d,Math.max(0,d));this.lensFlares.push({texture:a,size:b,distance:d,x:0,y:0,z:0,scale:1,rotation:1,opacity:g,color:f,blending:c})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,d,c=-this.positionScreen.x*2,f=-this.positionScreen.y*2;for(a=0;a<b;a++)d=this.lensFlares[a],d.x=this.positionScreen.x+c*d.distance,d.y=this.positionScreen.y+f*d.distance,d.wantedRotation=d.x*Math.PI*0.25,d.rotation+=(d.wantedRotation-d.rotation)*0.25};
 THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,d,c=-this.positionScreen.x*2,f=-this.positionScreen.y*2;for(a=0;a<b;a++)d=this.lensFlares[a],d.x=this.positionScreen.x+c*d.distance,d.y=this.positionScreen.y+f*d.distance,d.wantedRotation=d.x*Math.PI*0.25,d.rotation+=(d.wantedRotation-d.rotation)*0.25};
 THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),i=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(i,a.vertexShader);b.compileShader(d);b.compileShader(i);b.attachShader(c,d);b.attachShader(c,i);b.linkProgram(c);return c}var b,d,c={};this.init=function(f){b=f.context;d=f;c.vertices=new Float32Array(16);c.faces=new Uint16Array(6);f=0;c.vertices[f++]=-1;c.vertices[f++]=-1;c.vertices[f++]=0;c.vertices[f++]=0;
 THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),i=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(i,a.vertexShader);b.compileShader(d);b.compileShader(i);b.attachShader(c,d);b.attachShader(c,i);b.linkProgram(c);return c}var b,d,c={};this.init=function(f){b=f.context;d=f;c.vertices=new Float32Array(16);c.faces=new Uint16Array(6);f=0;c.vertices[f++]=-1;c.vertices[f++]=-1;c.vertices[f++]=0;c.vertices[f++]=0;

+ 339 - 8
examples/js/ctm/CTMLoader.js

@@ -8,7 +8,9 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.CTMLoader = function ( ) {
+THREE.CTMLoader = function ( context ) {
+
+	this.context = context;
 
 
 };
 };
 
 
@@ -21,7 +23,9 @@ THREE.CTMLoader.prototype.constructor = THREE.CTMLoader;
 //		- url (required)
 //		- url (required)
 //		- callback (required)
 //		- callback (required)
 
 
-THREE.CTMLoader.prototype.load = function( url, callback, useWorker ) {
+THREE.CTMLoader.prototype.load = function( url, callback, useWorker, useBuffers ) {
+
+	var scope = this;
 
 
 	var xhr = new XMLHttpRequest(),
 	var xhr = new XMLHttpRequest(),
 		callbackProgress = null;
 		callbackProgress = null;
@@ -45,7 +49,16 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker ) {
 					worker.onmessage = function( event ) {
 					worker.onmessage = function( event ) {
 
 
 						var ctmFile = event.data;
 						var ctmFile = event.data;
-						THREE.CTMLoader.prototype.createModel( ctmFile, callback );
+
+						if ( useBuffers ) {
+
+							scope.createModelBuffers( ctmFile, callback );
+
+						} else {
+
+							scope.createModelClassic( ctmFile, callback );
+
+						}
 
 
 						var e = Date.now();
 						var e = Date.now();
 						console.log( "CTM data parse time [worker]: " + (e-s) + " ms" );
 						console.log( "CTM data parse time [worker]: " + (e-s) + " ms" );
@@ -57,7 +70,16 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker ) {
 				} else {
 				} else {
 
 
 					var ctmFile = new CTM.File( new CTM.Stream( binaryData ) );
 					var ctmFile = new CTM.File( new CTM.Stream( binaryData ) );
-					THREE.CTMLoader.prototype.createModel( ctmFile, callback );
+
+					if ( useBuffers ) {
+
+						scope.createModelBuffers( ctmFile, callback );
+
+					} else {
+
+						scope.createModelClassic( ctmFile, callback );
+
+					}
 
 
 					var e = Date.now();
 					var e = Date.now();
 					console.log( "CTM data parse time [inline]: " + (e-s) + " ms" );
 					console.log( "CTM data parse time [inline]: " + (e-s) + " ms" );
@@ -99,9 +121,313 @@ THREE.CTMLoader.prototype.load = function( url, callback, useWorker ) {
 };
 };
 
 
 
 
-THREE.CTMLoader.prototype.createModel = function ( file, callback ) {
+THREE.CTMLoader.prototype.createModelBuffers = function ( file, callback ) {
+
+	var gl = this.context;
+
+	var Model = function ( ) {
+
+		var scope = this;
+
+		var dynamic = false,
+		computeNormals = true,
+		normalizeNormals = true;
+
+		scope.materials = [];
+
+		THREE.BufferGeometry.call( this );
+
+		// init GL buffers
+
+		var vertexIndexArray = file.body.indices,
+		vertexPositionArray = file.body.vertices,
+		vertexNormalArray = file.body.normals;
+
+		var vertexUvArray, vertexColorArray;
+
+		//console.log( "vertices", vertexPositionArray.length/3 );
+		//console.log( "triangles", vertexIndexArray.length/3 );
+
+		// compute face normals from scratch
+		// (must be done before computing offsets)
+
+		if ( vertexNormalArray === undefined && computeNormals ) {
+
+			var nElements = vertexPositionArray.length;
+
+			vertexNormalArray = new Float32Array( nElements );
+
+			var vA, vB, vC, x, y, z,
+
+			pA = new THREE.Vector3(),
+			pB = new THREE.Vector3(),
+			pC = new THREE.Vector3(),
+
+			cb = new THREE.Vector3(),
+			ab = new THREE.Vector3();
+
+			for ( var i = 0; i < vertexIndexArray.length; i += 3 ) {
+
+				vA = vertexIndexArray[ i ];
+				vB = vertexIndexArray[ i + 1 ];
+				vC = vertexIndexArray[ i + 2 ];
+
+				x = vertexPositionArray[ vA * 3 ];
+				y = vertexPositionArray[ vA * 3 + 1 ];
+				z = vertexPositionArray[ vA * 3 + 2 ];
+				pA.set( x, y, z );
+
+				x = vertexPositionArray[ vB * 3 ];
+				y = vertexPositionArray[ vB * 3 + 1 ];
+				z = vertexPositionArray[ vB * 3 + 2 ];
+				pB.set( x, y, z );
+
+				x = vertexPositionArray[ vC * 3 ];
+				y = vertexPositionArray[ vC * 3 + 1 ];
+				z = vertexPositionArray[ vC * 3 + 2 ];
+				pC.set( x, y, z );
+
+				cb.sub( pC, pB );
+				ab.sub( pA, pB );
+				cb.crossSelf( ab );
+
+				vertexNormalArray[ vA * 3 ] 	+= cb.x;
+				vertexNormalArray[ vA * 3 + 1 ] += cb.y;
+				vertexNormalArray[ vA * 3 + 2 ] += cb.z;
+
+				vertexNormalArray[ vB * 3 ] 	+= cb.x;
+				vertexNormalArray[ vB * 3 + 1 ] += cb.y;
+				vertexNormalArray[ vB * 3 + 2 ] += cb.z;
+
+				vertexNormalArray[ vC * 3 ] 	+= cb.x;
+				vertexNormalArray[ vC * 3 + 1 ] += cb.y;
+				vertexNormalArray[ vC * 3 + 2 ] += cb.z;
+
+			}
+
+			if ( normalizeNormals ) {
+
+				for ( var i = 0; i < nElements; i += 3 ) {
+
+					x = vertexNormalArray[ i ];
+					y = vertexNormalArray[ i + 1 ];
+					z = vertexNormalArray[ i + 2 ];
+
+					var n = 1.0 / Math.sqrt( x * x + y * y + z * z );
+
+					vertexNormalArray[ i ] 	   *= n;
+					vertexNormalArray[ i + 1 ] *= n;
+					vertexNormalArray[ i + 2 ] *= n;
+
+				}
+
+			}
+
+		}
+
+		// compute offsets
+
+		scope.offsets = [];
+
+		var indices = file.body.indices;
+
+		var start = 0,
+			min = file.body.vertices.length,
+			max = 0,
+			minPrev = min;
+
+		for ( var i = 0; i < indices.length; ) {
+
+			for ( var j = 0; j < 3; ++ j ) {
+
+				var idx = indices[ i ++ ];
+
+				if ( idx < min ) min = idx;
+				if ( idx > max ) max = idx;
+
+			}
+
+			if ( max - min > 65535 ) {
+
+				i -= 3;
+
+				for ( var k = start; k < i; ++ k ) {
+
+					indices[ k ] -= minPrev;
+
+				}
+
+				scope.offsets.push( { start: start, count: i - start, index: minPrev } );
+
+				start = i;
+				min = file.body.vertices.length;
+				max = 0;
+
+			}
+
+			minPrev = min;
+
+		}
+
+		for ( var k = start; k < i; ++ k ) {
+
+			indices[ k ] -= minPrev;
+
+		}
+
+		scope.offsets.push( { start: start, count: i - start, index: minPrev } );
+
+
+		// indices
+
+		scope.vertexIndexBuffer = gl.createBuffer();
+		gl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, scope.vertexIndexBuffer );
+		gl.bufferData( gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( vertexIndexArray ), gl.STATIC_DRAW );
+
+		scope.vertexIndexBuffer.itemSize = 1;
+		scope.vertexIndexBuffer.numItems = vertexIndexArray.length;
+
+		// vertices
+
+		scope.vertexPositionBuffer = gl.createBuffer();
+		gl.bindBuffer( gl.ARRAY_BUFFER, scope.vertexPositionBuffer );
+		gl.bufferData( gl.ARRAY_BUFFER, vertexPositionArray, gl.STATIC_DRAW );
+
+		scope.vertexPositionBuffer.itemSize = 3;
+		scope.vertexPositionBuffer.numItems = vertexPositionArray.length;
+
+		// normals
+
+		if ( vertexNormalArray !== undefined ) {
+
+			scope.vertexNormalBuffer = gl.createBuffer();
+			gl.bindBuffer( gl.ARRAY_BUFFER, scope.vertexNormalBuffer );
+			gl.bufferData( gl.ARRAY_BUFFER, vertexNormalArray, gl.STATIC_DRAW );
+
+			scope.vertexNormalBuffer.itemSize = 3;
+			scope.vertexNormalBuffer.numItems = vertexNormalArray.length;
+
+		}
+
+		// uvs
+
+		if ( file.body.uvMaps !== undefined && file.body.uvMaps.length > 0 ) {
+
+			vertexUvArray = file.body.uvMaps[ 0 ].uv;
+
+			// "fix" flipping
+
+			for ( var i = 0; i < vertexUvArray.length; i += 2 ) {
+
+				vertexUvArray[ i + 1 ] = 1 - vertexUvArray[ i + 1 ];
+
+			}
+
+			scope.vertexUvBuffer = gl.createBuffer();
+			gl.bindBuffer( gl.ARRAY_BUFFER, scope.vertexUvBuffer );
+			gl.bufferData( gl.ARRAY_BUFFER, vertexUvArray, gl.STATIC_DRAW );
+
+			scope.vertexUvBuffer.itemSize = 2;
+			scope.vertexUvBuffer.numItems = vertexUvArray.length;
+
+		}
+
+		// colors
+
+		if ( file.body.attrMaps !== undefined && file.body.attrMaps.length > 0 && file.body.attrMaps[ 0 ].name === "Color" ) {
+
+			vertexColorArray = file.body.attrMaps[ 0 ].attr;
+
+			scope.vertexColorBuffer = gl.createBuffer();
+			gl.bindBuffer( gl.ARRAY_BUFFER, scope.vertexColorBuffer );
+			gl.bufferData( gl.ARRAY_BUFFER, vertexColorArray, gl.STATIC_DRAW );
+
+			scope.vertexColorBuffer.itemSize = 4;
+			scope.vertexColorBuffer.numItems = vertexColorArray.length;
+
+		}
+
+		// compute bounding sphere and bounding box
+		// (must do it now as we don't keep typed arrays after setting GL buffers)
+
+		scope.boundingBox = { min: new THREE.Vector3( Infinity, Infinity, Infinity ), max: new THREE.Vector3( -Infinity, -Infinity, -Infinity ) };
+
+		var vertices = file.body.vertices,
+			bb = scope.boundingBox,
+			radius, maxRadius = 0,
+			x, y, z;
+
+		for ( var i = 0, il = vertices.length; i < il; i += 3 ) {
+
+			x = vertices[ i ];
+			y = vertices[ i + 1 ];
+			z = vertices[ i + 2 ];
+
+			// bounding sphere
+
+			radius = Math.sqrt( x * x + y * y + z * z );
+			if ( radius > maxRadius ) maxRadius = radius;
+
+			// bounding box
+
+			if ( x < bb.min.x ) {
 
 
-	var Model = function ( texture_path ) {
+				bb.min.x = x;
+
+			} else if ( x > bb.max.x ) {
+
+				bb.max.x = x;
+
+			}
+
+			if ( y < bb.min.y ) {
+
+				bb.min.y = y;
+
+			} else if ( y > bb.max.y ) {
+
+				bb.max.y = y;
+
+			}
+
+			if ( z < bb.min.z ) {
+
+				bb.min.z = z;
+
+			} else if ( z > bb.max.z ) {
+
+				bb.max.z = z;
+
+			}
+
+		}
+
+		scope.boundingSphere = { radius: maxRadius };
+
+		// keep references to typed arrays
+
+		if ( dynamic ) {
+
+			scope.vertexIndexArray = vertexIndexArray;
+			scope.vertexPositionArray = vertexPositionArray;
+			scope.vertexNormalArray = vertexNormalArray;
+			scope.vertexUvArray = vertexUvArray;
+			scope.vertexColorArray = vertexColorArray;
+
+		}
+
+	}
+
+	Model.prototype = new THREE.BufferGeometry();
+	Model.prototype.constructor = Model;
+
+	callback( new Model() );
+
+};
+
+THREE.CTMLoader.prototype.createModelClassic = function ( file, callback ) {
+
+	var Model = function ( ) {
 
 
 		var scope = this;
 		var scope = this;
 
 
@@ -217,11 +543,16 @@ THREE.CTMLoader.prototype.createModel = function ( file, callback ) {
 				b = buffer[ i + 1 ];
 				b = buffer[ i + 1 ];
 				c = buffer[ i + 2 ];
 				c = buffer[ i + 2 ];
 
 
-				if ( hasNormals )
+				if ( hasNormals ){
+
 					face = f3n( scope, normals, a, b, c, m, a, b, c );
 					face = f3n( scope, normals, a, b, c, m, a, b, c );
-				else
+
+				} else {
+
 					face = f3( scope, a, b, c, m );
 					face = f3( scope, a, b, c, m );
 
 
+				}
+
 				if ( hasColors ) {
 				if ( hasColors ) {
 
 
 					face.vertexColors[ 0 ] = colors[ a ];
 					face.vertexColors[ 0 ] = colors[ a ];

+ 6 - 5
examples/webgl_loader_ctm.html

@@ -141,9 +141,10 @@
 
 
 				}
 				}
 
 
-				var useWorker = true;
+				var useWorker = true
+					useBuffers = true;
 
 
-				var loader = new THREE.CTMLoader();
+				var loader = new THREE.CTMLoader( renderer.context );
 
 
 				loader.load( "ctm/ben.ctm",   function( geometry ) {
 				loader.load( "ctm/ben.ctm",   function( geometry ) {
 
 
@@ -151,7 +152,7 @@
 					callbackModel( geometry, 450, material, 0, -200, 0, 0, 0 );
 					callbackModel( geometry, 450, material, 0, -200, 0, 0, 0 );
 					checkTime();
 					checkTime();
 
 
-				}, useWorker );
+				}, useWorker, useBuffers );
 
 
 				loader.load( "ctm/WaltHead.ctm",  function( geometry ) {
 				loader.load( "ctm/WaltHead.ctm",  function( geometry ) {
 
 
@@ -161,7 +162,7 @@
 					callbackModel( geometry, 5, material, -200, 0, 0, 0, 0 );
 					callbackModel( geometry, 5, material, -200, 0, 0, 0, 0 );
 					checkTime();
 					checkTime();
 
 
-				}, useWorker );
+				}, useWorker, useBuffers );
 
 
 				loader.load( "ctm/LeePerry.ctm",  function( geometry ) {
 				loader.load( "ctm/LeePerry.ctm",  function( geometry ) {
 
 
@@ -169,7 +170,7 @@
 					callbackModel( geometry, 1300, material, 200, 50, 0, 0, 0 );
 					callbackModel( geometry, 1300, material, 200, 50, 0, 0, 0 );
 					checkTime();
 					checkTime();
 
 
-				}, useWorker );
+				}, useWorker, useBuffers );
 
 
 			}
 			}
 
 

+ 4 - 5
src/core/Geometry.js

@@ -401,17 +401,16 @@ THREE.Geometry.prototype = {
 
 
 	computeBoundingSphere: function () {
 	computeBoundingSphere: function () {
 
 
-		// var radius = this.boundingSphere === null ? 0 : this.boundingSphere.radius;
-
-		var radius = 0;
+		var radius, maxRadius = 0;
 
 
 		for ( var v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 		for ( var v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 
 
-			radius = Math.max( radius, this.vertices[ v ].position.length() );
+			radius = this.vertices[ v ].position.length();
+			if ( radius > maxRadius ) maxRadius = radius;
 
 
 		}
 		}
 
 
-		this.boundingSphere = { radius: radius };
+		this.boundingSphere = { radius: maxRadius };
 
 
 	},
 	},
 
 

+ 56 - 0
src/extras/core/BufferGeometry.js

@@ -0,0 +1,56 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.BufferGeometry = function () {
+
+	this.id = THREE.GeometryCount ++;
+
+	// GL buffers
+
+	this.vertexIndexBuffer = null;
+	this.vertexPositionBuffer = null;
+	this.vertexNormalBuffer = null;
+	this.vertexUvBuffer = null;
+	this.vertexColorBuffer = null;
+
+	// typed arrays (kept only if dynamic flag is set)
+
+	this.vertexIndexArray = null;
+	this.vertexPositionArray = null;
+	this.vertexNormalArray = null;
+	this.vertexUvArray = null;
+	this.vertexColorArray = null;
+
+	this.dynamic = false;
+
+	// boundings
+
+	this.boundingBox = null;
+	this.boundingSphere = null;
+
+	// for compatibility
+
+	this.morphTargets = [];
+
+};
+
+THREE.BufferGeometry.prototype = {
+
+	constructor : THREE.BufferGeometry,
+
+	// for compatibility
+
+	computeBoundingBox: function () {
+
+	},
+
+	// for compatibility
+
+	computeBoundingSphere: function () {
+
+	}
+
+
+};
+

+ 1 - 1
src/objects/Mesh.js

@@ -22,7 +22,7 @@ THREE.Mesh = function ( geometry, material ) {
 
 
 		// calc bound radius
 		// calc bound radius
 
 
-		if( !this.geometry.boundingSphere ) {
+		if( ! this.geometry.boundingSphere ) {
 
 
 			this.geometry.computeBoundingSphere();
 			this.geometry.computeBoundingSphere();
 
 

+ 173 - 39
src/renderers/WebGLRenderer.js

@@ -2703,6 +2703,98 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.renderBufferDirect = function ( camera, lights, fog, material, geometryGroup, object ) {
+
+		if ( material.opacity === 0 ) return;
+
+		var program, attributes, linewidth, primitives, a, attribute, i, il;
+
+		program = setProgram( camera, lights, fog, material, object );
+
+		attributes = program.attributes;
+
+		var updateBuffers = false,
+			wireframeBit = material.wireframe ? 1 : 0,
+			geometryGroupHash = ( geometryGroup.id * 0xffffff ) + ( program.id * 2 ) + wireframeBit;
+
+		if ( geometryGroupHash !== _currentGeometryGroupHash ) {
+
+			_currentGeometryGroupHash = geometryGroupHash;
+			updateBuffers = true;
+
+		}
+
+		// render mesh
+
+		if ( object instanceof THREE.Mesh ) {
+
+			var offsets = geometryGroup.offsets;
+
+			for ( var i = 0; i < offsets.length; ++ i ) {
+
+				if ( updateBuffers ) {
+
+					// vertices
+
+					_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexPositionBuffer );
+					_gl.vertexAttribPointer( attributes.position, geometryGroup.vertexPositionBuffer.itemSize, _gl.FLOAT, false, 0, offsets[ i ].index * 4 * 3 );
+
+					// normals
+
+					if ( attributes.normal >= 0 && geometryGroup.vertexNormalBuffer ) {
+
+						_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexNormalBuffer );
+						_gl.vertexAttribPointer( attributes.normal, geometryGroup.vertexNormalBuffer.itemSize, _gl.FLOAT, false, 0, offsets[ i ].index * 4 * 3 );
+
+					}
+
+					// uvs
+
+					if ( attributes.uv >= 0 && geometryGroup.vertexUvBuffer ) {
+
+						if ( geometryGroup.vertexUvBuffer ) {
+
+							_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexUvBuffer );
+							_gl.vertexAttribPointer(  attributes.uv, geometryGroup.vertexUvBuffer.itemSize, _gl.FLOAT, false, 0, offsets[ i ].index * 4 * 2 );
+
+							_gl.enableVertexAttribArray( attributes.uv );
+
+						} else {
+
+							_gl.disableVertexAttribArray( attributes.uv );
+
+						}
+
+					}
+
+					// colors
+
+					if ( attributes.color >= 0 && geometryGroup.vertexColorBuffer ) {
+
+						_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexColorBuffer );
+						_gl.vertexAttribPointer( attributes.color, geometryGroup.vertexColorBuffer.itemSize, _gl.FLOAT, false, 0, offsets[ i ].index * 4 * 4 );
+
+
+					}
+
+					_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.vertexIndexBuffer );
+
+				}
+
+				// render indexed triangles
+
+				_gl.drawElements( _gl.TRIANGLES, offsets[ i ].count, _gl.UNSIGNED_SHORT, offsets[ i ].start * 2 ); // 2 = Uint16
+
+				_this.info.render.calls ++;
+				_this.info.render.vertices += offsets[ i ].count; // not really true, here vertices can be shared
+				_this.info.render.faces += offsets[ i ].count / 3;
+
+			}
+
+		}
+
+	};
+
 	this.renderBuffer = function ( camera, lights, fog, material, geometryGroup, object ) {
 	this.renderBuffer = function ( camera, lights, fog, material, geometryGroup, object ) {
 
 
 		if ( material.opacity === 0 ) return;
 		if ( material.opacity === 0 ) return;
@@ -3253,7 +3345,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 				}
 				}
 
 
 				_this.setObjectFaces( object );
 				_this.setObjectFaces( object );
-				_this.renderBuffer( camera, lights, fog, material, buffer, object );
+
+				if ( buffer instanceof THREE.BufferGeometry ) {
+
+					_this.renderBufferDirect( camera, lights, fog, material, buffer, object );
+
+				} else {
+
+					_this.renderBuffer( camera, lights, fog, material, buffer, object );
+
+				}
 
 
 			}
 			}
 
 
@@ -3524,32 +3625,36 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				geometry = object.geometry;
 				geometry = object.geometry;
 
 
-				if ( geometry.geometryGroups === undefined ) {
+				if ( geometry instanceof THREE.Geometry ) {
 
 
-					sortFacesByMaterial( geometry );
+					if ( geometry.geometryGroups === undefined ) {
 
 
-				}
+						sortFacesByMaterial( geometry );
 
 
-				// create separate VBOs per geometry chunk
+					}
+
+					// create separate VBOs per geometry chunk
 
 
-				for ( g in geometry.geometryGroups ) {
+					for ( g in geometry.geometryGroups ) {
 
 
-					geometryGroup = geometry.geometryGroups[ g ];
+						geometryGroup = geometry.geometryGroups[ g ];
 
 
-					// initialise VBO on the first access
+						// initialise VBO on the first access
 
 
-					if ( ! geometryGroup.__webglVertexBuffer ) {
+						if ( ! geometryGroup.__webglVertexBuffer ) {
 
 
-						createMeshBuffers( geometryGroup );
-						initMeshBuffers( geometryGroup, object );
+							createMeshBuffers( geometryGroup );
+							initMeshBuffers( geometryGroup, object );
 
 
-						geometry.__dirtyVertices = true;
-						geometry.__dirtyMorphTargets = true;
-						geometry.__dirtyElements = true;
-						geometry.__dirtyUvs = true;
-						geometry.__dirtyNormals = true;
-						geometry.__dirtyTangents = true;
-						geometry.__dirtyColors = true;
+							geometry.__dirtyVertices = true;
+							geometry.__dirtyMorphTargets = true;
+							geometry.__dirtyElements = true;
+							geometry.__dirtyUvs = true;
+							geometry.__dirtyNormals = true;
+							geometry.__dirtyTangents = true;
+							geometry.__dirtyColors = true;
+
+						}
 
 
 					}
 					}
 
 
@@ -3607,11 +3712,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				geometry = object.geometry;
 				geometry = object.geometry;
 
 
-				for ( g in geometry.geometryGroups ) {
+				if ( geometry instanceof THREE.BufferGeometry ) {
+
+					addBuffer( scene.__webglObjects, geometry, object );
+
+				} else {
+
+					for ( g in geometry.geometryGroups ) {
+
+						geometryGroup = geometry.geometryGroups[ g ];
 
 
-					geometryGroup = geometry.geometryGroups[ g ];
+						addBuffer( scene.__webglObjects, geometryGroup, object );
 
 
-					addBuffer( scene.__webglObjects, geometryGroup, object );
+					}
 
 
 				}
 				}
 
 
@@ -3676,35 +3789,56 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		if ( object instanceof THREE.Mesh ) {
 		if ( object instanceof THREE.Mesh ) {
 
 
-			// check all geometry groups
+			if ( geometry instanceof THREE.BufferGeometry ) {
+
+				if ( geometry.__dirtyVertices || geometry.__dirtyElements ||
+					 geometry.__dirtyUvs || geometry.__dirtyNormals ||
+					 geometry.__dirtyColors  ) {
 
 
-			for( var i = 0, il = geometry.geometryGroupsList.length; i < il; i ++ ) {
+					// TODO
+					// set buffers from typed arrays
 
 
-				geometryGroup = geometry.geometryGroupsList[ i ];
+				}
 
 
-				material = getBufferMaterial( object, geometryGroup );
+				geometry.__dirtyVertices = false;
+				geometry.__dirtyElements = false;
+				geometry.__dirtyUvs = false;
+				geometry.__dirtyNormals = false;
+				geometry.__dirtyColors = false;
 
 
-				customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
+			} else {
 
 
-				if ( geometry.__dirtyVertices || geometry.__dirtyMorphTargets || geometry.__dirtyElements ||
-					 geometry.__dirtyUvs || geometry.__dirtyNormals ||
-					 geometry.__dirtyColors || geometry.__dirtyTangents || customAttributesDirty ) {
+				// check all geometry groups
 
 
-					setMeshBuffers( geometryGroup, object, _gl.DYNAMIC_DRAW, !geometry.dynamic, material );
+				for( var i = 0, il = geometry.geometryGroupsList.length; i < il; i ++ ) {
+
+					geometryGroup = geometry.geometryGroupsList[ i ];
+
+					material = getBufferMaterial( object, geometryGroup );
+
+					customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
+
+					if ( geometry.__dirtyVertices || geometry.__dirtyMorphTargets || geometry.__dirtyElements ||
+						 geometry.__dirtyUvs || geometry.__dirtyNormals ||
+						 geometry.__dirtyColors || geometry.__dirtyTangents || customAttributesDirty ) {
+
+						setMeshBuffers( geometryGroup, object, _gl.DYNAMIC_DRAW, !geometry.dynamic, material );
+
+					}
 
 
 				}
 				}
 
 
-			}
+				geometry.__dirtyVertices = false;
+				geometry.__dirtyMorphTargets = false;
+				geometry.__dirtyElements = false;
+				geometry.__dirtyUvs = false;
+				geometry.__dirtyNormals = false;
+				geometry.__dirtyColors = false;
+				geometry.__dirtyTangents = false;
 
 
-			geometry.__dirtyVertices = false;
-			geometry.__dirtyMorphTargets = false;
-			geometry.__dirtyElements = false;
-			geometry.__dirtyUvs = false;
-			geometry.__dirtyNormals = false;
-			geometry.__dirtyColors = false;
-			geometry.__dirtyTangents = false;
+				material.attributes && clearCustomAttributes( material );
 
 
-			material.attributes && clearCustomAttributes( material );
+			}
 
 
 		} else if ( object instanceof THREE.Ribbon ) {
 		} else if ( object instanceof THREE.Ribbon ) {
 
 

+ 3 - 1
utils/build.py

@@ -91,6 +91,7 @@ EXTRAS_FILES = [
 'extras/ImageUtils.js',
 'extras/ImageUtils.js',
 'extras/SceneUtils.js',
 'extras/SceneUtils.js',
 'extras/ShaderUtils.js',
 'extras/ShaderUtils.js',
+'extras/core/BufferGeometry.js',
 'extras/core/Curve.js',
 'extras/core/Curve.js',
 'extras/core/CurvePath.js',
 'extras/core/CurvePath.js',
 'extras/core/Path.js',
 'extras/core/Path.js',
@@ -335,6 +336,7 @@ WEBGL_FILES = [
 'renderers/WebGLRenderer.js',
 'renderers/WebGLRenderer.js',
 'renderers/WebGLRenderTarget.js',
 'renderers/WebGLRenderTarget.js',
 'renderers/WebGLRenderTargetCube.js',
 'renderers/WebGLRenderTargetCube.js',
+'extras/core/BufferGeometry.js',
 'extras/objects/LensFlare.js',
 'extras/objects/LensFlare.js',
 'extras/plugins/LensFlarePlugin.js',
 'extras/plugins/LensFlarePlugin.js',
 'extras/plugins/ShadowMapPlugin.js',
 'extras/plugins/ShadowMapPlugin.js',
@@ -425,7 +427,7 @@ def buildLib(files, debug, minified, filename):
 
 
 def buildIncludes(files, filename):
 def buildIncludes(files, filename):
 
 
-	template = '\t\t<script type="text/javascript" src="../src/%s"></script>'
+	template = '\t\t<script src="../src/%s"></script>'
 	text = "\n".join(template % f for f in files)
 	text = "\n".join(template % f for f in files)
 
 
 	output(text, filename + '.js')
 	output(text, filename + '.js')