Merge remote branch 'empaempa/master' into experimental

This commit is contained in:
Mr.doob
2011-03-24 20:49:31 +00:00
7 changed files with 1040 additions and 297 deletions
+299 -287
View File
@@ -1,7 +1,7 @@
// Three.js r37 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,k,j;if(b==0)d=e=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);j=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=j;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=j;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;
g=j;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,f,g,h,k,m;if(b==0)d=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);m=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a;
g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)};
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)};
@@ -12,78 +12,77 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)};
THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(b)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function c(H,E,I,A){A=A.clone().subSelf(E);I=I.clone().subSelf(E);var S=H.clone().subSelf(E);H=A.dot(A);E=A.dot(I);A=A.dot(S);var Q=I.dot(I);I=I.dot(S);S=1/(H*Q-E*E);Q=(Q*A-E*I)*S;H=(H*I-E*A)*S;return Q>0&&H>0&&Q+H<1}var b,d,e,g,h,k,j,m,t,x,
y,q=a.geometry,z=q.vertices,G=[];b=0;for(d=q.faces.length;b<d;b++){e=q.faces[b];x=this.origin.clone();y=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(z[e.a].position.clone());h=j.multiplyVector3(z[e.b].position.clone());k=j.multiplyVector3(z[e.c].position.clone());j=e instanceof THREE.Face4?j.multiplyVector3(z[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());t=y.dot(m);if(t<0){m=m.dot((new THREE.Vector3).sub(g,x))/t;x=x.addSelf(y.multiplyScalar(m));
if(e instanceof THREE.Face3){if(c(x,g,h,k)){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}else if(e instanceof THREE.Face4&&(c(x,g,h,j)||c(x,h,k,j))){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}}return G}};
THREE.Rectangle=function(){function a(){g=d-c;h=e-b}var c,b,d,e,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(j,m,t,x){k=!1;c=j;b=m;d=t;e=x;a()};this.addPoint=function(j,m){if(k){k=!1;c=j;b=m;d=j;e=m}else{c=c<j?c:j;b=b<m?b:m;d=d>j?d:j;e=e>m?e:m}a()};
this.add3Points=function(j,m,t,x,y,q){if(k){k=!1;c=j<t?j<y?j:y:t<y?t:y;b=m<x?m<q?m:q:x<q?x:q;d=j>t?j>y?j:y:t>y?t:y;e=m>x?m>q?m:q:x>q?x:q}else{c=j<t?j<y?j<c?j:c:y<c?y:c:t<y?t<c?t:c:y<c?y:c;b=m<x?m<q?m<b?m:b:q<b?q:b:x<q?x<b?x:b:q<b?q:b;d=j>t?j>y?j>d?j:d:y>d?y:d:t>y?t>d?t:d:y>d?y:d;e=m>x?m>q?m>e?m:e:q>e?q:e:x>q?x>e?x:e:q>e?q:e}a()};this.addRectangle=function(j){if(k){k=!1;c=j.getLeft();b=j.getTop();d=j.getRight();e=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();b=b<j.getTop()?b:j.getTop();d=d>j.getRight()?
d:j.getRight();e=e>j.getBottom()?e:j.getBottom()}a()};this.inflate=function(j){c-=j;b-=j;d+=j;e+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();b=b>j.getTop()?b:j.getTop();d=d<j.getRight()?d:j.getRight();e=e<j.getBottom()?e:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(e,j.getBottom())-Math.max(b,j.getTop())>=0};this.empty=function(){k=!0;e=d=b=c=0;a()};this.isEmpty=function(){return k}};
THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(b)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function c(I,C,J,B){B=B.clone().subSelf(C);J=J.clone().subSelf(C);var U=I.clone().subSelf(C);I=B.dot(B);C=B.dot(J);B=B.dot(U);var P=J.dot(J);J=J.dot(U);U=1/(I*P-C*C);P=(P*B-C*J)*U;I=(I*J-C*B)*U;return P>0&&I>0&&P+I<1}var b,d,f,g,h,k,m,n,q,x,
z,p=a.geometry,A=p.vertices,G=[];b=0;for(d=p.faces.length;b<d;b++){f=p.faces[b];x=this.origin.clone();z=this.direction.clone();m=a.matrixWorld;g=m.multiplyVector3(A[f.a].position.clone());h=m.multiplyVector3(A[f.b].position.clone());k=m.multiplyVector3(A[f.c].position.clone());m=f instanceof THREE.Face4?m.multiplyVector3(A[f.d].position.clone()):null;n=a.matrixRotationWorld.multiplyVector3(f.normal.clone());q=z.dot(n);if(q<0){n=n.dot((new THREE.Vector3).sub(g,x))/q;x=x.addSelf(z.multiplyScalar(n));
if(f instanceof THREE.Face3){if(c(x,g,h,k)){f={distance:this.origin.distanceTo(x),point:x,face:f,object:a};G.push(f)}}else if(f instanceof THREE.Face4&&(c(x,g,h,m)||c(x,h,k,m))){f={distance:this.origin.distanceTo(x),point:x,face:f,object:a};G.push(f)}}}return G}};
THREE.Rectangle=function(){function a(){g=d-c;h=f-b}var c,b,d,f,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(m,n,q,x){k=!1;c=m;b=n;d=q;f=x;a()};this.addPoint=function(m,n){if(k){k=!1;c=m;b=n;d=m;f=n}else{c=c<m?c:m;b=b<n?b:n;d=d>m?d:m;f=f>n?f:n}a()};
this.add3Points=function(m,n,q,x,z,p){if(k){k=!1;c=m<q?m<z?m:z:q<z?q:z;b=n<x?n<p?n:p:x<p?x:p;d=m>q?m>z?m:z:q>z?q:z;f=n>x?n>p?n:p:x>p?x:p}else{c=m<q?m<z?m<c?m:c:z<c?z:c:q<z?q<c?q:c:z<c?z:c;b=n<x?n<p?n<b?n:b:p<b?p:b:x<p?x<b?x:b:p<b?p:b;d=m>q?m>z?m>d?m:d:z>d?z:d:q>z?q>d?q:d:z>d?z:d;f=n>x?n>p?n>f?n:f:p>f?p:f:x>p?x>f?x:f:p>f?p:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();b=b<m.getTop()?b:m.getTop();d=d>m.getRight()?
d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d<m.getRight()?d:m.getRight();f=f<m.getBottom()?f:m.getBottom();a()};this.instersects=function(m){return Math.min(d,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=b=c=0;a()};this.isEmpty=function(){return k}};
THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
THREE.Matrix4=function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,k||0,j||0,m||0,t||1,x||0,y||0,q||0,z||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=z;this.n44=G;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,c,b){var d=THREE.Matrix4.__v1,
e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23*
d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();
return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44,I=c.n11,A=c.n12,S=c.n13,Q=c.n14,O=c.n21,X=c.n22,
f=c.n23,ea=c.n24,ka=c.n31,W=c.n32,T=c.n33,xa=c.n34;this.n11=b*I+d*O+e*ka;this.n12=b*A+d*X+e*W;this.n13=b*S+d*f+e*T;this.n14=b*Q+d*ea+e*xa+g;this.n21=h*I+k*O+j*ka;this.n22=h*A+k*X+j*W;this.n23=h*S+k*f+j*T;this.n24=h*Q+k*ea+j*xa+m;this.n31=t*I+x*O+y*ka;this.n32=t*A+x*X+y*W;this.n33=t*S+x*f+y*T;this.n34=t*Q+x*ea+y*xa+q;this.n41=z*I+G*O+H*ka;this.n42=z*A+G*X+H*W;this.n43=z*S+G*f+H*T;this.n44=z*Q+G*ea+H*xa+E;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=
this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,z=this.n43,G=this.n44;return d*h*m*y-b*k*m*y-d*g*t*y+c*k*t*y+b*g*x*y-c*h*x*y-d*h*j*q+b*k*j*q+d*e*t*q-a*k*t*q-b*e*x*q+a*h*x*q+d*g*j*z-c*k*j*z-d*e*m*z+a*k*m*z+c*e*x*z-a*g*x*z-b*g*j*G+c*h*j*G+b*e*m*G-a*h*m*G-c*e*t*G+a*g*t*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=
a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;
this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;
a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},
setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,k=
a.z,j=e*g,m=e*h;this.set(j*g+b,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+b,m*k-d*g,0,j*k-d*h,m*k+d*g,e*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},
setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var j=c*h;c*=k;var m=b*h;b*=k;d*=k;g*=e;h*=e;e*=k;this.n11=1-(m+d);this.n12=j-e;this.n13=c+h;this.n21=j+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=
a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*q*G-m*y*G+m*x*H-k*q*H-j*x*E+k*y*E;c.n12=g*y*G-e*q*G-g*x*H+d*q*H+e*x*E-d*y*E;c.n13=e*m*G-g*j*G+g*k*H-d*m*H-e*k*E+d*j*E;c.n14=g*j*x-e*m*x-g*k*y+d*m*y+e*k*q-d*j*q;c.n21=m*y*z-j*q*z-m*t*H+h*q*H+j*t*E-h*y*E;c.n22=e*q*z-g*y*z+g*t*H-b*q*H-e*t*E+b*y*E;c.n23=g*j*z-e*m*z-g*h*H+b*m*H+e*h*E-b*j*E;
c.n24=e*m*t-g*j*t+g*h*y-b*m*y-e*h*q+b*j*q;c.n31=k*q*z-m*x*z+m*t*G-h*q*G-k*t*E+h*x*E;c.n32=g*x*z-d*q*z-g*t*G+b*q*G+d*t*E-b*x*E;c.n33=e*m*z-g*k*z+g*h*G-b*m*G-d*h*E+b*k*E;c.n34=g*k*t-d*m*t-g*h*x+b*m*x+d*h*q-b*k*q;c.n41=j*x*z-k*y*z-j*t*G+h*y*G+k*t*H-h*x*H;c.n42=d*y*z-e*x*z+e*t*G-b*y*G-d*t*H+b*x*H;c.n43=e*k*z-d*j*z-e*h*G+b*j*G+d*h*H-b*k*H;c.n44=d*j*t-e*k*t+e*h*x-b*j*x-d*h*y+b*k*y;c.multiplyScalar(1/a.determinant());return c};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*j;b[6]=a*m;b[7]=a*t;b[8]=a*x;return c};
THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)};
THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,k,j,m;h=new THREE.Matrix4;k=c-a;j=b-d;m=g-e;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((b+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
THREE.Matrix4=function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,k||0,m||0,n||0,q||1,x||0,z||0,p||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=q;this.n34=x;this.n41=z;this.n42=p;this.n43=A;this.n44=G;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,c,b){var d=THREE.Matrix4.__v1,
f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23*
d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();
return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44,J=c.n11,B=c.n12,U=c.n13,P=c.n14,O=c.n21,V=c.n22,
Y=c.n23,e=c.n24,ja=c.n31,X=c.n32,W=c.n33,wa=c.n34;this.n11=b*J+d*O+f*ja;this.n12=b*B+d*V+f*X;this.n13=b*U+d*Y+f*W;this.n14=b*P+d*e+f*wa+g;this.n21=h*J+k*O+m*ja;this.n22=h*B+k*V+m*X;this.n23=h*U+k*Y+m*W;this.n24=h*P+k*e+m*wa+n;this.n31=q*J+x*O+z*ja;this.n32=q*B+x*V+z*X;this.n33=q*U+x*Y+z*W;this.n34=q*P+x*e+z*wa+p;this.n41=A*J+G*O+I*ja;this.n42=A*B+G*V+I*X;this.n43=A*U+G*Y+I*W;this.n44=A*P+G*e+I*wa+C;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;
b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
this.n11,c=this.n12,b=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,q=this.n33,x=this.n34,z=this.n41,p=this.n42,A=this.n43,G=this.n44;return d*h*n*z-b*k*n*z-d*g*q*z+c*k*q*z+b*g*x*z-c*h*x*z-d*h*m*p+b*k*m*p+d*f*q*p-a*k*q*p-b*f*x*p+a*h*x*p+d*g*m*A-c*k*m*A-d*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*q*G+a*g*q*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,
c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),f=1-b,g=a.x,h=a.y,k=a.z,m=f*g,n=f*h;this.set(m*
g+b,m*h-d*k,m*k+d*h,0,m*h+d*k,n*h+b,n*k-d*g,0,m*k-d*h,n*k+d*g,f*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c=
a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}};
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*p*G-n*z*G+n*x*I-k*p*I-m*x*C+k*z*C;c.n12=g*z*G-f*p*G-g*x*I+d*p*I+f*x*C-d*z*C;c.n13=f*n*G-g*m*G+g*k*I-d*n*I-f*k*C+d*m*C;c.n14=g*m*x-f*n*x-g*k*z+d*n*z+f*k*p-d*m*p;c.n21=n*z*A-m*p*A-n*q*I+h*p*I+m*q*C-h*z*C;c.n22=f*p*A-g*z*A+g*q*I-b*p*I-f*q*C+b*z*C;c.n23=g*m*A-f*n*A-g*h*I+b*n*I+f*h*C-b*m*C;
c.n24=f*n*q-g*m*q+g*h*z-b*n*z-f*h*p+b*m*p;c.n31=k*p*A-n*x*A+n*q*G-h*p*G-k*q*C+h*x*C;c.n32=g*x*A-d*p*A-g*q*G+b*p*G+d*q*C-b*x*C;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-d*h*C+b*k*C;c.n34=g*k*q-d*n*q-g*h*x+b*n*x+d*h*p-b*k*p;c.n41=m*x*A-k*z*A-m*q*G+h*z*G+k*q*I-h*x*I;c.n42=d*z*A-f*x*A+f*q*G-b*z*G-d*q*I+b*x*I;c.n43=f*k*A-d*m*A-f*h*G+b*m*G+d*h*I-b*k*I;c.n44=d*m*q-f*k*q+f*h*x-b*m*x-d*h*z+b*k*z;c.multiplyScalar(1/a.determinant());return c};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*f;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*m;b[6]=a*n;b[7]=a*q;b[8]=a*x;return c};
THREE.Matrix4.makeFrustum=function(a,c,b,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*f/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)};
THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-d;n=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/m;h.n23=0;h.n24=-((b+d)/m);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+f)/n);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
!0;this._vector=new THREE.Vector3};
THREE.Object3D.prototype={translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.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(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
c,b)}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==undefined?d:1)};
THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,k=d*e;this.w=h*g-k*b;this.x=h*b+k*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=c*a+e*g+b*k-d*h;this.y=b*a+e*h+d*g-c*k;this.z=d*a+e*k+c*h-b*g;this.w=e*a-c*g-b*h-d*k;return this},
multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*b+h*e-k*d,t=j*d+k*b-g*e,x=j*e+g*d-h*b;b=-g*b-h*d-k*e;c.x=m*j+b*-g+t*-k-x*-h;c.y=t*j+b*-h+x*-g-m*-k;c.z=x*j+b*-k+m*-h-t*-g;return c}};
THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};
THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,f=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(b);b=Math.sin(b);var h=a*c,k=d*f;this.w=h*g-k*b;this.x=h*b+k*g;this.y=d*c*g+a*f*b;this.z=a*f*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=c*a+f*g+b*k-d*h;this.y=b*a+f*h+d*g-c*k;this.z=d*a+f*k+c*h-b*g;this.w=f*a-c*g-b*h-d*k;return this},
multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,m=this.w,n=m*b+h*f-k*d,q=m*d+k*b-g*f,x=m*f+g*d-h*b;b=-g*b-h*d-k*f;c.x=n*m+b*-g+q*-k-x*-h;c.y=q*m+b*-h+x*-g-n*-k;c.z=x*m+b*-k+n*-h-q*-g;return c}};
THREE.Quaternion.slerp=function(a,c,b,d){var f=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(f)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
THREE.Face3=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
THREE.Face4=function(a,c,b,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};
THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];b.centroid.set(0,0,0);if(b instanceof THREE.Face3){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);b.centroid.divideScalar(3)}else if(b instanceof THREE.Face4){b.centroid.addSelf(this.vertices[b.a].position);b.centroid.addSelf(this.vertices[b.b].position);b.centroid.addSelf(this.vertices[b.c].position);
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)k.addSelf(g.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,b.position);j.sub(c.position,b.position);k.crossSelf(j)}k.isZero()||
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,f,g,h,k=new THREE.Vector3,m=new THREE.Vector3;d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)k.addSelf(g.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,b.position);m.sub(c.position,b.position);k.crossSelf(m)}k.isZero()||
k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal)}else if(b instanceof THREE.Face4){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal);d[b.d].addSelf(b.normal)}}a=0;for(c=this.vertices.length;a<c;a++)d[a].normalize();a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);
b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(oa,la,aa,P,M,da,sa){k=oa.vertices[la].position;j=oa.vertices[aa].position;m=oa.vertices[P].position;t=h[M];x=h[da];y=h[sa];q=j.x-k.x;z=m.x-k.x;G=j.y-k.y;H=m.y-k.y;E=j.z-k.z;I=m.z-k.z;A=x.u-t.u;S=y.u-t.u;Q=x.v-t.v;O=y.v-t.v;X=1/(A*O-S*
Q);W.set((O*q-Q*z)*X,(O*G-Q*H)*X,(O*E-Q*I)*X);T.set((A*z-S*q)*X,(A*H-S*G)*X,(A*I-S*E)*X);ea[la].addSelf(W);ea[aa].addSelf(W);ea[P].addSelf(W);ka[la].addSelf(T);ka[aa].addSelf(T);ka[P].addSelf(T)}var c,b,d,e,g,h,k,j,m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea=[],ka=[],W=new THREE.Vector3,T=new THREE.Vector3,xa=new THREE.Vector3,ca=new THREE.Vector3,Da=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){ea[c]=new THREE.Vector3;ka[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];
h=this.faceVertexUvs[0][c];if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var ja=["a","b","c","d"];c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];for(d=0;d<g.vertexNormals.length;d++){Da.copy(g.vertexNormals[d]);e=g[ja[d]];f=ea[e];xa.copy(f);xa.subSelf(Da.multiplyScalar(Da.dot(f))).normalize();ca.cross(g.vertexNormals[d],f);e=ca.dot(ka[e]);e=e<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(xa.x,xa.y,
xa.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;
if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere=
{radius:a}}};THREE.GeometryIdCounter=0;
THREE.Spline=function(a){function c(q,z,G,H,E,I,A){q=(G-q)*0.5;H=(H-z)*0.5;return(2*(z-G)+q+H)*A+(-3*(z-G)-2*q-H)*I+q*E+z}this.points=a;var b=[],d={x:0,y:0,z:0},e,g,h,k,j,m,t,x,y;this.initFromArray=function(q){this.points=[];for(var z=0;z<q.length;z++)this.points[z]={x:q[z][0],y:q[z][1],z:q[z][2]}};this.getPoint=function(q){e=(this.points.length-1)*q;g=Math.floor(e);h=e-g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>this.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;m=this.points[b[0]];t=this.points[b[1]];
x=this.points[b[2]];y=this.points[b[3]];k=h*h;j=h*k;d.x=c(m.x,t.x,x.x,y.x,h,k,j);d.y=c(m.y,t.y,x.y,y.y,h,k,j);d.z=c(m.z,t.z,x.z,y.z,h,k,j);return d};this.getControlPointsArray=function(){var q,z,G=this.points.length,H=[];for(q=0;q<G;q++){z=this.points[q];H[q]=[z.x,z.y,z.z]}return H};this.getLength=function(q){var z,G,H=z=z=0,E=new THREE.Vector3,I=new THREE.Vector3,A=[],S=0;A[0]=0;q||(q=100);G=this.points.length*q;E.copy(this.points[0]);for(q=1;q<G;q++){z=q/G;position=this.getPoint(z);I.copy(position);
S+=I.distanceTo(E);E.copy(position);z*=this.points.length-1;z=Math.floor(z);if(z!=H){A[z]=S;H=z}}A[A.length]=S;return{chunks:A,total:S}};this.reparametrizeByArcLength=function(q){var z,G,H,E,I,A,S=[],Q=new THREE.Vector3,O=this.getLength();S.push(Q.copy(this.points[0]).clone());for(z=1;z<this.points.length;z++){G=O.chunks[z]-O.chunks[z-1];A=Math.ceil(q*G/O.total);E=(z-1)/(this.points.length-1);I=z/(this.points.length-1);for(G=1;G<A-1;G++){H=E+G*(1/A)*(I-E);position=this.getPoint(H);S.push(Q.copy(position).clone())}S.push(Q.copy(this.points[z]).clone())}this.points=
S}};
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g<a.length;g++)a[g].update(e)};b.addToUpdate=function(e){a.indexOf(e)===-1&&a.push(e)};b.removeFromUpdate=function(e){e=a.indexOf(e);e!==-1&&a.splice(e,1)};b.add=function(e){c[e.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting.");c[e.name]=e;if(e.initialized!==!0){for(var g=0;g<e.hierarchy.length;g++){for(var h=0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=
0;if(e.hierarchy[g].keys[h].rot!==undefined&&!(e.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var k=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(e.hierarchy[g].keys[0].morphTargets!==undefined){k={};for(h=0;h<e.hierarchy[g].keys.length;h++)for(var j=0;j<e.hierarchy[g].keys[h].morphTargets.length;j++){var m=e.hierarchy[g].keys[h].morphTargets[j];k[m]=-1}e.hierarchy[g].usedMorphTargets=k;for(h=0;h<e.hierarchy[g].keys.length;h++){var t=
{};for(m in k){for(j=0;j<e.hierarchy[g].keys[h].morphTargets.length;j++)if(e.hierarchy[g].keys[h].morphTargets[j]===m){t[m]=e.hierarchy[g].keys[h].morphTargetsInfluences[j];break}j===e.hierarchy[g].keys[h].morphTargets.length&&(t[m]=0)}e.hierarchy[g].keys[h].morphTargetsInfluences=t}}for(h=1;h<e.hierarchy[g].keys.length;h++)if(e.hierarchy[g].keys[h].time===e.hierarchy[g].keys[h-1].time){e.hierarchy[g].keys.splice(h,1);h--}for(h=1;h<e.hierarchy[g].keys.length;h++)e.hierarchy[g].keys[h].index=h}h=parseInt(e.length*
e.fps,10);e.JIT={};e.JIT.hierarchy=[];for(g=0;g<e.hierarchy.length;g++)e.JIT.hierarchy.push(Array(h));e.initialized=!0}};b.get=function(e){if(typeof e==="string")if(c[e])return c[e];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+e);return null}};b.parse=function(e){var g=[];if(e instanceof THREE.SkinnedMesh)for(var h=0;h<e.bones.length;h++)g.push(e.bones[h]);else d(e,g);return g};var d=function(e,g){g.push(e);for(var h=0;h<e.children.length;h++)d(e.children[h],g)};b.LINEAR=
b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(oa,ma,ca,S,M,fa,ra){k=oa.vertices[ma].position;m=oa.vertices[ca].position;n=oa.vertices[S].position;q=h[M];x=h[fa];z=h[ra];p=m.x-k.x;A=n.x-k.x;G=m.y-k.y;I=n.y-k.y;C=m.z-k.z;J=n.z-k.z;B=x.u-q.u;U=z.u-q.u;P=x.v-q.v;O=z.v-q.v;V=1/(B*O-U*
P);X.set((O*p-P*A)*V,(O*G-P*I)*V,(O*C-P*J)*V);W.set((B*A-U*p)*V,(B*I-U*G)*V,(B*J-U*C)*V);e[ma].addSelf(X);e[ca].addSelf(X);e[S].addSelf(X);ja[ma].addSelf(W);ja[ca].addSelf(W);ja[S].addSelf(W)}var c,b,d,f,g,h,k,m,n,q,x,z,p,A,G,I,C,J,B,U,P,O,V,Y,e=[],ja=[],X=new THREE.Vector3,W=new THREE.Vector3,wa=new THREE.Vector3,ha=new THREE.Vector3,Aa=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){e[c]=new THREE.Vector3;ja[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];h=this.faceVertexUvs[0][c];
if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var ka=["a","b","c","d"];c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];for(d=0;d<g.vertexNormals.length;d++){Aa.copy(g.vertexNormals[d]);f=g[ka[d]];Y=e[f];wa.copy(Y);wa.subSelf(Aa.multiplyScalar(Aa.dot(Y))).normalize();ha.cross(g.vertexNormals[d],Y);f=ha.dot(ja[f]);f=f<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(wa.x,wa.y,wa.z,f)}}this.hasTangents=!0},
computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=
a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
THREE.Spline=function(a){function c(p,A,G,I,C,J,B){p=(G-p)*0.5;I=(I-A)*0.5;return(2*(A-G)+p+I)*B+(-3*(A-G)-2*p-I)*J+p*C+A}this.points=a;var b=[],d={x:0,y:0,z:0},f,g,h,k,m,n,q,x,z;this.initFromArray=function(p){this.points=[];for(var A=0;A<p.length;A++)this.points[A]={x:p[A][0],y:p[A][1],z:p[A][2]}};this.getPoint=function(p){f=(this.points.length-1)*p;g=Math.floor(f);h=f-g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>this.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];q=this.points[b[1]];
x=this.points[b[2]];z=this.points[b[3]];k=h*h;m=h*k;d.x=c(n.x,q.x,x.x,z.x,h,k,m);d.y=c(n.y,q.y,x.y,z.y,h,k,m);d.z=c(n.z,q.z,x.z,z.z,h,k,m);return d};this.getControlPointsArray=function(){var p,A,G=this.points.length,I=[];for(p=0;p<G;p++){A=this.points[p];I[p]=[A.x,A.y,A.z]}return I};this.getLength=function(p){var A,G,I=A=A=0,C=new THREE.Vector3,J=new THREE.Vector3,B=[],U=0;B[0]=0;p||(p=100);G=this.points.length*p;C.copy(this.points[0]);for(p=1;p<G;p++){A=p/G;position=this.getPoint(A);J.copy(position);
U+=J.distanceTo(C);C.copy(position);A*=this.points.length-1;A=Math.floor(A);if(A!=I){B[A]=U;I=A}}B[B.length]=U;return{chunks:B,total:U}};this.reparametrizeByArcLength=function(p){var A,G,I,C,J,B,U=[],P=new THREE.Vector3,O=this.getLength();U.push(P.copy(this.points[0]).clone());for(A=1;A<this.points.length;A++){G=O.chunks[A]-O.chunks[A-1];B=Math.ceil(p*G/O.total);C=(A-1)/(this.points.length-1);J=A/(this.points.length-1);for(G=1;G<B-1;G++){I=C+G*(1/B)*(J-C);position=this.getPoint(I);U.push(P.copy(position).clone())}U.push(P.copy(this.points[A]).clone())}this.points=
U}};
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(f){for(var g=0;g<a.length;g++)a[g].update(f)};b.addToUpdate=function(f){a.indexOf(f)===-1&&a.push(f)};b.removeFromUpdate=function(f){f=a.indexOf(f);f!==-1&&a.splice(f,1)};b.add=function(f){c[f.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+f.name+" already exists in library. Overwriting.");c[f.name]=f;if(f.initialized!==!0){for(var g=0;g<f.hierarchy.length;g++){for(var h=0;h<f.hierarchy[g].keys.length;h++){if(f.hierarchy[g].keys[h].time<0)f.hierarchy[g].keys[h].time=
0;if(f.hierarchy[g].keys[h].rot!==undefined&&!(f.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var k=f.hierarchy[g].keys[h].rot;f.hierarchy[g].keys[h].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(f.hierarchy[g].keys[0].morphTargets!==undefined){k={};for(h=0;h<f.hierarchy[g].keys.length;h++)for(var m=0;m<f.hierarchy[g].keys[h].morphTargets.length;m++){var n=f.hierarchy[g].keys[h].morphTargets[m];k[n]=-1}f.hierarchy[g].usedMorphTargets=k;for(h=0;h<f.hierarchy[g].keys.length;h++){var q=
{};for(n in k){for(m=0;m<f.hierarchy[g].keys[h].morphTargets.length;m++)if(f.hierarchy[g].keys[h].morphTargets[m]===n){q[n]=f.hierarchy[g].keys[h].morphTargetsInfluences[m];break}m===f.hierarchy[g].keys[h].morphTargets.length&&(q[n]=0)}f.hierarchy[g].keys[h].morphTargetsInfluences=q}}for(h=1;h<f.hierarchy[g].keys.length;h++)if(f.hierarchy[g].keys[h].time===f.hierarchy[g].keys[h-1].time){f.hierarchy[g].keys.splice(h,1);h--}for(h=1;h<f.hierarchy[g].keys.length;h++)f.hierarchy[g].keys[h].index=h}h=parseInt(f.length*
f.fps,10);f.JIT={};f.JIT.hierarchy=[];for(g=0;g<f.hierarchy.length;g++)f.JIT.hierarchy.push(Array(h));f.initialized=!0}};b.get=function(f){if(typeof f==="string")if(c[f])return c[f];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+f);return null}};b.parse=function(f){var g=[];if(f instanceof THREE.SkinnedMesh)for(var h=0;h<f.bones.length;h++)g.push(f.bones[h]);else d(f,g);return g};var d=function(f,g){g.push(f);for(var h=0;h<f.children.length;h++)d(f.children[h],g)};b.LINEAR=
0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();THREE.Animation=function(a,c,b,d){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==undefined?d:!0;this.points=[];this.target=new THREE.Vector3};
THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,d=this.hierarchy.length,e;for(b=0;b<d;b++){e=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===undefined){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 g=e.animationCache.prevKey;e=e.animationCache.nextKey;g.pos=this.data.hierarchy[b].keys[0];g.rot=this.data.hierarchy[b].keys[0];g.scl=this.data.hierarchy[b].keys[0];e.pos=this.getNextKeyWith("pos",b,1);e.rot=this.getNextKeyWith("rot",b,1);e.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,d=this.hierarchy.length,f;for(b=0;b<d;b++){f=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===undefined){f.animationCache={};f.animationCache.prevKey={pos:0,rot:0,scl:0};f.animationCache.nextKey={pos:0,rot:0,scl:0};f.animationCache.originalMatrix=
f instanceof THREE.Bone?f.skinMatrix:f.matrix}var g=f.animationCache.prevKey;f=f.animationCache.nextKey;g.pos=this.data.hierarchy[b].keys[0];g.rot=this.data.hierarchy[b].keys[0];g.scl=this.data.hierarchy[b].keys[0];f.pos=this.getNextKeyWith("pos",b,1);f.rot=this.getNextKeyWith("rot",b,1);f.scl=this.getNextKeyWith("scl",b,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.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,k,j,m,t=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=this.currentTime;x=this.currentTime%=this.data.length;m=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,z=this.hierarchy.length;q<z;q++){a=this.hierarchy[q];j=a.animationCache;if(this.JITCompile&&t[q][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
!1}else{a.matrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var G=0;G<3;G++){b=c[G];h=j.prevKey[b];k=j.nextKey[b];if(k.time<=y){if(x<y)if(this.loop){h=this.data.hierarchy[q].keys[0];for(k=this.getNextKeyWith(b,q,1);k.time<x;){h=k;k=this.getNextKeyWith(b,q,k.index+1)}}else{this.stop();return}else{do{h=k;k=this.getNextKeyWith(b,q,k.index+1)}while(k.time<
x)}j.prevKey[b]=h;j.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(x-h.time)/(k.time-h.time);e=h[b];g=k[b];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+q);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
this.getPrevKeyWith("pos",q,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",q,k.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);b.x=e[0];b.y=e[1];b.z=e[2];if(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(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b===
"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&t[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q<this.hierarchy.length;q++)t[q][m]=this.hierarchy[q]instanceof THREE.Bone?this.hierarchy[q].skinMatrix.clone():this.hierarchy[q].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],e,g,h,k,j,m;e=(a.length-1)*c;g=Math.floor(e);e-=g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>a.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];j=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],k[0],j[0],m[0],e,b,h);d[1]=this.interpolate(g[1],k[1],j[1],m[1],e,b,h);d[2]=this.interpolate(g[2],k[2],j[2],m[2],e,b,h);return d};
THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<d.length-1?b:d.length-1;else b%=d.length;for(;b<d.length;b++)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[0]};
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,f,g,h,k,m,n,q=this.data.JIT.hierarchy,x,z;this.currentTime+=a*this.timeScale;z=this.currentTime;x=this.currentTime%=this.data.length;n=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,A=this.hierarchy.length;p<A;p++){a=this.hierarchy[p];m=a.animationCache;if(this.JITCompile&&q[p][n]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=q[p][n];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
!1}else{a.matrix=q[p][n];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var G=0;G<3;G++){b=c[G];h=m.prevKey[b];k=m.nextKey[b];if(k.time<=z){if(x<z)if(this.loop){h=this.data.hierarchy[p].keys[0];for(k=this.getNextKeyWith(b,p,1);k.time<x;){h=k;k=this.getNextKeyWith(b,p,k.index+1)}}else{this.stop();return}else{do{h=k;k=this.getNextKeyWith(b,p,k.index+1)}while(k.time<
x)}m.prevKey[b]=h;m.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(x-h.time)/(k.time-h.time);f=h[b];g=k[b];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
this.getPrevKeyWith("pos",p,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[2];if(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(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b===
"rot")THREE.Quaternion.slerp(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;p<this.hierarchy.length;p++)q[p][n]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],f,g,h,k,m,n;f=(a.length-1)*c;g=Math.floor(f);f-=g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>a.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];m=a[b[2]];n=a[b[3]];b=f*f;h=f*b;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return d};
THREE.Animation.prototype.interpolate=function(a,c,b,d,f,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<d.length-1?b:d.length-1;else b%=d.length;for(;b<d.length;b++)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]};
THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
THREE.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
THREE.Camera.prototype.update=function(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
!1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
@@ -111,89 +110,96 @@ undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=
THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=!1;this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==
undefined)this.vertexShader=a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;
if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.lights!==undefined)this.lights=a.lights;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
THREE.ShadowVolumeDynamicMaterial=function(){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=
!1};
THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=a.sizeAttenuation;
if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
THREE.ParticleCanvasMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.program=function(){};this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.program!==undefined)this.program=a.program;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};
THREE.Texture=function(a,c,b,d,e,g){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrapS=b!==undefined?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
THREE.Texture=function(a,c,b,d,f,g){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrapS=b!==undefined?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==undefined?f:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;
THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==undefined?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==undefined?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==undefined?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==undefined?b.minFilter:THREE.LinearMipMapLinearFilter;this.format=b.format!==undefined?b.format:THREE.RGBFormat;this.type=b.type!==undefined?b.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,b,d,e={};for(c in a){e[c]={};for(b in a[c]){d=a[c][b];e[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return e},merge:function(a){var c,b,d,e={};for(c=0;c<a.length;c++){d=this.clone(a[c]);for(b in d)e[b]=d[b]}return e}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
var Uniforms={clone:function(a){var c,b,d,f={};for(c in a){f[c]={};for(b in a[c]){d=a[c][b];f[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return f},merge:function(a){var c,b,d,f={};for(c=0;c<a.length;c++){d=this.clone(a[c]);for(b in d)f[b]=d[b]}return f}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=b!=undefined?b:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c&&c.length?c:[c];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius;if(this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var b=0;b<this.geometry.morphTargets.length;b++){this.morphTargetInfluences.push(0);
this.morphTargetDictionary[this.geometry.morphTargets[b].name]=b}}}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==undefined)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
THREE.Bone.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,c,b):a.update(this.matrixWorld,!0,b)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
THREE.Bone.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<f;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,c,b):a.update(this.matrixWorld,!0,b)}}else for(d=0;d<f;d++)this.children[d].update(this.skinMatrix,
c,b)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,e,g,h,k;if(this.geometry.bones!==undefined){for(b=0;b<this.geometry.bones.length;b++){e=this.geometry.bones[b];g=e.pos;h=e.rotq;k=e.scl;d=this.addBone();d.name=e.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);d.useQuaternion=!0;k!==undefined?d.scale.set(k[0],k[1],k[2]):d.scale.set(1,1,1)}for(b=0;b<this.bones.length;b++){e=this.geometry.bones[b];
d=this.bones[b];e.parent===-1?this.addChild(d):this.bones[e.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
THREE.SkinnedMesh.prototype.update=function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,e=this.children.length;for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,b):a.update(this.matrixWorld,c,b)}b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<b;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,f,g,h,k;if(this.geometry.bones!==undefined){for(b=0;b<this.geometry.bones.length;b++){f=this.geometry.bones[b];g=f.pos;h=f.rotq;k=f.scl;d=this.addBone();d.name=f.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);d.useQuaternion=!0;k!==undefined?d.scale.set(k[0],k[1],k[2]):d.scale.set(1,1,1)}for(b=0;b<this.bones.length;b++){f=this.geometry.bones[b];
d=this.bones[b];f.parent===-1?this.addChild(d):this.bones[f.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
THREE.SkinnedMesh.prototype.update=function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,f=this.children.length;for(d=0;d<f;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,b):a.update(this.matrixWorld,c,b)}b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<b;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
c*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];c.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){b=this.geometry.vertices[a].position;var e=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[e].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[g].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=b;this.geometry.skinWeights[a].y+=b}}}};
THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];c.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){b=this.geometry.vertices[a].position;var f=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[f].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[g].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=b;this.geometry.skinWeights[a].y+=b}}}};
THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
THREE.Sound=function(a,c,b,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=c!==undefined?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,b!==undefined?b:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;b=this.sources.length;for(a=0;a<b;a++){c=this.sources[a];c.toLowerCase();if(c.indexOf(".mp3")!==-1)e=
"audio/mpeg";else if(c.indexOf(".ogg")!==-1)e="audio/ogg";else c.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
THREE.Sound=function(a,c,b,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=c!==undefined?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,b!==undefined?b:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var f;b=this.sources.length;for(a=0;a<b;a++){c=this.sources[a];c.toLowerCase();if(c.indexOf(".mp3")!==-1)f=
"audio/mpeg";else if(c.indexOf(".ogg")!==-1)f="audio/ogg";else c.indexOf(".wav")!==-1&&(f="audio/wav");if(this.domElement.canPlayType(f)){f=document.createElement("source");f.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(f);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
THREE.Sound.prototype.update=function(a,c,b){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);c=!0}if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(a,c){c===undefined&&(c=0);c=Math.abs(c);for(var b=0;b<this.LODs.length;b++)if(c<this.LODs[b].visibleAtDistance)break;this.LODs.splice(b,0,{visibleAtDistance:c,object3D:a});this.addChild(a)};
THREE.LOD.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}if(this.LODs.length>1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d<this.LODs.length;d++)if(a>=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=
!1;this.LODs[d].object3D.visible=!0}else break;for(;d<this.LODs.length;d++)this.LODs[d].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
!1;this.LODs[d].object3D.visible=!0}else break;for(;d<this.LODs.length;d++)this.LODs[d].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.ShadowVolume=function(a,c){THREE.Mesh.call(this,a.geometry,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);a.addChild(this);this.calculateShadowVolumeGeometry(a.geometry)};THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;
THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(a){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=a.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,b=this.geometry.faces,d=this.geometry.edgeFaces,f=a.faces;a=a.vertices;var g=f.length,h,k,m,n,q,x=["a","b","c","d"];for(m=0;m<g;m++){k=c.length;h=f[m];if(h instanceof THREE.Face4){n=4;k=new THREE.Face4(k,k+1,k+2,k+3)}else{n=3;k=new THREE.Face3(k,k+1,k+2)}k.normal.copy(h.normal);b.push(k);for(k=
0;k<n;k++){q=a[h[x[k]]];c.push(new THREE.Vertex(q.position.clone()))}}for(g=0;g<f.length-1;g++){a=b[g];for(h=g+1;h<f.length;h++){k=b[h];k=this.facesShareEdge(c,a,k);if(k!==undefined){k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]);k.normal.set(1,0,0);d.push(k)}}}};
THREE.ShadowVolume.prototype.facesShareEdge=function(a,c,b){var d,f,g,h,k,m,n,q,x,z,p,A,G,I=0,C=["a","b","c","d"];d=c instanceof THREE.Face4?4:3;f=b instanceof THREE.Face4?4:3;for(A=0;A<d;A++){g=c[C[A]];k=a[g];for(G=0;G<f;G++){h=b[C[G]];m=a[h];if(Math.abs(k.position.x-m.position.x)<1.0E-4&&Math.abs(k.position.y-m.position.y)<1.0E-4&&Math.abs(k.position.z-m.position.z)<1.0E-4){I++;if(I===1){n=k;q=m;x=g;z=h;p=C[A]}if(I===2){p+=C[A];return p==="ad"||p==="ac"?{faces:[c,b],vertices:[n,q,m,k],indices:[x,
z,h,g],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,b],vertices:[n,k,m,q],indices:[x,g,h,z],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var c=0;c<a.children.length;c++)this.addChildRecurse(a.children[c])};
THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);if(c!==-1){this.objects.splice(c,1);this.__objectsRemoved.push(a)}}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};
THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c||1;this.far=b||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==undefined?c:2.5E-4};
THREE.Projector=function(){function a(){var W=j[k]=j[k]||new THREE.RenderableVertex;k++;return W}function c(W,T){return T.z-W.z}function b(W,T){var xa=0,ca=1,Da=W.z+W.w,ja=T.z+T.w,oa=-W.z+W.w,la=-T.z+T.w;if(Da>=0&&ja>=0&&oa>=0&&la>=0)return!0;else if(Da<0&&ja<0||oa<0&&la<0)return!1;else{if(Da<0)xa=Math.max(xa,Da/(Da-ja));else ja<0&&(ca=Math.min(ca,Da/(Da-ja)));if(oa<0)xa=Math.max(xa,oa/(oa-la));else la<0&&(ca=Math.min(ca,oa/(oa-la)));if(ca<xa)return!1;else{W.lerpSelf(T,xa);T.lerpSelf(W,1-ca);return!0}}}
var d,e,g=[],h,k,j=[],m,t,x=[],y,q=[],z,G,H=[],E,I,A=[],S=new THREE.Vector4,Q=new THREE.Vector4,O=new THREE.Matrix4,X=new THREE.Matrix4,f=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,ka=new THREE.Vector4;this.projectVector=function(W,T){O.multiply(T.projectionMatrix,T.matrixWorldInverse);O.multiplyVector3(W);return W};this.unprojectVector=function(W,T){O.multiply(T.matrixWorld,THREE.Matrix4.makeInvert(T.projectionMatrix));
O.multiplyVector3(W);return W};this.projectObjects=function(W,T,xa){T=[];var ca,Da,ja;e=0;Da=W.objects;W=0;for(ca=Da.length;W<ca;W++){ja=Da[W];var oa;if(!(oa=!ja.visible))if(oa=ja instanceof THREE.Mesh){a:{oa=void 0;for(var la=ja.matrixWorld,aa=-ja.geometry.boundingSphere.radius*Math.max(ja.scale.x,Math.max(ja.scale.y,ja.scale.z)),P=0;P<6;P++){oa=f[P].x*la.n14+f[P].y*la.n24+f[P].z*la.n34+f[P].w;if(oa<=aa){oa=!1;break a}}oa=!0}oa=!oa}if(!oa){oa=g[e]=g[e]||new THREE.RenderableObject;e++;d=oa;S.copy(ja.position);
O.multiplyVector3(S);d.object=ja;d.z=S.z;T.push(d)}}xa&&T.sort(c);return T};this.projectScene=function(W,T,xa){var ca=[],Da=T.near,ja=T.far,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C,p,o,w;I=G=y=t=0;T.matrixAutoUpdate&&T.updateMatrix();W.update(undefined,!1,T);O.multiply(T.projectionMatrix,T.matrixWorldInverse);f[0].set(O.n41-O.n11,O.n42-O.n12,O.n43-O.n13,O.n44-O.n14);f[1].set(O.n41+O.n11,O.n42+O.n12,O.n43+O.n13,O.n44+O.n14);f[2].set(O.n41+O.n21,O.n42+O.n22,O.n43+O.n23,O.n44+O.n24);f[3].set(O.n41-O.n21,
O.n42-O.n22,O.n43-O.n23,O.n44-O.n24);f[4].set(O.n41-O.n31,O.n42-O.n32,O.n43-O.n33,O.n44-O.n34);f[5].set(O.n41+O.n31,O.n42+O.n32,O.n43+O.n33,O.n44+O.n34);for(oa=0;oa<6;oa++){ta=f[oa];ta.divideScalar(Math.sqrt(ta.x*ta.x+ta.y*ta.y+ta.z*ta.z))}ta=this.projectObjects(W,T,!0);W=0;for(oa=ta.length;W<oa;W++){ya=ta[W].object;if(ya.visible){La=ya.matrixWorld;ab=ya.matrixRotationWorld;n=ya.materials;C=ya.overdraw;k=0;if(ya instanceof THREE.Mesh){p=ya.geometry;P=p.vertices;o=p.faces;p=p.faceVertexUvs;la=0;for(aa=
P.length;la<aa;la++){h=a();h.positionWorld.copy(P[la].position);La.multiplyVector3(h.positionWorld);h.positionScreen.copy(h.positionWorld);O.multiplyVector4(h.positionScreen);h.positionScreen.x/=h.positionScreen.w;h.positionScreen.y/=h.positionScreen.w;h.visible=h.positionScreen.z>Da&&h.positionScreen.z<ja}P=0;for(la=o.length;P<la;P++){aa=o[P];if(aa instanceof THREE.Face3){M=j[aa.a];da=j[aa.b];sa=j[aa.c];if(M.visible&&da.visible&&sa.visible&&(ya.doubleSided||ya.flipSided!=(sa.positionScreen.x-M.positionScreen.x)*
(da.positionScreen.y-M.positionScreen.y)-(sa.positionScreen.y-M.positionScreen.y)*(da.positionScreen.x-M.positionScreen.x)<0)){ia=x[t]=x[t]||new THREE.RenderableFace3;t++;m=ia;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa)}else continue}else if(aa instanceof THREE.Face4){M=j[aa.a];da=j[aa.b];sa=j[aa.c];ia=j[aa.d];if(M.visible&&da.visible&&sa.visible&&ia.visible&&(ya.doubleSided||ya.flipSided!=((ia.positionScreen.x-M.positionScreen.x)*(da.positionScreen.y-M.positionScreen.y)-(ia.positionScreen.y-M.positionScreen.y)*
(da.positionScreen.x-M.positionScreen.x)<0||(da.positionScreen.x-sa.positionScreen.x)*(ia.positionScreen.y-sa.positionScreen.y)-(da.positionScreen.y-sa.positionScreen.y)*(ia.positionScreen.x-sa.positionScreen.x)<0))){w=q[y]=q[y]||new THREE.RenderableFace4;y++;m=w;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa);m.v4.copy(ia)}else continue}m.normalWorld.copy(aa.normal);ab.multiplyVector3(m.normalWorld);m.centroidWorld.copy(aa.centroid);La.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);
O.multiplyVector3(m.centroidScreen);sa=aa.vertexNormals;M=0;for(da=sa.length;M<da;M++){ia=m.vertexNormalsWorld[M];ia.copy(sa[M]);ab.multiplyVector3(ia)}M=0;for(da=p.length;M<da;M++)if(w=p[M][P]){sa=0;for(ia=w.length;sa<ia;sa++)m.uvs[M][sa]=w[sa]}m.meshMaterials=n;m.faceMaterials=aa.materials;m.overdraw=C;m.z=m.centroidScreen.z;ca.push(m)}}else if(ya instanceof THREE.Line){X.multiply(O,La);P=ya.geometry.vertices;M=a();M.positionScreen.copy(P[0].position);X.multiplyVector4(M.positionScreen);la=1;for(aa=
P.length;la<aa;la++){M=a();M.positionScreen.copy(P[la].position);X.multiplyVector4(M.positionScreen);da=j[k-2];ea.copy(M.positionScreen);ka.copy(da.positionScreen);if(b(ea,ka)){ea.multiplyScalar(1/ea.w);ka.multiplyScalar(1/ka.w);La=H[G]=H[G]||new THREE.RenderableLine;G++;z=La;z.v1.positionScreen.copy(ea);z.v2.positionScreen.copy(ka);z.z=Math.max(ea.z,ka.z);z.materials=ya.materials;ca.push(z)}}}else if(ya instanceof THREE.Particle){Q.set(ya.position.x,ya.position.y,ya.position.z,1);O.multiplyVector4(Q);
Q.z/=Q.w;if(Q.z>0&&Q.z<1){La=A[I]=A[I]||new THREE.RenderableParticle;I++;E=La;E.x=Q.x/Q.w;E.y=Q.y/Q.w;E.z=Q.z;E.rotation=ya.rotation.z;E.scale.x=ya.scale.x*Math.abs(E.x-(Q.x+T.projectionMatrix.n11)/(Q.w+T.projectionMatrix.n14));E.scale.y=ya.scale.y*Math.abs(E.y-(Q.y+T.projectionMatrix.n22)/(Q.w+T.projectionMatrix.n24));E.materials=ya.materials;ca.push(E)}}}}xa&&ca.sort(c);return ca}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;e=b/2;g=d/2};this.render=function(h,k){var j,m,t,x,y,q,z,G;a=c.projectScene(h,k);j=0;for(m=a.length;j<m;j++){y=a[j];if(y instanceof THREE.RenderableParticle){z=y.x*e+e;G=y.y*g+g;t=0;for(x=y.material.length;t<x;t++){q=y.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=G+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(Ca){if(y!=Ca)m.globalAlpha=y=Ca}function c(Ca){if(q!=Ca){switch(Ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=Ca}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,k,j,m=e.getContext("2d"),t=new THREE.Color(0),x=0,y=1,q=0,z=null,G=null,H=1,E,I,A,S,Q=new THREE.RenderableVertex,
O=new THREE.RenderableVertex,X,f,ea,ka,W,T,xa,ca,Da,ja,oa,la,aa=new THREE.Color,P=new THREE.Color,M=new THREE.Color,da=new THREE.Color,sa=new THREE.Color,ia,ta,ya,La,ab,n,C,p,o,w,D=new THREE.Rectangle,B=new THREE.Rectangle,F=new THREE.Rectangle,Z=!1,N=new THREE.Color,K=new THREE.Color,ra=new THREE.Color,Ea=new THREE.Color,$=new THREE.Vector3,Aa,ma,Ga,Ma,wa,Ia,V=16;Aa=document.createElement("canvas");Aa.width=Aa.height=2;ma=Aa.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);Ga=ma.getImageData(0,
0,2,2);Ma=Ga.data;wa=document.createElement("canvas");wa.width=wa.height=V;Ia=wa.getContext("2d");Ia.translate(-V/2,-V/2);Ia.scale(V,V);V--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(Ca,Ba){g=Ca;h=Ba;k=g/2;j=h/2;e.width=g;e.height=h;D.set(-k,-j,k,j);y=1;q=0;G=z=null;H=1};this.setClearColor=function(Ca,Ba){t=Ca;x=Ba};this.setClearColorHex=function(Ca,Ba){t.setHex(Ca);x=Ba};this.clear=function(){m.setTransform(1,0,0,-1,k,j);if(!B.isEmpty()){B.inflate(1);
B.minSelf(D);if(t.hex==0&&x==0)m.clearRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+x+")";m.fillRect(B.getX(),B.getY(),B.getWidth(),B.getHeight())}B.empty()}};this.render=function(Ca,Ba){function Ya(J){var Y,U,fa,za=J.lights;K.setRGB(0,0,0);ra.setRGB(0,0,0);Ea.setRGB(0,0,0);J=0;for(Y=za.length;J<Y;J++){U=za[J];fa=U.color;if(U instanceof THREE.AmbientLight){K.r+=fa.r;K.g+=
fa.g;K.b+=fa.b}else if(U instanceof THREE.DirectionalLight){ra.r+=fa.r;ra.g+=fa.g;ra.b+=fa.b}else if(U instanceof THREE.PointLight){Ea.r+=fa.r;Ea.g+=fa.g;Ea.b+=fa.b}}}function ua(J,Y,U,fa){var za,qa,pa,R,Ka=J.lights;J=0;for(za=Ka.length;J<za;J++){qa=Ka[J];pa=qa.color;R=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=U.dot(qa.position)*R;if(qa>0){fa.r+=pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}else if(qa instanceof THREE.PointLight){$.sub(qa.position,Y);$.normalize();qa=U.dot($)*R;if(qa>0){fa.r+=
pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}}}function ga(J,Y,U){a(U.opacity);c(U.blending);var fa,za,qa,pa,R,Ka;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){pa=U.map.image;R=pa.width>>1;Ka=pa.height>>1;U=Y.scale.x*k;qa=Y.scale.y*j;fa=U*R;za=qa*Ka;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(U,-qa);m.translate(-R,-Ka);m.drawImage(pa,0,0);m.restore()}}}else if(U instanceof THREE.ParticleCanvasMaterial){if(Z){N.r=K.r+ra.r+Ea.r;
N.g=K.g+ra.g+Ea.g;N.b=K.b+ra.b+Ea.b;aa.r=U.color.r*N.r;aa.g=U.color.g*N.g;aa.b=U.color.b*N.b;aa.updateStyleString()}else aa.__styleString=U.color.__styleString;fa=Y.scale.x*k;za=Y.scale.y*j;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(fa,za);U.program(m,aa);m.restore()}}}function ha(J,Y,U,fa){a(fa.opacity);c(fa.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(Y.positionScreen.x,Y.positionScreen.y);
m.closePath();if(fa instanceof THREE.LineBasicMaterial){aa.__styleString=fa.color.__styleString;J=fa.linewidth;if(H!=J)m.lineWidth=H=J;J=aa.__styleString;if(z!=J)m.strokeStyle=z=J;m.stroke();F.inflate(fa.linewidth*2)}}function na(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;Sa(X,f,ea,ka,W,T);if(R instanceof THREE.MeshBasicMaterial)if(R.map){if(R.map.mapping instanceof
THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}}else if(R.envMap){if(R.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=Ba.matrixWorldInverse;$.copy(pa.vertexNormalsWorld[0]);ab=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;n=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[1]);C=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;p=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[2]);o=($.x*J.n11+
$.y*J.n12+$.z*J.n13)*0.5+0.5;w=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;Ta(X,f,ea,ka,W,T,R.envMap.image,ab,n,C,p,o,w)}}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){if(R.map.mapping instanceof THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}c(THREE.SubtractiveBlending)}if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&
pa.vertexNormalsWorld.length==3){P.r=M.r=da.r=K.r;P.g=M.g=da.g=K.g;P.b=M.b=da.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],M);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],da);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();
R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);da.r=da.g=da.b=1-Va(U.positionScreen.z,ia,ta);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=
Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}}function Pa(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);if(R.map||R.envMap){na(J,Y,fa,0,1,3,pa,R,Ka);na(za,U,qa,1,2,3,pa,R,Ka)}else{X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;xa=fa.positionScreen.x;ca=fa.positionScreen.y;Da=za.positionScreen.x;
ja=za.positionScreen.y;oa=qa.positionScreen.x;la=qa.positionScreen.y;if(R instanceof THREE.MeshBasicMaterial){fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshLambertMaterial)if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&pa.vertexNormalsWorld.length==4){P.r=M.r=da.r=sa.r=K.r;P.g=M.g=da.g=sa.g=K.g;P.b=M.b=da.b=sa.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],
M);ua(Ka,pa.v4.positionWorld,pa.vertexNormalsWorld[3],da);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],sa);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else{fb(X,f,
ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);
da.r=da.g=da.b=1-Va(fa.positionScreen.z,ia,ta);sa.r=sa.g=sa.b=1-Va(U.positionScreen.z,ia,ta);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}}}function Sa(J,Y,U,fa,za,qa){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(J,Y);m.closePath()}function fb(J,Y,U,fa,za,qa,pa,R){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(pa,R);m.lineTo(J,Y);m.closePath()}function Na(J,Y){if(z!=J)m.strokeStyle=
z=J;if(H!=Y)m.lineWidth=H=Y;m.stroke();F.inflate(Y*2)}function Xa(J){if(G!=J)m.fillStyle=G=J;m.fill()}function Ta(J,Y,U,fa,za,qa,pa,R,Ka,cb,Za,db,hb){var bb,eb;bb=pa.width-1;eb=pa.height-1;R*=bb;Ka*=eb;cb*=bb;Za*=eb;db*=bb;hb*=eb;U-=J;fa-=Y;za-=J;qa-=Y;cb-=R;Za-=Ka;db-=R;hb-=Ka;bb=cb*hb-db*Za;if(bb!=0){eb=1/bb;bb=(hb*U-Za*za)*eb;Za=(hb*fa-Za*qa)*eb;U=(cb*za-db*U)*eb;fa=(cb*qa-db*fa)*eb;J=J-bb*R-U*Ka;Y=Y-Za*R-fa*Ka;m.save();m.transform(bb,Za,U,fa,J,Y);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ja(J,
Y,U,fa){var za=~~(J.r*255),qa=~~(J.g*255);J=~~(J.b*255);var pa=~~(Y.r*255),R=~~(Y.g*255);Y=~~(Y.b*255);var Ka=~~(U.r*255),cb=~~(U.g*255);U=~~(U.b*255);var Za=~~(fa.r*255),db=~~(fa.g*255);fa=~~(fa.b*255);Ma[0]=za<0?0:za>255?255:za;Ma[1]=qa<0?0:qa>255?255:qa;Ma[2]=J<0?0:J>255?255:J;Ma[4]=pa<0?0:pa>255?255:pa;Ma[5]=R<0?0:R>255?255:R;Ma[6]=Y<0?0:Y>255?255:Y;Ma[8]=Ka<0?0:Ka>255?255:Ka;Ma[9]=cb<0?0:cb>255?255:cb;Ma[10]=U<0?0:U>255?255:U;Ma[12]=Za<0?0:Za>255?255:Za;Ma[13]=db<0?0:db>255?255:db;Ma[14]=fa<
0?0:fa>255?255:fa;ma.putImageData(Ga,0,0);Ia.drawImage(Aa,0,0);return wa}function Va(J,Y,U){J=(J-Y)/(U-Y);return J*J*(3-2*J)}function Oa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function L(J,Y){var U=Y.x-J.x,fa=Y.y-J.y,za=1/Math.sqrt(U*U+fa*fa);U*=za;fa*=za;Y.x+=U;Y.y+=fa;J.x-=U;J.y-=fa}var Qa,Ua,Fa,$a,Wa,Ha,Ra,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);b=d.projectScene(Ca,Ba,this.sortElements);(Z=Ca.lights.length>0)&&Ya(Ca);Qa=0;for(Ua=b.length;Qa<Ua;Qa++){Fa=b[Qa];F.empty();if(Fa instanceof
THREE.RenderableParticle){E=Fa;E.x*=k;E.y*=j;$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ga(E,Fa,va,Ca)}}else if(Fa instanceof THREE.RenderableLine){E=Fa.v1;I=Fa.v2;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ha(E,I,Fa,va,Ca)}}}else if(Fa instanceof
THREE.RenderableFace3){E=Fa.v1;I=Fa.v2;A=Fa.v3;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,A.positionScreen);L(A.positionScreen,E.positionScreen)}F.add3Points(E.positionScreen.x,E.positionScreen.y,I.positionScreen.x,I.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<Wa;){va=
Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}else va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}}}else if(Fa instanceof THREE.RenderableFace4){E=Fa.v1;I=Fa.v2;A=Fa.v3;S=Fa.v4;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;S.positionScreen.x*=k;S.positionScreen.y*=j;Q.positionScreen.copy(I.positionScreen);
O.positionScreen.copy(S.positionScreen);if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,S.positionScreen);L(S.positionScreen,E.positionScreen);L(A.positionScreen,Q.positionScreen);L(A.positionScreen,O.positionScreen)}F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);F.addPoint(A.positionScreen.x,A.positionScreen.y);F.addPoint(S.positionScreen.x,S.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<
Wa;){va=Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}else va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}}}B.addRectangle(F)}m.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(ja,oa,la){var aa,P,M,da;aa=0;for(P=ja.lights.length;aa<P;aa++){M=ja.lights[aa];if(M instanceof THREE.DirectionalLight){da=oa.normalWorld.dot(M.position)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}else if(M instanceof THREE.PointLight){ea.sub(M.position,oa.centroidWorld);ea.normalize();da=oa.normalWorld.dot(ea)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}}}function c(ja,oa,la,aa,P,M){T=d(xa++);
T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(M,aa,S);A.r=P.color.r*S.r;A.g=P.color.g*S.g;A.b=P.color.b*S.b;A.updateStyleString()}else A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){f=
1-P.__2near/(P.__farPlusNear-aa.z*P.__farMinusNear);A.setRGB(f,f,f)}else P instanceof THREE.MeshNormalMaterial&&A.setRGB(e(aa.normalWorld.x),e(aa.normalWorld.y),e(aa.normalWorld.z));P.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+P.wireframeLinewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframeLinecap+"; stroke-linejoin: "+P.wireframeLinejoin):T.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+P.opacity);k.appendChild(T)}
function b(ja,oa,la,aa,P,M,da){T=d(xa++);T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)A.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(da,P,S);A.r=M.color.r*S.r;A.g=M.color.g*S.g;A.b=M.color.b*S.b;A.updateStyleString()}else A.__styleString=
M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){f=1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);A.setRGB(f,f,f)}else M instanceof THREE.MeshNormalMaterial&&A.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));M.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):T.setAttribute("style","fill: "+
A.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(T)}function d(ja){if(ka[ja]==null){ka[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&ka[ja].setAttribute("shape-rendering","crispEdges")}return ka[ja]}function e(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,t,x,y,q,z,G,H=new THREE.Rectangle,E=new THREE.Rectangle,I=!1,A=new THREE.Color(16777215),
S=new THREE.Color(16777215),Q=new THREE.Color(0),O=new THREE.Color(0),X=new THREE.Color(0),f,ea=new THREE.Vector3,ka=[],W=[],T,xa,ca,Da=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":Da=1;break;case "low":Da=0}};this.setSize=function(ja,oa){j=ja;m=oa;t=j/2;x=m/2;k.setAttribute("viewBox",-t+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-t,-x,t,x)};this.clear=function(){for(;k.childNodes.length>
0;)k.removeChild(k.childNodes[0])};this.render=function(ja,oa){var la,aa,P,M,da,sa,ia,ta;this.autoClear&&this.clear();g=h.projectScene(ja,oa,this.sortElements);ca=xa=0;if(I=ja.lights.length>0){ia=ja.lights;Q.setRGB(0,0,0);O.setRGB(0,0,0);X.setRGB(0,0,0);la=0;for(aa=ia.length;la<aa;la++){P=ia[la];M=P.color;if(P instanceof THREE.AmbientLight){Q.r+=M.r;Q.g+=M.g;Q.b+=M.b}else if(P instanceof THREE.DirectionalLight){O.r+=M.r;O.g+=M.g;O.b+=M.b}else if(P instanceof THREE.PointLight){X.r+=M.r;X.g+=M.g;X.b+=
M.b}}}la=0;for(aa=g.length;la<aa;la++){ia=g[la];E.empty();if(ia instanceof THREE.RenderableParticle){y=ia;y.x*=t;y.y*=-x;P=0;for(M=ia.materials.length;P<M;)P++}else if(ia instanceof THREE.RenderableLine){y=ia.v1;q=ia.v2;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.materials.length;P<M;)if((ta=ia.materials[P++])&&ta.opacity!=
0){da=y;sa=q;var ya=ca++;if(W[ya]==null){W[ya]=document.createElementNS("http://www.w3.org/2000/svg","line");Da==0&&W[ya].setAttribute("shape-rendering","crispEdges")}T=W[ya];T.setAttribute("x1",da.positionScreen.x);T.setAttribute("y1",da.positionScreen.y);T.setAttribute("x2",sa.positionScreen.x);T.setAttribute("y2",sa.positionScreen.y);if(ta instanceof THREE.LineBasicMaterial){A.__styleString=ta.color.__styleString;T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+
ta.linewidth+"; stroke-opacity: "+ta.opacity+"; stroke-linecap: "+ta.linecap+"; stroke-linejoin: "+ta.linejoin);k.appendChild(T)}}}}else if(ia instanceof THREE.RenderableFace3){y=ia.v1;q=ia.v2;z=ia.v3;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(E)){P=
0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}else ta&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}}}else if(ia instanceof THREE.RenderableFace4){y=ia.v1;q=ia.v2;z=ia.v3;G=ia.v4;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;G.positionScreen.x*=t;G.positionScreen.y*=
-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);E.addPoint(G.positionScreen.x,G.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}else ta&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}}}}}};
THREE.Projector=function(){function a(){var X=m[k]=m[k]||new THREE.RenderableVertex;k++;return X}function c(X,W){return W.z-X.z}function b(X,W){var wa=0,ha=1,Aa=X.z+X.w,ka=W.z+W.w,oa=-X.z+X.w,ma=-W.z+W.w;if(Aa>=0&&ka>=0&&oa>=0&&ma>=0)return!0;else if(Aa<0&&ka<0||oa<0&&ma<0)return!1;else{if(Aa<0)wa=Math.max(wa,Aa/(Aa-ka));else ka<0&&(ha=Math.min(ha,Aa/(Aa-ka)));if(oa<0)wa=Math.max(wa,oa/(oa-ma));else ma<0&&(ha=Math.min(ha,oa/(oa-ma)));if(ha<wa)return!1;else{X.lerpSelf(W,wa);W.lerpSelf(X,1-ha);return!0}}}
var d,f,g=[],h,k,m=[],n,q,x=[],z,p=[],A,G,I=[],C,J,B=[],U=new THREE.Vector4,P=new THREE.Vector4,O=new THREE.Matrix4,V=new THREE.Matrix4,Y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],e=new THREE.Vector4,ja=new THREE.Vector4;this.projectVector=function(X,W){O.multiply(W.projectionMatrix,W.matrixWorldInverse);O.multiplyVector3(X);return X};this.unprojectVector=function(X,W){O.multiply(W.matrixWorld,THREE.Matrix4.makeInvert(W.projectionMatrix));
O.multiplyVector3(X);return X};this.projectObjects=function(X,W,wa){W=[];var ha,Aa,ka;f=0;Aa=X.objects;X=0;for(ha=Aa.length;X<ha;X++){ka=Aa[X];var oa;if(!(oa=!ka.visible))if(oa=ka instanceof THREE.Mesh){a:{oa=void 0;for(var ma=ka.matrixWorld,ca=-ka.geometry.boundingSphere.radius*Math.max(ka.scale.x,Math.max(ka.scale.y,ka.scale.z)),S=0;S<6;S++){oa=Y[S].x*ma.n14+Y[S].y*ma.n24+Y[S].z*ma.n34+Y[S].w;if(oa<=ca){oa=!1;break a}}oa=!0}oa=!oa}if(!oa){oa=g[f]=g[f]||new THREE.RenderableObject;f++;d=oa;U.copy(ka.position);
O.multiplyVector3(U);d.object=ka;d.z=U.z;W.push(d)}}wa&&W.sort(c);return W};this.projectScene=function(X,W,wa){var ha=[],Aa=W.near,ka=W.far,oa,ma,ca,S,M,fa,ra,la,qa,xa,Ca,Za,$a,Ha,j,w,t;J=G=z=q=0;W.matrixAutoUpdate&&W.updateMatrix();X.update(undefined,!1,W);O.multiply(W.projectionMatrix,W.matrixWorldInverse);Y[0].set(O.n41-O.n11,O.n42-O.n12,O.n43-O.n13,O.n44-O.n14);Y[1].set(O.n41+O.n11,O.n42+O.n12,O.n43+O.n13,O.n44+O.n14);Y[2].set(O.n41+O.n21,O.n42+O.n22,O.n43+O.n23,O.n44+O.n24);Y[3].set(O.n41-O.n21,
O.n42-O.n22,O.n43-O.n23,O.n44-O.n24);Y[4].set(O.n41-O.n31,O.n42-O.n32,O.n43-O.n33,O.n44-O.n34);Y[5].set(O.n41+O.n31,O.n42+O.n32,O.n43+O.n33,O.n44+O.n34);for(oa=0;oa<6;oa++){qa=Y[oa];qa.divideScalar(Math.sqrt(qa.x*qa.x+qa.y*qa.y+qa.z*qa.z))}qa=this.projectObjects(X,W,!0);X=0;for(oa=qa.length;X<oa;X++){xa=qa[X].object;if(xa.visible){Ca=xa.matrixWorld;Za=xa.matrixRotationWorld;$a=xa.materials;Ha=xa.overdraw;k=0;if(xa instanceof THREE.Mesh){j=xa.geometry;S=j.vertices;w=j.faces;j=j.faceVertexUvs;ma=0;
for(ca=S.length;ma<ca;ma++){h=a();h.positionWorld.copy(S[ma].position);Ca.multiplyVector3(h.positionWorld);h.positionScreen.copy(h.positionWorld);O.multiplyVector4(h.positionScreen);h.positionScreen.x/=h.positionScreen.w;h.positionScreen.y/=h.positionScreen.w;h.visible=h.positionScreen.z>Aa&&h.positionScreen.z<ka}S=0;for(ma=w.length;S<ma;S++){ca=w[S];if(ca instanceof THREE.Face3){M=m[ca.a];fa=m[ca.b];ra=m[ca.c];if(M.visible&&fa.visible&&ra.visible&&(xa.doubleSided||xa.flipSided!=(ra.positionScreen.x-
M.positionScreen.x)*(fa.positionScreen.y-M.positionScreen.y)-(ra.positionScreen.y-M.positionScreen.y)*(fa.positionScreen.x-M.positionScreen.x)<0)){la=x[q]=x[q]||new THREE.RenderableFace3;q++;n=la;n.v1.copy(M);n.v2.copy(fa);n.v3.copy(ra)}else continue}else if(ca instanceof THREE.Face4){M=m[ca.a];fa=m[ca.b];ra=m[ca.c];la=m[ca.d];if(M.visible&&fa.visible&&ra.visible&&la.visible&&(xa.doubleSided||xa.flipSided!=((la.positionScreen.x-M.positionScreen.x)*(fa.positionScreen.y-M.positionScreen.y)-(la.positionScreen.y-
M.positionScreen.y)*(fa.positionScreen.x-M.positionScreen.x)<0||(fa.positionScreen.x-ra.positionScreen.x)*(la.positionScreen.y-ra.positionScreen.y)-(fa.positionScreen.y-ra.positionScreen.y)*(la.positionScreen.x-ra.positionScreen.x)<0))){t=p[z]=p[z]||new THREE.RenderableFace4;z++;n=t;n.v1.copy(M);n.v2.copy(fa);n.v3.copy(ra);n.v4.copy(la)}else continue}n.normalWorld.copy(ca.normal);Za.multiplyVector3(n.normalWorld);n.centroidWorld.copy(ca.centroid);Ca.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld);
O.multiplyVector3(n.centroidScreen);ra=ca.vertexNormals;M=0;for(fa=ra.length;M<fa;M++){la=n.vertexNormalsWorld[M];la.copy(ra[M]);Za.multiplyVector3(la)}M=0;for(fa=j.length;M<fa;M++)if(t=j[M][S]){ra=0;for(la=t.length;ra<la;ra++)n.uvs[M][ra]=t[ra]}n.meshMaterials=$a;n.faceMaterials=ca.materials;n.overdraw=Ha;n.z=n.centroidScreen.z;ha.push(n)}}else if(xa instanceof THREE.Line){V.multiply(O,Ca);S=xa.geometry.vertices;M=a();M.positionScreen.copy(S[0].position);V.multiplyVector4(M.positionScreen);ma=1;
for(ca=S.length;ma<ca;ma++){M=a();M.positionScreen.copy(S[ma].position);V.multiplyVector4(M.positionScreen);fa=m[k-2];e.copy(M.positionScreen);ja.copy(fa.positionScreen);if(b(e,ja)){e.multiplyScalar(1/e.w);ja.multiplyScalar(1/ja.w);Ca=I[G]=I[G]||new THREE.RenderableLine;G++;A=Ca;A.v1.positionScreen.copy(e);A.v2.positionScreen.copy(ja);A.z=Math.max(e.z,ja.z);A.materials=xa.materials;ha.push(A)}}}else if(xa instanceof THREE.Particle){P.set(xa.position.x,xa.position.y,xa.position.z,1);O.multiplyVector4(P);
P.z/=P.w;if(P.z>0&&P.z<1){Ca=B[J]=B[J]||new THREE.RenderableParticle;J++;C=Ca;C.x=P.x/P.w;C.y=P.y/P.w;C.z=P.z;C.rotation=xa.rotation.z;C.scale.x=xa.scale.x*Math.abs(C.x-(P.x+W.projectionMatrix.n11)/(P.w+W.projectionMatrix.n14));C.scale.y=xa.scale.y*Math.abs(C.y-(P.y+W.projectionMatrix.n22)/(P.w+W.projectionMatrix.n24));C.materials=xa.materials;ha.push(C)}}}}wa&&ha.sort(c);return ha}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;f=b/2;g=d/2};this.render=function(h,k){var m,n,q,x,z,p,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m<n;m++){z=a[m];if(z instanceof THREE.RenderableParticle){A=z.x*f+f;G=z.y*g+g;q=0;for(x=z.material.length;q<x;q++){p=z.material[q];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=A+"px";p.style.top=G+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(R){if(z!=R)n.globalAlpha=z=R}function c(R){if(p!=R){switch(R){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}p=R}}var b=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,m,n=f.getContext("2d"),q=new THREE.Color(0),x=0,z=1,p=0,A=null,G=null,I=1,C,J,B,U,P=new THREE.RenderableVertex,
O=new THREE.RenderableVertex,V,Y,e,ja,X,W,wa,ha,Aa,ka,oa,ma,ca=new THREE.Color,S=new THREE.Color,M=new THREE.Color,fa=new THREE.Color,ra=new THREE.Color,la,qa,xa,Ca,Za,$a,Ha,j,w,t,o=new THREE.Rectangle,y=new THREE.Rectangle,E=new THREE.Rectangle,K=!1,F=new THREE.Color,D=new THREE.Color,Q=new THREE.Color,H=new THREE.Color,T=new THREE.Vector3,ga,pa,sa,ya,ua,Ea,da=16;ga=document.createElement("canvas");ga.width=ga.height=2;pa=ga.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);sa=pa.getImageData(0,
0,2,2);ya=sa.data;ua=document.createElement("canvas");ua.width=ua.height=da;Ea=ua.getContext("2d");Ea.translate(-da/2,-da/2);Ea.scale(da,da);da--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(R,ia){g=R;h=ia;k=g/2;m=h/2;f.width=g;f.height=h;o.set(-k,-m,k,m);z=1;p=0;G=A=null;I=1};this.setClearColor=function(R,ia){q=R;x=ia};this.setClearColorHex=function(R,ia){q.setHex(R);x=ia};this.clear=function(){n.setTransform(1,0,0,-1,k,m);if(!y.isEmpty()){y.inflate(1);
y.minSelf(o);if(q.hex==0&&x==0)n.clearRect(y.getX(),y.getY(),y.getWidth(),y.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+x+")";n.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight())}y.empty()}};this.render=function(R,ia){function La(L){var Z,na,aa,ta=L.lights;D.setRGB(0,0,0);Q.setRGB(0,0,0);H.setRGB(0,0,0);L=0;for(Z=ta.length;L<Z;L++){na=ta[L];aa=na.color;if(na instanceof THREE.AmbientLight){D.r+=aa.r;
D.g+=aa.g;D.b+=aa.b}else if(na instanceof THREE.DirectionalLight){Q.r+=aa.r;Q.g+=aa.g;Q.b+=aa.b}else if(na instanceof THREE.PointLight){H.r+=aa.r;H.g+=aa.g;H.b+=aa.b}}}function Ga(L,Z,na,aa){var ta,za,ea,$,Ka=L.lights;L=0;for(ta=Ka.length;L<ta;L++){za=Ka[L];ea=za.color;$=za.intensity;if(za instanceof THREE.DirectionalLight){za=na.dot(za.position)*$;if(za>0){aa.r+=ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}else if(za instanceof THREE.PointLight){T.sub(za.position,Z);T.normalize();za=na.dot(T)*$;if(za>0){aa.r+=
ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,za,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;za=Z.scale.y*m;aa=na*$;ta=za*Ka;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-za);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(K){F.r=D.r+
Q.r+H.r;F.g=D.g+Q.g+H.g;F.b=D.b+Q.b+H.b;ca.r=na.color.r*F.r;ca.g=na.color.g*F.g;ca.b=na.color.b*F.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y);
n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(I!=L)n.lineWidth=I=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();E.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;bb(V,Y,e,ja,X,W);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof
THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;T.copy(ea.vertexNormalsWorld[0]);Za=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;$a=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[1]);Ha=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;j=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[2]);w=(T.x*L.n11+
T.y*L.n12+T.z*L.n13)*0.5+0.5;t=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Da(V,Y,e,ja,X,W,$.envMap.image,Za,$a,Ha,j,w,t)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}c(THREE.SubtractiveBlending)}if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&&
ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=D.r;S.g=M.g=fa.g=D.g;S.b=M.b=fa.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString();
$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,la,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=
N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,za,1,2,3,ea,$,Ka)}else{V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;wa=aa.positionScreen.x;ha=aa.positionScreen.y;Aa=ta.positionScreen.x;
ka=ta.positionScreen.y;oa=za.positionScreen.x;ma=za.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=D.r;S.g=M.g=fa.g=ra.g=D.g;S.b=M.b=fa.b=ra.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],
M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(V,Y,e,ja,
X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g=
fa.b=1-Ma(aa.positionScreen.z,la,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,la,qa);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,za){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,za,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle=
A=L;if(I!=Z)n.lineWidth=I=Z;n.stroke();E.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,za,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;za-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*za)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*za-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}}
function Va(L,Z,na,aa){var ta=~~(L.r*255),za=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);ya[0]=ta<0?0:ta>255?255:ta;ya[1]=za<0?0:za>255?255:za;ya[2]=L<0?0:L>255?255:L;ya[4]=ea<0?0:ea>255?255:ea;ya[5]=$<0?0:$>255?255:$;ya[6]=Z<0?0:Z>255?255:Z;ya[8]=Ka<0?0:Ka>255?255:Ka;ya[9]=Xa<0?0:Xa>255?255:Xa;ya[10]=na<0?0:na>255?255:na;ya[12]=Ya<0?0:Ya>255?255:Ya;ya[13]=cb<0?0:cb>
255?255:cb;ya[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ga,0,0);return ua}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,va;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(R,ia,this.sortElements);(K=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa<ib;Qa++){Ba=
b[Qa];E.empty();if(Ba instanceof THREE.RenderableParticle){C=Ba;C.x*=k;C.y*=m;Sa=0;for(Fa=Ba.materials.length;Sa<Fa;){va=Ba.materials[Sa++];va.opacity!=0&&eb(C,Ba,va,R)}}else if(Ba instanceof THREE.RenderableLine){C=Ba.v1;J=Ba.v2;C.positionScreen.x*=k;C.positionScreen.y*=m;J.positionScreen.x*=k;J.positionScreen.y*=m;E.addPoint(C.positionScreen.x,C.positionScreen.y);E.addPoint(J.positionScreen.x,J.positionScreen.y);if(o.instersects(E)){Sa=0;for(Fa=Ba.materials.length;Sa<Fa;){va=Ba.materials[Sa++];
va.opacity!=0&&Ta(C,J,Ba,va,R)}}}else if(Ba instanceof THREE.RenderableFace3){C=Ba.v1;J=Ba.v2;B=Ba.v3;C.positionScreen.x*=k;C.positionScreen.y*=m;J.positionScreen.x*=k;J.positionScreen.y*=m;B.positionScreen.x*=k;B.positionScreen.y*=m;if(Ba.overdraw){Na(C.positionScreen,J.positionScreen);Na(J.positionScreen,B.positionScreen);Na(B.positionScreen,C.positionScreen)}E.add3Points(C.positionScreen.x,C.positionScreen.y,J.positionScreen.x,J.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(o.instersects(E)){Sa=
0;for(Fa=Ba.meshMaterials.length;Sa<Fa;){va=Ba.meshMaterials[Sa++];if(va instanceof THREE.MeshFaceMaterial){Oa=0;for(Ja=Ba.faceMaterials.length;Oa<Ja;)(va=Ba.faceMaterials[Oa++])&&va.opacity!=0&&Ia(C,J,B,0,1,2,Ba,va,R)}else va.opacity!=0&&Ia(C,J,B,0,1,2,Ba,va,R)}}}else if(Ba instanceof THREE.RenderableFace4){C=Ba.v1;J=Ba.v2;B=Ba.v3;U=Ba.v4;C.positionScreen.x*=k;C.positionScreen.y*=m;J.positionScreen.x*=k;J.positionScreen.y*=m;B.positionScreen.x*=k;B.positionScreen.y*=m;U.positionScreen.x*=k;U.positionScreen.y*=
m;P.positionScreen.copy(J.positionScreen);O.positionScreen.copy(U.positionScreen);if(Ba.overdraw){Na(C.positionScreen,J.positionScreen);Na(J.positionScreen,U.positionScreen);Na(U.positionScreen,C.positionScreen);Na(B.positionScreen,P.positionScreen);Na(B.positionScreen,O.positionScreen)}E.addPoint(C.positionScreen.x,C.positionScreen.y);E.addPoint(J.positionScreen.x,J.positionScreen.y);E.addPoint(B.positionScreen.x,B.positionScreen.y);E.addPoint(U.positionScreen.x,U.positionScreen.y);if(o.instersects(E)){Sa=
0;for(Fa=Ba.meshMaterials.length;Sa<Fa;){va=Ba.meshMaterials[Sa++];if(va instanceof THREE.MeshFaceMaterial){Oa=0;for(Ja=Ba.faceMaterials.length;Oa<Ja;)(va=Ba.faceMaterials[Oa++])&&va.opacity!=0&&Ra(C,J,B,U,P,O,Ba,va,R)}else va.opacity!=0&&Ra(C,J,B,U,P,O,Ba,va,R)}}}y.addRectangle(E)}n.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(ka,oa,ma){var ca,S,M,fa;ca=0;for(S=ka.lights.length;ca<S;ca++){M=ka.lights[ca];if(M instanceof THREE.DirectionalLight){fa=oa.normalWorld.dot(M.position)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){e.sub(M.position,oa.centroidWorld);e.normalize();fa=oa.normalWorld.dot(e)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(ka,oa,ma,ca,S,M){W=d(wa++);
W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);B.r=S.color.r*U.r;B.g=S.color.g*U.g;B.b=S.color.b*U.b;B.updateStyleString()}else B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y=
1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);B.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&B.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):W.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(W)}
function b(ka,oa,ma,ca,S,M,fa){W=d(wa++);W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)B.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);B.r=M.color.r*U.r;B.g=M.color.g*U.g;B.b=M.color.b*U.b;B.updateStyleString()}else B.__styleString=
M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);B.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&B.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):W.setAttribute("style","fill: "+
B.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(W)}function d(ka){if(ja[ka]==null){ja[ka]=document.createElementNS("http://www.w3.org/2000/svg","path");Aa==0&&ja[ka].setAttribute("shape-rendering","crispEdges")}return ja[ka]}function f(ka){return ka<0?Math.min((1+ka)*0.5,0.5):0.5+Math.min(ka*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,q,x,z,p,A,G,I=new THREE.Rectangle,C=new THREE.Rectangle,J=!1,B=new THREE.Color(16777215),
U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),V=new THREE.Color(0),Y,e=new THREE.Vector3,ja=[],X=[],W,wa,ha,Aa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ka){switch(ka){case "high":Aa=1;break;case "low":Aa=0}};this.setSize=function(ka,oa){m=ka;n=oa;q=m/2;x=n/2;k.setAttribute("viewBox",-q+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-q,-x,q,x)};this.clear=function(){for(;k.childNodes.length>
0;)k.removeChild(k.childNodes[0])};this.render=function(ka,oa){var ma,ca,S,M,fa,ra,la,qa;this.autoClear&&this.clear();g=h.projectScene(ka,oa,this.sortElements);ha=wa=0;if(J=ka.lights.length>0){la=ka.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);V.setRGB(0,0,0);ma=0;for(ca=la.length;ma<ca;ma++){S=la[ma];M=S.color;if(S instanceof THREE.AmbientLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}else if(S instanceof THREE.DirectionalLight){O.r+=M.r;O.g+=M.g;O.b+=M.b}else if(S instanceof THREE.PointLight){V.r+=M.r;V.g+=M.g;V.b+=
M.b}}}ma=0;for(ca=g.length;ma<ca;ma++){la=g[ma];C.empty();if(la instanceof THREE.RenderableParticle){z=la;z.x*=q;z.y*=-x;S=0;for(M=la.materials.length;S<M;)S++}else if(la instanceof THREE.RenderableLine){z=la.v1;p=la.v2;z.positionScreen.x*=q;z.positionScreen.y*=-x;p.positionScreen.x*=q;p.positionScreen.y*=-x;C.addPoint(z.positionScreen.x,z.positionScreen.y);C.addPoint(p.positionScreen.x,p.positionScreen.y);if(I.instersects(C)){S=0;for(M=la.materials.length;S<M;)if((qa=la.materials[S++])&&qa.opacity!=
0){fa=z;ra=p;var xa=ha++;if(X[xa]==null){X[xa]=document.createElementNS("http://www.w3.org/2000/svg","line");Aa==0&&X[xa].setAttribute("shape-rendering","crispEdges")}W=X[xa];W.setAttribute("x1",fa.positionScreen.x);W.setAttribute("y1",fa.positionScreen.y);W.setAttribute("x2",ra.positionScreen.x);W.setAttribute("y2",ra.positionScreen.y);if(qa instanceof THREE.LineBasicMaterial){B.__styleString=qa.color.__styleString;W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+
qa.linewidth+"; stroke-opacity: "+qa.opacity+"; stroke-linecap: "+qa.linecap+"; stroke-linejoin: "+qa.linejoin);k.appendChild(W)}}}}else if(la instanceof THREE.RenderableFace3){z=la.v1;p=la.v2;A=la.v3;z.positionScreen.x*=q;z.positionScreen.y*=-x;p.positionScreen.x*=q;p.positionScreen.y*=-x;A.positionScreen.x*=q;A.positionScreen.y*=-x;C.addPoint(z.positionScreen.x,z.positionScreen.y);C.addPoint(p.positionScreen.x,p.positionScreen.y);C.addPoint(A.positionScreen.x,A.positionScreen.y);if(I.instersects(C)){S=
0;for(M=la.meshMaterials.length;S<M;){qa=la.meshMaterials[S++];if(qa instanceof THREE.MeshFaceMaterial){fa=0;for(ra=la.faceMaterials.length;fa<ra;)(qa=la.faceMaterials[fa++])&&qa.opacity!=0&&c(z,p,A,la,qa,ka)}else qa&&qa.opacity!=0&&c(z,p,A,la,qa,ka)}}}else if(la instanceof THREE.RenderableFace4){z=la.v1;p=la.v2;A=la.v3;G=la.v4;z.positionScreen.x*=q;z.positionScreen.y*=-x;p.positionScreen.x*=q;p.positionScreen.y*=-x;A.positionScreen.x*=q;A.positionScreen.y*=-x;G.positionScreen.x*=q;G.positionScreen.y*=
-x;C.addPoint(z.positionScreen.x,z.positionScreen.y);C.addPoint(p.positionScreen.x,p.positionScreen.y);C.addPoint(A.positionScreen.x,A.positionScreen.y);C.addPoint(G.positionScreen.x,G.positionScreen.y);if(I.instersects(C)){S=0;for(M=la.meshMaterials.length;S<M;){qa=la.meshMaterials[S++];if(qa instanceof THREE.MeshFaceMaterial){fa=0;for(ra=la.faceMaterials.length;fa<ra;)(qa=la.faceMaterials[fa++])&&qa.opacity!=0&&b(z,p,A,G,la,qa,ka)}else qa&&qa.opacity!=0&&b(z,p,A,G,la,qa,ka)}}}}}};
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 int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float 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",
@@ -207,115 +213,121 @@ default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = pr
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",
value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",
value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
THREE.ShaderLib={shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nvoid main( void )\n{\ngl_FragColor = vec4( 0, 0, 0, 0.5 );\n}"},shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;\nvec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;\nvec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );\ngl_Position = projectionMatrix * viewMatrix * final;\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1, 1, 1, 1 );\n}"},
depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}},
fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,
THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",
THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",
THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),
vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
THREE.WebGLRenderer=function(a){function c(n,C,p){var o,w,D,B=n.vertices,F=B.length,Z=n.colors,N=Z.length,K=n.__vertexArray,ra=n.__colorArray,Ea=n.__sortArray,$=n.__dirtyVertices,Aa=n.__dirtyColors;if(p.sortParticles){M.multiplySelf(p.matrixWorld);for(o=0;o<F;o++){w=B[o].position;ia.copy(w);M.multiplyVector3(ia);Ea[o]=[ia.z,o]}Ea.sort(function(ma,Ga){return Ga[0]-ma[0]});for(o=0;o<F;o++){w=B[Ea[o][1]].position;D=o*3;K[D]=w.x;K[D+1]=w.y;K[D+2]=w.z}for(o=0;o<N;o++){D=o*3;color=Z[Ea[o][1]];ra[D]=color.r;
ra[D+1]=color.g;ra[D+2]=color.b}}else{if($)for(o=0;o<F;o++){w=B[o].position;D=o*3;K[D]=w.x;K[D+1]=w.y;K[D+2]=w.z}if(Aa)for(o=0;o<N;o++){color=Z[o];D=o*3;ra[D]=color.r;ra[D+1]=color.g;ra[D+2]=color.b}}if($||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,K,C)}if(Aa||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,ra,C)}}function b(n,C){n.fragmentShader=C.fragmentShader;n.vertexShader=C.vertexShader;n.uniforms=
Uniforms.clone(C.uniforms)}function d(n,C,p,o,w){o.program||W.initMaterial(o,C,p,w);var D=o.program,B=D.uniforms,F=o.uniforms;if(D!=ea){f.useProgram(D);ea=D}f.uniformMatrix4fv(B.projectionMatrix,!1,da);if(p&&(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial||o instanceof THREE.LineBasicMaterial||o instanceof THREE.ParticleBasicMaterial)){F.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){F.fogNear.value=p.near;F.fogFar.value=
p.far}else if(p instanceof THREE.FogExp2)F.fogDensity.value=p.density}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o.lights){var Z,N,K=0,ra=0,Ea=0,$,Aa,ma,Ga=ta,Ma=Ga.directional.colors,wa=Ga.directional.positions,Ia=Ga.point.colors,V=Ga.point.positions,Ca=0,Ba=0;p=N=N=0;for(Z=C.length;p<Z;p++){N=C[p];$=N.color;Aa=N.position;ma=N.intensity;if(N instanceof THREE.AmbientLight){K+=$.r;ra+=$.g;Ea+=$.b}else if(N instanceof THREE.DirectionalLight){N=Ca*3;Ma[N]=$.r*ma;
Ma[N+1]=$.g*ma;Ma[N+2]=$.b*ma;wa[N]=Aa.x;wa[N+1]=Aa.y;wa[N+2]=Aa.z;Ca+=1}else if(N instanceof THREE.PointLight){N=Ba*3;Ia[N]=$.r*ma;Ia[N+1]=$.g*ma;Ia[N+2]=$.b*ma;V[N]=Aa.x;V[N+1]=Aa.y;V[N+2]=Aa.z;Ba+=1}}for(p=Ca*3;p<Ma.length;p++)Ma[p]=0;for(p=Ba*3;p<Ia.length;p++)Ia[p]=0;Ga.point.length=Ba;Ga.directional.length=Ca;Ga.ambient[0]=K;Ga.ambient[1]=ra;Ga.ambient[2]=Ea;C=ta;F.enableLighting.value=C.directional.length+C.point.length;F.ambientLightColor.value=C.ambient;F.directionalLightColor.value=C.directional.colors;
F.directionalLightDirection.value=C.directional.positions;F.pointLightColor.value=C.point.colors;F.pointLightPosition.value=C.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.map.texture=o.map;F.lightMap.texture=o.lightMap;F.envMap.texture=o.envMap;F.reflectivity.value=o.reflectivity;F.refractionRatio.value=
o.refractionRatio;F.combine.value=o.combine;F.useRefract.value=o.envMap&&o.envMap.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){F.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.size.value=o.size;F.scale.value=X.height/2;F.map.texture=o.map}else if(o instanceof
THREE.MeshPhongMaterial){F.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);F.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);F.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){F.mNear.value=n.near;F.mFar.value=n.far;F.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)F.opacity.value=o.opacity;for(var Ya in F)if(K=D.uniforms[Ya]){p=F[Ya];Z=p.type;C=p.value;if(Z=="i")f.uniform1i(K,C);else if(Z=="f")f.uniform1f(K,C);else if(Z=="fv1")f.uniform1fv(K,
C);else if(Z=="fv")f.uniform3fv(K,C);else if(Z=="v2")f.uniform2f(K,C.x,C.y);else if(Z=="v3")f.uniform3f(K,C.x,C.y,C.z);else if(Z=="c")f.uniform3f(K,C.r,C.g,C.b);else if(Z=="t"){f.uniform1i(K,C);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(Z=0;Z<6;++Z)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,f.RGBA,f.UNSIGNED_BYTE,p.image[Z])}else{p.image.__webGLTextureCube=
f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(Z=0;Z<6;++Z)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image[Z]);p.__wasSetOnce=!0}I(f.TEXTURE_CUBE_MAP,p,p.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+C);f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,
0,0,0,f.RGBA,f.UNSIGNED_BYTE,p.image)}else{p.__webGLTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image);p.__wasSetOnce=!0}I(f.TEXTURE_2D,p,p.image);f.bindTexture(f.TEXTURE_2D,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+C);f.bindTexture(f.TEXTURE_2D,p.__webGLTexture)}}}f.uniformMatrix4fv(B.modelViewMatrix,!1,w._modelViewMatrixArray);f.uniformMatrix3fv(B.normalMatrix,!1,w._normalMatrixArray);(o instanceof THREE.MeshShaderMaterial||
o instanceof THREE.MeshPhongMaterial||o.envMap)&&f.uniform3f(B.cameraPosition,n.position.x,n.position.y,n.position.z);(o instanceof THREE.MeshShaderMaterial||o.envMap||o.skinning)&&f.uniformMatrix4fv(B.objectMatrix,!1,w._objectMatrixArray);(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial||o.skinning)&&f.uniformMatrix4fv(B.viewMatrix,!1,sa);if(o.skinning){f.uniformMatrix4fv(B.cameraInverseMatrix,!1,sa);f.uniformMatrix4fv(B.boneGlobalMatrices,
!1,w.boneMatrices)}return D}function e(n,C,p,o,w,D){if(o.opacity!=0){n=d(n,C,p,o,D).attributes;if(o.morphTargets){C=o.program.attributes;D.morphTargetBase!==-1?f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[D.morphTargetBase]):f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(C.position,3,f.FLOAT,!1,0,0);if(D.morphTargetForcedOrder.length){p=0;for(var B=D.morphTargetForcedOrder,F=D.morphTargetInfluences;p<o.numSupportedMorphTargets&&p<B.length;){f.bindBuffer(f.ARRAY_BUFFER,
w.__webGLMorphTargetsBuffers[B[p]]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=F[B[p]];p++}}else{B=[];var Z=-1,N=0;F=D.morphTargetInfluences;var K,ra=F.length;p=0;for(D.morphTargetBase!==-1&&(B[D.morphTargetBase]=!0);p<o.numSupportedMorphTargets;){for(K=0;K<ra;K++)if(!B[K]&&F[K]>Z){N=K;Z=F[N]}f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[N]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=Z;B[N]=
1;Z=-1;p++}}f.uniform1fv(o.program.uniforms.morphTargetInfluences,D.__webGLMorphTargetInfluences)}else{f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(n.position,3,f.FLOAT,!1,0,0)}if(n.color>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLColorBuffer);f.vertexAttribPointer(n.color,3,f.FLOAT,!1,0,0)}if(n.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLNormalBuffer);f.vertexAttribPointer(n.normal,3,f.FLOAT,!1,0,0)}if(n.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLTangentBuffer);
f.vertexAttribPointer(n.tangent,4,f.FLOAT,!1,0,0)}if(n.uv>=0)if(w.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUVBuffer);f.vertexAttribPointer(n.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv)}else f.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(w.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUV2Buffer);f.vertexAttribPointer(n.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv2)}else f.disableVertexAttribArray(n.uv2);if(o.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=
0&&n.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexABuffer);f.vertexAttribPointer(n.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexBBuffer);f.vertexAttribPointer(n.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinIndicesBuffer);f.vertexAttribPointer(n.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinWeightsBuffer);f.vertexAttribPointer(n.skinWeight,4,f.FLOAT,!1,0,0)}if(D instanceof THREE.Mesh)if(o.wireframe){f.lineWidth(o.wireframeLinewidth);
f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);f.drawElements(f.LINES,w.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,w.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(D instanceof THREE.Line){D=D.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(o.linewidth);f.drawArrays(D,0,w.__webGLLineCount)}else if(D instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,w.__webGLParticleCount);else D instanceof THREE.Ribbon&&
f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(n,C){if(!n.__webGLVertexBuffer)n.__webGLVertexBuffer=f.createBuffer();if(!n.__webGLNormalBuffer)n.__webGLNormalBuffer=f.createBuffer();if(n.hasPos){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,n.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.position);f.vertexAttribPointer(C.attributes.position,3,f.FLOAT,!1,0,0)}if(n.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLNormalBuffer);
f.bufferData(f.ARRAY_BUFFER,n.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.normal);f.vertexAttribPointer(C.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,n.count);n.count=0}function h(n){if(T!=n.doubleSided){n.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);T=n.doubleSided}if(xa!=n.flipSided){n.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);xa=n.flipSided}}function k(n){if(Da!=n){n?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);Da=n}}function j(n){P[0].set(n.n41-
n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);P[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);P[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);P[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);P[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);P[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=P[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=n.matrixWorld,p=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,
Math.max(n.scale.y,n.scale.z)),o=0;o<6;o++){n=P[o].x*C.n14+P[o].y*C.n24+P[o].z*C.n34+P[o].w;if(n<=p)return!1}return!0}function t(n,C){n.list[n.count]=C;n.count+=1}function x(n){var C,p,o=n.object,w=n.opaque,D=n.transparent;D.count=0;n=w.count=0;for(C=o.materials.length;n<C;n++){p=o.materials[n];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?t(D,p):t(w,p)}}function y(n){var C,p,o,w,D=n.object,B=n.buffer,F=n.opaque,Z=n.transparent;Z.count=0;n=F.count=0;for(o=D.materials.length;n<o;n++){C=
D.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=0;for(p=B.materials.length;C<p;C++)(w=B.materials[C])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w))}else{w=C;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w)}}}function q(n,C){return C.z-n.z}function z(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){function C(Ea){var $=
[];p=0;for(o=Ea.length;p<o;p++)Ea[p]==undefined?$.push("undefined"):$.push(Ea[p].id);return $.join("_")}var p,o,w,D,B,F,Z,N,K={},ra=n.morphTargets!==undefined?n.morphTargets.length:0;n.geometryGroups={};w=0;for(D=n.faces.length;w<D;w++){B=n.faces[w];F=B.materials;Z=C(F);K[Z]==undefined&&(K[Z]={hash:Z,counter:0});N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra});B=B instanceof THREE.Face3?3:4;if(n.geometryGroups[N].vertices+
B>65535){K[Z].counter+=1;N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra})}n.geometryGroups[N].faces.push(w);n.geometryGroups[N].vertices+=B}}function H(n,C,p){n.push({buffer:C,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(n){if(n!=ca){switch(n){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,
f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=n}}function I(n,C,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(n,f.TEXTURE_WRAP_S,O(C.wrapS));f.texParameteri(n,f.TEXTURE_WRAP_T,O(C.wrapT));f.texParameteri(n,f.TEXTURE_MAG_FILTER,
O(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,O(C.minFilter));f.generateMipmap(n)}else{f.texParameteri(n,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_MAG_FILTER,Q(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,Q(C.minFilter))}}function A(n){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=f.createFramebuffer();n.__webGLRenderbuffer=f.createRenderbuffer();n.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,
n.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,n.width,n.height);f.bindTexture(f.TEXTURE_2D,n.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,O(n.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,O(n.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,O(n.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,O(n.minFilter));f.texImage2D(f.TEXTURE_2D,0,O(n.format),n.width,n.height,0,O(n.format),O(n.type),null);f.bindFramebuffer(f.FRAMEBUFFER,
n.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,n.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,n.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var C,p;if(n){C=n.__webGLFramebuffer;p=n.width;n=n.height}else{C=null;p=la;n=aa}if(C!=ka){f.bindFramebuffer(f.FRAMEBUFFER,C);f.viewport(ja,oa,p,n);ka=C}}function S(n,C){var p;if(n==
"fragment")p=f.createShader(f.FRAGMENT_SHADER);else n=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,C);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(C);return null}return p}function Q(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}
function O(n){switch(n){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}
var X=document.createElement("canvas"),f,ea=null,ka=null,W=this,T=null,xa=null,ca=null,Da=null,ja=0,oa=0,la=0,aa=0,P=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Matrix4,da=new Float32Array(16),sa=new Float32Array(16),ia=new THREE.Vector4,ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},ya=!0,La=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)ya=a.antialias;
a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=X;this.autoClear=!0;this.sortObjects=!0;(function(n,C,p){try{if(!(f=X.getContext("experimental-webgl",{antialias:n})))throw"Error creating WebGL context.";}catch(o){console.error(o)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);
f.clearColor(C.r,C.g,C.b,p);_cullEnabled=!0})(ya,La,ab);this.context=f;this.setSize=function(n,C){X.width=n;X.height=C;this.setViewport(0,0,X.width,X.height)};this.setViewport=function(n,C,p,o){ja=n;oa=C;la=p;aa=o;f.viewport(ja,oa,la,aa)};this.setScissor=function(n,C,p,o){f.scissor(n,C,p,o)};this.enableScissorTest=function(n){n?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){f.depthMask(n)};this.setClearColorHex=function(n,C){var p=new THREE.Color(n);f.clearColor(p.r,
p.g,p.b,C)};this.setClearColor=function(n,C){f.clearColor(n.r,n.g,n.b,C)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(n,C,p,o){var w,D,B;if(n instanceof THREE.MeshDepthMaterial)b(n,THREE.ShaderLib.depth);else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial)b(n,THREE.ShaderLib.basic);else if(n instanceof THREE.MeshLambertMaterial)b(n,THREE.ShaderLib.lambert);else if(n instanceof THREE.MeshPhongMaterial)b(n,
THREE.ShaderLib.phong);else if(n instanceof THREE.LineBasicMaterial)b(n,THREE.ShaderLib.basic);else n instanceof THREE.ParticleBasicMaterial&&b(n,THREE.ShaderLib.particle_basic);var F,Z,N,K;B=N=K=0;for(F=C.length;B<F;B++){Z=C[B];Z instanceof THREE.DirectionalLight&&N++;Z instanceof THREE.PointLight&&K++}if(K+N<=4)C=N;else{C=Math.ceil(4*N/(K+N));K=4-C}B={directional:C,point:K};F=50;if(o!==undefined&&o instanceof THREE.SkinnedMesh)F=o.bones.length;K=n.fragmentShader;C=n.vertexShader;F={fog:p,map:n.map,
envMap:n.envMap,lightMap:n.lightMap,vertexColors:n.vertexColors,sizeAttenuation:n.sizeAttenuation,skinning:n.skinning,morphTargets:n.morphTargets,maxDirLights:B.directional,maxPointLights:B.point,maxBones:F};p=f.createProgram();B=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":
"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":
"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
f.attachShader(p,S("fragment",B+K));f.attachShader(p,S("vertex",F+C));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};n.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in n.uniforms)p.push(w);
w=n.program;K=0;for(C=p.length;K<C;K++){B=p[K];w.uniforms[B]=f.getUniformLocation(w,B)}p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<this.maxMorphTargets;w++)p.push("morphTarget"+w);for(D in n.attributes)p.push(D);D=n.program;w=p;p=0;for(K=w.length;p<K;p++){C=w[p];D.attributes[C]=f.getAttribLocation(D,C)}D=n.program.attributes;f.enableVertexAttribArray(D.position);D.color>=0&&f.enableVertexAttribArray(D.color);D.normal>=0&&f.enableVertexAttribArray(D.normal);
D.tangent>=0&&f.enableVertexAttribArray(D.tangent);if(n.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){f.enableVertexAttribArray(D.skinVertexA);f.enableVertexAttribArray(D.skinVertexB);f.enableVertexAttribArray(D.skinIndex);f.enableVertexAttribArray(D.skinWeight)}if(n.morphTargets){n.numSupportedMorphTargets=0;if(D.morphTarget0>=0){f.enableVertexAttribArray(D.morphTarget0);n.numSupportedMorphTargets++}if(D.morphTarget1>=0){f.enableVertexAttribArray(D.morphTarget1);
n.numSupportedMorphTargets++}if(D.morphTarget2>=0){f.enableVertexAttribArray(D.morphTarget2);n.numSupportedMorphTargets++}if(D.morphTarget3>=0){f.enableVertexAttribArray(D.morphTarget3);n.numSupportedMorphTargets++}if(D.morphTarget4>=0){f.enableVertexAttribArray(D.morphTarget4);n.numSupportedMorphTargets++}if(D.morphTarget5>=0){f.enableVertexAttribArray(D.morphTarget5);n.numSupportedMorphTargets++}if(D.morphTarget6>=0){f.enableVertexAttribArray(D.morphTarget6);n.numSupportedMorphTargets++}if(D.morphTarget7>=
0){f.enableVertexAttribArray(D.morphTarget7);n.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w<this.maxMorphTargets;w++)o.__webGLMorphTargetInfluences[w]=0}};this.render=function(n,C,p,o){var w,D,B,F,Z,N,K,ra,Ea=n.lights,$=n.fog;C.matrixAutoUpdate&&C.updateMatrix();n.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray(sa);C.projectionMatrix.flattenToArray(da);M.multiply(C.projectionMatrix,C.matrixWorldInverse);j(M);this.initWebGLObjects(n);
A(p);(this.autoClear||o)&&this.clear();Z=n.__webglObjects.length;for(o=0;o<Z;o++){w=n.__webglObjects[o];K=w.object;if(K.visible)if(!(K instanceof THREE.Mesh)||m(K)){K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);y(w);w.render=!0;if(this.sortObjects){ia.copy(K.position);M.multiplyVector3(ia);w.z=ia.z}}else w.render=!1;else w.render=!1}this.sortObjects&&n.__webglObjects.sort(q);N=n.__webglObjectsImmediate.length;for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){K.matrixAutoUpdate&&
K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);x(w)}}E(THREE.NormalBlending);for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=w.buffer;B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=
w.buffer;B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}if(p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};
this.initWebGLObjects=function(n){if(!n.__webglObjects){n.__webglObjects=[];n.__webglObjectsImmediate=[]}for(;n.__objectsAdded.length;){var C=n.__objectsAdded[0],p=n,o=void 0,w=void 0,D=void 0;if(C._modelViewMatrix==undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){w=C.geometry;w.geometryGroups==
undefined&&G(w);for(o in w.geometryGroups){D=w.geometryGroups[o];if(!D.__webGLVertexBuffer){var B=D;B.__webGLVertexBuffer=f.createBuffer();B.__webGLNormalBuffer=f.createBuffer();B.__webGLTangentBuffer=f.createBuffer();B.__webGLColorBuffer=f.createBuffer();B.__webGLUVBuffer=f.createBuffer();B.__webGLUV2Buffer=f.createBuffer();B.__webGLSkinVertexABuffer=f.createBuffer();B.__webGLSkinVertexBBuffer=f.createBuffer();B.__webGLSkinIndicesBuffer=f.createBuffer();B.__webGLSkinWeightsBuffer=f.createBuffer();
B.__webGLFaceBuffer=f.createBuffer();B.__webGLLineBuffer=f.createBuffer();if(B.numMorphTargets){var F=void 0,Z=void 0;B.__webGLMorphTargetsBuffers=[];F=0;for(Z=B.numMorphTargets;F<Z;F++)B.__webGLMorphTargetsBuffers.push(f.createBuffer())}B=D;var N=C,K=void 0,ra=void 0,Ea=Z=F=0;K=void 0;ra=void 0;var $=void 0;ra=void 0;var Aa=N.geometry;$=Aa.faces;var ma=B.faces;K=0;for(ra=ma.length;K<ra;K++){fi=ma[K];face=$[fi];if(face instanceof THREE.Face3){F+=3;Z+=1;Ea+=3}else if(face instanceof THREE.Face4){F+=
4;Z+=2;Ea+=4}}K=B;ra=N;$=void 0;ma=void 0;var Ga=void 0,Ma=void 0;Ga=void 0;var wa=[];$=0;for(ma=ra.materials.length;$<ma;$++){Ga=ra.materials[$];if(Ga instanceof THREE.MeshFaceMaterial){Ga=0;for(l=K.materials.length;Ga<l;Ga++)(Ma=K.materials[Ga])&&wa.push(Ma)}else(Ma=Ga)&&wa.push(Ma)}ra=wa;a:{K=void 0;$=void 0;ma=ra.length;for(K=0;K<ma;K++){$=ra[K];if($.map||$.lightMap||$ instanceof THREE.MeshShaderMaterial){K=!0;break a}}K=!1}a:{$=ra;ma=void 0;wa=void 0;Ga=$.length;for(ma=0;ma<Ga;ma++){wa=$[ma];
if(!(wa instanceof THREE.MeshBasicMaterial&&!wa.envMap||wa instanceof THREE.MeshDepthMaterial)){$=wa&&wa.shading!=undefined&&wa.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}$=!1}a:{ma=void 0;wa=void 0;Ga=ra.length;for(ma=0;ma<Ga;ma++){wa=ra[ma];if(wa.vertexColors){ra=wa.vertexColors;break a}}ra=!1}B.__vertexArray=new Float32Array(F*3);if($)B.__normalArray=new Float32Array(F*3);if(Aa.hasTangents)B.__tangentArray=new Float32Array(F*4);if(ra)B.__colorArray=new Float32Array(F*
3);if(K){if(Aa.faceUvs.length>0||Aa.faceVertexUvs.length>0)B.__uvArray=new Float32Array(F*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)B.__uv2Array=new Float32Array(F*2)}if(N.geometry.skinWeights.length&&N.geometry.skinIndices.length){B.__skinVertexAArray=new Float32Array(F*4);B.__skinVertexBArray=new Float32Array(F*4);B.__skinIndexArray=new Float32Array(F*4);B.__skinWeightArray=new Float32Array(F*4)}B.__faceArray=new Uint16Array(Z*3);B.__lineArray=new Uint16Array(Ea*2);if(B.numMorphTargets){N=
void 0;Aa=void 0;B.__morphTargetsArrays=[];N=0;for(Aa=B.numMorphTargets;N<Aa;N++)B.__morphTargetsArrays.push(new Float32Array(F*3))}B.__needsSmoothNormals=$==THREE.SmoothShading;B.__uvType=K;B.__vertexColorType=ra;B.__normalType=$;B.__webGLFaceCount=Z*3;B.__webGLLineCount=Ea*2;w.__dirtyVertices=!0;w.__dirtyMorphTargets=!0;w.__dirtyElements=!0;w.__dirtyUvs=!0;w.__dirtyNormals=!0;w.__dirtyTangents=!0;w.__dirtyColors=!0}H(p.__webglObjects,D,C)}}else if(C instanceof THREE.Ribbon){w=C.geometry;if(!w.__webGLVertexBuffer){o=
w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*3);o.__webGLVertexCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else if(C instanceof THREE.Line){w=C.geometry;if(!w.__webGLVertexBuffer){o=w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*
3);o.__webGLLineCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else if(C instanceof THREE.ParticleSystem){w=C.geometry;if(!w.__webGLVertexBuffer){o=w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*3);o.__sortArray=[];o.__webGLParticleCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else THREE.MarchingCubes!==undefined&&C instanceof
THREE.MarchingCubes&&p.__webglObjectsImmediate.push({object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}});n.__objectsAdded.splice(0,1)}for(;n.__objectsRemoved.length;){C=n.__objectsRemoved[0];p=n;w=void 0;o=void 0;for(w=p.__webglObjects.length-1;w>=0;w--){o=p.__webglObjects[w].object;C==o&&p.__webglObjects.splice(w,1)}n.__objectsRemoved.splice(0,1)}C=0;for(p=n.__webglObjects.length;C<p;C++){o=n.__webglObjects[C].object;D=void 0;w=void 0;B=void 0;if(o instanceof THREE.Mesh){w=o.geometry;
for(D in w.geometryGroups){B=w.geometryGroups[D];if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents){F=f.DYNAMIC_DRAW;Z=void 0;Ea=void 0;var Ia=void 0,V=void 0;Ia=void 0;var Ca=void 0,Ba=void 0,Ya=void 0,ua=void 0;N=void 0;Aa=void 0;K=void 0;ra=void 0;$=void 0;var ga=void 0,ha=void 0,na=void 0,Pa=void 0;Ba=void 0;Ya=void 0;V=void 0;ua=void 0;V=void 0;ga=void 0;ha=void 0;Ba=void 0;ga=void 0;ha=void 0;na=void 0;Pa=void 0;
ga=void 0;ha=void 0;na=void 0;Pa=void 0;ga=void 0;ha=void 0;na=void 0;Pa=void 0;ga=void 0;ha=void 0;na=void 0;V=void 0;ua=void 0;Ca=void 0;Ia=void 0;Ia=void 0;var Sa=void 0,fb=void 0,Na=void 0,Xa=Ma=Ga=wa=ma=0,Ta=0,Ja=0,Va=0,Oa=0,L=0,Qa=0,Ua=B.__vertexArray,Fa=B.__uvArray,$a=B.__uv2Array,Wa=B.__normalArray,Ha=B.__tangentArray,Ra=B.__colorArray,va=B.__skinVertexAArray,J=B.__skinVertexBArray,Y=B.__skinIndexArray,U=B.__skinWeightArray,fa=B.__morphTargetsArrays,za=B.__faceArray,qa=B.__lineArray,pa=B.__needsSmoothNormals;
Aa=B.__vertexColorType;N=B.__uvType;K=B.__normalType;var R=o.geometry,Ka=R.__dirtyVertices,cb=R.__dirtyElements,Za=R.__dirtyUvs,db=R.__dirtyNormals,hb=R.__dirtyTangents,bb=R.__dirtyColors,eb=R.__dirtyMorphTargets,jb=R.vertices,nb=B.faces,qb=R.faces,ob=R.faceVertexUvs[0],pb=R.faceVertexUvs[1],kb=R.skinVerticesA,lb=R.skinVerticesB,mb=R.skinIndices,ib=R.skinWeights,gb=R.morphTargets;Z=0;for(Ea=nb.length;Z<Ea;Z++){Ia=nb[Z];V=qb[Ia];ob&&(ra=ob[Ia]);pb&&($=pb[Ia]);Ia=V.vertexNormals;Ca=V.normal;Ba=V.vertexColors;
Ya=V.color;ua=V.vertexTangents;if(V instanceof THREE.Face3){if(Ka){ga=jb[V.a].position;ha=jb[V.b].position;na=jb[V.c].position;Ua[wa]=ga.x;Ua[wa+1]=ga.y;Ua[wa+2]=ga.z;Ua[wa+3]=ha.x;Ua[wa+4]=ha.y;Ua[wa+5]=ha.z;Ua[wa+6]=na.x;Ua[wa+7]=na.y;Ua[wa+8]=na.z;wa+=9}if(eb){Sa=0;for(fb=gb.length;Sa<fb;Sa++){ga=gb[Sa].vertices[V.a].position;ha=gb[Sa].vertices[V.b].position;na=gb[Sa].vertices[V.c].position;Na=fa[Sa];Na[Qa+0]=ga.x;Na[Qa+1]=ga.y;Na[Qa+2]=ga.z;Na[Qa+3]=ha.x;Na[Qa+4]=ha.y;Na[Qa+5]=ha.z;Na[Qa+6]=na.x;
Na[Qa+7]=na.y;Na[Qa+8]=na.z}Qa+=9}if(ib.length){ga=ib[V.a];ha=ib[V.b];na=ib[V.c];U[L]=ga.x;U[L+1]=ga.y;U[L+2]=ga.z;U[L+3]=ga.w;U[L+4]=ha.x;U[L+5]=ha.y;U[L+6]=ha.z;U[L+7]=ha.w;U[L+8]=na.x;U[L+9]=na.y;U[L+10]=na.z;U[L+11]=na.w;ga=mb[V.a];ha=mb[V.b];na=mb[V.c];Y[L]=ga.x;Y[L+1]=ga.y;Y[L+2]=ga.z;Y[L+3]=ga.w;Y[L+4]=ha.x;Y[L+5]=ha.y;Y[L+6]=ha.z;Y[L+7]=ha.w;Y[L+8]=na.x;Y[L+9]=na.y;Y[L+10]=na.z;Y[L+11]=na.w;ga=kb[V.a];ha=kb[V.b];na=kb[V.c];va[L]=ga.x;va[L+1]=ga.y;va[L+2]=ga.z;va[L+3]=1;va[L+4]=ha.x;va[L+5]=
ha.y;va[L+6]=ha.z;va[L+7]=1;va[L+8]=na.x;va[L+9]=na.y;va[L+10]=na.z;va[L+11]=1;ga=lb[V.a];ha=lb[V.b];na=lb[V.c];J[L]=ga.x;J[L+1]=ga.y;J[L+2]=ga.z;J[L+3]=1;J[L+4]=ha.x;J[L+5]=ha.y;J[L+6]=ha.z;J[L+7]=1;J[L+8]=na.x;J[L+9]=na.y;J[L+10]=na.z;J[L+11]=1;L+=12}if(bb&&Aa){if(Ba.length==3&&Aa==THREE.VertexColors){V=Ba[0];ga=Ba[1];ha=Ba[2]}else ha=ga=V=Ya;Ra[Oa]=V.r;Ra[Oa+1]=V.g;Ra[Oa+2]=V.b;Ra[Oa+3]=ga.r;Ra[Oa+4]=ga.g;Ra[Oa+5]=ga.b;Ra[Oa+6]=ha.r;Ra[Oa+7]=ha.g;Ra[Oa+8]=ha.b;Oa+=9}if(hb&&R.hasTangents){Ba=ua[0];
Ya=ua[1];V=ua[2];Ha[Ja]=Ba.x;Ha[Ja+1]=Ba.y;Ha[Ja+2]=Ba.z;Ha[Ja+3]=Ba.w;Ha[Ja+4]=Ya.x;Ha[Ja+5]=Ya.y;Ha[Ja+6]=Ya.z;Ha[Ja+7]=Ya.w;Ha[Ja+8]=V.x;Ha[Ja+9]=V.y;Ha[Ja+10]=V.z;Ha[Ja+11]=V.w;Ja+=12}if(db&&K)if(Ia.length==3&&pa)for(ua=0;ua<3;ua++){Ca=Ia[ua];Wa[Ta]=Ca.x;Wa[Ta+1]=Ca.y;Wa[Ta+2]=Ca.z;Ta+=3}else for(ua=0;ua<3;ua++){Wa[Ta]=Ca.x;Wa[Ta+1]=Ca.y;Wa[Ta+2]=Ca.z;Ta+=3}if(Za&&ra!==undefined&&N)for(ua=0;ua<3;ua++){Ia=ra[ua];Fa[Ga]=Ia.u;Fa[Ga+1]=Ia.v;Ga+=2}if(Za&&$!==undefined&&N)for(ua=0;ua<3;ua++){Ia=$[ua];
$a[Ma]=Ia.u;$a[Ma+1]=Ia.v;Ma+=2}if(cb){za[Xa]=ma;za[Xa+1]=ma+1;za[Xa+2]=ma+2;Xa+=3;qa[Va]=ma;qa[Va+1]=ma+1;qa[Va+2]=ma;qa[Va+3]=ma+2;qa[Va+4]=ma+1;qa[Va+5]=ma+2;Va+=6;ma+=3}}else if(V instanceof THREE.Face4){if(Ka){ga=jb[V.a].position;ha=jb[V.b].position;na=jb[V.c].position;Pa=jb[V.d].position;Ua[wa]=ga.x;Ua[wa+1]=ga.y;Ua[wa+2]=ga.z;Ua[wa+3]=ha.x;Ua[wa+4]=ha.y;Ua[wa+5]=ha.z;Ua[wa+6]=na.x;Ua[wa+7]=na.y;Ua[wa+8]=na.z;Ua[wa+9]=Pa.x;Ua[wa+10]=Pa.y;Ua[wa+11]=Pa.z;wa+=12}if(eb){Sa=0;for(fb=gb.length;Sa<
fb;Sa++){ga=gb[Sa].vertices[V.a].position;ha=gb[Sa].vertices[V.b].position;na=gb[Sa].vertices[V.c].position;Pa=gb[Sa].vertices[V.d].position;Na=fa[Sa];Na[Qa+0]=ga.x;Na[Qa+1]=ga.y;Na[Qa+2]=ga.z;Na[Qa+3]=ha.x;Na[Qa+4]=ha.y;Na[Qa+5]=ha.z;Na[Qa+6]=na.x;Na[Qa+7]=na.y;Na[Qa+8]=na.z;Na[Qa+9]=Pa.x;Na[Qa+10]=Pa.y;Na[Qa+11]=Pa.z}Qa+=12}if(ib.length){ga=ib[V.a];ha=ib[V.b];na=ib[V.c];Pa=ib[V.d];U[L]=ga.x;U[L+1]=ga.y;U[L+2]=ga.z;U[L+3]=ga.w;U[L+4]=ha.x;U[L+5]=ha.y;U[L+6]=ha.z;U[L+7]=ha.w;U[L+8]=na.x;U[L+9]=na.y;
U[L+10]=na.z;U[L+11]=na.w;U[L+12]=Pa.x;U[L+13]=Pa.y;U[L+14]=Pa.z;U[L+15]=Pa.w;ga=mb[V.a];ha=mb[V.b];na=mb[V.c];Pa=mb[V.d];Y[L]=ga.x;Y[L+1]=ga.y;Y[L+2]=ga.z;Y[L+3]=ga.w;Y[L+4]=ha.x;Y[L+5]=ha.y;Y[L+6]=ha.z;Y[L+7]=ha.w;Y[L+8]=na.x;Y[L+9]=na.y;Y[L+10]=na.z;Y[L+11]=na.w;Y[L+12]=Pa.x;Y[L+13]=Pa.y;Y[L+14]=Pa.z;Y[L+15]=Pa.w;ga=kb[V.a];ha=kb[V.b];na=kb[V.c];Pa=kb[V.d];va[L]=ga.x;va[L+1]=ga.y;va[L+2]=ga.z;va[L+3]=1;va[L+4]=ha.x;va[L+5]=ha.y;va[L+6]=ha.z;va[L+7]=1;va[L+8]=na.x;va[L+9]=na.y;va[L+10]=na.z;va[L+
11]=1;va[L+12]=Pa.x;va[L+13]=Pa.y;va[L+14]=Pa.z;va[L+15]=1;ga=lb[V.a];ha=lb[V.b];na=lb[V.c];V=lb[V.d];J[L]=ga.x;J[L+1]=ga.y;J[L+2]=ga.z;J[L+3]=1;J[L+4]=ha.x;J[L+5]=ha.y;J[L+6]=ha.z;J[L+7]=1;J[L+8]=na.x;J[L+9]=na.y;J[L+10]=na.z;J[L+11]=1;J[L+12]=V.x;J[L+13]=V.y;J[L+14]=V.z;J[L+15]=1;L+=16}if(bb&&Aa){if(Ba.length==4&&Aa==THREE.VertexColors){V=Ba[0];ga=Ba[1];ha=Ba[2];Ba=Ba[3]}else Ba=ha=ga=V=Ya;Ra[Oa]=V.r;Ra[Oa+1]=V.g;Ra[Oa+2]=V.b;Ra[Oa+3]=ga.r;Ra[Oa+4]=ga.g;Ra[Oa+5]=ga.b;Ra[Oa+6]=ha.r;Ra[Oa+7]=ha.g;
Ra[Oa+8]=ha.b;Ra[Oa+9]=Ba.r;Ra[Oa+10]=Ba.g;Ra[Oa+11]=Ba.b;Oa+=12}if(hb&&R.hasTangents){Ba=ua[0];Ya=ua[1];V=ua[2];ua=ua[3];Ha[Ja]=Ba.x;Ha[Ja+1]=Ba.y;Ha[Ja+2]=Ba.z;Ha[Ja+3]=Ba.w;Ha[Ja+4]=Ya.x;Ha[Ja+5]=Ya.y;Ha[Ja+6]=Ya.z;Ha[Ja+7]=Ya.w;Ha[Ja+8]=V.x;Ha[Ja+9]=V.y;Ha[Ja+10]=V.z;Ha[Ja+11]=V.w;Ha[Ja+12]=ua.x;Ha[Ja+13]=ua.y;Ha[Ja+14]=ua.z;Ha[Ja+15]=ua.w;Ja+=16}if(db&&K)if(Ia.length==4&&pa)for(ua=0;ua<4;ua++){Ca=Ia[ua];Wa[Ta]=Ca.x;Wa[Ta+1]=Ca.y;Wa[Ta+2]=Ca.z;Ta+=3}else for(ua=0;ua<4;ua++){Wa[Ta]=Ca.x;Wa[Ta+
1]=Ca.y;Wa[Ta+2]=Ca.z;Ta+=3}if(Za&&ra!==undefined&&N)for(ua=0;ua<4;ua++){Ia=ra[ua];Fa[Ga]=Ia.u;Fa[Ga+1]=Ia.v;Ga+=2}if(Za&&$!==undefined&&N)for(ua=0;ua<4;ua++){Ia=$[ua];$a[Ma]=Ia.u;$a[Ma+1]=Ia.v;Ma+=2}if(cb){za[Xa]=ma;za[Xa+1]=ma+1;za[Xa+2]=ma+3;za[Xa+3]=ma+1;za[Xa+4]=ma+2;za[Xa+5]=ma+3;Xa+=6;qa[Va]=ma;qa[Va+1]=ma+1;qa[Va+2]=ma;qa[Va+3]=ma+3;qa[Va+4]=ma+1;qa[Va+5]=ma+2;qa[Va+6]=ma+2;qa[Va+7]=ma+3;Va+=8;ma+=4}}}if(Ka){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Ua,
F)}if(eb){Sa=0;for(fb=gb.length;Sa<fb;Sa++){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLMorphTargetsBuffers[Sa]);f.bufferData(f.ARRAY_BUFFER,fa[Sa],F)}}if(bb&&Oa>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ra,F)}if(db){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Wa,F)}if(hb&&R.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Ha,F)}if(Za&&Ga>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUVBuffer);
f.bufferData(f.ARRAY_BUFFER,Fa,F)}if(Za&&Ma>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,$a,F)}if(cb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,za,F);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,qa,F)}if(L>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,va,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,
J,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Y,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,U,F)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(o instanceof THREE.Ribbon){w=o.geometry;if(w.__dirtyVertices||w.__dirtyColors){o=w;D=f.DYNAMIC_DRAW;N=void 0;N=void 0;Aa=void 0;B=void 0;K=o.vertices;F=o.colors;ra=K.length;
Z=F.length;$=o.__vertexArray;Ea=o.__colorArray;ma=o.__dirtyColors;if(o.__dirtyVertices){for(N=0;N<ra;N++){Aa=K[N].position;B=N*3;$[B]=Aa.x;$[B+1]=Aa.y;$[B+2]=Aa.z}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,$,D)}if(ma){for(N=0;N<Z;N++){color=F[N];B=N*3;Ea[B]=color.r;Ea[B+1]=color.g;Ea[B+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ea,D)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(o instanceof THREE.Line){w=o.geometry;
if(w.__dirtyVertices||w.__dirtyColors){o=w;D=f.DYNAMIC_DRAW;N=void 0;N=void 0;Aa=void 0;B=void 0;K=o.vertices;F=o.colors;ra=K.length;Z=F.length;$=o.__vertexArray;Ea=o.__colorArray;ma=o.__dirtyColors;if(o.__dirtyVertices){for(N=0;N<ra;N++){Aa=K[N].position;B=N*3;$[B]=Aa.x;$[B+1]=Aa.y;$[B+2]=Aa.z}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,$,D)}if(ma){for(N=0;N<Z;N++){color=F[N];B=N*3;Ea[B]=color.r;Ea[B+1]=color.g;Ea[B+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);
f.bufferData(f.ARRAY_BUFFER,Ea,D)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(o instanceof THREE.ParticleSystem){w=o.geometry;(w.__dirtyVertices||w.__dirtyColors||o.sortParticles)&&c(w,f.DYNAMIC_DRAW,o);w.__dirtyVertices=!1;w.__dirtyColors=!1}}};this.setFaceCulling=function(n,C){if(n){!C||C=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(n=="back")f.cullFace(f.BACK);else n=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK);f.enable(f.CULL_FACE)}else f.disable(f.CULL_FACE)};this.supportsVertexTextures=
function(){return f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,e=b.length;for(d=0;d<e;d++){a=b[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(c.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
THREE.WebGLRenderer=function(a){function c(j,w,t){var o,y,E,K=j.vertices,F=K.length,D=j.colors,Q=D.length,H=j.__vertexArray,T=j.__colorArray,ga=j.__sortArray,pa=j.__dirtyVertices,sa=j.__dirtyColors;if(t.sortParticles){fa.multiplySelf(t.matrixWorld);for(o=0;o<F;o++){y=K[o].position;qa.copy(y);fa.multiplyVector3(qa);ga[o]=[qa.z,o]}ga.sort(function(ya,ua){return ua[0]-ya[0]});for(o=0;o<F;o++){y=K[ga[o][1]].position;E=o*3;H[E]=y.x;H[E+1]=y.y;H[E+2]=y.z}for(o=0;o<Q;o++){E=o*3;color=D[ga[o][1]];T[E]=color.r;
T[E+1]=color.g;T[E+2]=color.b}}else{if(pa)for(o=0;o<F;o++){y=K[o].position;E=o*3;H[E]=y.x;H[E+1]=y.y;H[E+2]=y.z}if(sa)for(o=0;o<Q;o++){color=D[o];E=o*3;T[E]=color.r;T[E+1]=color.g;T[E+2]=color.b}}if(pa||t.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,H,w)}if(sa||t.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,w)}}function b(j,w){j.fragmentShader=w.fragmentShader;j.vertexShader=w.vertexShader;j.uniforms=
Uniforms.clone(w.uniforms)}function d(j,w,t,o,y){o.program||W.initMaterial(o,w,t,y);var E=o.program,K=E.uniforms,F=o.uniforms;if(E!=ja){e.useProgram(E);ja=E}e.uniformMatrix4fv(K.projectionMatrix,!1,ra);if(t&&(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial||o instanceof THREE.LineBasicMaterial||o instanceof THREE.ParticleBasicMaterial)){F.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){F.fogNear.value=t.near;F.fogFar.value=
t.far}else if(t instanceof THREE.FogExp2)F.fogDensity.value=t.density}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o.lights){var D,Q,H=0,T=0,ga=0,pa,sa,ya,ua=xa,Ea=ua.directional.colors,da=ua.directional.positions,R=ua.point.colors,ia=ua.point.positions,La=0,Ga=0;t=Q=Q=0;for(D=w.length;t<D;t++){Q=w[t];pa=Q.color;sa=Q.position;ya=Q.intensity;if(Q instanceof THREE.AmbientLight){H+=pa.r;T+=pa.g;ga+=pa.b}else if(Q instanceof THREE.DirectionalLight){Q=La*3;Ea[Q]=pa.r*
ya;Ea[Q+1]=pa.g*ya;Ea[Q+2]=pa.b*ya;da[Q]=sa.x;da[Q+1]=sa.y;da[Q+2]=sa.z;La+=1}else if(Q instanceof THREE.PointLight){Q=Ga*3;R[Q]=pa.r*ya;R[Q+1]=pa.g*ya;R[Q+2]=pa.b*ya;ia[Q]=sa.x;ia[Q+1]=sa.y;ia[Q+2]=sa.z;Ga+=1}}for(t=La*3;t<Ea.length;t++)Ea[t]=0;for(t=Ga*3;t<R.length;t++)R[t]=0;ua.point.length=Ga;ua.directional.length=La;ua.ambient[0]=H;ua.ambient[1]=T;ua.ambient[2]=ga;t=xa;F.enableLighting.value=t.directional.length+t.point.length;F.ambientLightColor.value=t.ambient;F.directionalLightColor.value=
t.directional.colors;F.directionalLightDirection.value=t.directional.positions;F.pointLightColor.value=t.point.colors;F.pointLightPosition.value=t.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.map.texture=o.map;F.lightMap.texture=o.lightMap;F.envMap.texture=o.envMap;F.reflectivity.value=o.reflectivity;
F.refractionRatio.value=o.refractionRatio;F.combine.value=o.combine;F.useRefract.value=o.envMap&&o.envMap.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){F.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.size.value=o.size;F.scale.value=Y.height/
2;F.map.texture=o.map}else if(o instanceof THREE.MeshPhongMaterial){F.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);F.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);F.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){F.mNear.value=j.near;F.mFar.value=j.far;F.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)F.opacity.value=o.opacity;for(var eb in F)if(T=E.uniforms[eb]){D=F[eb];H=D.type;t=D.value;if(H=="i")e.uniform1i(T,t);else if(H==
"f")e.uniform1f(T,t);else if(H=="fv1")e.uniform1fv(T,t);else if(H=="fv")e.uniform3fv(T,t);else if(H=="v2")e.uniform2f(T,t.x,t.y);else if(H=="v3")e.uniform3f(T,t.x,t.y,t.z);else if(H=="c")e.uniform3f(T,t.r,t.g,t.b);else if(H=="t"){e.uniform1i(T,t);if(D=D.texture)if(D.image instanceof Array&&D.image.length==6){if(D.image.length==6){if(D.needsUpdate){if(D.__wasSetOnce){e.bindTexture(e.TEXTURE_CUBE_MAP,D.image.__webGLTextureCube);for(H=0;H<6;++H)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,0,0,e.RGBA,
e.UNSIGNED_BYTE,D.image[H])}else{D.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,D.image.__webGLTextureCube);for(H=0;H<6;++H)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,D.image[H]);D.__wasSetOnce=!0}B(e.TEXTURE_CUBE_MAP,D,D.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);D.needsUpdate=!1}e.activeTexture(e.TEXTURE0+t);e.bindTexture(e.TEXTURE_CUBE_MAP,D.image.__webGLTextureCube)}}else{if(D.needsUpdate){if(D.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
D.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,D.image)}else{D.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,D.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,D.image);D.__wasSetOnce=!0}B(e.TEXTURE_2D,D,D.image);e.bindTexture(e.TEXTURE_2D,null);D.needsUpdate=!1}e.activeTexture(e.TEXTURE0+t);e.bindTexture(e.TEXTURE_2D,D.__webGLTexture)}}}e.uniformMatrix4fv(K.modelViewMatrix,!1,y._modelViewMatrixArray);e.uniformMatrix3fv(K.normalMatrix,
!1,y._normalMatrixArray);(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshPhongMaterial||o.envMap)&&e.uniform3f(K.cameraPosition,j.position.x,j.position.y,j.position.z);(o instanceof THREE.MeshShaderMaterial||o.envMap||o.skinning)&&e.uniformMatrix4fv(K.objectMatrix,!1,y._objectMatrixArray);(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial||o.skinning)&&e.uniformMatrix4fv(K.viewMatrix,!1,la);if(o instanceof THREE.ShadowVolumeDynamicMaterial){j=
F.directionalLightDirection.value;j[0]=-w.position.x;j[1]=-w.position.y;j[2]=-w.position.z;e.uniform3fv(K.directionalLightDirection,j);e.uniformMatrix4fv(K.objectMatrix,!1,y._objectMatrixArray);e.uniformMatrix4fv(K.viewMatrix,!1,la)}if(o.skinning){e.uniformMatrix4fv(K.cameraInverseMatrix,!1,la);e.uniformMatrix4fv(K.boneGlobalMatrices,!1,y.boneMatrices)}return E}function f(j,w,t,o,y,E){if(o.opacity!=0){j=d(j,w,t,o,E).attributes;if(o.morphTargets){w=o.program.attributes;E.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,
y.__webGLMorphTargetsBuffers[E.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(w.position,3,e.FLOAT,!1,0,0);if(E.morphTargetForcedOrder.length){t=0;for(var K=E.morphTargetForcedOrder,F=E.morphTargetInfluences;t<o.numSupportedMorphTargets&&t<K.length;){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLMorphTargetsBuffers[K[t]]);e.vertexAttribPointer(w["morphTarget"+t],3,e.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[t]=F[K[t]];t++}}else{K=[];var D=-1,Q=0;F=E.morphTargetInfluences;
var H,T=F.length;t=0;for(E.morphTargetBase!==-1&&(K[E.morphTargetBase]=!0);t<o.numSupportedMorphTargets;){for(H=0;H<T;H++)if(!K[H]&&F[H]>D){Q=H;D=F[Q]}e.bindBuffer(e.ARRAY_BUFFER,y.__webGLMorphTargetsBuffers[Q]);e.vertexAttribPointer(w["morphTarget"+t],3,e.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[t]=D;K[Q]=1;D=-1;t++}}e.uniform1fv(o.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(j.position,3,
e.FLOAT,!1,0,0)}if(j.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(j.color,3,e.FLOAT,!1,0,0)}if(j.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(j.normal,3,e.FLOAT,!1,0,0)}if(j.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(j.tangent,4,e.FLOAT,!1,0,0)}if(j.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(j.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv)}else e.disableVertexAttribArray(j.uv);
if(j.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(j.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv2)}else e.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(j.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(j.skinVertexB,4,e.FLOAT,!1,0,
0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(j.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(j.skinWeight,4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(o.wireframe){e.lineWidth(o.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);e.drawElements(e.LINES,y.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,
y.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(o.linewidth);e.drawArrays(E,0,y.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}}function g(j,w){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=e.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=e.createBuffer();
if(j.hasPos){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,j.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.position);e.vertexAttribPointer(w.attributes.position,3,e.FLOAT,!1,0,0)}if(j.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,j.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.normal);e.vertexAttribPointer(w.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,j.count);
j.count=0}function h(j){if(wa!=j.doubleSided){j.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);wa=j.doubleSided}if(ha!=j.flipSided){j.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ha=j.flipSided}}function k(j){if(ka!=j){j?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ka=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42-
j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);var w;for(j=0;j<6;j++){w=M[j];w.divideScalar(Math.sqrt(w.x*w.x+w.y*w.y+w.z*w.z))}}function n(j){for(var w=j.matrixWorld,t=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),o=0;o<6;o++){j=M[o].x*w.n14+M[o].y*w.n24+M[o].z*w.n34+M[o].w;if(j<=t)return!1}return!0}function q(j,w){j.list[j.count]=w;j.count+=1}function x(j){var w,
t,o=j.object,y=j.opaque,E=j.transparent;E.count=0;j=y.count=0;for(w=o.materials.length;j<w;j++){t=o.materials[j];t.opacity&&t.opacity<1||t.blending!=THREE.NormalBlending?q(E,t):q(y,t)}}function z(j){var w,t,o,y,E=j.object,K=j.buffer,F=j.opaque,D=j.transparent;D.count=0;j=F.count=0;for(o=E.materials.length;j<o;j++){w=E.materials[j];if(w instanceof THREE.MeshFaceMaterial){w=0;for(t=K.materials.length;w<t;w++)(y=K.materials[w])&&(y.opacity&&y.opacity<1||y.blending!=THREE.NormalBlending?q(D,y):q(F,y))}else{y=
w;y.opacity&&y.opacity<1||y.blending!=THREE.NormalBlending?q(D,y):q(F,y)}}}function p(j,w){return w.z-j.z}function A(j,w){j._modelViewMatrix.multiplyToArray(w.matrixWorldInverse,j.matrixWorld,j._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(j._modelViewMatrix).transposeIntoArray(j._normalMatrixArray)}function G(j){var w,t,o;if(j instanceof THREE.Mesh){t=j.geometry;for(w in t.geometryGroups){o=t.geometryGroups[w];if(t.__dirtyVertices||t.__dirtyMorphTargets||t.__dirtyElements||t.__dirtyUvs||t.__dirtyNormals||
t.__dirtyColors||t.__dirtyTangents){var y=e.DYNAMIC_DRAW,E=void 0,K=void 0,F=void 0,D=void 0;F=void 0;var Q=void 0,H=void 0,T=void 0,ga=void 0,pa=void 0,sa=void 0,ya=void 0,ua=void 0,Ea=void 0,da=void 0,R=void 0,ia=void 0,La=void 0;H=void 0;T=void 0;D=void 0;ga=void 0;D=void 0;da=void 0;R=void 0;H=void 0;da=void 0;R=void 0;ia=void 0;La=void 0;da=void 0;R=void 0;ia=void 0;La=void 0;da=void 0;R=void 0;ia=void 0;La=void 0;da=void 0;R=void 0;ia=void 0;D=void 0;ga=void 0;Q=void 0;F=void 0;F=void 0;var Ga=
void 0,eb=void 0,Ta=void 0,Ia=0,Ra=0,bb=0,db=0,Pa=0,Ua=0,Da=0,Va=0,Ma=0,N=0,Na=0,Qa=o.__vertexArray,ib=o.__uvArray,Ba=o.__uv2Array,Sa=o.__normalArray,Fa=o.__tangentArray,Oa=o.__colorArray,Ja=o.__skinVertexAArray,va=o.__skinVertexBArray,L=o.__skinIndexArray,Z=o.__skinWeightArray,na=o.__morphTargetsArrays,aa=o.__faceArray,ta=o.__lineArray,za=o.__needsSmoothNormals;sa=o.__vertexColorType;pa=o.__uvType;ya=o.__normalType;var ea=j.geometry,$=ea.__dirtyVertices,Ka=ea.__dirtyElements,Xa=ea.__dirtyUvs,Ya=
ea.__dirtyNormals,cb=ea.__dirtyTangents,gb=ea.__dirtyColors,ab=ea.__dirtyMorphTargets,Wa=ea.vertices,nb=o.faces,qb=ea.faces,ob=ea.faceVertexUvs[0],pb=ea.faceVertexUvs[1],kb=ea.skinVerticesA,lb=ea.skinVerticesB,mb=ea.skinIndices,hb=ea.skinWeights,jb=ea.edgeFaces,fb=ea.morphTargets;E=0;for(K=nb.length;E<K;E++){F=nb[E];D=qb[F];ob&&(ua=ob[F]);pb&&(Ea=pb[F]);F=D.vertexNormals;Q=D.normal;H=D.vertexColors;T=D.color;ga=D.vertexTangents;if(D instanceof THREE.Face3){if($){da=Wa[D.a].position;R=Wa[D.b].position;
ia=Wa[D.c].position;Qa[Ra]=da.x;Qa[Ra+1]=da.y;Qa[Ra+2]=da.z;Qa[Ra+3]=R.x;Qa[Ra+4]=R.y;Qa[Ra+5]=R.z;Qa[Ra+6]=ia.x;Qa[Ra+7]=ia.y;Qa[Ra+8]=ia.z;Ra+=9}if(ab){Ga=0;for(eb=fb.length;Ga<eb;Ga++){da=fb[Ga].vertices[D.a].position;R=fb[Ga].vertices[D.b].position;ia=fb[Ga].vertices[D.c].position;Ta=na[Ga];Ta[Na+0]=da.x;Ta[Na+1]=da.y;Ta[Na+2]=da.z;Ta[Na+3]=R.x;Ta[Na+4]=R.y;Ta[Na+5]=R.z;Ta[Na+6]=ia.x;Ta[Na+7]=ia.y;Ta[Na+8]=ia.z}Na+=9}if(hb.length){da=hb[D.a];R=hb[D.b];ia=hb[D.c];Z[N]=da.x;Z[N+1]=da.y;Z[N+2]=da.z;
Z[N+3]=da.w;Z[N+4]=R.x;Z[N+5]=R.y;Z[N+6]=R.z;Z[N+7]=R.w;Z[N+8]=ia.x;Z[N+9]=ia.y;Z[N+10]=ia.z;Z[N+11]=ia.w;da=mb[D.a];R=mb[D.b];ia=mb[D.c];L[N]=da.x;L[N+1]=da.y;L[N+2]=da.z;L[N+3]=da.w;L[N+4]=R.x;L[N+5]=R.y;L[N+6]=R.z;L[N+7]=R.w;L[N+8]=ia.x;L[N+9]=ia.y;L[N+10]=ia.z;L[N+11]=ia.w;da=kb[D.a];R=kb[D.b];ia=kb[D.c];Ja[N]=da.x;Ja[N+1]=da.y;Ja[N+2]=da.z;Ja[N+3]=1;Ja[N+4]=R.x;Ja[N+5]=R.y;Ja[N+6]=R.z;Ja[N+7]=1;Ja[N+8]=ia.x;Ja[N+9]=ia.y;Ja[N+10]=ia.z;Ja[N+11]=1;da=lb[D.a];R=lb[D.b];ia=lb[D.c];va[N]=da.x;va[N+
1]=da.y;va[N+2]=da.z;va[N+3]=1;va[N+4]=R.x;va[N+5]=R.y;va[N+6]=R.z;va[N+7]=1;va[N+8]=ia.x;va[N+9]=ia.y;va[N+10]=ia.z;va[N+11]=1;N+=12}if(gb&&sa){if(H.length==3&&sa==THREE.VertexColors){D=H[0];da=H[1];R=H[2]}else R=da=D=T;Oa[Ma]=D.r;Oa[Ma+1]=D.g;Oa[Ma+2]=D.b;Oa[Ma+3]=da.r;Oa[Ma+4]=da.g;Oa[Ma+5]=da.b;Oa[Ma+6]=R.r;Oa[Ma+7]=R.g;Oa[Ma+8]=R.b;Ma+=9}if(cb&&ea.hasTangents){H=ga[0];T=ga[1];D=ga[2];Fa[Da]=H.x;Fa[Da+1]=H.y;Fa[Da+2]=H.z;Fa[Da+3]=H.w;Fa[Da+4]=T.x;Fa[Da+5]=T.y;Fa[Da+6]=T.z;Fa[Da+7]=T.w;Fa[Da+8]=
D.x;Fa[Da+9]=D.y;Fa[Da+10]=D.z;Fa[Da+11]=D.w;Da+=12}if(Ya&&ya)if(F.length==3&&za)for(ga=0;ga<3;ga++){Q=F[ga];Sa[Ua]=Q.x;Sa[Ua+1]=Q.y;Sa[Ua+2]=Q.z;Ua+=3}else for(ga=0;ga<3;ga++){Sa[Ua]=Q.x;Sa[Ua+1]=Q.y;Sa[Ua+2]=Q.z;Ua+=3}if(Xa&&ua!==undefined&&pa)for(ga=0;ga<3;ga++){F=ua[ga];ib[bb]=F.u;ib[bb+1]=F.v;bb+=2}if(Xa&&Ea!==undefined&&pa)for(ga=0;ga<3;ga++){F=Ea[ga];Ba[db]=F.u;Ba[db+1]=F.v;db+=2}if(Ka){aa[Pa]=Ia;aa[Pa+1]=Ia+1;aa[Pa+2]=Ia+2;Pa+=3;ta[Va]=Ia;ta[Va+1]=Ia+1;ta[Va+2]=Ia;ta[Va+3]=Ia+2;ta[Va+4]=Ia+
1;ta[Va+5]=Ia+2;Va+=6;Ia+=3}}else if(D instanceof THREE.Face4){if($){da=Wa[D.a].position;R=Wa[D.b].position;ia=Wa[D.c].position;La=Wa[D.d].position;Qa[Ra]=da.x;Qa[Ra+1]=da.y;Qa[Ra+2]=da.z;Qa[Ra+3]=R.x;Qa[Ra+4]=R.y;Qa[Ra+5]=R.z;Qa[Ra+6]=ia.x;Qa[Ra+7]=ia.y;Qa[Ra+8]=ia.z;Qa[Ra+9]=La.x;Qa[Ra+10]=La.y;Qa[Ra+11]=La.z;Ra+=12}if(ab){Ga=0;for(eb=fb.length;Ga<eb;Ga++){da=fb[Ga].vertices[D.a].position;R=fb[Ga].vertices[D.b].position;ia=fb[Ga].vertices[D.c].position;La=fb[Ga].vertices[D.d].position;Ta=na[Ga];
Ta[Na+0]=da.x;Ta[Na+1]=da.y;Ta[Na+2]=da.z;Ta[Na+3]=R.x;Ta[Na+4]=R.y;Ta[Na+5]=R.z;Ta[Na+6]=ia.x;Ta[Na+7]=ia.y;Ta[Na+8]=ia.z;Ta[Na+9]=La.x;Ta[Na+10]=La.y;Ta[Na+11]=La.z}Na+=12}if(hb.length){da=hb[D.a];R=hb[D.b];ia=hb[D.c];La=hb[D.d];Z[N]=da.x;Z[N+1]=da.y;Z[N+2]=da.z;Z[N+3]=da.w;Z[N+4]=R.x;Z[N+5]=R.y;Z[N+6]=R.z;Z[N+7]=R.w;Z[N+8]=ia.x;Z[N+9]=ia.y;Z[N+10]=ia.z;Z[N+11]=ia.w;Z[N+12]=La.x;Z[N+13]=La.y;Z[N+14]=La.z;Z[N+15]=La.w;da=mb[D.a];R=mb[D.b];ia=mb[D.c];La=mb[D.d];L[N]=da.x;L[N+1]=da.y;L[N+2]=da.z;L[N+
3]=da.w;L[N+4]=R.x;L[N+5]=R.y;L[N+6]=R.z;L[N+7]=R.w;L[N+8]=ia.x;L[N+9]=ia.y;L[N+10]=ia.z;L[N+11]=ia.w;L[N+12]=La.x;L[N+13]=La.y;L[N+14]=La.z;L[N+15]=La.w;da=kb[D.a];R=kb[D.b];ia=kb[D.c];La=kb[D.d];Ja[N]=da.x;Ja[N+1]=da.y;Ja[N+2]=da.z;Ja[N+3]=1;Ja[N+4]=R.x;Ja[N+5]=R.y;Ja[N+6]=R.z;Ja[N+7]=1;Ja[N+8]=ia.x;Ja[N+9]=ia.y;Ja[N+10]=ia.z;Ja[N+11]=1;Ja[N+12]=La.x;Ja[N+13]=La.y;Ja[N+14]=La.z;Ja[N+15]=1;da=lb[D.a];R=lb[D.b];ia=lb[D.c];D=lb[D.d];va[N]=da.x;va[N+1]=da.y;va[N+2]=da.z;va[N+3]=1;va[N+4]=R.x;va[N+5]=
R.y;va[N+6]=R.z;va[N+7]=1;va[N+8]=ia.x;va[N+9]=ia.y;va[N+10]=ia.z;va[N+11]=1;va[N+12]=D.x;va[N+13]=D.y;va[N+14]=D.z;va[N+15]=1;N+=16}if(gb&&sa){if(H.length==4&&sa==THREE.VertexColors){D=H[0];da=H[1];R=H[2];H=H[3]}else H=R=da=D=T;Oa[Ma]=D.r;Oa[Ma+1]=D.g;Oa[Ma+2]=D.b;Oa[Ma+3]=da.r;Oa[Ma+4]=da.g;Oa[Ma+5]=da.b;Oa[Ma+6]=R.r;Oa[Ma+7]=R.g;Oa[Ma+8]=R.b;Oa[Ma+9]=H.r;Oa[Ma+10]=H.g;Oa[Ma+11]=H.b;Ma+=12}if(cb&&ea.hasTangents){H=ga[0];T=ga[1];D=ga[2];ga=ga[3];Fa[Da]=H.x;Fa[Da+1]=H.y;Fa[Da+2]=H.z;Fa[Da+3]=H.w;
Fa[Da+4]=T.x;Fa[Da+5]=T.y;Fa[Da+6]=T.z;Fa[Da+7]=T.w;Fa[Da+8]=D.x;Fa[Da+9]=D.y;Fa[Da+10]=D.z;Fa[Da+11]=D.w;Fa[Da+12]=ga.x;Fa[Da+13]=ga.y;Fa[Da+14]=ga.z;Fa[Da+15]=ga.w;Da+=16}if(Ya&&ya)if(F.length==4&&za)for(ga=0;ga<4;ga++){Q=F[ga];Sa[Ua]=Q.x;Sa[Ua+1]=Q.y;Sa[Ua+2]=Q.z;Ua+=3}else for(ga=0;ga<4;ga++){Sa[Ua]=Q.x;Sa[Ua+1]=Q.y;Sa[Ua+2]=Q.z;Ua+=3}if(Xa&&ua!==undefined&&pa)for(ga=0;ga<4;ga++){F=ua[ga];ib[bb]=F.u;ib[bb+1]=F.v;bb+=2}if(Xa&&Ea!==undefined&&pa)for(ga=0;ga<4;ga++){F=Ea[ga];Ba[db]=F.u;Ba[db+1]=
F.v;db+=2}if(Ka){aa[Pa]=Ia;aa[Pa+1]=Ia+1;aa[Pa+2]=Ia+3;aa[Pa+3]=Ia+1;aa[Pa+4]=Ia+2;aa[Pa+5]=Ia+3;Pa+=6;ta[Va]=Ia;ta[Va+1]=Ia+1;ta[Va+2]=Ia;ta[Va+3]=Ia+3;ta[Va+4]=Ia+1;ta[Va+5]=Ia+2;ta[Va+6]=Ia+2;ta[Va+7]=Ia+3;Va+=8;Ia+=4}}}if(jb){E=0;for(K=jb.length;E<K;E++){aa[Pa]=jb[E].a;aa[Pa+1]=jb[E].b;aa[Pa+2]=jb[E].c;aa[Pa+3]=jb[E].a;aa[Pa+4]=jb[E].c;aa[Pa+5]=jb[E].d;Pa+=6}}if($){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Qa,y)}if(ab){Ga=0;for(eb=fb.length;Ga<eb;Ga++){e.bindBuffer(e.ARRAY_BUFFER,
o.__webGLMorphTargetsBuffers[Ga]);e.bufferData(e.ARRAY_BUFFER,na[Ga],y)}}if(gb&&Ma>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,y)}if(Ya){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,y)}if(cb&&ea.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Fa,y)}if(Xa&&bb>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,y)}if(Xa&&db>0){e.bindBuffer(e.ARRAY_BUFFER,
o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ba,y)}if(Ka){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,aa,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,y)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ja,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,va,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);
e.bufferData(e.ARRAY_BUFFER,L,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Z,y)}}}t.__dirtyVertices=!1;t.__dirtyMorphTargets=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){t=j.geometry;if(t.__dirtyVertices||t.__dirtyColors){j=t;w=e.DYNAMIC_DRAW;ya=j.vertices;y=j.colors;ua=ya.length;E=y.length;Ea=j.__vertexArray;K=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa=
0;pa<ua;pa++){sa=ya[pa].position;o=pa*3;Ea[o]=sa.x;Ea[o+1]=sa.y;Ea[o+2]=sa.z}e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ea,w)}if(Ia){for(pa=0;pa<E;pa++){color=y[pa];o=pa*3;K[o]=color.r;K[o+1]=color.g;K[o+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,j.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,w)}}t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Line){t=j.geometry;if(t.__dirtyVertices||t.__dirtyColors){j=t;w=e.DYNAMIC_DRAW;ya=j.vertices;y=j.colors;
ua=ya.length;E=y.length;Ea=j.__vertexArray;K=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa=0;pa<ua;pa++){sa=ya[pa].position;o=pa*3;Ea[o]=sa.x;Ea[o+1]=sa.y;Ea[o+2]=sa.z}e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ea,w)}if(Ia){for(pa=0;pa<E;pa++){color=y[pa];o=pa*3;K[o]=color.r;K[o+1]=color.g;K[o+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,j.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,w)}}t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof
THREE.ParticleSystem){t=j.geometry;(t.__dirtyVertices||t.__dirtyColors||j.sortParticles)&&c(t,e.DYNAMIC_DRAW,j);t.__dirtyVertices=!1;t.__dirtyColors=!1}}function I(j){function w(ga){var pa=[];t=0;for(o=ga.length;t<o;t++)ga[t]==undefined?pa.push("undefined"):pa.push(ga[t].id);return pa.join("_")}var t,o,y,E,K,F,D,Q,H={},T=j.morphTargets!==undefined?j.morphTargets.length:0;j.geometryGroups={};y=0;for(E=j.faces.length;y<E;y++){K=j.faces[y];F=K.materials;D=w(F);H[D]==undefined&&(H[D]={hash:D,counter:0});
Q=H[D].hash+"_"+H[D].counter;j.geometryGroups[Q]==undefined&&(j.geometryGroups[Q]={faces:[],materials:F,vertices:0,numMorphTargets:T});K=K instanceof THREE.Face3?3:4;if(j.geometryGroups[Q].vertices+K>65535){H[D].counter+=1;Q=H[D].hash+"_"+H[D].counter;j.geometryGroups[Q]==undefined&&(j.geometryGroups[Q]={faces:[],materials:F,vertices:0,numMorphTargets:T})}j.geometryGroups[Q].faces.push(y);j.geometryGroups[Q].vertices+=K}}function C(j,w,t){j.push({buffer:w,object:t,opaque:{list:[],count:0},transparent:{list:[],
count:0}})}function J(j){if(j!=Aa){switch(j){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Aa=
j}}function B(j,w,t){if((t.width&t.width-1)==0&&(t.height&t.height-1)==0){e.texParameteri(j,e.TEXTURE_WRAP_S,V(w.wrapS));e.texParameteri(j,e.TEXTURE_WRAP_T,V(w.wrapT));e.texParameteri(j,e.TEXTURE_MAG_FILTER,V(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,V(w.minFilter));e.generateMipmap(j)}else{e.texParameteri(j,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_MAG_FILTER,O(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,
O(w.minFilter))}}function U(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=e.createFramebuffer();j.__webGLRenderbuffer=e.createRenderbuffer();j.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,j.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,j.width,j.height);e.bindTexture(e.TEXTURE_2D,j.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,V(j.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,V(j.wrapT));e.texParameteri(e.TEXTURE_2D,
e.TEXTURE_MAG_FILTER,V(j.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,V(j.minFilter));e.texImage2D(e.TEXTURE_2D,0,V(j.format),j.width,j.height,0,V(j.format),V(j.type),null);e.bindFramebuffer(e.FRAMEBUFFER,j.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,j.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,j.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);
e.bindFramebuffer(e.FRAMEBUFFER,null)}var w,t;if(j){w=j.__webGLFramebuffer;t=j.width;j=j.height}else{w=null;t=ca;j=S}if(w!=X){e.bindFramebuffer(e.FRAMEBUFFER,w);e.viewport(oa,ma,t,j);X=w}}function P(j,w){var t;if(j=="fragment")t=e.createShader(e.FRAGMENT_SHADER);else j=="vertex"&&(t=e.createShader(e.VERTEX_SHADER));e.shaderSource(t,w);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(t));console.error(w);return null}return t}function O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;
default:return e.LINEAR}}function V(j){switch(j){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 Y=document.createElement("canvas"),e,ja=null,X=null,W=this,wa=null,ha=null,Aa=null,ka=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias;
a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,w,t){try{if(!(e=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,
e.ONE_MINUS_SRC_ALPHA);e.clearColor(w.r,w.g,w.b,t)})(Ca,Za,$a);this.context=e;var Ha={};a=[];Ca=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=e.createBuffer();Ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,
new Uint16Array(Ca),e.STATIC_DRAW);Ha.program=e.createProgram();e.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ha.program);Ha.vertexLocation=e.getAttribLocation(Ha.program,"position");Ha.projectionLocation=e.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,w){Y.width=j;Y.height=w;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j,
w,t,o){oa=j;ma=w;ca=t;S=o;e.viewport(oa,ma,ca,S)};this.setScissor=function(j,w,t,o){e.scissor(j,w,t,o)};this.enableScissorTest=function(j){j?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){e.depthMask(j)};this.setClearColorHex=function(j,w){var t=new THREE.Color(j);e.clearColor(t.r,t.g,t.b,w)};this.setClearColor=function(j,w){e.clearColor(j.r,j.g,j.b,w)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial=
function(j,w,t,o){var y,E,K;if(j instanceof THREE.MeshDepthMaterial)b(j,THREE.ShaderLib.depth);else if(j instanceof THREE.ShadowVolumeDynamicMaterial)b(j,THREE.ShaderLib.shadowVolumeDynamic);else if(j instanceof THREE.MeshNormalMaterial)b(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial)b(j,THREE.ShaderLib.basic);else if(j instanceof THREE.MeshLambertMaterial)b(j,THREE.ShaderLib.lambert);else if(j instanceof THREE.MeshPhongMaterial)b(j,THREE.ShaderLib.phong);else if(j instanceof
THREE.LineBasicMaterial)b(j,THREE.ShaderLib.basic);else j instanceof THREE.ParticleBasicMaterial&&b(j,THREE.ShaderLib.particle_basic);var F,D,Q,H;K=Q=H=0;for(F=w.length;K<F;K++){D=w[K];D instanceof THREE.DirectionalLight&&Q++;D instanceof THREE.PointLight&&H++}if(H+Q<=4)w=Q;else{w=Math.ceil(4*Q/(H+Q));H=4-w}K={directional:w,point:H};F=50;if(o!==undefined&&o instanceof THREE.SkinnedMesh)F=o.bones.length;H=j.fragmentShader;w=j.vertexShader;F={fog:t,map:j.map,envMap:j.envMap,lightMap:j.lightMap,vertexColors:j.vertexColors,
sizeAttenuation:j.sizeAttenuation,skinning:j.skinning,morphTargets:j.morphTargets,maxDirLights:K.directional,maxPointLights:K.point,maxBones:F};t=e.createProgram();K=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":
"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
e.attachShader(t,P("fragment",K+H));e.attachShader(t,P("vertex",F+w));e.linkProgram(t);e.getProgramParameter(t,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(t,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");t.uniforms={};t.attributes={};j.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in j.uniforms)t.push(y);
y=j.program;H=0;for(w=t.length;H<w;H++){K=t[H];y.uniforms[K]=e.getUniformLocation(y,K)}t=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(y=0;y<this.maxMorphTargets;y++)t.push("morphTarget"+y);for(E in j.attributes)t.push(E);E=j.program;y=t;t=0;for(H=y.length;t<H;t++){w=y[t];E.attributes[w]=e.getAttribLocation(E,w)}E=j.program.attributes;e.enableVertexAttribArray(E.position);E.color>=0&&e.enableVertexAttribArray(E.color);E.normal>=0&&e.enableVertexAttribArray(E.normal);
E.tangent>=0&&e.enableVertexAttribArray(E.tangent);if(j.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){e.enableVertexAttribArray(E.skinVertexA);e.enableVertexAttribArray(E.skinVertexB);e.enableVertexAttribArray(E.skinIndex);e.enableVertexAttribArray(E.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(E.morphTarget0>=0){e.enableVertexAttribArray(E.morphTarget0);j.numSupportedMorphTargets++}if(E.morphTarget1>=0){e.enableVertexAttribArray(E.morphTarget1);
j.numSupportedMorphTargets++}if(E.morphTarget2>=0){e.enableVertexAttribArray(E.morphTarget2);j.numSupportedMorphTargets++}if(E.morphTarget3>=0){e.enableVertexAttribArray(E.morphTarget3);j.numSupportedMorphTargets++}if(E.morphTarget4>=0){e.enableVertexAttribArray(E.morphTarget4);j.numSupportedMorphTargets++}if(E.morphTarget5>=0){e.enableVertexAttribArray(E.morphTarget5);j.numSupportedMorphTargets++}if(E.morphTarget6>=0){e.enableVertexAttribArray(E.morphTarget6);j.numSupportedMorphTargets++}if(E.morphTarget7>=
0){e.enableVertexAttribArray(E.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(y=0;y<this.maxMorphTargets;y++)o.__webGLMorphTargetInfluences[y]=0}};this.render=function(j,w,t,o){var y,E,K,F,D,Q,H,T,ga=j.lights,pa=j.fog;w.matrixAutoUpdate&&w.updateMatrix();j.update(undefined,!1,w);w.matrixWorldInverse.flattenToArray(la);w.projectionMatrix.flattenToArray(ra);fa.multiply(w.projectionMatrix,w.matrixWorldInverse);m(fa);this.initWebGLObjects(j);
U(t);(this.autoClear||o)&&this.clear();D=j.__webglObjects.length;for(o=0;o<D;o++){y=j.__webglObjects[o];H=y.object;if(H.visible)if(!(H instanceof THREE.Mesh)||n(H)){H.matrixWorld.flattenToArray(H._objectMatrixArray);A(H,w);z(y);y.render=!0;if(this.sortObjects){qa.copy(H.position);fa.multiplyVector3(qa);y.z=qa.z}}else y.render=!1;else y.render=!1}this.sortObjects&&j.__webglObjects.sort(p);Q=j.__webglObjectsImmediate.length;for(o=0;o<Q;o++){y=j.__webglObjectsImmediate[o];H=y.object;if(H.visible){H.matrixAutoUpdate&&
H.matrixWorld.flattenToArray(H._objectMatrixArray);A(H,w);x(y)}}J(THREE.NormalBlending);for(o=0;o<D;o++){y=j.__webglObjects[o];if(y.render){H=y.object;T=y.buffer;K=y.opaque;h(H);for(y=0;y<K.count;y++){F=K.list[y];k(F.depthTest);f(w,ga,pa,F,T,H)}}}for(o=0;o<Q;o++){y=j.__webglObjectsImmediate[o];H=y.object;if(H.visible){K=y.opaque;h(H);for(y=0;y<K.count;y++){F=K.list[y];k(F.depthTest);E=d(w,ga,pa,F,H);H.render(function(ua){g(ua,E)})}}}for(o=0;o<D;o++){y=j.__webglObjects[o];if(y.render){H=y.object;T=
y.buffer;K=y.transparent;h(H);for(y=0;y<K.count;y++){F=K.list[y];J(F.blending);k(F.depthTest);f(w,ga,pa,F,T,H)}}}for(o=0;o<Q;o++){y=j.__webglObjectsImmediate[o];H=y.object;if(H.visible){K=y.transparent;h(H);for(y=0;y<K.count;y++){F=K.list[y];J(F.blending);k(F.depthTest);E=d(w,ga,pa,F,H);H.render(function(ua){g(ua,E)})}}}if(j.__webglShadowVolumes.length&&j.lights.length){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,
1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);Q=j.lights.length;var sa,ya;D=j.__webglShadowVolumes.length;for(ga=0;ga<Q;ga++){ya=j.lights[ga];if(ya instanceof THREE.DirectionalLight)for(o=0;o<D;o++){y=j.__webglShadowVolumes[o];H=y.object;T=y.buffer;K=y.opaque;H.matrixWorld.flattenToArray(H._objectMatrixArray);A(H,w);z(y);e.cullFace(e.FRONT);for(sa=0;sa<2;sa++){for(y=0;y<K.count;y++){F=K.list[y];f(w,ya,pa,F,T,H)}e.cullFace(e.BACK)}}}e.disable(e.POLYGON_OFFSET_FILL);
e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,e.KEEP,e.KEEP);e.disable(e.DEPTH_TEST);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);Aa="";ja=Ha.program;e.useProgram(Ha.program);e.uniformMatrix4fv(Ha.projectionLocation,!1,ra);e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.vertexAttribPointer(Ha.vertexLocation,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(Ha.vertexLocation);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.drawElements(e.TRIANGLES,
6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.disable(e.BLEND);e.depthMask(!0)}if(t&&t.minFilter!==THREE.NearestFilter&&t.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,t.__webGLTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(j){if(!j.__webglObjects){j.__webglObjects=[];j.__webglObjectsImmediate=[];j.__webglShadowVolumes=[]}for(;j.__objectsAdded.length;){var w=j.__objectsAdded[0],t=j,o=void 0,y=void 0,
E=void 0;if(w._modelViewMatrix==undefined){w._modelViewMatrix=new THREE.Matrix4;w._normalMatrixArray=new Float32Array(9);w._modelViewMatrixArray=new Float32Array(16);w._objectMatrixArray=new Float32Array(16);w.matrixWorld.flattenToArray(w._objectMatrixArray)}if(w instanceof THREE.Mesh){y=w.geometry;y.geometryGroups==undefined&&I(y);for(o in y.geometryGroups){E=y.geometryGroups[o];if(!E.__webGLVertexBuffer){var K=E;K.__webGLVertexBuffer=e.createBuffer();K.__webGLNormalBuffer=e.createBuffer();K.__webGLTangentBuffer=
e.createBuffer();K.__webGLColorBuffer=e.createBuffer();K.__webGLUVBuffer=e.createBuffer();K.__webGLUV2Buffer=e.createBuffer();K.__webGLSkinVertexABuffer=e.createBuffer();K.__webGLSkinVertexBBuffer=e.createBuffer();K.__webGLSkinIndicesBuffer=e.createBuffer();K.__webGLSkinWeightsBuffer=e.createBuffer();K.__webGLFaceBuffer=e.createBuffer();K.__webGLLineBuffer=e.createBuffer();if(K.numMorphTargets){var F=void 0,D=void 0;K.__webGLMorphTargetsBuffers=[];F=0;for(D=K.numMorphTargets;F<D;F++)K.__webGLMorphTargetsBuffers.push(e.createBuffer())}K=
E;F=w;var Q=void 0,H=void 0,T=void 0;T=void 0;var ga=D=0,pa=0;Q=void 0;H=void 0;var sa=void 0;H=void 0;var ya=F.geometry;sa=ya.faces;var ua=K.faces;Q=0;for(H=ua.length;Q<H;Q++){T=ua[Q];T=sa[T];if(T instanceof THREE.Face3){D+=3;ga+=1;pa+=3}else if(T instanceof THREE.Face4){D+=4;ga+=2;pa+=4}}Q=K;H=F;sa=void 0;ua=void 0;var Ea=void 0,da=void 0;Ea=void 0;T=[];sa=0;for(ua=H.materials.length;sa<ua;sa++){Ea=H.materials[sa];if(Ea instanceof THREE.MeshFaceMaterial){Ea=0;for(l=Q.materials.length;Ea<l;Ea++)(da=
Q.materials[Ea])&&T.push(da)}else(da=Ea)&&T.push(da)}H=T;a:{Q=void 0;sa=void 0;ua=H.length;for(Q=0;Q<ua;Q++){sa=H[Q];if(sa.map||sa.lightMap||sa instanceof THREE.MeshShaderMaterial){Q=!0;break a}}Q=!1}a:{sa=H;ua=void 0;T=void 0;Ea=sa.length;for(ua=0;ua<Ea;ua++){T=sa[ua];if(!(T instanceof THREE.MeshBasicMaterial&&!T.envMap||T instanceof THREE.MeshDepthMaterial)){sa=T&&T.shading!=undefined&&T.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}sa=!1}a:{ua=void 0;T=void 0;Ea=H.length;
for(ua=0;ua<Ea;ua++){T=H[ua];if(T.vertexColors){H=T.vertexColors;break a}}H=!1}K.__vertexArray=new Float32Array(D*3);if(sa)K.__normalArray=new Float32Array(D*3);if(ya.hasTangents)K.__tangentArray=new Float32Array(D*4);if(H)K.__colorArray=new Float32Array(D*3);if(Q){if(ya.faceUvs.length>0||ya.faceVertexUvs.length>0)K.__uvArray=new Float32Array(D*2);if(ya.faceUvs.length>1||ya.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(D*2)}if(F.geometry.skinWeights.length&&F.geometry.skinIndices.length){K.__skinVertexAArray=
new Float32Array(D*4);K.__skinVertexBArray=new Float32Array(D*4);K.__skinIndexArray=new Float32Array(D*4);K.__skinWeightArray=new Float32Array(D*4)}K.__faceArray=new Uint16Array(ga*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(pa*2);if(K.numMorphTargets){ya=void 0;ua=void 0;K.__morphTargetsArrays=[];ya=0;for(ua=K.numMorphTargets;ya<ua;ya++)K.__morphTargetsArrays.push(new Float32Array(D*3))}K.__needsSmoothNormals=sa==THREE.SmoothShading;K.__uvType=Q;K.__vertexColorType=
H;K.__normalType=sa;K.__webGLFaceCount=ga*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0);K.__webGLLineCount=pa*2;y.__dirtyVertices=!0;y.__dirtyMorphTargets=!0;y.__dirtyElements=!0;y.__dirtyUvs=!0;y.__dirtyNormals=!0;y.__dirtyTangents=!0;y.__dirtyColors=!0}w instanceof THREE.ShadowVolume?C(t.__webglShadowVolumes,E,w):C(t.__webglObjects,E,w)}}else if(w instanceof THREE.Ribbon){y=w.geometry;if(!y.__webGLVertexBuffer){o=y;o.__webGLVertexBuffer=e.createBuffer();o.__webGLColorBuffer=e.createBuffer();
o=y;E=o.vertices.length;o.__vertexArray=new Float32Array(E*3);o.__colorArray=new Float32Array(E*3);o.__webGLVertexCount=E;y.__dirtyVertices=!0;y.__dirtyColors=!0}C(t.__webglObjects,y,w)}else if(w instanceof THREE.Line){y=w.geometry;if(!y.__webGLVertexBuffer){o=y;o.__webGLVertexBuffer=e.createBuffer();o.__webGLColorBuffer=e.createBuffer();o=y;E=o.vertices.length;o.__vertexArray=new Float32Array(E*3);o.__colorArray=new Float32Array(E*3);o.__webGLLineCount=E;y.__dirtyVertices=!0;y.__dirtyColors=!0}C(t.__webglObjects,
y,w)}else if(w instanceof THREE.ParticleSystem){y=w.geometry;if(!y.__webGLVertexBuffer){o=y;o.__webGLVertexBuffer=e.createBuffer();o.__webGLColorBuffer=e.createBuffer();o=y;E=o.vertices.length;o.__vertexArray=new Float32Array(E*3);o.__colorArray=new Float32Array(E*3);o.__sortArray=[];o.__webGLParticleCount=E;y.__dirtyVertices=!0;y.__dirtyColors=!0}C(t.__webglObjects,y,w)}else THREE.MarchingCubes!==undefined&&w instanceof THREE.MarchingCubes&&t.__webglObjectsImmediate.push({object:w,opaque:{list:[],
count:0},transparent:{list:[],count:0}});j.__objectsAdded.splice(0,1)}for(;j.__objectsRemoved.length;){w=j.__objectsRemoved[0];t=j;y=void 0;o=void 0;for(y=t.__webglObjects.length-1;y>=0;y--){o=t.__webglObjects[y].object;w==o&&t.__webglObjects.splice(y,1)}j.__objectsRemoved.splice(0,1)}w=0;for(t=j.__webglObjects.length;w<t;w++)G(j.__webglObjects[w].object,j);w=0;for(t=j.__webglShadowVolumes.length;w<t;w++)G(j.__webglShadowVolumes[w].object,j)};this.setFaceCulling=function(j,w){if(j){!w||w=="ccw"?e.frontFace(e.CCW):
e.frontFace(e.CW);if(j=="back")e.cullFace(e.BACK);else j=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,f=b.length;for(d=0;d<f;d++){a=b[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(c.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,k=a.faces,j=e.faces,m=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=j.length;t<x;t++){h=j[t];var q,z,G=h.vertexNormals;y=h.vertexColors;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+
d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.normal.copy(h.normal);b=0;for(g=G.length;b<g;b++){z=G[b];q.vertexNormals.push(z.clone())}q.color.copy(h.color);b=0;for(g=y.length;b<g;b++){z=y[b];q.vertexColors.push(z.clone())}q.materials=h.materials.slice();q.centroid.copy(h.centroid);k.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];k=[];b=0;for(g=d.length;b<g;b++)k.push(new THREE.UV(d[b].u,d[b].v));m.push(k)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=
new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,c,b){var d,e=[],g=new THREE.Texture(e,c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in X.objects)if(!ca.objects[t]){G=X.objects[t];if(A=ca.geometries[G.geometry]){O=
[];for(i=0;i<G.materials.length;i++)O[i]=ca.materials[G.materials[i]];H=G.position;r=G.rotation;s=G.scale;object=new THREE.Mesh(A,O);object.position.set(H[0],H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;ca.scene.addObject(object);ca.objects[t]=object}}}function h(Da){return function(ja){ca.geometries[Da]=ja;g();ka-=1;k()}}function k(){d({total_models:T,total_textures:xa,loaded_models:T-ka,loaded_textures:xa-W},ca);ka==0&&W==0&&b(ca)}var j,
m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea,ka,W,T,xa,ca;X=e.data;f=new THREE.BinaryLoader;ea=new THREE.JSONLoader;W=ka=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){W-=1;k()};for(y in X.cameras){E=X.cameras[y];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho"){S=new THREE.Camera;S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far)}H=E.position;E=E.target;
S.position.set(H[0],H[1],H[2]);S.target.position.set(E[0],E[1],E[2]);ca.cameras[y]=S}for(x in X.lights){y=X.lights[x];if(y.type=="directional"){H=y.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],H[2]);light.position.normalize()}else if(y.type=="point"){H=y.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}E=y.color;i=y.intensity||1;light.color.setRGB(E[0]*i,E[1]*i,E[2]*i);ca.scene.addLight(light);ca.lights[x]=light}for(q in X.fogs){x=X.fogs[q];if(x.type==
"linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));E=x.color;Q.color.setRGB(E[0],E[1],E[2]);ca.fogs[q]=Q}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];E=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(E[0],E[1],E[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(j in X.geometries){q=X.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")ka+=
1}T=ka;for(j in X.geometries){q=X.geometries[j];if(q.type=="cube"){A=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);ca.geometries[j]=A}else if(q.type=="plane"){A=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="sphere"){A=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="cylinder"){A=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);
ca.geometries[j]=A}else if(q.type=="torus"){A=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);ca.geometries[j]=A}else if(q.type=="icosahedron"){A=new Icosahedron(q.subdivisions);ca.geometries[j]=A}else if(q.type=="bin_mesh")f.load({model:q.url,callback:h(j)});else q.type=="ascii_mesh"&&ea.load({model:q.url,callback:h(j)})}for(z in X.textures){j=X.textures[z];W+=j.url instanceof Array?j.url.length:1}xa=W;for(z in X.textures){j=X.textures[z];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=
new THREE[j.mapping];if(j.url instanceof Array)q=ImageUtils.loadTextureCube(j.url,j.mapping,e);else{q=ImageUtils.loadTexture(j.url,j.mapping,e);if(THREE[j.minFilter]!=undefined)q.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)q.magFilter=THREE[j.magFilter]}ca.textures[z]=q}for(m in X.materials){z=X.materials[m];for(I in z.parameters)if(I=="envMap"||I=="map"||I=="lightMap")z.parameters[I]=ca.textures[z.parameters[I]];else if(I=="shading")z.parameters[I]=z.parameters[I]=="flat"?THREE.FlatShading:
THREE.SmoothShading;else if(I=="blending")z.parameters[I]=THREE[z.parameters[I]]?THREE[z.parameters[I]]:THREE.NormalBlending;else I=="combine"&&(z.parameters[I]=z.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);z=new THREE[z.type](z.parameters);ca.materials[m]=z}g();c(ca)}},addMesh:function(a,c,b,d,e,g,h,k,j,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=k;c.rotation.z=j;a.addObject(c);return c},
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,f=b?c.geometry:c,g=a.vertices,h=f.vertices,k=a.faces,m=f.faces,n=a.faceVertexUvs[0];f=f.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var q=0,x=h.length;q<x;q++){var z=new THREE.Vertex(h[q].position.clone());b&&c.matrix.multiplyVector3(z.position);g.push(z)}q=0;for(x=m.length;q<x;q++){h=m[q];var p,A,G=h.vertexNormals;z=h.vertexColors;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+
d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));p.normal.copy(h.normal);b=0;for(g=G.length;b<g;b++){A=G[b];p.vertexNormals.push(A.clone())}p.color.copy(h.color);b=0;for(g=z.length;b<g;b++){A=z[b];p.vertexColors.push(A.clone())}p.materials=h.materials.slice();p.centroid.copy(h.centroid);k.push(p)}q=0;for(x=f.length;q<x;q++){d=f[q];k=[];b=0;for(g=d.length;b<g;b++)k.push(new THREE.UV(d[b].u,d[b].v));n.push(k)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,f=
new THREE.Texture(d,c);d.onload=function(){f.needsUpdate=!0;b&&b(this)};d.src=a;return f},loadTextureCube:function(a,c,b){var d,f=[],g=new THREE.Texture(f,c);c=f.loadCount=0;for(d=a.length;c<d;++c){f[c]=new Image;f[c].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;b&&b(this)};f[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(q in V.objects)if(!ha.objects[q]){G=V.objects[q];if(B=ha.geometries[G.geometry]){O=
[];for(i=0;i<G.materials.length;i++)O[i]=ha.materials[G.materials[i]];I=G.position;r=G.rotation;s=G.scale;object=new THREE.Mesh(B,O);object.position.set(I[0],I[1],I[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;ha.scene.addObject(object);ha.objects[q]=object}}}function h(Aa){return function(ka){ha.geometries[Aa]=ka;g();ja-=1;k()}}function k(){d({total_models:W,total_textures:wa,loaded_models:W-ja,loaded_textures:wa-X},ha);ja==0&&X==0&&b(ha)}var m,
n,q,x,z,p,A,G,I,C,J,B,U,P,O,V,Y,e,ja,X,W,wa,ha;V=f.data;Y=new THREE.BinaryLoader;e=new THREE.JSONLoader;X=ja=0;ha={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};f=function(){X-=1;k()};for(z in V.cameras){C=V.cameras[z];if(C.type=="perspective")U=new THREE.Camera(C.fov,C.aspect,C.near,C.far);else if(C.type=="ortho"){U=new THREE.Camera;U.projectionMatrix=THREE.Matrix4.makeOrtho(C.left,C.right,C.top,C.bottom,C.near,C.far)}I=C.position;C=C.target;
U.position.set(I[0],I[1],I[2]);U.target.position.set(C[0],C[1],C[2]);ha.cameras[z]=U}for(x in V.lights){z=V.lights[x];if(z.type=="directional"){I=z.direction;light=new THREE.DirectionalLight;light.position.set(I[0],I[1],I[2]);light.position.normalize()}else if(z.type=="point"){I=z.position;light=new THREE.PointLight;light.position.set(I[0],I[1],I[2])}C=z.color;i=z.intensity||1;light.color.setRGB(C[0]*i,C[1]*i,C[2]*i);ha.scene.addLight(light);ha.lights[x]=light}for(p in V.fogs){x=V.fogs[p];if(x.type==
"linear")P=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(P=new THREE.FogExp2(0,x.density));C=x.color;P.color.setRGB(C[0],C[1],C[2]);ha.fogs[p]=P}if(ha.cameras&&V.defaults.camera)ha.currentCamera=ha.cameras[V.defaults.camera];if(ha.fogs&&V.defaults.fog)ha.scene.fog=ha.fogs[V.defaults.fog];C=V.defaults.bgcolor;ha.bgColor=new THREE.Color;ha.bgColor.setRGB(C[0],C[1],C[2]);ha.bgColorAlpha=V.defaults.bgalpha;for(m in V.geometries){p=V.geometries[m];if(p.type=="bin_mesh"||p.type=="ascii_mesh")ja+=
1}W=ja;for(m in V.geometries){p=V.geometries[m];if(p.type=="cube"){B=new Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides);ha.geometries[m]=B}else if(p.type=="plane"){B=new Plane(p.width,p.height,p.segmentsWidth,p.segmentsHeight);ha.geometries[m]=B}else if(p.type=="sphere"){B=new Sphere(p.radius,p.segmentsWidth,p.segmentsHeight);ha.geometries[m]=B}else if(p.type=="cylinder"){B=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);
ha.geometries[m]=B}else if(p.type=="torus"){B=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);ha.geometries[m]=B}else if(p.type=="icosahedron"){B=new Icosahedron(p.subdivisions);ha.geometries[m]=B}else if(p.type=="bin_mesh")Y.load({model:p.url,callback:h(m)});else p.type=="ascii_mesh"&&e.load({model:p.url,callback:h(m)})}for(A in V.textures){m=V.textures[A];X+=m.url instanceof Array?m.url.length:1}wa=X;for(A in V.textures){m=V.textures[A];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=
new THREE[m.mapping];if(m.url instanceof Array)p=ImageUtils.loadTextureCube(m.url,m.mapping,f);else{p=ImageUtils.loadTexture(m.url,m.mapping,f);if(THREE[m.minFilter]!=undefined)p.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=undefined)p.magFilter=THREE[m.magFilter]}ha.textures[A]=p}for(n in V.materials){A=V.materials[n];for(J in A.parameters)if(J=="envMap"||J=="map"||J=="lightMap")A.parameters[J]=ha.textures[A.parameters[J]];else if(J=="shading")A.parameters[J]=A.parameters[J]=="flat"?THREE.FlatShading:
THREE.SmoothShading;else if(J=="blending")A.parameters[J]=THREE[A.parameters[J]]?THREE[A.parameters[J]]:THREE.NormalBlending;else J=="combine"&&(A.parameters[J]=A.parameters[J]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);ha.materials[n]=A}g();c(ha)}},addMesh:function(a,c,b,d,f,g,h,k,m,n){c=new THREE.Mesh(c,n);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=f;c.position.z=g;c.rotation.x=h;c.rotation.y=k;c.rotation.z=m;a.addObject(c);return c},
addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,
c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;
for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var f=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,
c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,f=a.children.length;
for(d=0;d<f;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
@@ -324,8 +336,8 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,e,g=2*Math.ceil(a*3)+1;g>25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-e)*(c-e))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}};
THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}};
THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=
!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
@@ -333,77 +345,77 @@ this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBack
var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
THREE.PathCamera=function(a){function c(m,t,x,y){var q={name:x,fps:0.6,length:y,hierarchy:[]},z,G=t.getControlPointsArray(),H=t.getLength(),E=G.length,I=0;z=E-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[z]={time:y,pos:G[z],rot:[0,0,0,1],scl:[1,1,1]};for(z=1;z<E-1;z++){I=y*H.chunks[z]/H.total;t.keys[z]={time:I,pos:G[z]}}q.hierarchy[0]=t;THREE.AnimationHandler.add(q);return new THREE.Animation(m,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,t){var x,
y,q=new THREE.Geometry;for(x=0;x<m.points.length*t;x++){y=x/(m.points.length*t);y=m.getPoint(y);q.vertices[x]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return q}function d(m,t){var x=b(t,10),y=b(t,10),q=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(x,q);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);y=new Sphere(1,
16,8);q=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<t.points.length;i++){x=new THREE.Mesh(y,q);x.position.copy(t.points[i]);x.updateMatrix();m.addChild(x)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
THREE.PathCamera=function(a){function c(n,q,x,z){var p={name:x,fps:0.6,length:z,hierarchy:[]},A,G=q.getControlPointsArray(),I=q.getLength(),C=G.length,J=0;A=C-1;q={parent:-1,keys:[]};q.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};q.keys[A]={time:z,pos:G[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A<C-1;A++){J=z*I.chunks[A]/I.total;q.keys[A]={time:J,pos:G[A]}}p.hierarchy[0]=q;THREE.AnimationHandler.add(p);return new THREE.Animation(n,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(n,q){var x,
z,p=new THREE.Geometry;for(x=0;x<n.points.length*q;x++){z=x/(n.points.length*q);z=n.getPoint(z);p.vertices[x]=new THREE.Vertex(new THREE.Vector3(z.x,z.y,z.z))}return p}function d(n,q){var x=b(q,10),z=b(q,10),p=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(x,p);particleObj=new THREE.ParticleSystem(z,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);n.addChild(lineObj);particleObj.scale.set(1,1,1);n.addChild(particleObj);z=new Sphere(1,
16,8);p=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<q.points.length;i++){x=new THREE.Mesh(z,p);x.position.copy(q.points[i]);x.updateMatrix();n.addChild(x)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,g=Math.PI/180;this.update=function(m,t,x){var y,q;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;y=this.phi%e;this.phi=y>=0?y:y+e;y=this.verticalAngleMap.srcRange;q=this.verticalAngleMap.dstRange;
this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,t,x)};this.onMouseMove=function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,t){return function(){t.apply(m,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
var Cube=function(a,c,b,d,e,g,h,k,j){function m(H,E,I,A,S,Q,O,X){var f,ea,ka=d||1,W=e||1,T=S/2,xa=Q/2,ca=t.vertices.length;if(H=="x"&&E=="y"||H=="y"&&E=="x")f="z";else if(H=="x"&&E=="z"||H=="z"&&E=="x"){f="y";W=g||1}else if(H=="z"&&E=="y"||H=="y"&&E=="z"){f="x";ka=g||1}var Da=ka+1,ja=W+1;S/=ka;var oa=Q/W;for(ea=0;ea<ja;ea++)for(Q=0;Q<Da;Q++){var la=new THREE.Vector3;la[H]=(Q*S-T)*I;la[E]=(ea*oa-xa)*A;la[f]=O;t.vertices.push(new THREE.Vertex(la))}for(ea=0;ea<W;ea++)for(Q=0;Q<ka;Q++){t.faces.push(new THREE.Face4(Q+
Da*ea+ca,Q+Da*(ea+1)+ca,Q+1+Da*(ea+1)+ca,Q+1+Da*ea+ca,null,null,X));t.faceVertexUvs[0].push([new THREE.UV(Q/ka,ea/W),new THREE.UV(Q/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,ea/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;k=k?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var G in j)this.sides[G]!=
undefined&&(this.sides[G]=j[G]);this.sides.px&&m("z","y",1*k,-1,b,c,-x,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,b,c,x,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,b,y,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,b,-y,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,c,q,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,c,-q,this.materials[5]);(function(){for(var H=[],E=[],I=0,A=t.vertices.length;I<A;I++){for(var S=t.vertices[I],Q=!1,O=0,X=H.length;O<X;O++){var f=H[O];
if(S.position.x==f.position.x&&S.position.y==f.position.y&&S.position.z==f.position.z){E[I]=O;Q=!0;break}}if(!Q){E[I]=H.length;H.push(new THREE.Vertex(S.position.clone()))}}I=0;for(A=t.faces.length;I<A;I++){S=t.faces[I];S.a=E[S.a];S.b=E[S.b];S.c=E[S.c];S.d=E[S.d]}t.vertices=H})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,c,b,d,e,g){function h(t,x,y){k.vertices.push(new THREE.Vertex(new THREE.Vector3(t,x,y)))}THREE.Geometry.call(this);var k=this,j=Math.PI,m=d/2;for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*c,Math.cos(2*j*d/a)*c,-m);for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*b,Math.cos(2*j*d/a)*b,m);for(d=0;d<a;d++)k.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-m-(g||0));for(d=a;d<a+a/2;d++)k.faces.push(new THREE.Face4(2*a,(2*d-2*a)%a,(2*d-2*a+1)%a,(2*d-2*a+2)%a))}if(c>0){h(0,0,m+(e||0));
this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(n,q,x){var z,p;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;z=this.phi%f;this.phi=z>=0?z:z+f;z=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange;
this.phi=(this.phi-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,q,x)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(m,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,q){return function(){q.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
var Cube=function(a,c,b,d,f,g,h,k,m){function n(I,C,J,B,U,P,O,V){var Y,e,ja=d||1,X=f||1,W=U/2,wa=P/2,ha=q.vertices.length;if(I=="x"&&C=="y"||I=="y"&&C=="x")Y="z";else if(I=="x"&&C=="z"||I=="z"&&C=="x"){Y="y";X=g||1}else if(I=="z"&&C=="y"||I=="y"&&C=="z"){Y="x";ja=g||1}var Aa=ja+1,ka=X+1;U/=ja;var oa=P/X;for(e=0;e<ka;e++)for(P=0;P<Aa;P++){var ma=new THREE.Vector3;ma[I]=(P*U-W)*J;ma[C]=(e*oa-wa)*B;ma[Y]=O;q.vertices.push(new THREE.Vertex(ma))}for(e=0;e<X;e++)for(P=0;P<ja;P++){q.faces.push(new THREE.Face4(P+
Aa*e+ha,P+Aa*(e+1)+ha,P+1+Aa*(e+1)+ha,P+1+Aa*e+ha,null,null,V));q.faceVertexUvs[0].push([new THREE.UV(P/ja,e/X),new THREE.UV(P/ja,(e+1)/X),new THREE.UV((P+1)/ja,(e+1)/X),new THREE.UV((P+1)/ja,e/X)])}}THREE.Geometry.call(this);var q=this,x=a/2,z=c/2,p=b/2;k=k?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=undefined)for(var G in m)this.sides[G]!=
undefined&&(this.sides[G]=m[G]);this.sides.px&&n("z","y",1*k,-1,b,c,-x,this.materials[0]);this.sides.nx&&n("z","y",-1*k,-1,b,c,x,this.materials[1]);this.sides.py&&n("x","z",1*k,1,a,b,z,this.materials[2]);this.sides.ny&&n("x","z",1*k,-1,a,b,-z,this.materials[3]);this.sides.pz&&n("x","y",1*k,-1,a,c,p,this.materials[4]);this.sides.nz&&n("x","y",-1*k,-1,a,c,-p,this.materials[5]);(function(){for(var I=[],C=[],J=0,B=q.vertices.length;J<B;J++){for(var U=q.vertices[J],P=!1,O=0,V=I.length;O<V;O++){var Y=I[O];
if(U.position.x==Y.position.x&&U.position.y==Y.position.y&&U.position.z==Y.position.z){C[J]=O;P=!0;break}}if(!P){C[J]=I.length;I.push(new THREE.Vertex(U.position.clone()))}}J=0;for(B=q.faces.length;J<B;J++){U=q.faces[J];U.a=C[U.a];U.b=C[U.b];U.c=C[U.c];U.d=C[U.d]}q.vertices=I})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,c,b,d,f,g){function h(q,x,z){k.vertices.push(new THREE.Vertex(new THREE.Vector3(q,x,z)))}THREE.Geometry.call(this);var k=this,m=Math.PI,n=d/2;for(d=0;d<a;d++)h(Math.sin(2*m*d/a)*c,Math.cos(2*m*d/a)*c,-n);for(d=0;d<a;d++)h(Math.sin(2*m*d/a)*b,Math.cos(2*m*d/a)*b,n);for(d=0;d<a;d++)k.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-n-(g||0));for(d=a;d<a+a/2;d++)k.faces.push(new THREE.Face4(2*a,(2*d-2*a)%a,(2*d-2*a+1)%a,(2*d-2*a+2)%a))}if(c>0){h(0,0,n+(f||0));
for(d=a+a/2;d<2*a;d++)k.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Icosahedron=function(a){function c(x,y,q){var z=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/z,y/z,q/z)))-1}function b(x,y,q,z){z.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,z=e.vertices[y].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),t=d(g.faces[k].c,g.faces[k].a);b(g.faces[k].a,j,t,h);b(g.faces[k].b,m,j,h);b(g.faces[k].c,
t,m,h);b(j,m,t,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],e=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));d[k]=a[k].clone();e[k]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(c),m=0;m<=this.angle+0.001;m+=c){for(k=0;k<d.length;k++)if(m<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=e);for(k=
0;k<e.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],e[k+1],e[k]));this.faceVertexUvs[0].push([new THREE.UV(m/b,k/a.length),new THREE.UV(m/b,(k+1)/a.length),new THREE.UV((m-c)/b,(k+1)/a.length),new THREE.UV((m-c)/b,k/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var k=b+1,j=d+1;a/=b;var m=c/d;for(e=0;e<j;e++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*m-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+k*e,c+k*(e+1),c+1+k*(e+1),c+1+k*e));this.faceVertexUvs[0].push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();this.computeFaceNormals()};
var Icosahedron=function(a){function c(x,z,p){var A=Math.sqrt(x*x+z*z+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,z/A,p/A)))-1}function b(x,z,p,A){A.faces.push(new THREE.Face3(x,z,p))}function d(x,z){var p=f.vertices[x].position,A=f.vertices[z].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var m=d(g.faces[k].a,g.faces[k].b),n=d(g.faces[k].b,g.faces[k].c),q=d(g.faces[k].c,g.faces[k].a);b(g.faces[k].a,m,q,h);b(g.faces[k].b,n,m,h);b(g.faces[k].c,
q,n,h);b(m,n,q,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));d[k]=a[k].clone();f[k]=this.vertices.length-1}for(var m=(new THREE.Matrix4).setRotationZ(c),n=0;n<=this.angle+0.0010;n+=c){for(k=0;k<d.length;k++)if(n<this.angle){d[k]=m.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;n==0&&(h=f);for(k=
0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k]));this.faceVertexUvs[0].push([new THREE.UV(n/b,k/a.length),new THREE.UV(n/b,(k+1)/a.length),new THREE.UV((n-c)/b,(k+1)/a.length),new THREE.UV((n-c)/b,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var f,g=a/2,h=c/2;b=b||1;d=d||1;var k=b+1,m=d+1;a/=b;var n=c/d;for(f=0;f<m;f++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(f*n-h),0)));for(f=0;f<d;f++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+k*f,c+k*(f+1),c+1+k*(f+1),c+1+k*f));this.faceVertexUvs[0].push([new THREE.UV(c/b,f/d),new THREE.UV(c/b,(f+1)/d),new THREE.UV((c+1)/b,(f+1)/d),new THREE.UV((c+1)/b,f/d)])}this.computeCentroids();this.computeFaceNormals()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var k=a*Math.cos(d*e),j=a*Math.sin(d*e),m=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=j*Math.sin(x*e);x=j*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);m.push(t)}c.push(m)}var q,z,G;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){m=d==g-1;h=c[b][m?0:d+1];k=c[b][m?g-1:d];j=c[b-1][m?g-1:d];m=c[b-1][m?
0:d+1];y=b/(e-1);q=(b-1)/(e-1);z=(d+1)/g;x=d/g;t=new THREE.UV(1-z,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-z,q);if(b<c.length-1){q=this.vertices[h].position.clone();z=this.vertices[k].position.clone();G=this.vertices[j].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
z=this.vertices[j].position.clone();G=this.vertices[m].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var TorusKnot=function(a,c,b,d,e,g,h){function k(x,y,q,z,G,H){y=q/z*x;q=Math.cos(y);return new THREE.Vector3(G*(2+q)*0.5*Math.cos(x),G*(2+q)*Math.sin(x)*0.5,H*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;e=k(j,h,this.q,this.p,this.radius,this.heightScale);j=k(j+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=j.x-e.x;b.y=j.y-e.y;b.z=j.z-e.z;d.x=j.x+e.x;d.y=j.y+e.y;d.z=j.z+e.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();j=this.tube*Math.cos(h);h=this.tube*Math.sin(h);e.x+=j*d.x+h*g.x;e.y+=j*d.y+h*g.y;e.z+=j*d.z+h*g.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;e=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var m=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,d));this.faceVertexUvs[0].push([h,j,m]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([t,
m,j])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var k=a*Math.cos(d*f),m=a*Math.sin(d*f),n=[],q=0;for(d=0;d<g;d++){var x=2*d/g,z=m*Math.sin(x*f);x=m*Math.cos(x*f);(b==0||b==h)&&d>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(q)}c.push(n)}var p,A,G;f=c.length;for(b=0;b<f;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){n=d==g-1;h=c[b][n?0:d+1];k=c[b][n?g-1:d];m=c[b-1][n?g-1:d];n=c[b-1][n?
0:d+1];z=b/(f-1);p=(b-1)/(f-1);A=(d+1)/g;x=d/g;q=new THREE.UV(1-A,z);z=new THREE.UV(1-x,z);x=new THREE.UV(1-x,p);var I=new THREE.UV(1-A,p);if(b<c.length-1){p=this.vertices[h].position.clone();A=this.vertices[k].position.clone();G=this.vertices[m].position.clone();p.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,z,x])}if(b>1){p=this.vertices[h].position.clone();
A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();p.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,x,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
var TorusKnot=function(a,c,b,d,f,g,h){function k(x,z,p,A,G,I){z=p/A*x;p=Math.cos(z);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,I*G*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var m=
a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;f=k(m,h,this.q,this.p,this.radius,this.heightScale);m=k(m+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=m.x-f.x;b.y=m.y-f.y;b.z=m.z-f.z;d.x=m.x+f.x;d.y=m.y+f.y;d.z=m.z+f.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();m=this.tube*Math.cos(h);h=this.tube*Math.sin(h);f.x+=m*d.x+h*g.x;f.y+=m*d.y+h*g.y;f.z+=m*d.z+h*g.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;f=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);m=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var n=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),q=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(f,b,d));this.faceVertexUvs[0].push([h,m,n]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([q,
n,m])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(c[d],b)]},createMaterial:function(a,c){function b(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var t=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
k.image.width=t;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,t,x)}else k.image=this;k.needsUpdate=!0};m.src=j}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1};if(a.shading)if(a.shading=="Phong")e="MeshPhongMaterial";else a.shading=="Basic"&&(e="MeshBasicMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);g.map.sourceFile=a.mapDiffuse;d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=
(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLightmap;d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[e](g)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(c[d],b)]},createMaterial:function(a,c){function b(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,m){var n=new Image;n.onload=function(){if(!b(this.width)||!b(this.height)){var q=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
k.image.width=q;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,q,x)}else k.image=this;k.needsUpdate=!0};n.src=m}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1};if(a.shading)if(a.shading=="Phong")f="MeshPhongMaterial";else a.shading=="Basic"&&(f="MeshBasicMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);g.map.sourceFile=a.mapDiffuse;d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=
(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLightmap;d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[f](g)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
THREE.JSONLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(e){THREE.JSONLoader.prototype.createModel(e.data,b,d)};c.postMessage(a)},createModel:function(a,c,b){var d=function(e){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,e);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");
else{var h,k,j,m,t,x,y,q,z,G,H=a.faces;q=a.vertices;var E=a.normals,I=a.colors,A=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&A++;for(h=0;h<A;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}j=0;for(m=q.length;j<m;){z=new THREE.Vertex;z.position.x=q[j++];z.position.y=q[j++];z.position.z=q[j++];g.vertices.push(z)}j=0;for(m=H.length;j<m;){t=H[j++];x=t&1;h=t&2;y=t&4;k=t&8;q=t&16;z=t&32;G=t&64;t&=128;if(x){x=new THREE.Face4;x.a=H[j++];x.b=H[j++];x.c=H[j++];x.d=H[j++];nVertices=4}else{x=new THREE.Face3;x.a=
H[j++];x.b=H[j++];x.c=H[j++];nVertices=3}if(h){materialIndex=H[j++];x.materials=g.materials[materialIndex]}if(y)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(k)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvs=[];for(k=0;k<nVertices;k++){uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[k]=new THREE.UV(u,v)}k=g.faces.length;g.faceVertexUvs[h][k]=uvs}if(q){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=
E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.normal=normal}if(z)for(h=0;h<nVertices;h++){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.vertexNormals.push(normal)}if(G){color=new THREE.Color(H[j++]);x.color=color}if(t)for(h=0;h<nVertices;h++){colorIndex=H[j++];color=new THREE.Color(I[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<
k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];g.skinWeights.push(new THREE.Vector4(j,m,0,0))}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];g.skinIndices.push(new THREE.Vector4(j,m,0,0))}}g.bones=a.bones;g.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var h,k,j,m;h=0;for(k=a.morphTargets.length;h<k;h++){g.morphTargets[h]={};g.morphTargets[h].name=a.morphTargets[h].name;g.morphTargets[h].vertices=[];dstVertices=g.morphTargets[h].vertices;
srcVertices=a.morphTargets[h].vertices;j=0;for(m=srcVertices.length;j<m;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
THREE.JSONLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.JSONLoader.prototype.createModel(f.data,b,d)};c.postMessage(a)},createModel:function(a,c,b){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");
else{var h,k,m,n,q,x,z,p,A,G,I=a.faces;p=a.vertices;var C=a.normals,J=a.colors,B=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&B++;for(h=0;h<B;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}m=0;for(n=p.length;m<n;){A=new THREE.Vertex;A.position.x=p[m++];A.position.y=p[m++];A.position.z=p[m++];g.vertices.push(A)}m=0;for(n=I.length;m<n;){q=I[m++];x=q&1;h=q&2;z=q&4;k=q&8;p=q&16;A=q&32;G=q&64;q&=128;if(x){x=new THREE.Face4;x.a=I[m++];x.b=I[m++];x.c=I[m++];x.d=I[m++];nVertices=4}else{x=new THREE.Face3;x.a=
I[m++];x.b=I[m++];x.c=I[m++];nVertices=3}if(h){materialIndex=I[m++];x.materials=g.materials[materialIndex]}if(z)for(h=0;h<B;h++){uvLayer=a.uvs[h];uvIndex=I[m++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(k)for(h=0;h<B;h++){uvLayer=a.uvs[h];uvs=[];for(k=0;k<nVertices;k++){uvIndex=I[m++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[k]=new THREE.UV(u,v)}k=g.faces.length;g.faceVertexUvs[h][k]=uvs}if(p){normalIndex=I[m++]*3;normal=new THREE.Vector3;normal.x=
C[normalIndex++];normal.y=C[normalIndex++];normal.z=C[normalIndex];x.normal=normal}if(A)for(h=0;h<nVertices;h++){normalIndex=I[m++]*3;normal=new THREE.Vector3;normal.x=C[normalIndex++];normal.y=C[normalIndex++];normal.z=C[normalIndex];x.vertexNormals.push(normal)}if(G){color=new THREE.Color(I[m++]);x.color=color}if(q)for(h=0;h<nVertices;h++){colorIndex=I[m++];color=new THREE.Color(J[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,k,m,n;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<
k;h+=2){m=a.skinWeights[h];n=a.skinWeights[h+1];g.skinWeights.push(new THREE.Vector4(m,n,0,0))}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){m=a.skinIndices[h];n=a.skinIndices[h+1];g.skinIndices.push(new THREE.Vector4(m,n,0,0))}}g.bones=a.bones;g.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var h,k,m,n;h=0;for(k=a.morphTargets.length;h<k;h++){g.morphTargets[h]={};g.morphTargets[h].name=a.morphTargets[h].name;g.morphTargets[h].vertices=[];dstVertices=g.morphTargets[h].vertices;
srcVertices=a.morphTargets[h].vertices;m=0;for(n=srcVertices.length;m<n;m+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[m],srcVertices[m+1],srcVertices[m+2])))}}})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,e,d,g)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,e,c):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,d){var e=function(g){function h(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2),F=t(p,o+3),Z=(F<<1&255|B>>7)-127;w|=(B&127)<<16|D<<8;if(w==0&&Z==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,Z)}function k(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2);return(t(p,o+3)<<24)+(B<<16)+(D<<8)+w}function j(p,o){var w=t(p,o);return(t(p,o+1)<<8)+w}function m(p,o){var w=t(p,o);return w>127?w-256:w}function t(p,
o){return p.charCodeAt(o)&255}function x(p){var o,w,D;o=k(a,p);w=k(a,p+O);D=k(a,p+X);p=j(a,p+f);THREE.BinaryLoader.prototype.f3(E,o,w,D,p)}function y(p){var o,w,D,B,F,Z;o=k(a,p);w=k(a,p+O);D=k(a,p+X);B=j(a,p+f);F=k(a,p+ea);Z=k(a,p+ka);p=k(a,p+W);THREE.BinaryLoader.prototype.f3n(E,S,o,w,D,B,F,Z,p)}function q(p){var o,w,D,B;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);p=j(a,p+Da);THREE.BinaryLoader.prototype.f4(E,o,w,D,B,p)}function z(p){var o,w,D,B,F,Z,N,K;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);
F=j(a,p+Da);Z=k(a,p+ja);N=k(a,p+oa);K=k(a,p+la);p=k(a,p+aa);THREE.BinaryLoader.prototype.f4n(E,S,o,w,D,B,F,Z,N,K,p)}function G(p){var o,w;o=k(a,p);w=k(a,p+P);p=k(a,p+M);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function H(p){var o,w,D;o=k(a,p);w=k(a,p+da);D=k(a,p+sa);p=k(a,p+ia);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[D*2],Q[D*2+1],Q[p*2],Q[p*2+1])}var E=this,I=0,A,S=[],Q=[],O,X,f,ea,ka,W,T,xa,
ca,Da,ja,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,d,g);A={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,
I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};I+=A.header_bytes;O=A.vertex_index_bytes;X=A.vertex_index_bytes*2;f=A.vertex_index_bytes*3;ea=A.vertex_index_bytes*3+A.material_index_bytes;ka=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;T=A.vertex_index_bytes;xa=A.vertex_index_bytes*2;ca=A.vertex_index_bytes*3;Da=
A.vertex_index_bytes*4;ja=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;la=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;aa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;P=A.uv_index_bytes;M=A.uv_index_bytes*2;da=A.uv_index_bytes;sa=A.uv_index_bytes*2;ia=A.uv_index_bytes*3;g=A.vertex_index_bytes*3+A.material_index_bytes;C=A.vertex_index_bytes*4+A.material_index_bytes;ta=A.ntri_flat*
g;ya=A.ntri_smooth*(g+A.normal_index_bytes*3);La=A.ntri_flat_uv*(g+A.uv_index_bytes*3);ab=A.ntri_smooth_uv*(g+A.normal_index_bytes*3+A.uv_index_bytes*3);n=A.nquad_flat*C;g=A.nquad_smooth*(C+A.normal_index_bytes*4);C=A.nquad_flat_uv*(C+A.uv_index_bytes*4);I+=function(p){for(var o,w,D,B=A.vertex_coordinate_bytes*3,F=p+A.nvertices*B;p<F;p+=B){o=h(a,p);w=h(a,p+A.vertex_coordinate_bytes);D=h(a,p+A.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(E,o,w,D)}return A.nvertices*B}(I);I+=function(p){for(var o,
w,D,B=A.normal_coordinate_bytes*3,F=p+A.nnormals*B;p<F;p+=B){o=m(a,p);w=m(a,p+A.normal_coordinate_bytes);D=m(a,p+A.normal_coordinate_bytes*2);S.push(o/127,w/127,D/127)}return A.nnormals*B}(I);I+=function(p){for(var o,w,D=A.uv_coordinate_bytes*2,B=p+A.nuvs*D;p<B;p+=D){o=h(a,p);w=h(a,p+A.uv_coordinate_bytes);Q.push(o,w)}return A.nuvs*D}(I);ta=I+ta;ya=ta+ya;La=ya+La;ab=La+ab;n=ab+n;g=n+g;C=g+C;(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=w+A.uv_index_bytes*3,B=p+A.ntri_flat_uv*
D;for(o=p;o<B;o+=D){x(o);G(o+w)}return B-p})(ya);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=w+A.uv_index_bytes*3,B=p+A.ntri_smooth_uv*D;for(o=p;o<B;o+=D){y(o);G(o+w)}return B-p})(La);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=w+A.uv_index_bytes*4,B=p+A.nquad_flat_uv*D;for(o=p;o<B;o+=D){q(o);H(o+w)}return B-p})(g);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,D=w+A.uv_index_bytes*
4,B=p+A.nquad_smooth_uv*D;for(o=p;o<B;o+=D){z(o);H(o+w)}return B-p})(C);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=p+A.ntri_flat*w;for(o=p;o<D;o+=w)x(o);return D-p})(I);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=p+A.ntri_smooth*w;for(o=p;o<D;o+=w)y(o);return D-p})(ta);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=p+A.nquad_flat*w;for(o=p;o<D;o+=w)q(o);return D-p})(ab);(function(p){var o,w=A.vertex_index_bytes*
4+A.material_index_bytes+A.normal_index_bytes*4,D=p+A.nquad_smooth*w;for(o=p;o<D;o+=w)z(o);return D-p})(n);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,d)))},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,null,a.materials[g]))},f3n:function(a,c,
b,d,e,g,h,k,j){g=a.materials[g];var m=c[k*3],t=c[k*3+1];k=c[k*3+2];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,d,e,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,t,k),new THREE.Vector3(x,y,j)],null,g))},f4n:function(a,c,b,d,e,g,h,k,j,m,t){h=a.materials[h];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];var q=c[m*3],z=c[m*3+1];m=c[m*3+2];var G=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,
y,j),new THREE.Vector3(q,z,m),new THREE.Vector3(G,H,t)],null,h))},uv3:function(a,c,b,d,e,g,h){var k=[];k.push(new THREE.UV(c,b));k.push(new THREE.UV(d,e));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,c,b,d,e,g,h,k,j){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,f,d,g)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,f,g){var h=new XMLHttpRequest,k=d+"/"+a,m=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,f,c):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){m==0&&(m=h.getResponseHeader("Content-Length"));g({total:m,loaded:h.responseText.length})}}else h.readyState==2&&(m=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,d){var f=function(g){function h(j,w){var t=q(j,w),o=q(j,w+1),y=q(j,w+2),E=q(j,w+3),K=(E<<1&255|y>>7)-127;t|=(y&127)<<16|o<<8;if(t==0&&K==-127)return 0;return(1-2*(E>>7))*(1+t*Math.pow(2,-23))*Math.pow(2,K)}function k(j,w){var t=q(j,w),o=q(j,w+1),y=q(j,w+2);return(q(j,w+3)<<24)+(y<<16)+(o<<8)+t}function m(j,w){var t=q(j,w);return(q(j,w+1)<<8)+t}function n(j,w){var t=q(j,w);return t>127?t-256:t}function q(j,
w){return j.charCodeAt(w)&255}function x(j){var w,t,o;w=k(a,j);t=k(a,j+O);o=k(a,j+V);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(C,w,t,o,j)}function z(j){var w,t,o,y,E,K;w=k(a,j);t=k(a,j+O);o=k(a,j+V);y=m(a,j+Y);E=k(a,j+e);K=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(C,U,w,t,o,y,E,K,j)}function p(j){var w,t,o,y;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha);j=m(a,j+Aa);THREE.BinaryLoader.prototype.f4(C,w,t,o,y,j)}function A(j){var w,t,o,y,E,K,F,D;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha);
E=m(a,j+Aa);K=k(a,j+ka);F=k(a,j+oa);D=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(C,U,w,t,o,y,E,K,F,D,j)}function G(j){var w,t;w=k(a,j);t=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[j*2],P[j*2+1])}function I(j){var w,t,o;w=k(a,j);t=k(a,j+fa);o=k(a,j+ra);j=k(a,j+la);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[o*2],P[o*2+1],P[j*2],P[j*2+1])}var C=this,J=0,B,U=[],P=[],O,V,Y,e,ja,X,W,wa,
ha,Aa,ka,oa,ma,ca,S,M,fa,ra,la,qa,xa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,d,g);B={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a,
J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};J+=B.header_bytes;O=B.vertex_index_bytes;V=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;e=B.vertex_index_bytes*3+B.material_index_bytes;ja=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;X=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;W=B.vertex_index_bytes;wa=B.vertex_index_bytes*2;ha=B.vertex_index_bytes*3;Aa=
B.vertex_index_bytes*4;ka=B.vertex_index_bytes*4+B.material_index_bytes;oa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;ma=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;ca=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;S=B.uv_index_bytes;M=B.uv_index_bytes*2;fa=B.uv_index_bytes;ra=B.uv_index_bytes*2;la=B.uv_index_bytes*3;g=B.vertex_index_bytes*3+B.material_index_bytes;Ha=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat*
g;xa=B.ntri_smooth*(g+B.normal_index_bytes*3);Ca=B.ntri_flat_uv*(g+B.uv_index_bytes*3);Za=B.ntri_smooth_uv*(g+B.normal_index_bytes*3+B.uv_index_bytes*3);$a=B.nquad_flat*Ha;g=B.nquad_smooth*(Ha+B.normal_index_bytes*4);Ha=B.nquad_flat_uv*(Ha+B.uv_index_bytes*4);J+=function(j){for(var w,t,o,y=B.vertex_coordinate_bytes*3,E=j+B.nvertices*y;j<E;j+=y){w=h(a,j);t=h(a,j+B.vertex_coordinate_bytes);o=h(a,j+B.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(C,w,t,o)}return B.nvertices*y}(J);J+=function(j){for(var w,
t,o,y=B.normal_coordinate_bytes*3,E=j+B.nnormals*y;j<E;j+=y){w=n(a,j);t=n(a,j+B.normal_coordinate_bytes);o=n(a,j+B.normal_coordinate_bytes*2);U.push(w/127,t/127,o/127)}return B.nnormals*y}(J);J+=function(j){for(var w,t,o=B.uv_coordinate_bytes*2,y=j+B.nuvs*o;j<y;j+=o){w=h(a,j);t=h(a,j+B.uv_coordinate_bytes);P.push(w,t)}return B.nuvs*o}(J);qa=J+qa;xa=qa+xa;Ca=xa+Ca;Za=Ca+Za;$a=Za+$a;g=$a+g;Ha=g+Ha;(function(j){var w,t=B.vertex_index_bytes*3+B.material_index_bytes,o=t+B.uv_index_bytes*3,y=j+B.ntri_flat_uv*
o;for(w=j;w<y;w+=o){x(w);G(w+t)}return y-j})(xa);(function(j){var w,t=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,o=t+B.uv_index_bytes*3,y=j+B.ntri_smooth_uv*o;for(w=j;w<y;w+=o){z(w);G(w+t)}return y-j})(Ca);(function(j){var w,t=B.vertex_index_bytes*4+B.material_index_bytes,o=t+B.uv_index_bytes*4,y=j+B.nquad_flat_uv*o;for(w=j;w<y;w+=o){p(w);I(w+t)}return y-j})(g);(function(j){var w,t=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*4,o=t+B.uv_index_bytes*
4,y=j+B.nquad_smooth_uv*o;for(w=j;w<y;w+=o){A(w);I(w+t)}return y-j})(Ha);(function(j){var w,t=B.vertex_index_bytes*3+B.material_index_bytes,o=j+B.ntri_flat*t;for(w=j;w<o;w+=t)x(w);return o-j})(J);(function(j){var w,t=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,o=j+B.ntri_smooth*t;for(w=j;w<o;w+=t)z(w);return o-j})(qa);(function(j){var w,t=B.vertex_index_bytes*4+B.material_index_bytes,o=j+B.nquad_flat*t;for(w=j;w<o;w+=t)p(w);return o-j})(Za);(function(j){var w,t=B.vertex_index_bytes*
4+B.material_index_bytes+B.normal_index_bytes*4,o=j+B.nquad_smooth*t;for(w=j;w<o;w+=t)A(w);return o-j})($a);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(b))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,d)))},f3:function(a,c,b,d,f){a.faces.push(new THREE.Face3(c,b,d,null,null,a.materials[f]))},f4:function(a,c,b,d,f,g){a.faces.push(new THREE.Face4(c,b,d,f,null,null,a.materials[g]))},f3n:function(a,
c,b,d,f,g,h,k,m){g=a.materials[g];var n=c[k*3],q=c[k*3+1];k=c[k*3+2];var x=c[m*3],z=c[m*3+1];m=c[m*3+2];a.faces.push(new THREE.Face3(b,d,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(n,q,k),new THREE.Vector3(x,z,m)],null,g))},f4n:function(a,c,b,d,f,g,h,k,m,n,q){h=a.materials[h];var x=c[m*3],z=c[m*3+1];m=c[m*3+2];var p=c[n*3],A=c[n*3+1];n=c[n*3+2];var G=c[q*3],I=c[q*3+1];q=c[q*3+2];a.faces.push(new THREE.Face4(b,d,f,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,
z,m),new THREE.Vector3(p,A,n),new THREE.Vector3(G,I,q)],null,h))},uv3:function(a,c,b,d,f,g,h){var k=[];k.push(new THREE.UV(c,b));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,c,b,d,f,g,h,k,m){var n=[];n.push(new THREE.UV(c,b));n.push(new THREE.UV(d,f));n.push(new THREE.UV(g,h));n.push(new THREE.UV(k,m));a.push(n)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,d,e){return b+(d-b)*e};this.VIntX=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;e[g]=this.lerp(t[b],t[b+3],h);e[g+1]=this.lerp(t[b+1],t[b+4],h);e[g+2]=this.lerp(t[b+2],t[b+5],h)};this.VIntY=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
2]=m;d=b+this.yd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.VIntZ=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=b+this.zd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.compNorm=function(b){var d=b*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[b-1]-this.field[b+1];this.normal_cache[d+1]=this.field[b-this.yd]-
this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,e,g,h,k){var j=g+1,m=g+this.yd,t=g+this.zd,x=j+this.yd,y=j+this.zd,q=g+this.yd+this.zd,z=j+this.yd+this.zd,G=0,H=this.field[g],E=this.field[j],I=this.field[m],A=this.field[x],S=this.field[t],Q=this.field[y],O=this.field[q],X=this.field[z];H<h&&(G|=1);E<h&&(G|=2);I<h&&(G|=8);A<h&&(G|=4);S<h&&(G|=16);Q<h&&(G|=32);O<h&&(G|=128);X<h&&(G|=64);var f=THREE.edgeTable[G];if(f==0)return 0;
var ea=this.delta,ka=b+ea,W=d+ea;ea=e+ea;if(f&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,H,E)}if(f&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,ka,d,e,E,A)}if(f&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,W,e,I,A)}if(f&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,H,I)}if(f&16){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,12,
h,b,d,ea,S,Q)}if(f&32){this.compNorm(y);this.compNorm(z);this.VIntY(y*3,this.vlist,this.nlist,15,h,ka,d,ea,Q,X)}if(f&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,W,ea,O,X)}if(f&128){this.compNorm(t);this.compNorm(q);this.VIntY(t*3,this.vlist,this.nlist,21,h,b,d,ea,S,O)}if(f&256){this.compNorm(g);this.compNorm(t);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,H,S)}if(f&512){this.compNorm(j);this.compNorm(y);this.VIntZ(j*3,this.vlist,this.nlist,27,h,ka,d,e,E,Q)}if(f&
1024){this.compNorm(x);this.compNorm(z);this.VIntZ(x*3,this.vlist,this.nlist,30,h,ka,W,e,A,X)}if(f&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,W,e,I,O)}G<<=4;for(h=g=0;THREE.triTable[G+h]!=-1;){b=G+h;d=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[e],k);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,k){var j=this.count*3;this.positionArray[j]=b[e];this.positionArray[j+1]=b[e+1];this.positionArray[j+
2]=b[e+2];this.positionArray[j+3]=b[g];this.positionArray[j+4]=b[g+1];this.positionArray[j+5]=b[g+2];this.positionArray[j+6]=b[h];this.positionArray[j+7]=b[h+1];this.positionArray[j+8]=b[h+2];this.normalArray[j]=d[e];this.normalArray[j+1]=d[e+1];this.normalArray[j+2]=d[e+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=
this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;b(this)}};this.addBall=function(b,d,e,g,h){var k=this.size*Math.sqrt(g/h),j=e*this.size,m=d*this.size,t=b*this.size,x=Math.floor(j-k);x<1&&(x=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var y=Math.floor(m-k);y<1&&(y=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var q=Math.floor(t-
k);q<1&&(q=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,G,H,E,I,A;x<j;x++){t=this.size2*x;G=x/this.size-e;I=G*G;for(G=y;G<m;G++){H=t+this.size*G;z=G/this.size-d;A=z*z;for(z=q;z<k;z++){E=z/this.size-b;E=g/(1.0E-6+E*E+A+I)-h;E>0&&(this.field[H+z]+=E)}}}};this.addPlaneX=function(b,d){var e,g,h,k,j,m=this.size,t=this.yd,x=this.zd,y=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e<q;e++){g=e/m;g*=g;k=b/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=e+g*t;for(h=0;h<m;h++)y[x*h+j]+=k}}};this.addPlaneY=
function(b,d){var e,g,h,k,j,m,t=this.size,x=this.yd,y=this.zd,q=this.field,z=t*Math.sqrt(b/d);z>t&&(z=t);for(g=0;g<z;g++){e=g/t;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=g*x;for(e=0;e<t;e++){m=j+e;for(h=0;h<t;h++)q[y*h+m]+=k}}}};this.addPlaneZ=function(b,d){var e,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(e=0;e<size;e++)field[m+e]+=k}}}};this.reset=
function(){var b;for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var d,e,g,h,k,j,m,t,x,y=this.size-2;for(h=1;h<y;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){t=x+this.size*g;j=(g-this.halfsize)/this.halfsize;for(e=1;e<y;e++){k=(e-this.halfsize)/this.halfsize;d=t+e;this.polygonize(k,j,m,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(e){var g,h,k,
j,m,t,x,y;for(g=0;g<e.count;g++){m=g*3;x=m+1;y=m+2;h=e.positionArray[m];k=e.positionArray[x];j=e.positionArray[y];t=new THREE.Vector3(h,k,j);h=e.normalArray[m];k=e.normalArray[x];j=e.normalArray[y];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(t,m);d.vertices.push(m)}nfaces=e.count/3;for(g=0;g<nfaces;g++){m=(b+g)*3;x=m+1;y=m+2;t=d.vertices[m].normal;h=d.vertices[x].normal;k=d.vertices[y].normal;m=new THREE.Face3(m,x,y,[t,h,k]);d.faces.push(m)}b+=nfaces;e.count=0});return d};this.init(a)};
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,d,f){return b+(d-b)*f};this.VIntX=function(b,d,f,g,h,k,m,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=m;d[g+2]=n;f[g]=this.lerp(q[b],q[b+3],h);f[g+1]=this.lerp(q[b+1],q[b+4],h);f[g+2]=this.lerp(q[b+2],q[b+5],h)};this.VIntY=function(b,d,f,g,h,k,m,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=k;d[g+1]=m+h*this.delta;d[g+
2]=n;d=b+this.yd*3;f[g]=this.lerp(q[b],q[d],h);f[g+1]=this.lerp(q[b+1],q[d+1],h);f[g+2]=this.lerp(q[b+2],q[d+2],h)};this.VIntZ=function(b,d,f,g,h,k,m,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=k;d[g+1]=m;d[g+2]=n+h*this.delta;d=b+this.zd*3;f[g]=this.lerp(q[b],q[d],h);f[g+1]=this.lerp(q[b+1],q[d+1],h);f[g+2]=this.lerp(q[b+2],q[d+2],h)};this.compNorm=function(b){var d=b*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[b-1]-this.field[b+1];this.normal_cache[d+1]=this.field[b-this.yd]-
this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,f,g,h,k){var m=g+1,n=g+this.yd,q=g+this.zd,x=m+this.yd,z=m+this.zd,p=g+this.yd+this.zd,A=m+this.yd+this.zd,G=0,I=this.field[g],C=this.field[m],J=this.field[n],B=this.field[x],U=this.field[q],P=this.field[z],O=this.field[p],V=this.field[A];I<h&&(G|=1);C<h&&(G|=2);J<h&&(G|=8);B<h&&(G|=4);U<h&&(G|=16);P<h&&(G|=32);O<h&&(G|=128);V<h&&(G|=64);var Y=THREE.edgeTable[G];if(Y==0)return 0;
var e=this.delta,ja=b+e,X=d+e;e=f+e;if(Y&1){this.compNorm(g);this.compNorm(m);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,f,I,C)}if(Y&2){this.compNorm(m);this.compNorm(x);this.VIntY(m*3,this.vlist,this.nlist,3,h,ja,d,f,C,B)}if(Y&4){this.compNorm(n);this.compNorm(x);this.VIntX(n*3,this.vlist,this.nlist,6,h,b,X,f,J,B)}if(Y&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,f,I,J)}if(Y&16){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,12,h,b,d,
e,U,P)}if(Y&32){this.compNorm(z);this.compNorm(A);this.VIntY(z*3,this.vlist,this.nlist,15,h,ja,d,e,P,V)}if(Y&64){this.compNorm(p);this.compNorm(A);this.VIntX(p*3,this.vlist,this.nlist,18,h,b,X,e,O,V)}if(Y&128){this.compNorm(q);this.compNorm(p);this.VIntY(q*3,this.vlist,this.nlist,21,h,b,d,e,U,O)}if(Y&256){this.compNorm(g);this.compNorm(q);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,f,I,U)}if(Y&512){this.compNorm(m);this.compNorm(z);this.VIntZ(m*3,this.vlist,this.nlist,27,h,ja,d,f,C,P)}if(Y&1024){this.compNorm(x);
this.compNorm(A);this.VIntZ(x*3,this.vlist,this.nlist,30,h,ja,X,f,B,V)}if(Y&2048){this.compNorm(n);this.compNorm(p);this.VIntZ(n*3,this.vlist,this.nlist,33,h,b,X,f,J,O)}G<<=4;for(h=g=0;THREE.triTable[G+h]!=-1;){b=G+h;d=b+1;f=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(b,d,f,g,h,k){var m=this.count*3;this.positionArray[m]=b[f];this.positionArray[m+1]=b[f+1];this.positionArray[m+2]=b[f+2];this.positionArray[m+
3]=b[g];this.positionArray[m+4]=b[g+1];this.positionArray[m+5]=b[g+2];this.positionArray[m+6]=b[h];this.positionArray[m+7]=b[h+1];this.positionArray[m+8]=b[h+2];this.normalArray[m]=d[f];this.normalArray[m+1]=d[f+1];this.normalArray[m+2]=d[f+2];this.normalArray[m+3]=d[g];this.normalArray[m+4]=d[g+1];this.normalArray[m+5]=d[g+2];this.normalArray[m+6]=d[h];this.normalArray[m+7]=d[h+1];this.normalArray[m+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;b(this)}};this.addBall=function(b,d,f,g,h){var k=this.size*Math.sqrt(g/h),m=f*this.size,n=d*this.size,q=b*this.size,x=Math.floor(m-k);x<1&&(x=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var z=Math.floor(n-k);z<1&&(z=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var p=Math.floor(q-k);p<1&&(p=1);k=Math.floor(q+k);
k>this.size-1&&(k=this.size-1);for(var A,G,I,C,J,B;x<m;x++){q=this.size2*x;G=x/this.size-f;J=G*G;for(G=z;G<n;G++){I=q+this.size*G;A=G/this.size-d;B=A*A;for(A=p;A<k;A++){C=A/this.size-b;C=g/(1.0E-6+C*C+B+J)-h;C>0&&(this.field[I+A]+=C)}}}};this.addPlaneX=function(b,d){var f,g,h,k,m,n=this.size,q=this.yd,x=this.zd,z=this.field,p=n*Math.sqrt(b/d);p>n&&(p=n);for(f=0;f<p;f++){g=f/n;g*=g;k=b/(1.0E-4+g)-d;if(k>0)for(g=0;g<n;g++){m=f+g*q;for(h=0;h<n;h++)z[x*h+m]+=k}}};this.addPlaneY=function(b,d){var f,g,
h,k,m,n,q=this.size,x=this.yd,z=this.zd,p=this.field,A=q*Math.sqrt(b/d);A>q&&(A=q);for(g=0;g<A;g++){f=g/q;f*=f;k=b/(1.0E-4+f)-d;if(k>0){m=g*x;for(f=0;f<q;f++){n=m+f;for(h=0;h<q;h++)p[z*h+n]+=k}}}};this.addPlaneZ=function(b,d){var f,g,h,k,m,n;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=b/(1.0E-4+f)-d;if(k>0){m=zd*h;for(g=0;g<size;g++){n=m+g*yd;for(f=0;f<size;f++)field[n+f]+=k}}}};this.reset=function(){var b;
for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var d,f,g,h,k,m,n,q,x,z=this.size-2;for(h=1;h<z;h++){x=this.size2*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<z;g++){q=x+this.size*g;m=(g-this.halfsize)/this.halfsize;for(f=1;f<z;f++){k=(f-this.halfsize)/this.halfsize;d=q+f;this.polygonize(k,m,n,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,m,n,q,x,z;for(g=
0;g<f.count;g++){n=g*3;x=n+1;z=n+2;h=f.positionArray[n];k=f.positionArray[x];m=f.positionArray[z];q=new THREE.Vector3(h,k,m);h=f.normalArray[n];k=f.normalArray[x];m=f.normalArray[z];n=new THREE.Vector3(h,k,m);n.normalize();n=new THREE.Vertex(q,n);d.vertices.push(n)}nfaces=f.count/3;for(g=0;g<nfaces;g++){n=(b+g)*3;x=n+1;z=n+2;q=d.vertices[n].normal;h=d.vertices[x].normal;k=d.vertices[z].normal;n=new THREE.Face3(n,x,z,[q,h,k]);d.faces.push(n)}b+=nfaces;f.count=0});return d};this.init(a)};
THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
+174
View File
@@ -0,0 +1,174 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>three.js - webgl</title>
<meta charset="utf-8">
<style type="text/css">
body {
background:#fff;
padding:0;
margin:0;
font-weight: bold;
overflow:hidden;
}
</style>
</head>
<body>
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
<script type="text/javascript">
var statsEnabled = true;
var container, stats;
var camera, scene, renderer;
var mesh, boxMesh, light, lightCube, light2, lightCube2, zmesh, lightMesh, geometry;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
init();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 250;
scene = new THREE.Scene();
// world
var cube = new Cube( 300, 300, 10 );
var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
var mesh1 = new THREE.Mesh( cube, material0 );
mesh1.position.z = -150;
scene.addChild( mesh1 );
var mesh2 = new THREE.Mesh( cube, material1 );
mesh2.position.x = -150;
mesh2.rotation.y = 90 * Math.PI / 180;
scene.addChild( mesh2 );
var mesh3 = new THREE.Mesh( cube, material2 );
mesh3.position.y = -150;
mesh3.rotation.x = 90 * Math.PI / 180;
scene.addChild( mesh3 );
new THREE.ShadowVolume( mesh1 )
new THREE.ShadowVolume( mesh2 )
new THREE.ShadowVolume( mesh3 )
// moving objects
var cube = new Cube( 40, 40, 40 );
var torus = new Torus( 40, 10 );
var sphere = new Sphere( 40 );
var cylinder = new Cylinder( 10, 10, 20, 40, 0, 0 );
mesh = new THREE.Mesh( torus, material1 );
scene.addChild( mesh );
boxMesh = new THREE.Mesh( cube, material2 );
scene.addChild( boxMesh );
new THREE.ShadowVolume( mesh );
new THREE.ShadowVolume( boxMesh );
// lights
light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0, 1, 0 );
scene.addChild( light );
var cube = new Sphere( 5 );
lightCube = new THREE.Mesh( cube, material2 );
scene.addChild( lightCube );
// renderer
renderer = new THREE.WebGLRenderer();
renderer.setClearColorHex( 0xaaaaaa, 1 );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
if ( statsEnabled ) {
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
stats.domElement.style.zIndex = 100;
container.appendChild( stats.domElement );
}
setInterval( loop, 1000 / 60 );
}
function onDocumentMouseMove(event) {
mouseX = ( event.clientX - windowHalfX );
mouseY = ( event.clientY - windowHalfY );
}
var t = 0;
function loop() {
mesh.position.x = Math.sin( t ) * 100;
mesh.position.y = Math.cos( t ) * 100;
mesh.rotation.x += 0.5 * Math.PI / 180;
mesh.rotation.y += 1.0 * Math.PI / 180;
mesh.rotation.z += 1.5 * Math.PI / 180;
boxMesh.position.z = Math.sin( t ) * 100;
boxMesh.rotation.x = Math.sin( t ) * 180 * Math.PI / 180;
light.position.x = Math.sin( t );
light.position.y = 1.5;
light.position.z = Math.cos( t );
lightCube.position.copy( light.position );
lightCube.position.multiplyScalar( 200 );
t += 0.02;
camera.position.x += ( mouseX - camera.position.x ) * .05;
camera.position.y += ( - mouseY - camera.position.y ) * .05;
renderer.render( scene, camera );
if ( statsEnabled ) stats.update();
}
function log( text ) {
var e = document.getElementById("log");
e.innerHTML = text + "<br/>" + e.innerHTML;
}
</script>
</body>
</html>
@@ -0,0 +1,59 @@
/**
* @author mr.doob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
*
* parameters = {
* color: <hex>,
* opacity: <float>,
* map: new THREE.Texture( <Image> ),
* lightMap: new THREE.Texture( <Image> ),
* envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
* combine: THREE.Multiply,
* reflectivity: <float>,
* refractionRatio: <float>,
* shading: THREE.SmoothShading,
* blending: THREE.NormalBlending,
* depthTest: <bool>,
* wireframe: <boolean>,
* wireframeLinewidth: <float>,
* vertexColors: <bool>,
* skinning: <bool>
* }
*/
THREE.ShadowVolumeDynamicMaterial = function ( parameters ) {
this.id = THREE.MaterialCounter.value ++;
this.color = new THREE.Color( 0xffffff );
this.opacity = 1.0;
this.map = null;
this.lightMap = null;
this.envMap = null;
this.combine = THREE.MultiplyOperation;
this.reflectivity = 1.0;
this.refractionRatio = 0.98;
this.fog = true; // implemented just in WebGLRenderer2
this.shading = THREE.FlatShading;
this.blending = THREE.NormalBlending;
this.depthTest = true;
this.wireframe = false;
this.wireframeLinewidth = 1.0;
this.wireframeLinecap = 'round'; // implemented just in CanvasRenderer
this.wireframeLinejoin = 'round'; // implemented just in CanvasRenderer
this.vertexColors = false;
this.skinning = false;
this.morphTargets = false;
};
+200
View File
@@ -0,0 +1,200 @@
/*
* Shadow Volume
*/
THREE.ShadowVolume = function( mesh, isStatic ) {
THREE.Mesh.call( this, mesh.geometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] );
mesh.addChild( this );
this.calculateShadowVolumeGeometry( mesh.geometry );
}
THREE.ShadowVolume.prototype = new THREE.Mesh();
THREE.ShadowVolume.prototype.constructor = THREE.ShadowVolume;
THREE.ShadowVolume.prototype.supr = THREE.Mesh.prototype;
/*
* Calculate Geometry
*/
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function( originalGeometry ) {
// create geometry
this.geometry = new THREE.Geometry();
this.geometry.boundingSphere = originalGeometry.boundingSphere;
this.geometry.edgeFaces = [];
// copy vertices / faces from original mesh
var vertexTypes = this.geometry.vertexTypes;
var vertices = this.geometry.vertices;
var faces = this.geometry.faces;
var edgeFaces = this.geometry.edgeFaces;
var originalFaces = originalGeometry.faces;
var originalVertices = originalGeometry.vertices;
var fl = originalFaces.length;
var originalFace, face, i, f, n, vertex, numVertices;
var indices = [ "a", "b", "c", "d" ];
for( f = 0; f < fl; f++ ) {
numVertices = vertices.length;
originalFace = originalFaces[ f ];
if ( originalFace instanceof THREE.Face4 ) {
n = 4;
face = new THREE.Face4( numVertices, numVertices + 1, numVertices + 2, numVertices + 3 );
} else {
n = 3;
face = new THREE.Face3( numVertices, numVertices + 1, numVertices + 2 );
}
face.normal.copy( originalFace.normal );
faces.push( face );
for( i = 0; i < n; i++ ) {
vertex = originalVertices[ originalFace[ indices[ i ]]];
vertices.push( new THREE.Vertex( vertex.position.clone()));
}
}
// calculate edge faces
var result, faceA, faceB, v, vl;
for( var fa = 0; fa < originalFaces.length - 1; fa++ ) {
faceA = faces[ fa ];
for( var fb = fa + 1; fb < originalFaces.length; fb++ ) {
faceB = faces[ fb ];
result = this.facesShareEdge( vertices, faceA, faceB );
if( result !== undefined ) {
numVertices = vertices.length;
face = new THREE.Face4( result.indices[ 0 ], result.indices[ 3 ], result.indices[ 2 ], result.indices[ 1 ] );
face.normal.set( 1, 0, 0 );
edgeFaces.push( face );
}
}
}
}
/*
* Faces share edge?
*/
THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB ) {
var indicesA,
indicesB,
indexA,
indexB,
vertexA,
vertexB,
savedVertexA,
savedVertexB,
savedIndexA,
savedIndexB,
indexLetters,
a, b,
numMatches = 0,
indices = [ "a", "b", "c", "d" ];
if( faceA instanceof THREE.Face4 ) indicesA = 4;
else indicesA = 3;
if( faceB instanceof THREE.Face4 ) indicesB = 4;
else indicesB = 3;
for( a = 0; a < indicesA; a++ ) {
indexA = faceA[ indices[ a ] ];
vertexA = vertices[ indexA ];
for( b = 0; b < indicesB; b++ ) {
indexB = faceB[ indices[ b ] ];
vertexB = vertices[ indexB ];
if( Math.abs( vertexA.position.x - vertexB.position.x ) < 0.0001 &&
Math.abs( vertexA.position.y - vertexB.position.y ) < 0.0001 &&
Math.abs( vertexA.position.z - vertexB.position.z ) < 0.0001 ) {
numMatches++;
if( numMatches === 1 ) {
savedVertexA = vertexA;
savedVertexB = vertexB;
savedIndexA = indexA;
savedIndexB = indexB;
indexLetters = indices[ a ];
}
if( numMatches === 2 ) {
indexLetters += indices[ a ];
if( indexLetters === "ad" || indexLetters === "ac" ) {
return {
faces : [ faceA, faceB ],
vertices : [ savedVertexA, savedVertexB, vertexB, vertexA ],
indices : [ savedIndexA, savedIndexB, indexB, indexA ],
vertexTypes : [ 1, 2, 2, 1 ],
extrudable : true
};
} else {
return {
faces : [ faceA, faceB ],
vertices : [ savedVertexA, vertexA, vertexB, savedVertexB ],
indices : [ savedIndexA, indexA, indexB, savedIndexB ],
vertexTypes : [ 1, 1, 2, 2 ],
extrudable : true
};
}
}
}
}
}
return undefined;
}
+245 -10
View File
@@ -32,6 +32,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_oldFlipSided = null,
_oldBlending = null,
_oldDepth = null,
_cullEnabled = true,
_viewportX = 0,
_viewportY = 0,
@@ -88,7 +89,42 @@ THREE.WebGLRenderer = function ( parameters ) {
this.context = _gl;
// alert( dumpObject( getGLParams() ) );
// create shadow polygons
var _shadow = {};
var vertices = [];
var faces = [];
vertices[ 0 * 3 + 0 ] = -2; vertices[ 0 * 3 + 1 ] = -1; vertices[ 0 * 3 + 2 ] = -1;
vertices[ 1 * 3 + 0 ] = 2; vertices[ 1 * 3 + 1 ] = -1; vertices[ 1 * 3 + 2 ] = -1;
vertices[ 2 * 3 + 0 ] = 2; vertices[ 2 * 3 + 1 ] = 1; vertices[ 2 * 3 + 2 ] = -1;
vertices[ 3 * 3 + 0 ] = -2; vertices[ 3 * 3 + 1 ] = 1; vertices[ 3 * 3 + 2 ] = -1;
faces[ 0 ] = 0; faces[ 1 ] = 1; faces[ 2 ] = 2;
faces[ 3 ] = 0; faces[ 4 ] = 2; faces[ 5 ] = 3;
_shadow.vertexBuffer = _gl.createBuffer();
_shadow.elementBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, _shadow.vertexBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertices ), _gl.STATIC_DRAW );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _shadow.elementBuffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faces ), _gl.STATIC_DRAW );
_shadow.program = _gl.createProgram();
_gl.attachShader( _shadow.program, getShader( "fragment", THREE.ShaderLib.shadowPost.fragmentShader ));
_gl.attachShader( _shadow.program, getShader( "vertex", THREE.ShaderLib.shadowPost.vertexShader ));
_gl.linkProgram( _shadow.program );
_shadow.vertexLocation = _gl.getAttribLocation ( _shadow.program, "position" );
_shadow.projectionLocation = _gl.getUniformLocation( _shadow.program, "projectionMatrix" );
this.setSize = function ( width, height ) {
@@ -147,7 +183,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.clear = function () {
_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );
_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT | _gl.STENCIL_BUFFER_BIT );
};
@@ -321,7 +357,7 @@ THREE.WebGLRenderer = function ( parameters ) {
function initMeshBuffers ( geometryGroup, object ) {
var f, fl,
var f, fl, fi, face,
nvertices = 0, ntris = 0, nlines = 0,
@@ -408,7 +444,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
geometryGroup.__faceArray = new Uint16Array( ntris * 3 );
geometryGroup.__faceArray = new Uint16Array( ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 ));
geometryGroup.__lineArray = new Uint16Array( nlines * 2 );
if( geometryGroup.numMorphTargets ) {
@@ -429,7 +465,7 @@ THREE.WebGLRenderer = function ( parameters ) {
geometryGroup.__vertexColorType = vertexColorType;
geometryGroup.__normalType = normalType;
geometryGroup.__webGLFaceCount = ntris * 3;
geometryGroup.__webGLFaceCount = ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 );
geometryGroup.__webGLLineCount = nlines * 2;
};
@@ -510,6 +546,7 @@ THREE.WebGLRenderer = function ( parameters ) {
obj_skinVerticesB = geometry.skinVerticesB,
obj_skinIndices = geometry.skinIndices,
obj_skinWeights = geometry.skinWeights,
obj_edgeFaces = geometry.edgeFaces,
morphTargets = geometry.morphTargets;
@@ -1163,6 +1200,24 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if( obj_edgeFaces ) {
for( f = 0, fl = obj_edgeFaces.length; f < fl; f++ ) {
faceArray[ offset_face ] = obj_edgeFaces[ f ].a;
faceArray[ offset_face + 1 ] = obj_edgeFaces[ f ].b;
faceArray[ offset_face + 2 ] = obj_edgeFaces[ f ].c;
faceArray[ offset_face + 3 ] = obj_edgeFaces[ f ].a;
faceArray[ offset_face + 4 ] = obj_edgeFaces[ f ].c;
faceArray[ offset_face + 5 ] = obj_edgeFaces[ f ].d;
offset_face += 6;
}
}
if ( dirtyVertices ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer );
@@ -1556,6 +1611,10 @@ THREE.WebGLRenderer = function ( parameters ) {
setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
} else if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) {
setMaterialShaders( material, THREE.ShaderLib[ 'shadowVolumeDynamic' ] );
} else if ( material instanceof THREE.MeshNormalMaterial ) {
setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
@@ -1791,6 +1850,20 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if( material instanceof THREE.ShadowVolumeDynamicMaterial ) {
var dirLight = m_uniforms.directionalLightDirection.value;
dirLight[ 0 ] = -lights.position.x;
dirLight[ 1 ] = -lights.position.y;
dirLight[ 2 ] = -lights.position.z;
_gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight );
_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray );
}
if ( material.skinning ) {
loadUniformsSkinning( p_uniforms, object );
@@ -2270,6 +2343,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.clear();
}
// set matrices
@@ -2459,6 +2533,150 @@ THREE.WebGLRenderer = function ( parameters ) {
}
//////////////////////// stencil shadows begin //////////////////////
// method: we're rendering the world in light, then the shadow
// volumes into the stencil and last a big darkening
// quad over the whole thing. This is NOT how you're
// supposed to do stencil shadows but is much faster
//
if( scene.__webglShadowVolumes.length && scene.lights.length ) {
// setup stencil
_gl.enable( _gl.POLYGON_OFFSET_FILL );
_gl.polygonOffset( 0.1, 1.0 );
_gl.enable( _gl.STENCIL_TEST );
_gl.depthMask( false );
_gl.colorMask( false, false, false, false );
_gl.stencilFunc( _gl.ALWAYS, 1, 0xFF );
_gl.stencilOpSeparate( _gl.BACK, _gl.KEEP, _gl.INCR, _gl.KEEP );
_gl.stencilOpSeparate( _gl.FRONT, _gl.KEEP, _gl.DECR, _gl.KEEP );
// loop through all directional lights
var l, ll = scene.lights.length;
var p;
var light, geometryGroup;
var dirLight = [];
var program;
var p_uniforms;
var m_uniforms;
var attributes;
ol = scene.__webglShadowVolumes.length;
for( l = 0; l < ll; l++ ) {
light = scene.lights[ l ];
if( light instanceof THREE.DirectionalLight ) {
dirLight[ 0 ] = -light.position.x;
dirLight[ 1 ] = -light.position.y;
dirLight[ 2 ] = -light.position.z;
// render all volumes
for ( o = 0; o < ol; o++ ) {
object = scene.__webglShadowVolumes[ o ].object;
geometryGroup = scene.__webglShadowVolumes[ o ].buffer;
material = object.materials[ 0 ];
if ( !material.program ) _this.initMaterial( material, lights, fog, object );
program = material.program,
p_uniforms = program.uniforms,
m_uniforms = material.uniforms,
attributes = program.attributes;
if( _oldProgram !== program ) {
_gl.useProgram( program );
_oldProgram = program;
_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray );
_gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight );
}
object.matrixWorld.flattenToArray( object._objectMatrixArray );
//object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
//_gl.uniformMatrix4fv( p_uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer );
_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer );
_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer );
_gl.cullFace( _gl.FRONT );
_gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
_gl.cullFace( _gl.BACK );
_gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
}
}
}
// draw darkening polygon
_gl.disable( _gl.POLYGON_OFFSET_FILL );
_gl.colorMask( true, true, true, true );
_gl.stencilFunc( _gl.NOTEQUAL, 0, 0xFF );
_gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP );
_gl.disable( _gl.DEPTH_TEST );
_gl.enable( _gl.BLEND );
_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
_gl.blendEquation( _gl.FUNC_ADD );
_oldBlending = "";
_oldProgram = _shadow.program;
_gl.useProgram( _shadow.program );
_gl.uniformMatrix4fv( _shadow.projectionLocation, false, _projectionMatrixArray );
_gl.bindBuffer( _gl.ARRAY_BUFFER, _shadow.vertexBuffer );
_gl.vertexAttribPointer( _shadow.vertexLocation, 3, _gl.FLOAT, false, 0, 0 );
_gl.enableVertexAttribArray( _shadow.vertexLocation );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _shadow.elementBuffer );
_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
// disable stencil
_gl.disable ( _gl.STENCIL_TEST );
_gl.enable ( _gl.DEPTH_TEST );
_gl.disable ( _gl.BLEND );
_gl.depthMask( true );
}
//////////////////////// stencil shadows end //////////////////////
// Generate mipmap if we're using any kind of mipmap filtering
if ( renderTarget && renderTarget.minFilter !== THREE.NearestFilter && renderTarget.minFilter !== THREE.LinearFilter ) {
@@ -2482,7 +2700,7 @@ THREE.WebGLRenderer = function ( parameters ) {
scene.__webglObjects = [];
scene.__webglObjectsImmediate = [];
scene.__webglShadowVolumes = [];
}
while ( scene.__objectsAdded.length ) {
@@ -2506,6 +2724,13 @@ THREE.WebGLRenderer = function ( parameters ) {
updateObject( scene.__webglObjects[ o ].object, scene );
}
for ( var o = 0, ol = scene.__webglShadowVolumes.length; o < ol; o ++ ) {
updateObject( scene.__webglShadowVolumes[ o ].object, scene );
}
};
@@ -2560,8 +2785,15 @@ THREE.WebGLRenderer = function ( parameters ) {
// create separate wrapper per each use of VBO
addBuffer( scene.__webglObjects, geometryGroup, object );
if( object instanceof THREE.ShadowVolume ) {
addBuffer( scene.__webglShadowVolumes, geometryGroup, object );
} else {
addBuffer( scene.__webglObjects, geometryGroup, object );
}
}
} else if ( object instanceof THREE.Ribbon ) {
@@ -2870,7 +3102,7 @@ THREE.WebGLRenderer = function ( parameters ) {
try {
if ( ! ( _gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } ) ) ) {
if ( ! ( _gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias, stencil:true } ) ) ) {
throw 'Error creating WebGL context.';
@@ -3363,7 +3595,10 @@ THREE.WebGLRenderer = function ( parameters ) {
case THREE.LinearFilter:
case THREE.LinearMipMapNearestFilter:
case THREE.LinearMipMapLinearFilter: return _gl.LINEAR; break;
case THREE.LinearMipMapLinearFilter:
default:
return _gl.LINEAR; break;
}
+61
View File
@@ -6,6 +6,7 @@
THREE.ShaderChunk = {
// FOG
fog_pars_fragment: [
@@ -555,6 +556,66 @@ THREE.UniformsLib = {
THREE.ShaderLib = {
'shadowPost': {
vertexShader: [
"uniform mat4 projectionMatrix;",
"attribute vec3 position;",
"void main(void)",
"{",
"gl_Position = projectionMatrix * vec4( position, 1.0 );",
"}"
].join( "\n" ),
fragmentShader: [
"#ifdef GL_ES",
"precision highp float;",
"#endif",
"void main( void )",
"{",
"gl_FragColor = vec4( 0, 0, 0, 0.5 );",
"}"
].join( "\n" )
},
'shadowVolumeDynamic': {
uniforms: { "directionalLightDirection": { type: "fv", value: [] }},
vertexShader: [
"uniform vec3 directionalLightDirection;",
"void main() {",
"vec4 pos = objectMatrix * vec4( position, 1.0 );",
"vec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;",
"vec4 extruded = vec4( directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 0.0 );",
"gl_Position = projectionMatrix * viewMatrix * ( pos + extruded );",
"}"
].join( "\n" ),
fragmentShader: [
"void main() {",
"gl_FragColor = vec4( 1, 1, 1, 1 );",
"}"
].join( "\n" )
},
'depth': {
uniforms: { "mNear": { type: "f", value: 1.0 },
+2
View File
@@ -46,6 +46,7 @@ COMMON_FILES = [
'materials/MeshNormalMaterial.js',
'materials/MeshFaceMaterial.js',
'materials/MeshShaderMaterial.js',
'materials/ShadowVolumeDynamicMaterial.js',
'materials/ParticleBasicMaterial.js',
'materials/ParticleCanvasMaterial.js',
'materials/ParticleDOMMaterial.js',
@@ -61,6 +62,7 @@ COMMON_FILES = [
'objects/Ribbon.js',
'objects/Sound.js',
'objects/LOD.js',
'objects/ShadowVolume.js',
'scenes/Scene.js',
'scenes/Fog.js',
'scenes/FogExp2.js',