Partially merged szimek's pull request

https://github.com/mrdoob/three.js/pull/97
This commit is contained in:
alteredq
2011-01-23 19:22:49 +01:00
parent 679bbec701
commit 09571ee3d0
8 changed files with 353 additions and 352 deletions
+89 -89
View File
@@ -5,61 +5,61 @@ THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,o){return h.distance-o.distance});return g},intersectObject:function(a){function c(K,p,U,F){F=F.clone().subSelf(p);U=U.clone().subSelf(p);var e=K.clone().subSelf(p);K=F.dot(F);p=F.dot(U);F=F.dot(e);var j=U.dot(U);U=U.dot(e);e=1/(K*j-p*p);j=(j*F-p*U)*e;K=(K*U-p*F)*e;return j>0&&K>0&&j+K<1}var d,f,g,h,o,b,i,k,y,z,
u,x=a.geometry,H=x.vertices,J=[];d=0;for(f=x.faces.length;d<f;d++){g=x.faces[d];z=this.origin.clone();u=this.direction.clone();h=a.matrix.multiplyVector3(H[g.a].position.clone());o=a.matrix.multiplyVector3(H[g.b].position.clone());b=a.matrix.multiplyVector3(H[g.c].position.clone());i=g instanceof THREE.Face4?a.matrix.multiplyVector3(H[g.d].position.clone()):null;k=a.rotationMatrix.multiplyVector3(g.normal.clone());y=u.dot(k);if(y<0){k=k.dot((new THREE.Vector3).sub(h,z))/y;z=z.addSelf(u.multiplyScalar(k));
THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,g=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,o){return h.distance-o.distance});return g},intersectObject:function(a){function c(K,p,U,F){F=F.clone().subSelf(p);U=U.clone().subSelf(p);var f=K.clone().subSelf(p);K=F.dot(F);p=F.dot(U);F=F.dot(f);var j=U.dot(U);U=U.dot(f);f=1/(K*j-p*p);j=(j*F-p*U)*f;K=(K*U-p*F)*f;return j>0&&K>0&&j+K<1}var d,e,g,h,o,b,i,k,y,z,
u,x=a.geometry,H=x.vertices,J=[];d=0;for(e=x.faces.length;d<e;d++){g=x.faces[d];z=this.origin.clone();u=this.direction.clone();h=a.matrix.multiplyVector3(H[g.a].position.clone());o=a.matrix.multiplyVector3(H[g.b].position.clone());b=a.matrix.multiplyVector3(H[g.c].position.clone());i=g instanceof THREE.Face4?a.matrix.multiplyVector3(H[g.d].position.clone()):null;k=a.rotationMatrix.multiplyVector3(g.normal.clone());y=u.dot(k);if(y<0){k=k.dot((new THREE.Vector3).sub(h,z))/y;z=z.addSelf(u.multiplyScalar(k));
if(g instanceof THREE.Face3){if(c(z,h,o,b)){g={distance:this.origin.distanceTo(z),point:z,face:g,object:a};J.push(g)}}else if(g instanceof THREE.Face4)if(c(z,h,o,i)||c(z,o,b,i)){g={distance:this.origin.distanceTo(z),point:z,face:g,object:a};J.push(g)}}}return J}};
THREE.Rectangle=function(){function a(){h=f-c;o=g-d}var c,d,f,g,h,o,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return o};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(i,k,y,z){b=false;c=i;d=k;f=y;g=z;a()};this.addPoint=function(i,k){if(b){b=false;c=i;d=k;f=i;g=k}else{c=c<i?c:i;d=d<k?d:k;f=f>i?f:i;g=g>k?
g:k}a()};this.add3Points=function(i,k,y,z,u,x){if(b){b=false;c=i<y?i<u?i:u:y<u?y:u;d=k<z?k<x?k:x:z<x?z:x;f=i>y?i>u?i:u:y>u?y:u;g=k>z?k>x?k:x:z>x?z:x}else{c=i<y?i<u?i<c?i:c:u<c?u:c:y<u?y<c?y:c:u<c?u:c;d=k<z?k<x?k<d?k:d:x<d?x:d:z<x?z<d?z:d:x<d?x:d;f=i>y?i>u?i>f?i:f:u>f?u:f:y>u?y>f?y:f:u>f?u:f;g=k>z?k>x?k>g?k:g:x>g?x:g:z>x?z>g?z:g:x>g?x:g}a()};this.addRectangle=function(i){if(b){b=false;c=i.getLeft();d=i.getTop();f=i.getRight();g=i.getBottom()}else{c=c<i.getLeft()?c:i.getLeft();d=d<i.getTop()?d:i.getTop();
f=f>i.getRight()?f:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){c-=i;d-=i;f+=i;g+=i;a()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();f=f<i.getRight()?f:i.getRight();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(f,i.getRight())-Math.max(c,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){b=true;g=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+h+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
THREE.Matrix4=function(a,c,d,f,g,h,o,b,i,k,y,z,u,x,H,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=h||1;this.n23=o||0;this.n24=b||0;this.n31=i||0;this.n32=k||0;this.n33=y||1;this.n34=z||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,f,g,h,o,b,i,k,y,z,u,x,H,J){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=h;this.n23=o;this.n24=b;this.n31=i;this.n32=k;this.n33=y;this.n34=z;this.n41=u;this.n42=x;this.n43=H;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,c).normalize();f.cross(d,h).normalize();g.cross(h,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;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 d=a.n11,f=a.n12,g=a.n13,h=a.n14,o=a.n21,b=a.n22,i=a.n23,k=a.n24,y=a.n31,
z=a.n32,u=a.n33,x=a.n34,H=a.n41,J=a.n42,K=a.n43,p=a.n44,U=c.n11,F=c.n12,e=c.n13,j=c.n14,q=c.n21,l=c.n22,r=c.n23,C=c.n24,m=c.n31,t=c.n32,v=c.n33,s=c.n34,n=c.n41,E=c.n42,A=c.n43,O=c.n44;this.n11=d*U+f*q+g*m+h*n;this.n12=d*F+f*l+g*t+h*E;this.n13=d*e+f*r+g*v+h*A;this.n14=d*j+f*C+g*s+h*O;this.n21=o*U+b*q+i*m+k*n;this.n22=o*F+b*l+i*t+k*E;this.n23=o*e+b*r+i*v+k*A;this.n24=o*j+b*C+i*s+k*O;this.n31=y*U+z*q+u*m+x*n;this.n32=y*F+z*l+u*t+x*E;this.n33=y*e+z*r+u*v+x*A;this.n34=y*j+z*C+u*s+x*O;this.n41=H*U+J*q+
K*m+p*n;this.n42=H*F+J*l+K*t+p*E;this.n43=H*e+J*r+K*v+p*A;this.n44=H*j+J*C+K*s+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,h=this.n21,o=this.n22,b=this.n23,i=this.n24,k=this.n31,y=this.n32,z=this.n33,u=this.n34,x=this.n41,H=this.n42,J=this.n43,K=this.n44,p=a.n11,U=a.n21,F=a.n31,e=a.n41,j=a.n12,q=a.n22,l=a.n32,r=a.n42,C=a.n13,m=a.n23,t=a.n33,v=a.n43,s=a.n14,n=a.n24,E=a.n34;a=a.n44;this.n11=c*p+d*U+f*F+g*e;this.n12=c*j+d*q+f*l+g*r;this.n13=c*C+d*m+f*t+g*
v;this.n14=c*s+d*n+f*E+g*a;this.n21=h*p+o*U+b*F+i*e;this.n22=h*j+o*q+b*l+i*r;this.n23=h*C+o*m+b*t+i*v;this.n24=h*s+o*n+b*E+i*a;this.n31=k*p+y*U+z*F+u*e;this.n32=k*j+y*q+z*l+u*r;this.n33=k*C+y*m+z*t+u*v;this.n34=k*s+y*n+z*E+u*a;this.n41=x*p+H*U+J*F+K*e;this.n42=x*j+H*q+J*l+K*r;this.n43=x*C+H*m+J*t+K*v;this.n44=x*s+H*n+J*E+K*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,d=this.n13,f=this.n14,g=this.n21,h=this.n22,o=this.n23,b=this.n24,i=this.n31,k=this.n32,y=this.n33,z=this.n34,u=this.n41,x=this.n42,H=this.n43,J=this.n44;return f*o*k*u-d*b*k*u-f*h*y*u+c*b*y*u+d*h*z*u-c*o*z*u-f*o*i*x+d*b*i*x+f*g*y*x-a*b*y*x-d*g*z*x+a*o*z*x+f*h*i*H-c*b*i*H-f*g*k*H+a*b*k*H+c*g*z*H-a*h*z*H-d*h*i*J+c*o*i*J+d*g*k*J-a*o*k*J-c*g*y*J+a*h*y*J},transpose:function(){function a(c,d,
f){var g=c[d];c[d]=c[f];c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},
setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),g=1-d,h=a.x,o=a.y,b=a.z,i=g*h,k=g*o;this.set(i*h+d,i*o-f*b,i*b+f*o,0,i*o+f*b,k*o+d,k*b-f*h,0,i*b-f*o,k*b+f*h,g*b*b+d,0,0,
0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};
THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,o=a.n22,b=a.n23,i=a.n24,k=a.n31,y=a.n32,z=a.n33,u=a.n34,x=a.n41,H=a.n42,J=a.n43,K=a.n44,p=new THREE.Matrix4;p.n11=b*u*H-i*z*H+i*y*J-o*u*J-b*y*K+o*z*K;p.n12=g*z*H-f*u*H-g*y*J+d*u*J+f*y*K-d*z*K;p.n13=f*i*H-g*b*H+g*o*J-d*i*J-f*o*K+d*b*K;p.n14=g*b*y-f*i*y-g*o*z+d*i*z+f*o*u-d*b*u;p.n21=i*z*x-b*u*x-i*k*J+h*u*J+b*k*K-h*z*K;p.n22=f*u*x-g*z*x+g*k*J-c*u*J-f*k*K+c*z*K;p.n23=g*b*x-f*i*x-g*h*J+c*i*J+f*h*K-c*b*K;p.n24=f*i*k-g*b*k+
g*h*z-c*i*z-f*h*u+c*b*u;p.n31=o*u*x-i*y*x+i*k*H-h*u*H-o*k*K+h*y*K;p.n32=g*y*x-d*u*x-g*k*H+c*u*H+d*k*K-c*y*K;p.n33=f*i*x-g*o*x+g*h*H-c*i*H-d*h*K+c*o*K;p.n34=g*o*k-d*i*k-g*h*y+c*i*y+d*h*u-c*o*u;p.n41=b*y*x-o*z*x-b*k*H+h*z*H+o*k*J-h*y*J;p.n42=d*z*x-f*y*x+f*k*H-c*z*H-d*k*J+c*y*J;p.n43=f*o*x-d*b*x-f*h*H+c*b*H+d*h*J-c*o*J;p.n44=d*b*k-f*o*k+f*h*y-c*b*y-d*h*z+c*o*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],i=c[9]*c[4]-c[5]*c[8],k=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*h+c[2]*i;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*f;a.m[2]=c*g;a.m[3]=c*h;a.m[4]=c*o;a.m[5]=c*b;a.m[6]=c*i;a.m[7]=c*k;a.m[8]=c*y;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,f,g,h){var o,b,i;o=new THREE.Matrix4;b=2*g/(c-a);i=2*g/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(h+g)/(h-g);g=-2*h*g/(h-g);o.n11=b;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=i;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=f;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,g,h){var o,b,i,k;o=new THREE.Matrix4;b=c-a;i=d-f;k=h-g;a=(c+a)/b;d=(d+f)/i;g=(h+g)/k;o.n11=2/b;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/i;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/k;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Rectangle=function(){function a(){h=e-c;o=g-d}var c,d,e,g,h,o,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return o};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(i,k,y,z){b=false;c=i;d=k;e=y;g=z;a()};this.addPoint=function(i,k){if(b){b=false;c=i;d=k;e=i;g=k}else{c=c<i?c:i;d=d<k?d:k;e=e>i?e:i;g=g>k?
g:k}a()};this.add3Points=function(i,k,y,z,u,x){if(b){b=false;c=i<y?i<u?i:u:y<u?y:u;d=k<z?k<x?k:x:z<x?z:x;e=i>y?i>u?i:u:y>u?y:u;g=k>z?k>x?k:x:z>x?z:x}else{c=i<y?i<u?i<c?i:c:u<c?u:c:y<u?y<c?y:c:u<c?u:c;d=k<z?k<x?k<d?k:d:x<d?x:d:z<x?z<d?z:d:x<d?x:d;e=i>y?i>u?i>e?i:e:u>e?u:e:y>u?y>e?y:e:u>e?u:e;g=k>z?k>x?k>g?k:g:x>g?x:g:z>x?z>g?z:g:x>g?x:g}a()};this.addRectangle=function(i){if(b){b=false;c=i.getLeft();d=i.getTop();e=i.getRight();g=i.getBottom()}else{c=c<i.getLeft()?c:i.getLeft();d=d<i.getTop()?d:i.getTop();
e=e>i.getRight()?e:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){c-=i;d-=i;e+=i;g+=i;a()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e<i.getRight()?e:i.getRight();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(c,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+h+", height: "+o+" )"}};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}};
THREE.Matrix4=function(a,c,d,e,g,h,o,b,i,k,y,z,u,x,H,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=o||0;this.n24=b||0;this.n31=i||0;this.n32=k||0;this.n33=y||1;this.n34=z||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,g,h,o,b,i,k,y,z,u,x,H,J){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=o;this.n24=b;this.n31=i;this.n32=k;this.n33=y;this.n34=z;this.n41=u;this.n42=x;this.n43=H;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,c).normalize();e.cross(d,h).normalize();g.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;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 d=a.n11,e=a.n12,g=a.n13,h=a.n14,o=a.n21,b=a.n22,i=a.n23,k=a.n24,y=a.n31,
z=a.n32,u=a.n33,x=a.n34,H=a.n41,J=a.n42,K=a.n43,p=a.n44,U=c.n11,F=c.n12,f=c.n13,j=c.n14,q=c.n21,l=c.n22,r=c.n23,C=c.n24,m=c.n31,t=c.n32,v=c.n33,s=c.n34,n=c.n41,E=c.n42,A=c.n43,O=c.n44;this.n11=d*U+e*q+g*m+h*n;this.n12=d*F+e*l+g*t+h*E;this.n13=d*f+e*r+g*v+h*A;this.n14=d*j+e*C+g*s+h*O;this.n21=o*U+b*q+i*m+k*n;this.n22=o*F+b*l+i*t+k*E;this.n23=o*f+b*r+i*v+k*A;this.n24=o*j+b*C+i*s+k*O;this.n31=y*U+z*q+u*m+x*n;this.n32=y*F+z*l+u*t+x*E;this.n33=y*f+z*r+u*v+x*A;this.n34=y*j+z*C+u*s+x*O;this.n41=H*U+J*q+
K*m+p*n;this.n42=H*F+J*l+K*t+p*E;this.n43=H*f+J*r+K*v+p*A;this.n44=H*j+J*C+K*s+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,o=this.n22,b=this.n23,i=this.n24,k=this.n31,y=this.n32,z=this.n33,u=this.n34,x=this.n41,H=this.n42,J=this.n43,K=this.n44,p=a.n11,U=a.n21,F=a.n31,f=a.n41,j=a.n12,q=a.n22,l=a.n32,r=a.n42,C=a.n13,m=a.n23,t=a.n33,v=a.n43,s=a.n14,n=a.n24,E=a.n34;a=a.n44;this.n11=c*p+d*U+e*F+g*f;this.n12=c*j+d*q+e*l+g*r;this.n13=c*C+d*m+e*t+g*
v;this.n14=c*s+d*n+e*E+g*a;this.n21=h*p+o*U+b*F+i*f;this.n22=h*j+o*q+b*l+i*r;this.n23=h*C+o*m+b*t+i*v;this.n24=h*s+o*n+b*E+i*a;this.n31=k*p+y*U+z*F+u*f;this.n32=k*j+y*q+z*l+u*r;this.n33=k*C+y*m+z*t+u*v;this.n34=k*s+y*n+z*E+u*a;this.n41=x*p+H*U+J*F+K*f;this.n42=x*j+H*q+J*l+K*r;this.n43=x*C+H*m+J*t+K*v;this.n44=x*s+H*n+J*E+K*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,d=this.n13,e=this.n14,g=this.n21,h=this.n22,o=this.n23,b=this.n24,i=this.n31,k=this.n32,y=this.n33,z=this.n34,u=this.n41,x=this.n42,H=this.n43,J=this.n44;return e*o*k*u-d*b*k*u-e*h*y*u+c*b*y*u+d*h*z*u-c*o*z*u-e*o*i*x+d*b*i*x+e*g*y*x-a*b*y*x-d*g*z*x+a*o*z*x+e*h*i*H-c*b*i*H-e*g*k*H+a*b*k*H+c*g*z*H-a*h*z*H-d*h*i*J+c*o*i*J+d*g*k*J-a*o*k*J-c*g*y*J+a*h*y*J},transpose:function(){function a(c,d,
e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,h=a.x,o=a.y,b=a.z,i=g*h,k=g*o;this.set(i*h+d,i*o-e*b,i*b+e*o,0,i*o+e*b,k*o+d,k*b-e*h,0,i*b-e*o,k*b+e*h,g*b*b+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,o=a.n22,b=a.n23,i=a.n24,k=a.n31,y=a.n32,z=a.n33,u=a.n34,x=a.n41,H=a.n42,J=a.n43,K=a.n44,p=new THREE.Matrix4;p.n11=b*u*H-i*z*H+i*y*J-o*u*J-b*y*K+o*z*K;p.n12=g*z*H-e*u*H-g*y*J+d*u*J+e*y*K-d*z*K;p.n13=e*i*H-g*b*H+g*o*J-d*i*J-e*o*K+d*b*K;p.n14=g*b*y-e*i*y-g*o*z+d*i*z+e*o*u-d*b*u;p.n21=i*z*x-b*u*x-i*k*J+h*u*J+b*k*K-h*z*K;p.n22=e*u*x-g*z*x+g*k*J-c*u*J-e*k*K+c*z*K;p.n23=g*b*x-e*i*x-g*h*J+c*i*J+e*h*K-c*b*K;p.n24=e*i*k-g*b*k+
g*h*z-c*i*z-e*h*u+c*b*u;p.n31=o*u*x-i*y*x+i*k*H-h*u*H-o*k*K+h*y*K;p.n32=g*y*x-d*u*x-g*k*H+c*u*H+d*k*K-c*y*K;p.n33=e*i*x-g*o*x+g*h*H-c*i*H-d*h*K+c*o*K;p.n34=g*o*k-d*i*k-g*h*y+c*i*y+d*h*u-c*o*u;p.n41=b*y*x-o*z*x-b*k*H+h*z*H+o*k*J-h*y*J;p.n42=d*z*x-e*y*x+e*k*H-c*z*H-d*k*J+c*y*J;p.n43=e*o*x-d*b*x-e*h*H+c*b*H+d*h*J-c*o*J;p.n44=d*b*k-e*o*k+e*h*y-c*b*y-d*h*z+c*o*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],g=-c[10]*c[1]+c[2]*c[9],h=c[6]*c[1]-c[2]*c[5],o=-c[10]*c[4]+c[6]*c[8],b=c[10]*c[0]-c[2]*c[8],i=-c[6]*c[0]+c[2]*c[4],k=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],z=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*o+c[2]*k;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*g;d[2]=c*h;d[3]=c*o;d[4]=c*b;d[5]=c*i;d[6]=c*k;d[7]=c*y;d[8]=c*z;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,e,g,h){var o,b,i;o=new THREE.Matrix4;b=2*g/(c-a);i=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(h+g)/(h-g);g=-2*h*g/(h-g);o.n11=b;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=i;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)};
THREE.Matrix4.makeOrtho=function(a,c,d,e,g,h){var o,b,i,k;o=new THREE.Matrix4;b=c-a;i=d-e;k=h-g;a=(c+a)/b;d=(d+e)/i;g=(h+g)/k;o.n11=2/b;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/i;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/k;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
THREE.Face3=function(a,c,d,f,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,g,h){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.Face3=function(a,c,d,e,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,e,g,h){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,h,o,b=new THREE.Vector3,i=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){h=this.vertices[f];h.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(a&&h.vertexNormals.length){b.set(0,0,0);c=0;for(d=h.normal.length;c<d;c++)b.addSelf(h.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[h.a];d=this.vertices[h.b];o=this.vertices[h.c];b.sub(o.position,
d.position);i.sub(c.position,d.position);b.crossSelf(i)}b.isZero()||b.normalize();h.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(s,n,E,A,O,N,G){h=s.vertices[n].position;o=s.vertices[E].position;b=s.vertices[A].position;i=g[O];k=g[N];y=g[G];z=o.x-h.x;u=b.x-h.x;x=o.y-h.y;H=b.y-h.y;
J=o.z-h.z;K=b.z-h.z;p=k.u-i.u;U=y.u-i.u;F=k.v-i.v;e=y.v-i.v;j=1/(p*e-U*F);r.set((e*z-F*u)*j,(e*x-F*H)*j,(e*J-F*K)*j);C.set((p*u-U*z)*j,(p*H-U*x)*j,(p*K-U*J)*j);q[n].addSelf(r);q[E].addSelf(r);q[A].addSelf(r);l[n].addSelf(C);l[E].addSelf(C);l[A].addSelf(C)}var c,d,f,g,h,o,b,i,k,y,z,u,x,H,J,K,p,U,F,e,j,q=[],l=[],r=new THREE.Vector3,C=new THREE.Vector3,m=new THREE.Vector3,t=new THREE.Vector3,v=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;l[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){v.copy(this.vertices[c].normal);f=q[c];m.copy(f);m.subSelf(v.multiplyScalar(v.dot(f))).normalize();t.cross(this.vertices[c].normal,f);f=t.dot(l[c]);f=f<0?-1:1;this.vertices[c].tangent.set(m.x,m.y,m.z,f)}this.hasTangents=true},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],
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,h,o,b=new THREE.Vector3,i=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){b.set(0,0,0);c=0;for(d=h.normal.length;c<d;c++)b.addSelf(h.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[h.a];d=this.vertices[h.b];o=this.vertices[h.c];b.sub(o.position,
d.position);i.sub(c.position,d.position);b.crossSelf(i)}b.isZero()||b.normalize();h.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(s,n,E,A,O,N,G){h=s.vertices[n].position;o=s.vertices[E].position;b=s.vertices[A].position;i=g[O];k=g[N];y=g[G];z=o.x-h.x;u=b.x-h.x;x=o.y-h.y;H=b.y-h.y;
J=o.z-h.z;K=b.z-h.z;p=k.u-i.u;U=y.u-i.u;F=k.v-i.v;f=y.v-i.v;j=1/(p*f-U*F);r.set((f*z-F*u)*j,(f*x-F*H)*j,(f*J-F*K)*j);C.set((p*u-U*z)*j,(p*H-U*x)*j,(p*K-U*J)*j);q[n].addSelf(r);q[E].addSelf(r);q[A].addSelf(r);l[n].addSelf(C);l[E].addSelf(C);l[A].addSelf(C)}var c,d,e,g,h,o,b,i,k,y,z,u,x,H,J,K,p,U,F,f,j,q=[],l=[],r=new THREE.Vector3,C=new THREE.Vector3,m=new THREE.Vector3,t=new THREE.Vector3,v=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;l[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){e=this.faces[c];g=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){v.copy(this.vertices[c].normal);e=q[c];m.copy(e);m.subSelf(v.multiplyScalar(v.dot(e))).normalize();t.cross(this.vertices[c].normal,e);e=t.dot(l[c]);e=e<0?-1:1;this.vertices[c].tangent.set(m.x,m.y,m.z,e)}this.hasTangents=true},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,d=this.vertices.length;c<d;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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var z=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?z.push("undefined"):z.push(y[c].toString());return z.join("_")}var c,d,f,g,h,o,b,i,k={};f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];
o=h.materials;b=a(o);if(k[b]==undefined)k[b]={hash:b,counter:0};i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:o,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){k[b].counter+=1;i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:o,vertices:0}}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var z=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?z.push("undefined"):z.push(y[c].toString());return z.join("_")}var c,d,e,g,h,o,b,i,k={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
o=h.materials;b=a(o);if(k[b]==undefined)k[b]={hash:b,counter:0};i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:o,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){k[b].counter+=1;i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:o,vertices:0}}this.geometryChunks[i].faces.push(e);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};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.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
@@ -89,100 +89,100 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
THREE.Texture=function(a,c,d,f,g,h){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture=function(a,c,d,e,g,h){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,d,f,g={};for(c in a){g[c]={};for(d in a[c]){f=a[c][d];g[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var c,d,f,g={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)g[d]=f[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]){e=a[c][d];g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var c,d,e,g={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)g[d]=e[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(l,r){return r.z-l.z}function c(l,r){var C=0,m=1,t=l.z+l.w,v=r.z+r.w,s=-l.z+l.w,n=-r.z+r.w;if(t>=0&&v>=0&&s>=0&&n>=0)return true;else if(t<0&&v<0||s<0&&n<0)return false;else{if(t<0)C=Math.max(C,t/(t-v));else if(v<0)m=Math.min(m,t/(t-v));if(s<0)C=Math.max(C,s/(s-n));else if(n<0)m=Math.min(m,s/(s-n));if(m<C)return false;else{l.lerpSelf(r,C);r.lerpSelf(l,1-m);return true}}}var d,f,g=[],h,o,b,i=[],k,y,z=[],u,x,H=[],J=new THREE.Vector4,K=new THREE.Vector4,p=new THREE.Matrix4,
U=new THREE.Matrix4,F=[],e=new THREE.Vector4,j=new THREE.Vector4,q;this.projectObjects=function(l,r,C){var m=[],t,v;f=0;p.multiply(r.projectionMatrix,r.matrix);F[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);F[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);F[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);F[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);F[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
THREE.Projector=function(){function a(l,r){return r.z-l.z}function c(l,r){var C=0,m=1,t=l.z+l.w,v=r.z+r.w,s=-l.z+l.w,n=-r.z+r.w;if(t>=0&&v>=0&&s>=0&&n>=0)return true;else if(t<0&&v<0||s<0&&n<0)return false;else{if(t<0)C=Math.max(C,t/(t-v));else if(v<0)m=Math.min(m,t/(t-v));if(s<0)C=Math.max(C,s/(s-n));else if(n<0)m=Math.min(m,s/(s-n));if(m<C)return false;else{l.lerpSelf(r,C);r.lerpSelf(l,1-m);return true}}}var d,e,g=[],h,o,b,i=[],k,y,z=[],u,x,H=[],J=new THREE.Vector4,K=new THREE.Vector4,p=new THREE.Matrix4,
U=new THREE.Matrix4,F=[],f=new THREE.Vector4,j=new THREE.Vector4,q;this.projectObjects=function(l,r,C){var m=[],t,v;e=0;p.multiply(r.projectionMatrix,r.matrix);F[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);F[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);F[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);F[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);F[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
p.n33,p.n44-p.n34);F[5]=new THREE.Vector4(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);r=0;for(t=F.length;r<t;r++){v=F[r];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}t=l.objects;l=0;for(r=t.length;l<r;l++){v=t[l];var s;if(!(s=!v.visible)){if(s=v instanceof THREE.Mesh){a:{s=void 0;for(var n=v.position,E=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),A=0;A<6;A++){s=F[A].x*n.x+F[A].y*n.y+F[A].z*n.z+F[A].w;if(s<=E){s=false;break a}}s=true}s=!s}s=s}if(!s){d=
g[f]=g[f]||new THREE.RenderableObject;J.copy(v.position);p.multiplyVector3(J);d.object=v;d.z=J.z;m.push(d);f++}}C&&m.sort(a);return m};this.projectScene=function(l,r,C){var m=[],t=r.near,v=r.far,s,n,E,A,O,N,G,W,P,I,L,V,S,w,M,Q;b=y=x=0;r.autoUpdateMatrix&&r.updateMatrix();p.multiply(r.projectionMatrix,r.matrix);N=this.projectObjects(l,r,true);l=0;for(s=N.length;l<s;l++){G=N[l].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();W=G.matrix;P=G.rotationMatrix;I=G.materials;L=G.overdraw;if(G instanceof
g[e]=g[e]||new THREE.RenderableObject;J.copy(v.position);p.multiplyVector3(J);d.object=v;d.z=J.z;m.push(d);e++}}C&&m.sort(a);return m};this.projectScene=function(l,r,C){var m=[],t=r.near,v=r.far,s,n,E,A,O,N,G,W,P,I,L,V,S,w,M,Q;b=y=x=0;r.autoUpdateMatrix&&r.updateMatrix();p.multiply(r.projectionMatrix,r.matrix);N=this.projectObjects(l,r,true);l=0;for(s=N.length;l<s;l++){G=N[l].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();W=G.matrix;P=G.rotationMatrix;I=G.materials;L=G.overdraw;if(G instanceof
THREE.Mesh){V=G.geometry;S=V.vertices;n=0;for(E=S.length;n<E;n++){w=S[n];w.positionWorld.copy(w.position);W.multiplyVector3(w.positionWorld);A=w.positionScreen;A.copy(w.positionWorld);p.multiplyVector4(A);A.x/=A.w;A.y/=A.w;w.__visible=A.z>t&&A.z<v}V=V.faces;n=0;for(E=V.length;n<E;n++){w=V[n];if(w instanceof THREE.Face3){A=S[w.a];O=S[w.b];M=S[w.c];if(A.__visible&&O.__visible&&M.__visible)if(G.doubleSided||G.flipSided!=(M.positionScreen.x-A.positionScreen.x)*(O.positionScreen.y-A.positionScreen.y)-
(M.positionScreen.y-A.positionScreen.y)*(O.positionScreen.x-A.positionScreen.x)<0){h=i[b]=i[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(A.positionWorld);h.v2.positionWorld.copy(O.positionWorld);h.v3.positionWorld.copy(M.positionWorld);h.v1.positionScreen.copy(A.positionScreen);h.v2.positionScreen.copy(O.positionScreen);h.v3.positionScreen.copy(M.positionScreen);h.normalWorld.copy(w.normal);P.multiplyVector3(h.normalWorld);h.centroidWorld.copy(w.centroid);W.multiplyVector3(h.centroidWorld);
h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);M=w.vertexNormals;q=h.vertexNormalsWorld;A=0;for(O=M.length;A<O;A++){Q=q[A]=q[A]||new THREE.Vector3;Q.copy(M[A]);P.multiplyVector3(Q)}h.z=h.centroidScreen.z;h.meshMaterials=I;h.faceMaterials=w.materials;h.overdraw=L;if(G.geometry.uvs[n]){h.uvs[0]=G.geometry.uvs[n][0];h.uvs[1]=G.geometry.uvs[n][1];h.uvs[2]=G.geometry.uvs[n][2]}m.push(h);b++}}else if(w instanceof THREE.Face4){A=S[w.a];O=S[w.b];M=S[w.c];Q=S[w.d];if(A.__visible&&
O.__visible&&M.__visible&&Q.__visible)if(G.doubleSided||G.flipSided!=((Q.positionScreen.x-A.positionScreen.x)*(O.positionScreen.y-A.positionScreen.y)-(Q.positionScreen.y-A.positionScreen.y)*(O.positionScreen.x-A.positionScreen.x)<0||(O.positionScreen.x-M.positionScreen.x)*(Q.positionScreen.y-M.positionScreen.y)-(O.positionScreen.y-M.positionScreen.y)*(Q.positionScreen.x-M.positionScreen.x)<0)){h=i[b]=i[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(A.positionWorld);h.v2.positionWorld.copy(O.positionWorld);
h.v3.positionWorld.copy(Q.positionWorld);h.v1.positionScreen.copy(A.positionScreen);h.v2.positionScreen.copy(O.positionScreen);h.v3.positionScreen.copy(Q.positionScreen);h.normalWorld.copy(w.normal);P.multiplyVector3(h.normalWorld);h.centroidWorld.copy(w.centroid);W.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=I;h.faceMaterials=w.materials;h.overdraw=L;if(G.geometry.uvs[n]){h.uvs[0]=G.geometry.uvs[n][0];
h.uvs[1]=G.geometry.uvs[n][1];h.uvs[2]=G.geometry.uvs[n][3]}m.push(h);b++;o=i[b]=i[b]||new THREE.RenderableFace3;o.v1.positionWorld.copy(O.positionWorld);o.v2.positionWorld.copy(M.positionWorld);o.v3.positionWorld.copy(Q.positionWorld);o.v1.positionScreen.copy(O.positionScreen);o.v2.positionScreen.copy(M.positionScreen);o.v3.positionScreen.copy(Q.positionScreen);o.normalWorld.copy(h.normalWorld);o.centroidWorld.copy(h.centroidWorld);o.centroidScreen.copy(h.centroidScreen);o.z=o.centroidScreen.z;o.meshMaterials=
I;o.faceMaterials=w.materials;o.overdraw=L;if(G.geometry.uvs[n]){o.uvs[0]=G.geometry.uvs[n][1];o.uvs[1]=G.geometry.uvs[n][2];o.uvs[2]=G.geometry.uvs[n][3]}m.push(o);b++}}}}else if(G instanceof THREE.Line){U.multiply(p,W);S=G.geometry.vertices;w=S[0];w.positionScreen.copy(w.position);U.multiplyVector4(w.positionScreen);n=1;for(E=S.length;n<E;n++){A=S[n];A.positionScreen.copy(A.position);U.multiplyVector4(A.positionScreen);O=S[n-1];e.copy(A.positionScreen);j.copy(O.positionScreen);if(c(e,j)){e.multiplyScalar(1/
e.w);j.multiplyScalar(1/j.w);k=z[y]=z[y]||new THREE.RenderableLine;k.v1.positionScreen.copy(e);k.v2.positionScreen.copy(j);k.z=Math.max(e.z,j.z);k.materials=G.materials;m.push(k);y++}}}else if(G instanceof THREE.Particle){K.set(G.position.x,G.position.y,G.position.z,1);p.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=K.x/K.w;u.y=K.y/K.w;u.z=K.z;u.rotation=G.rotation.z;u.scale.x=G.scale.x*Math.abs(u.x-(K.x+r.projectionMatrix.n11)/(K.w+r.projectionMatrix.n14));
u.scale.y=G.scale.y*Math.abs(u.y-(K.y+r.projectionMatrix.n22)/(K.w+r.projectionMatrix.n24));u.materials=G.materials;m.push(u);x++}}}}C&&m.sort(a);return m};this.unprojectVector=function(l,r){var C=new THREE.Matrix4;C.multiply(THREE.Matrix4.makeInvert(r.matrix),THREE.Matrix4.makeInvert(r.projectionMatrix));C.multiplyVector3(l);return l}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,h;this.domElement=document.createElement("div");this.setSize=function(o,b){d=o;f=b;g=d/2;h=f/2};this.render=function(o,b){var i,k,y,z,u,x,H,J;a=c.projectScene(o,b);i=0;for(k=a.length;i<k;i++){u=a[i];if(u instanceof THREE.RenderableParticle){H=u.x*g+g;J=u.y*h+h;y=0;for(z=u.material.length;y<z;y++){x=u.material[y];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=J+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(u!=da)k.globalAlpha=u=da}function c(da){if(x!=da){switch(da){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),h,o,b,i,k=g.getContext("2d"),y=null,z=null,u=1,x=0,H=null,J=null,K=1,p,U,F,e,j,q,l,r,C,m=new THREE.Color,
I;o.faceMaterials=w.materials;o.overdraw=L;if(G.geometry.uvs[n]){o.uvs[0]=G.geometry.uvs[n][1];o.uvs[1]=G.geometry.uvs[n][2];o.uvs[2]=G.geometry.uvs[n][3]}m.push(o);b++}}}}else if(G instanceof THREE.Line){U.multiply(p,W);S=G.geometry.vertices;w=S[0];w.positionScreen.copy(w.position);U.multiplyVector4(w.positionScreen);n=1;for(E=S.length;n<E;n++){A=S[n];A.positionScreen.copy(A.position);U.multiplyVector4(A.positionScreen);O=S[n-1];f.copy(A.positionScreen);j.copy(O.positionScreen);if(c(f,j)){f.multiplyScalar(1/
f.w);j.multiplyScalar(1/j.w);k=z[y]=z[y]||new THREE.RenderableLine;k.v1.positionScreen.copy(f);k.v2.positionScreen.copy(j);k.z=Math.max(f.z,j.z);k.materials=G.materials;m.push(k);y++}}}else if(G instanceof THREE.Particle){K.set(G.position.x,G.position.y,G.position.z,1);p.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=K.x/K.w;u.y=K.y/K.w;u.z=K.z;u.rotation=G.rotation.z;u.scale.x=G.scale.x*Math.abs(u.x-(K.x+r.projectionMatrix.n11)/(K.w+r.projectionMatrix.n14));
u.scale.y=G.scale.y*Math.abs(u.y-(K.y+r.projectionMatrix.n22)/(K.w+r.projectionMatrix.n24));u.materials=G.materials;m.push(u);x++}}}}C&&m.sort(a);return m};this.unprojectVector=function(l,r){var C=THREE.Matrix4.makeInvert(r.matrix);C.multiplySelf(THREE.Matrix4.makeInvert(r.projectionMatrix));C.multiplyVector3(l);return l}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(o,b){d=o;e=b;g=d/2;h=e/2};this.render=function(o,b){var i,k,y,z,u,x,H,J;a=c.projectScene(o,b);i=0;for(k=a.length;i<k;i++){u=a[i];if(u instanceof THREE.RenderableParticle){H=u.x*g+g;J=u.y*h+h;y=0;for(z=u.material.length;y<z;y++){x=u.material[y];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=J+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(u!=da)k.globalAlpha=u=da}function c(da){if(x!=da){switch(da){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=da}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),h,o,b,i,k=g.getContext("2d"),y=null,z=null,u=1,x=0,H=null,J=null,K=1,p,U,F,f,j,q,l,r,C,m=new THREE.Color,
t=new THREE.Color,v=new THREE.Color,s=new THREE.Color,n=new THREE.Color,E,A,O,N,G,W,P,I,L,V=new THREE.Rectangle,S=new THREE.Rectangle,w=new THREE.Rectangle,M=false,Q=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Z=new THREE.Color,ja=Math.PI*2,Y=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){h=da;o=ra;b=h/2;i=o/2;g.width=h;g.height=o;V.set(-b,-i,b,i);u=1;x=0;J=H=null;K=1};this.setClearColor=function(da,ra){y=da!==null?new THREE.Color(da):null;z=ra;S.set(-b,-i,b,i);k.setTransform(1,0,0,-1,b,i);this.clear()};this.clear=function(){if(!S.isEmpty()){S.inflate(1);S.minSelf(V);if(y!==null){c(THREE.NormalBlending);
a(1);k.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+z+")";k.fillRect(S.getX(),S.getY(),S.getWidth(),S.getHeight())}else k.clearRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());S.empty()}};this.render=function(da,ra){function Ma(B){var X,T,D,R=B.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Z.setRGB(0,0,0);B=0;for(X=R.length;B<X;B++){T=R[B];D=T.color;if(T instanceof THREE.AmbientLight){ea.r+=D.r;ea.g+=D.g;ea.b+=D.b}else if(T instanceof THREE.DirectionalLight){ba.r+=
D.r;ba.g+=D.g;ba.b+=D.b}else if(T instanceof THREE.PointLight){Z.r+=D.r;Z.g+=D.g;Z.b+=D.b}}}function Aa(B,X,T,D){var R,$,ca,ga,ia=B.lights;B=0;for(R=ia.length;B<R;B++){$=ia[B];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=T.dot($.position)*ga;if($>0){D.r+=ca.r*$;D.g+=ca.g*$;D.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=T.dot(Y)*ga;if($>0){D.r+=ca.r*$;D.g+=ca.g*$;D.b+=ca.b*$}}}}function Na(B,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending);
var D,R,$,ca,ga,ia;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){ca=T.map;ga=ca.width>>1;ia=ca.height>>1;R=X.scale.x*b;$=X.scale.y*i;T=R*ga;D=$*ia;w.set(B.x-T,B.y-D,B.x+T,B.y+D);if(V.instersects(w)){k.save();k.translate(B.x,B.y);k.rotate(-X.rotation);k.scale(R,-$);k.translate(-ga,-ia);k.drawImage(ca,0,0);k.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(M){Q.r=ea.r+ba.r+Z.r;Q.g=ea.g+ba.g+Z.g;Q.b=ea.b+ba.b+Z.b;m.r=T.color.r*Q.r;m.g=T.color.g*Q.g;m.b=T.color.b*Q.b;m.updateStyleString()}else m.__styleString=
T.color.__styleString;T=X.scale.x*b;D=X.scale.y*i;w.set(B.x-T,B.y-D,B.x+T,B.y+D);if(V.instersects(w)){R=m.__styleString;if(J!=R)k.fillStyle=J=R;k.save();k.translate(B.x,B.y);k.rotate(-X.rotation);k.scale(T,D);k.beginPath();k.arc(0,0,1,0,ja,true);k.closePath();k.fill();k.restore()}}}}function Oa(B,X,T,D){if(D.opacity!=0){a(D.opacity);c(D.blending);k.beginPath();k.moveTo(B.positionScreen.x,B.positionScreen.y);k.lineTo(X.positionScreen.x,X.positionScreen.y);k.closePath();if(D instanceof THREE.LineBasicMaterial){m.__styleString=
D.color.__styleString;B=D.linewidth;if(K!=B)k.lineWidth=K=B;B=m.__styleString;if(H!=B)k.strokeStyle=H=B;k.stroke();w.inflate(D.linewidth*2)}}}function Ia(B,X,T,D,R,$){if(R.opacity!=0){a(R.opacity);c(R.blending);e=B.positionScreen.x;j=B.positionScreen.y;q=X.positionScreen.x;l=X.positionScreen.y;r=T.positionScreen.x;C=T.positionScreen.y;k.beginPath();k.moveTo(e,j);k.lineTo(q,l);k.lineTo(r,C);k.lineTo(e,j);k.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof
THREE.UVMapping&&xa(e,j,q,l,r,C,R.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof THREE.SphericalReflectionMapping){B=ra.matrix;Y.copy(D.vertexNormalsWorld[0]);N=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;G=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[1]);W=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;P=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[2]);I=
(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;L=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;xa(e,j,q,l,r,C,R.env_map.image,N,G,W,P,I,L)}}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&xa(e,j,q,l,r,C,R.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!R.wireframe&&R.shading==THREE.SmoothShading&&
D.vertexNormalsWorld.length==3){t.r=v.r=s.r=ea.r;t.g=v.g=s.g=ea.g;t.b=v.b=s.b=ea.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],t);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],v);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],s);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(e,j,q,l,r,C,O,0,0,1,0,0,1)}else{Q.r=ea.r;Q.g=ea.g;Q.b=ea.b;Aa($,D.centroidWorld,D.normalWorld,Q);m.r=R.color.r*Q.r;m.g=R.color.g*Q.g;m.b=R.color.b*Q.b;m.updateStyleString();R.wireframe?Ba(m.__styleString,
R.wireframe_linewidth):Ca(m.__styleString)}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){E=ra.near;A=ra.far;t.r=t.g=t.b=1-Ea(B.positionScreen.z,E,A);v.r=v.g=v.b=1-Ea(X.positionScreen.z,E,A);s.r=s.g=s.b=1-Ea(T.positionScreen.z,E,A);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(e,j,q,l,r,C,O,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){m.r=Fa(D.normalWorld.x);m.g=Fa(D.normalWorld.y);
D.color.__styleString;B=D.linewidth;if(K!=B)k.lineWidth=K=B;B=m.__styleString;if(H!=B)k.strokeStyle=H=B;k.stroke();w.inflate(D.linewidth*2)}}}function Ia(B,X,T,D,R,$){if(R.opacity!=0){a(R.opacity);c(R.blending);f=B.positionScreen.x;j=B.positionScreen.y;q=X.positionScreen.x;l=X.positionScreen.y;r=T.positionScreen.x;C=T.positionScreen.y;k.beginPath();k.moveTo(f,j);k.lineTo(q,l);k.lineTo(r,C);k.lineTo(f,j);k.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof
THREE.UVMapping&&xa(f,j,q,l,r,C,R.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof THREE.SphericalReflectionMapping){B=ra.matrix;Y.copy(D.vertexNormalsWorld[0]);N=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;G=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[1]);W=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;P=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[2]);I=
(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;L=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;xa(f,j,q,l,r,C,R.env_map.image,N,G,W,P,I,L)}}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&xa(f,j,q,l,r,C,R.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!R.wireframe&&R.shading==THREE.SmoothShading&&
D.vertexNormalsWorld.length==3){t.r=v.r=s.r=ea.r;t.g=v.g=s.g=ea.g;t.b=v.b=s.b=ea.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],t);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],v);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],s);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(f,j,q,l,r,C,O,0,0,1,0,0,1)}else{Q.r=ea.r;Q.g=ea.g;Q.b=ea.b;Aa($,D.centroidWorld,D.normalWorld,Q);m.r=R.color.r*Q.r;m.g=R.color.g*Q.g;m.b=R.color.b*Q.b;m.updateStyleString();R.wireframe?Ba(m.__styleString,
R.wireframe_linewidth):Ca(m.__styleString)}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){E=ra.near;A=ra.far;t.r=t.g=t.b=1-Ea(B.positionScreen.z,E,A);v.r=v.g=v.b=1-Ea(X.positionScreen.z,E,A);s.r=s.g=s.b=1-Ea(T.positionScreen.z,E,A);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(f,j,q,l,r,C,O,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){m.r=Fa(D.normalWorld.x);m.g=Fa(D.normalWorld.y);
m.b=Fa(D.normalWorld.z);m.updateStyleString();R.wireframe?Ba(m.__styleString,R.wireframe_linewidth):Ca(m.__styleString)}}}function Ba(B,X){if(H!=B)k.strokeStyle=H=B;if(K!=X)k.lineWidth=K=X;k.stroke();w.inflate(X*2)}function Ca(B){if(J!=B)k.fillStyle=J=B;k.fill()}function xa(B,X,T,D,R,$,ca,ga,ia,na,la,oa,ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;T-=B;D-=X;R-=B;$-=X;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*T-la*R)*pa;la=(ya*D-la*$)*pa;T=(na*R-
oa*T)*pa;D=(na*$-oa*D)*pa;B=B-ta*ga-T*ia;X=X-la*ga-D*ia;k.save();k.transform(ta,la,T,D,B,X);k.clip();k.drawImage(ca,0,0);k.restore()}function Ja(B,X,T,D){var R=~~(B.r*255),$=~~(B.g*255);B=~~(B.b*255);var ca=~~(X.r*255),ga=~~(X.g*255);X=~~(X.b*255);var ia=~~(T.r*255),na=~~(T.g*255);T=~~(T.b*255);var la=~~(D.r*255),oa=~~(D.g*255);D=~~(D.b*255);ha[0]=R<0?0:R>255?255:R;ha[1]=$<0?0:$>255?255:$;ha[2]=B<0?0:B>255?255:B;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=X<0?0:X>255?255:X;ha[8]=ia<
0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=T<0?0:T>255?255:T;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=D<0?0:D>255?255:D;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(B,X,T){B=(B-X)/(T-X);return B*B*(3-2*B)}function Fa(B){B=(B+1)*0.5;return B<0?0:B>1?1:B}function Ga(B,X){var T=X.x-B.x,D=X.y-B.y,R=1/Math.sqrt(T*T+D*D);T*=R;D*=R;X.x+=T;X.y+=D;B.x-=T;B.y-=D}var Da,Ka,aa,ma,wa,Ha,La,za;k.setTransform(1,0,0,-1,b,i);this.autoClear&&this.clear();d=f.projectScene(da,
0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=T<0?0:T>255?255:T;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=D<0?0:D>255?255:D;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(B,X,T){B=(B-X)/(T-X);return B*B*(3-2*B)}function Fa(B){B=(B+1)*0.5;return B<0?0:B>1?1:B}function Ga(B,X){var T=X.x-B.x,D=X.y-B.y,R=1/Math.sqrt(T*T+D*D);T*=R;D*=R;X.x+=T;X.y+=D;B.x-=T;B.y-=D}var Da,Ka,aa,ma,wa,Ha,La,za;k.setTransform(1,0,0,-1,b,i);this.autoClear&&this.clear();d=e.projectScene(da,
ra,this.sortElements);(M=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];w.empty();if(aa instanceof THREE.RenderableParticle){p=aa;p.x*=b;p.y*=i;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(p,aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){p=aa.v1;U=aa.v2;p.positionScreen.x*=b;p.positionScreen.y*=i;U.positionScreen.x*=b;U.positionScreen.y*=i;w.addPoint(p.positionScreen.x,p.positionScreen.y);w.addPoint(U.positionScreen.x,U.positionScreen.y);if(V.instersects(w)){ma=
0;for(wa=aa.materials.length;ma<wa;)Oa(p,U,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){p=aa.v1;U=aa.v2;F=aa.v3;p.positionScreen.x*=b;p.positionScreen.y*=i;U.positionScreen.x*=b;U.positionScreen.y*=i;F.positionScreen.x*=b;F.positionScreen.y*=i;if(aa.overdraw){Ga(p.positionScreen,U.positionScreen);Ga(U.positionScreen,F.positionScreen);Ga(F.positionScreen,p.positionScreen)}w.add3Points(p.positionScreen.x,p.positionScreen.y,U.positionScreen.x,U.positionScreen.y,F.positionScreen.x,
F.positionScreen.y);if(V.instersects(w)){ma=0;for(wa=aa.meshMaterials.length;ma<wa;){za=aa.meshMaterials[ma++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterials.length;Ha<La;)(za=aa.faceMaterials[Ha++])&&Ia(p,U,F,aa,za,da)}else Ia(p,U,F,aa,za,da)}}}S.addRectangle(w)}k.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(N,G,W){var P,I,L,V;P=0;for(I=N.lights.length;P<I;P++){L=N.lights[P];if(L instanceof THREE.DirectionalLight){V=G.normalWorld.dot(L.position)*L.intensity;if(V>0){W.r+=L.color.r*V;W.g+=L.color.g*V;W.b+=L.color.b*V}}else if(L instanceof THREE.PointLight){C.sub(L.position,G.centroidWorld);C.normalize();V=G.normalWorld.dot(C)*L.intensity;if(V>0){W.r+=L.color.r*V;W.g+=L.color.g*V;W.b+=L.color.b*V}}}}function c(N,G,W,P,I,L){s=f(n++);s.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(U){e.r=j.r;e.g=j.g;e.b=j.b;a(L,P,e);F.r=I.color.r*e.r;F.g=I.color.g*e.g;F.b=I.color.b*e.b;F.updateStyleString()}else F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){r=1-I.__2near/(I.__farPlusNear-P.z*I.__farMinusNear);
F.setRGB(r,r,r)}else I instanceof THREE.MeshNormalMaterial&&F.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));I.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(s)}function d(N,G,W,P,I,L,V){s=f(n++);s.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(U){e.r=j.r;e.g=j.g;e.b=j.b;a(V,I,e);F.r=L.color.r*e.r;F.g=L.color.g*e.g;F.b=L.color.b*e.b;F.updateStyleString()}else F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){r=
THREE.SVGRenderer=function(){function a(N,G,W){var P,I,L,V;P=0;for(I=N.lights.length;P<I;P++){L=N.lights[P];if(L instanceof THREE.DirectionalLight){V=G.normalWorld.dot(L.position)*L.intensity;if(V>0){W.r+=L.color.r*V;W.g+=L.color.g*V;W.b+=L.color.b*V}}else if(L instanceof THREE.PointLight){C.sub(L.position,G.centroidWorld);C.normalize();V=G.normalWorld.dot(C)*L.intensity;if(V>0){W.r+=L.color.r*V;W.g+=L.color.g*V;W.b+=L.color.b*V}}}}function c(N,G,W,P,I,L){s=e(n++);s.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(U){f.r=j.r;f.g=j.g;f.b=j.b;a(L,P,f);F.r=I.color.r*f.r;F.g=I.color.g*f.g;F.b=I.color.b*f.b;F.updateStyleString()}else F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){r=1-I.__2near/(I.__farPlusNear-P.z*I.__farMinusNear);
F.setRGB(r,r,r)}else I instanceof THREE.MeshNormalMaterial&&F.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));I.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(s)}function d(N,G,W,P,I,L,V){s=e(n++);s.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(U){f.r=j.r;f.g=j.g;f.b=j.b;a(V,I,f);F.r=L.color.r*f.r;F.g=L.color.g*f.g;F.b=L.color.b*f.b;F.updateStyleString()}else F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){r=
1-L.__2near/(L.__farPlusNear-I.z*L.__farMinusNear);F.setRGB(r,r,r)}else L instanceof THREE.MeshNormalMaterial&&F.setRGB(g(I.normalWorld.x),g(I.normalWorld.y),g(I.normalWorld.z));L.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+L.opacity);b.appendChild(s)}
function f(N){if(m[N]==null){m[N]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&m[N].setAttribute("shape-rendering","crispEdges");return m[N]}return m[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var h=null,o=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,k,y,z,u,x,H,J,K=new THREE.Rectangle,p=new THREE.Rectangle,U=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),j=new THREE.Color(0),q=new THREE.Color(0),
function e(N){if(m[N]==null){m[N]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&m[N].setAttribute("shape-rendering","crispEdges");return m[N]}return m[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var h=null,o=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,k,y,z,u,x,H,J,K=new THREE.Rectangle,p=new THREE.Rectangle,U=false,F=new THREE.Color(16777215),f=new THREE.Color(16777215),j=new THREE.Color(0),q=new THREE.Color(0),
l=new THREE.Color(0),r,C=new THREE.Vector3,m=[],t=[],v=[],s,n,E,A,O=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(N){switch(N){case "high":O=1;break;case "low":O=0}};this.setSize=function(N,G){i=N;k=G;y=i/2;z=k/2;b.setAttribute("viewBox",-y+" "+-z+" "+i+" "+k);b.setAttribute("width",i);b.setAttribute("height",k);K.set(-y,-z,y,z)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(N,G){var W,P,
I,L,V,S,w,M;this.autoClear&&this.clear();h=o.projectScene(N,G,this.sortElements);A=E=n=0;if(U=N.lights.length>0){w=N.lights;j.setRGB(0,0,0);q.setRGB(0,0,0);l.setRGB(0,0,0);W=0;for(P=w.length;W<P;W++){I=w[W];L=I.color;if(I instanceof THREE.AmbientLight){j.r+=L.r;j.g+=L.g;j.b+=L.b}else if(I instanceof THREE.DirectionalLight){q.r+=L.r;q.g+=L.g;q.b+=L.b}else if(I instanceof THREE.PointLight){l.r+=L.r;l.g+=L.g;l.b+=L.b}}}W=0;for(P=h.length;W<P;W++){w=h[W];p.empty();if(w instanceof THREE.RenderableParticle){u=
w;u.x*=y;u.y*=-z;I=0;for(L=w.materials.length;I<L;I++)if(M=w.materials[I]){V=u;S=w;M=M;var Q=E++;if(t[Q]==null){t[Q]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[Q].setAttribute("shape-rendering","crispEdges")}s=t[Q];s.setAttribute("cx",V.x);s.setAttribute("cy",V.y);s.setAttribute("r",S.scale.x*y);if(M instanceof THREE.ParticleCircleMaterial){if(U){e.r=j.r+q.r+l.r;e.g=j.g+q.g+l.g;e.b=j.b+q.b+l.b;F.r=M.color.r*e.r;F.g=M.color.g*e.g;F.b=M.color.b*e.b;F.updateStyleString()}else F=
w;u.x*=y;u.y*=-z;I=0;for(L=w.materials.length;I<L;I++)if(M=w.materials[I]){V=u;S=w;M=M;var Q=E++;if(t[Q]==null){t[Q]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[Q].setAttribute("shape-rendering","crispEdges")}s=t[Q];s.setAttribute("cx",V.x);s.setAttribute("cy",V.y);s.setAttribute("r",S.scale.x*y);if(M instanceof THREE.ParticleCircleMaterial){if(U){f.r=j.r+q.r+l.r;f.g=j.g+q.g+l.g;f.b=j.b+q.b+l.b;F.r=M.color.r*f.r;F.g=M.color.g*f.g;F.b=M.color.b*f.b;F.updateStyleString()}else F=
M.color;s.setAttribute("style","fill: "+F.__styleString)}b.appendChild(s)}}else if(w instanceof THREE.RenderableLine){u=w.v1;x=w.v2;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);if(K.instersects(p)){I=0;for(L=w.materials.length;I<L;)if(M=w.materials[I++]){V=u;S=x;M=M;Q=A++;if(v[Q]==null){v[Q]=document.createElementNS("http://www.w3.org/2000/svg","line");O==
0&&v[Q].setAttribute("shape-rendering","crispEdges")}s=v[Q];s.setAttribute("x1",V.positionScreen.x);s.setAttribute("y1",V.positionScreen.y);s.setAttribute("x2",S.positionScreen.x);s.setAttribute("y2",S.positionScreen.y);if(M instanceof THREE.LineBasicMaterial){F.__styleString=M.color.__styleString;s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+M.linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.linecap+"; stroke-linejoin: "+M.linejoin);b.appendChild(s)}}}}else if(w instanceof
THREE.RenderableFace3){u=w.v1;x=w.v2;H=w.v3;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;H.positionScreen.x*=y;H.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);if(K.instersects(p)){I=0;for(L=w.meshMaterials.length;I<L;){M=w.meshMaterials[I++];if(M instanceof THREE.MeshFaceMaterial){V=0;for(S=w.faceMaterials.length;V<S;)(M=w.faceMaterials[V++])&&
c(u,x,H,w,M,N)}else M&&c(u,x,H,w,M,N)}}}else if(w instanceof THREE.RenderableFace4){u=w.v1;x=w.v2;H=w.v3;J=w.v4;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;H.positionScreen.x*=y;H.positionScreen.y*=-z;J.positionScreen.x*=y;J.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);p.addPoint(J.positionScreen.x,J.positionScreen.y);if(K.instersects(p)){I=
0;for(L=w.meshMaterials.length;I<L;){M=w.meshMaterials[I++];if(M instanceof THREE.MeshFaceMaterial){V=0;for(S=w.faceMaterials.length;V<S;)(M=w.faceMaterials[V++])&&d(u,x,H,J,w,M,N)}else M&&d(u,x,H,J,w,M,N)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,j){e.fragment_shader=j.fragment_shader;e.vertex_shader=j.vertex_shader;e.uniforms=Uniforms.clone(j.uniforms)}function d(e,j){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=
e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(j){e.uniforms.fogColor.value.setHex(j.color.hex);if(j instanceof THREE.Fog){e.uniforms.fogNear.value=j.near;e.uniforms.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)e.uniforms.fogDensity.value=j.density}}function f(e,j){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(j){e.uniforms.fogColor.value.setHex(j.color.hex);if(j instanceof THREE.Fog){e.uniforms.fogNear.value=
j.near;e.uniforms.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)e.uniforms.fogDensity.value=j.density}}function g(e,j){var q;if(e=="fragment")q=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")q=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,j);b.compileShader(q);if(!b.getShaderParameter(q,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(q));return null}return q}function h(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
THREE.WebGLRenderer=function(a){function c(f,j){f.fragment_shader=j.fragment_shader;f.vertex_shader=j.vertex_shader;f.uniforms=Uniforms.clone(j.uniforms)}function d(f,j){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;f.uniforms.map.texture=f.map;f.uniforms.env_map.texture=f.env_map;f.uniforms.reflectivity.value=f.reflectivity;f.uniforms.refraction_ratio.value=f.refraction_ratio;f.uniforms.combine.value=f.combine;f.uniforms.useRefract.value=
f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;if(j){f.uniforms.fogColor.value.setHex(j.color.hex);if(j instanceof THREE.Fog){f.uniforms.fogNear.value=j.near;f.uniforms.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)f.uniforms.fogDensity.value=j.density}}function e(f,j){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;if(j){f.uniforms.fogColor.value.setHex(j.color.hex);if(j instanceof THREE.Fog){f.uniforms.fogNear.value=
j.near;f.uniforms.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)f.uniforms.fogDensity.value=j.density}}function g(f,j){var q;if(f=="fragment")q=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")q=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,j);b.compileShader(q);if(!b.getShaderParameter(q,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(q));return null}return q}function h(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),b,i=null,k=null,y=new THREE.Matrix4,z,u=new Float32Array(16),x=new Float32Array(16),H=new Float32Array(16),J=new Float32Array(9),
K=new Float32Array(16),p=true,U=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&U.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(e,j,q){try{b=o.getContext("experimental-webgl",{antialias:e})}catch(l){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(j.r,j.g,j.b,q)})(p,U,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,j){o.width=e;o.height=j;b.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,j){var q=new THREE.Color(e);b.clearColor(q.r,q.g,q.b,j)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(e,j){var q,l,r,C=0,m=0,t=0,v,s,n,E=this.lights,A=E.directional.colors,O=E.directional.positions,N=E.point.colors,G=E.point.positions,W=0,P=0;q=0;for(l=j.length;q<l;q++){r=j[q];v=r.color;s=r.position;n=r.intensity;if(r instanceof THREE.AmbientLight){C+=v.r;m+=v.g;t+=v.b}else if(r instanceof THREE.DirectionalLight){A[W*3]=v.r*n;A[W*3+1]=v.g*n;A[W*3+2]=v.b*n;O[W*3]=s.x;O[W*3+1]=s.y;O[W*3+2]=s.z;W+=1}else if(r instanceof THREE.PointLight){N[P*3]=v.r*n;N[P*3+1]=v.g*n;N[P*3+2]=v.b*n;G[P*3]=s.x;
G[P*3+1]=s.y;G[P*3+2]=s.z;P+=1}}E.point.length=P;E.directional.length=W;E.ambient[0]=C;E.ambient[1]=m;E.ambient[2]=t};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLNormalBuffer=b.createBuffer();e.__webGLTangentBuffer=b.createBuffer();e.__webGLUVBuffer=
b.createBuffer();e.__webGLFaceBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(e){var j=e.vertices.length;e.__vertexArray=new Float32Array(j*3);e.__lineArray=new Uint16Array(j);e.__webGLLineCount=j};this.initMeshBuffers=function(e,j){var q,l,r=0,C=0,m=0,t=j.geometry.faces,v=e.faces;q=0;for(l=v.length;q<l;q++){fi=v[q];face=t[fi];if(face instanceof THREE.Face3){r+=3;C+=1;m+=3}else if(face instanceof THREE.Face4){r+=4;C+=2;m+=4}}e.__vertexArray=new Float32Array(r*
3);e.__normalArray=new Float32Array(r*3);e.__tangentArray=new Float32Array(r*4);e.__uvArray=new Float32Array(r*2);e.__faceArray=new Uint16Array(C*3);e.__lineArray=new Uint16Array(m*2);r=false;q=0;for(l=j.materials.length;q<l;q++){t=j.materials[q];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=e.materials.length;t<v;t++)if(e.materials[t]&&e.materials[t].shading!=undefined&&e.materials[t].shading==THREE.SmoothShading){r=true;break}}else if(t&&t.shading!=undefined&&t.shading==THREE.SmoothShading){r=
true;break}if(r)break}e.__needsSmoothNormals=r;e.__webGLFaceCount=C*3;e.__webGLLineCount=m*2};this.setMeshBuffers=function(e,j,q,l,r,C,m,t){var v,s,n,E,A,O,N,G,W,P=0,I=0,L=0,V=0,S=0,w=0,M=0,Q=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Z=e.__tangentArray,ja=e.__faceArray,Y=e.__lineArray,qa=e.__needsSmoothNormals,ka=j.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;j=0;for(v=ha.length;j<v;j++){s=ha[j];n=sa[s];s=ua[s];E=n.vertexNormals;A=n.normal;if(n instanceof THREE.Face3){if(l){O=
K=new Float32Array(16),p=true,U=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&U.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(f,j,q){try{b=o.getContext("experimental-webgl",{antialias:f})}catch(l){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(j.r,j.g,j.b,q)})(p,U,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,j){o.width=f;o.height=j;b.viewport(0,0,o.width,o.height)};this.setClearColor=function(f,j){var q=new THREE.Color(f);b.clearColor(q.r,q.g,q.b,j)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(f,j){var q,l,r,C=0,m=0,t=0,v,s,n,E=this.lights,A=E.directional.colors,O=E.directional.positions,N=E.point.colors,G=E.point.positions,W=0,P=0;q=0;for(l=j.length;q<l;q++){r=j[q];v=r.color;s=r.position;n=r.intensity;if(r instanceof THREE.AmbientLight){C+=v.r;m+=v.g;t+=v.b}else if(r instanceof THREE.DirectionalLight){A[W*3]=v.r*n;A[W*3+1]=v.g*n;A[W*3+2]=v.b*n;O[W*3]=s.x;O[W*3+1]=s.y;O[W*3+2]=s.z;W+=1}else if(r instanceof THREE.PointLight){N[P*3]=v.r*n;N[P*3+1]=v.g*n;N[P*3+2]=v.b*n;G[P*3]=s.x;
G[P*3+1]=s.y;G[P*3+2]=s.z;P+=1}}E.point.length=P;E.directional.length=W;E.ambient[0]=C;E.ambient[1]=m;E.ambient[2]=t};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=
b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var j=f.vertices.length;f.__vertexArray=new Float32Array(j*3);f.__lineArray=new Uint16Array(j);f.__webGLLineCount=j};this.initMeshBuffers=function(f,j){var q,l,r=0,C=0,m=0,t=j.geometry.faces,v=f.faces;q=0;for(l=v.length;q<l;q++){fi=v[q];face=t[fi];if(face instanceof THREE.Face3){r+=3;C+=1;m+=3}else if(face instanceof THREE.Face4){r+=4;C+=2;m+=4}}f.__vertexArray=new Float32Array(r*
3);f.__normalArray=new Float32Array(r*3);f.__tangentArray=new Float32Array(r*4);f.__uvArray=new Float32Array(r*2);f.__faceArray=new Uint16Array(C*3);f.__lineArray=new Uint16Array(m*2);r=false;q=0;for(l=j.materials.length;q<l;q++){t=j.materials[q];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=f.materials.length;t<v;t++)if(f.materials[t]&&f.materials[t].shading!=undefined&&f.materials[t].shading==THREE.SmoothShading){r=true;break}}else if(t&&t.shading!=undefined&&t.shading==THREE.SmoothShading){r=
true;break}if(r)break}f.__needsSmoothNormals=r;f.__webGLFaceCount=C*3;f.__webGLLineCount=m*2};this.setMeshBuffers=function(f,j,q,l,r,C,m,t){var v,s,n,E,A,O,N,G,W,P=0,I=0,L=0,V=0,S=0,w=0,M=0,Q=f.__vertexArray,ea=f.__uvArray,ba=f.__normalArray,Z=f.__tangentArray,ja=f.__faceArray,Y=f.__lineArray,qa=f.__needsSmoothNormals,ka=j.geometry,fa=ka.vertices,ha=f.faces,sa=ka.faces,ua=ka.uvs;j=0;for(v=ha.length;j<v;j++){s=ha[j];n=sa[s];s=ua[s];E=n.vertexNormals;A=n.normal;if(n instanceof THREE.Face3){if(l){O=
fa[n.a].position;N=fa[n.b].position;G=fa[n.c].position;Q[I]=O.x;Q[I+1]=O.y;Q[I+2]=O.z;Q[I+3]=N.x;Q[I+4]=N.y;Q[I+5]=N.z;Q[I+6]=G.x;Q[I+7]=G.y;Q[I+8]=G.z;I+=9}if(t&&ka.hasTangents){O=fa[n.a].tangent;N=fa[n.b].tangent;G=fa[n.c].tangent;Z[w]=O.x;Z[w+1]=O.y;Z[w+2]=O.z;Z[w+3]=O.w;Z[w+4]=N.x;Z[w+5]=N.y;Z[w+6]=N.z;Z[w+7]=N.w;Z[w+8]=G.x;Z[w+9]=G.y;Z[w+10]=G.z;Z[w+11]=G.w;w+=12}if(m)if(E.length==3&&qa)for(n=0;n<3;n++){A=E[n];ba[S]=A.x;ba[S+1]=A.y;ba[S+2]=A.z;S+=3}else for(n=0;n<3;n++){ba[S]=A.x;ba[S+1]=A.y;
ba[S+2]=A.z;S+=3}if(C&&s)for(n=0;n<3;n++){E=s[n];ea[L]=E.u;ea[L+1]=E.v;L+=2}if(r){ja[V]=P;ja[V+1]=P+1;ja[V+2]=P+2;V+=3;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+2;Y[M+4]=P+1;Y[M+5]=P+2;M+=6;P+=3}}else if(n instanceof THREE.Face4){if(l){O=fa[n.a].position;N=fa[n.b].position;G=fa[n.c].position;W=fa[n.d].position;Q[I]=O.x;Q[I+1]=O.y;Q[I+2]=O.z;Q[I+3]=N.x;Q[I+4]=N.y;Q[I+5]=N.z;Q[I+6]=G.x;Q[I+7]=G.y;Q[I+8]=G.z;Q[I+9]=W.x;Q[I+10]=W.y;Q[I+11]=W.z;I+=12}if(t&&ka.hasTangents){O=fa[n.a].tangent;N=fa[n.b].tangent;
G=fa[n.c].tangent;n=fa[n.d].tangent;Z[w]=O.x;Z[w+1]=O.y;Z[w+2]=O.z;Z[w+3]=O.w;Z[w+4]=N.x;Z[w+5]=N.y;Z[w+6]=N.z;Z[w+7]=N.w;Z[w+8]=G.x;Z[w+9]=G.y;Z[w+10]=G.z;Z[w+11]=G.w;Z[w+12]=n.x;Z[w+13]=n.y;Z[w+14]=n.z;Z[w+15]=n.w;w+=16}if(m)if(E.length==4&&qa)for(n=0;n<4;n++){A=E[n];ba[S]=A.x;ba[S+1]=A.y;ba[S+2]=A.z;S+=3}else for(n=0;n<4;n++){ba[S]=A.x;ba[S+1]=A.y;ba[S+2]=A.z;S+=3}if(C&&s)for(n=0;n<4;n++){E=s[n];ea[L]=E.u;ea[L+1]=E.v;L+=2}if(r){ja[V]=P;ja[V+1]=P+1;ja[V+2]=P+2;ja[V+3]=P;ja[V+4]=P+2;ja[V+5]=P+3;
V+=6;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+3;Y[M+4]=P+1;Y[M+5]=P+2;Y[M+6]=P+2;Y[M+7]=P+3;M+=8;P+=4}}}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,q)}if(m){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,q)}if(t&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,q)}if(C&&L>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,q)}if(r){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,q)}};this.setLineBuffers=function(e,j,q,l){var r,C,m=e.vertices,t=m.length,v=e.__vertexArray,s=e.__lineArray;if(q)for(q=0;q<t;q++){r=m[q].position;C=q*3;v[C]=r.x;v[C+1]=r.y;v[C+2]=r.z}if(l)for(q=0;q<t;q++)s[q]=q;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,j);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,j)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,j,q,l,r,C){var m,t,v,s;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){c(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=e.near;l.uniforms.mFar.value=e.far}else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){c(l,THREE.ShaderLib.basic);d(l,q)}else if(l instanceof THREE.MeshLambertMaterial){c(l,THREE.ShaderLib.lambert);
d(l,q)}else if(l instanceof THREE.MeshPhongMaterial){c(l,THREE.ShaderLib.phong);d(l,q)}else if(l instanceof THREE.LineBasicMaterial){c(l,THREE.ShaderLib.basic);f(l,q)}var n,E,A;n=s=t=0;for(E=j.length;n<E;n++){A=j[n];A instanceof THREE.DirectionalLight&&s++;A instanceof THREE.PointLight&&t++}if(t+s<=4){n=s;t=t}else{n=Math.ceil(4*s/(t+s));t=4-n}t={directional:n,point:t};s={fog:q,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;n=l.vertex_shader;E=b.createProgram();
V+=6;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+3;Y[M+4]=P+1;Y[M+5]=P+2;Y[M+6]=P+2;Y[M+7]=P+3;M+=8;P+=4}}}if(l){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,q)}if(m){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,q)}if(t&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,q)}if(C&&L>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,q)}if(r){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,q)}};this.setLineBuffers=function(f,j,q,l){var r,C,m=f.vertices,t=m.length,v=f.__vertexArray,s=f.__lineArray;if(q)for(q=0;q<t;q++){r=m[q].position;C=q*3;v[C]=r.x;v[C+1]=r.y;v[C+2]=r.z}if(l)for(q=0;q<t;q++)s[q]=q;b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,j);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,j)};this.setParticleBuffers=function(){};this.renderBuffer=function(f,j,q,l,r,C){var m,t,v,s;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){c(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=f.near;l.uniforms.mFar.value=f.far}else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){c(l,THREE.ShaderLib.basic);d(l,q)}else if(l instanceof THREE.MeshLambertMaterial){c(l,THREE.ShaderLib.lambert);
d(l,q)}else if(l instanceof THREE.MeshPhongMaterial){c(l,THREE.ShaderLib.phong);d(l,q)}else if(l instanceof THREE.LineBasicMaterial){c(l,THREE.ShaderLib.basic);e(l,q)}var n,E,A;n=s=t=0;for(E=j.length;n<E;n++){A=j[n];A instanceof THREE.DirectionalLight&&s++;A instanceof THREE.PointLight&&t++}if(t+s<=4){n=s;t=t}else{n=Math.ceil(4*s/(t+s));t=4-n}t={directional:n,point:t};s={fog:q,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;n=l.vertex_shader;E=b.createProgram();
A=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,s.fog?"#define USE_FOG":"",s.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");s=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,
s.map?"#define USE_MAP":"",s.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");b.attachShader(E,g("fragment",A+t));b.attachShader(E,g("vertex",s+n));b.linkProgram(E);b.getProgramParameter(E,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
b.getProgramParameter(E,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");E.uniforms={};E.attributes={};l.program=E;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in l.uniforms)t.push(m);m=l.program;n=0;for(E=t.length;n<E;n++){A=t[n];m.uniforms[A]=b.getUniformLocation(m,A)}m=l.program;t=["position","normal","uv","tangent"];n=0;for(E=t.length;n<E;n++){A=t[n];m.attributes[A]=b.getAttribLocation(m,A)}}m=l.program;if(m!=i){b.useProgram(m);
i=m}this.loadCamera(m,e);this.loadMatrices(m);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(m,j);e=this.lights;l.uniforms.enableLighting.value=e.directional.length+e.point.length;l.uniforms.ambientLightColor.value=e.ambient;l.uniforms.directionalLightColor.value=e.directional.colors;l.uniforms.directionalLightDirection.value=e.directional.positions;l.uniforms.pointLightColor.value=e.point.colors;l.uniforms.pointLightPosition.value=e.point.positions}if(l instanceof
THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)d(l,q);l instanceof THREE.LineBasicMaterial&&f(l,q);if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);l.uniforms.shininess.value=l.shininess}q=l.uniforms;for(v in q)if(n=m.uniforms[v]){j=q[v];t=j.type;e=j.value;if(t=="i")b.uniform1i(n,e);else if(t=="f")b.uniform1f(n,
e);else if(t=="fv1")b.uniform1fv(n,e);else if(t=="fv")b.uniform3fv(n,e);else if(t=="v2")b.uniform2f(n,e.x,e.y);else if(t=="v3")b.uniform3f(n,e.x,e.y,e.z);else if(t=="c")b.uniform3f(n,e.r,e.g,e.b);else if(t=="t"){b.uniform1i(n,e);if(j=j.texture)if(j.image instanceof Array&&j.image.length==6){j=j;e=e;if(j.image.length==6){if(!j.image.__webGLTextureCube&&!j.image.__cubeMapInitialized&&j.image.loadCount==6){j.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube);
i=m}this.loadCamera(m,f);this.loadMatrices(m);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(m,j);f=this.lights;l.uniforms.enableLighting.value=f.directional.length+f.point.length;l.uniforms.ambientLightColor.value=f.ambient;l.uniforms.directionalLightColor.value=f.directional.colors;l.uniforms.directionalLightDirection.value=f.directional.positions;l.uniforms.pointLightColor.value=f.point.colors;l.uniforms.pointLightPosition.value=f.point.positions}if(l instanceof
THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)d(l,q);l instanceof THREE.LineBasicMaterial&&e(l,q);if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);l.uniforms.shininess.value=l.shininess}q=l.uniforms;for(v in q)if(n=m.uniforms[v]){j=q[v];t=j.type;f=j.value;if(t=="i")b.uniform1i(n,f);else if(t=="f")b.uniform1f(n,
f);else if(t=="fv1")b.uniform1fv(n,f);else if(t=="fv")b.uniform3fv(n,f);else if(t=="v2")b.uniform2f(n,f.x,f.y);else if(t=="v3")b.uniform3f(n,f.x,f.y,f.z);else if(t=="c")b.uniform3f(n,f.r,f.g,f.b);else if(t=="t"){b.uniform1i(n,f);if(j=j.texture)if(j.image instanceof Array&&j.image.length==6){j=j;f=f;if(j.image.length==6){if(!j.image.__webGLTextureCube&&!j.image.__cubeMapInitialized&&j.image.loadCount==6){j.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube);
b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image[t]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);j.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+
e);b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube)}}else{j=j;e=e;if(!j.__webGLTexture&&j.image.loaded){j.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,j.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(j.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(j.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(j.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(j.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+e);b.bindTexture(b.TEXTURE_2D,j.__webGLTexture)}}}v=m.attributes;b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.vertexAttribPointer(v.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.position);if(v.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.vertexAttribPointer(v.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.normal)}if(v.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);
f);b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube)}}else{j=j;f=f;if(!j.__webGLTexture&&j.image.loaded){j.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,j.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(j.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(j.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(j.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(j.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+f);b.bindTexture(b.TEXTURE_2D,j.__webGLTexture)}}}v=m.attributes;b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.vertexAttribPointer(v.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.position);if(v.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.vertexAttribPointer(v.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.normal)}if(v.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);
b.vertexAttribPointer(v.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(r.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUVBuffer);b.vertexAttribPointer(v.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.uv)}else b.disableVertexAttribArray(v.uv);if(l.wireframe||l instanceof THREE.LineBasicMaterial){v=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&C.type==THREE.LineStrip?
b.LINE_STRIP:b.LINES;b.lineWidth(v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.drawElements(l,r.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,r.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,j,q,l,r,C,m){var t,v,s,n,E;s=0;for(n=l.materials.length;s<n;s++){t=l.materials[s];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=r.materials.length;t<v;t++)if((E=r.materials[t])&&E.blending==C&&
E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(e,j,q,E,r,l)}}else if((E=t)&&E.blending==C&&E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(e,j,q,E,r,l)}}};this.render=function(e,j,q,l){var r,C,m,t=e.lights,v=e.fog;this.initWebGLObjects(e);l=l!==undefined?l:true;if(q&&!q.__webGLFramebuffer){q.__webGLFramebuffer=b.createFramebuffer();q.__webGLRenderbuffer=b.createRenderbuffer();q.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,q.__webGLRenderbuffer);
b.LINE_STRIP:b.LINES;b.lineWidth(v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.drawElements(l,r.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,r.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,j,q,l,r,C,m){var t,v,s,n,E;s=0;for(n=l.materials.length;s<n;s++){t=l.materials[s];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=r.materials.length;t<v;t++)if((E=r.materials[t])&&E.blending==C&&
E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(f,j,q,E,r,l)}}else if((E=t)&&E.blending==C&&E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(f,j,q,E,r,l)}}};this.render=function(f,j,q,l){var r,C,m,t=f.lights,v=f.fog;this.initWebGLObjects(f);l=l!==undefined?l:true;if(q&&!q.__webGLFramebuffer){q.__webGLFramebuffer=b.createFramebuffer();q.__webGLRenderbuffer=b.createRenderbuffer();q.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,q.__webGLRenderbuffer);
b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,q.width,q.height);b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(q.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(q.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(q.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(q.min_filter));b.texImage2D(b.TEXTURE_2D,0,h(q.format),q.width,q.height,0,h(q.format),h(q.type),null);b.bindFramebuffer(b.FRAMEBUFFER,q.__webGLFramebuffer);
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,q.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,q.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(q){r=q.__webGLFramebuffer;m=q.width;C=q.height}else{r=null;m=o.width;C=o.height}if(r!=k){b.bindFramebuffer(b.FRAMEBUFFER,r);b.viewport(0,0,m,C);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=r}this.autoClear&&
this.clear();j.autoUpdateMatrix&&j.updateMatrix();u.set(j.matrix.flatten());H.set(j.projectionMatrix.flatten());l=0;for(r=e.__webGLObjects.length;l<r;l++){C=e.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,t,v,m,C,THREE.NormalBlending,false)}}l=0;for(r=e.__webGLObjects.length;l<r;l++){C=e.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,j);if(m.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);m.flipSided?b.frontFace(b.CW):
this.clear();j.autoUpdateMatrix&&j.updateMatrix();u.set(j.matrix.flatten());H.set(j.projectionMatrix.flatten());l=0;for(r=f.__webGLObjects.length;l<r;l++){C=f.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,t,v,m,C,THREE.NormalBlending,false)}}l=0;for(r=f.__webGLObjects.length;l<r;l++){C=f.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,j);if(m.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);m.flipSided?b.frontFace(b.CW):
b.frontFace(b.CCW)}this.renderPass(j,t,v,m,C,THREE.AdditiveBlending,false);this.renderPass(j,t,v,m,C,THREE.SubtractiveBlending,false);this.renderPass(j,t,v,m,C,THREE.AdditiveBlending,true);this.renderPass(j,t,v,m,C,THREE.SubtractiveBlending,true);this.renderPass(j,t,v,m,C,THREE.NormalBlending,true)}}if(q&&q.min_filter!==THREE.NearestFilter&&q.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
function(e){function j(s,n,E,A){if(s[n]==undefined){e.__webGLObjects.push({buffer:E,object:A});s[n]=1}}var q,l,r,C,m,t,v;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}q=0;for(l=e.objects.length;q<l;q++){r=e.objects[q];m=r.geometry;if(e.__webGLObjectsMap[r.id]==undefined)e.__webGLObjectsMap[r.id]={};v=e.__webGLObjectsMap[r.id];if(r instanceof THREE.Mesh){for(C in m.geometryChunks){t=m.geometryChunks[C];if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,r);
function(f){function j(s,n,E,A){if(s[n]==undefined){f.__webGLObjects.push({buffer:E,object:A});s[n]=1}}var q,l,r,C,m,t,v;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}q=0;for(l=f.objects.length;q<l;q++){r=f.objects[q];m=r.geometry;if(f.__webGLObjectsMap[r.id]==undefined)f.__webGLObjectsMap[r.id]={};v=f.__webGLObjectsMap[r.id];if(r instanceof THREE.Mesh){for(C in m.geometryChunks){t=m.geometryChunks[C];if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,r);
m.__dirtyVertices=true;m.__dirtyElements=true;m.__dirtyUvs=true;m.__dirtyNormals=true;m.__dirtyTangents=true}if(m.__dirtyVertices||m.__dirtyElements||m.__dirtyUvs)this.setMeshBuffers(t,r,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements,m.__dirtyUvs,m.__dirtyNormals,m.__dirtyTangents);j(v,C,t,r)}m.__dirtyVertices=false;m.__dirtyElements=false;m.__dirtyUvs=false;m.__dirtyNormals=false;m.__dirtyTangents=false}else if(r instanceof THREE.Line){if(!m.__webGLVertexBuffer){this.createLineBuffers(m);this.initLineBuffers(m);
m.__dirtyVertices=true;m.__dirtyElements=true}m.__dirtyVertices&&this.setLineBuffers(m,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements);j(v,0,m,r);m.__dirtyVertices=false;m.__dirtyElements=false}else if(r instanceof THREE.ParticleSystem){m.__webGLVertexBuffer||this.createParticleBuffers(m);j(v,0,m,r)}}};this.removeObject=function(e,j){var q,l;for(q=e.__webGLObjects.length-1;q>=0;q--){l=e.__webGLObjects[q].object;j==l&&e.__webGLObjects.splice(q,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&
e.updateMatrix();y.multiply(j.matrix,e.matrix);x.set(y.flatten());z=THREE.Matrix4.makeInvert3x3(y).transpose();J.set(z.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,u);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,H);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};this.loadCamera=function(e,j){b.uniform3f(e.uniforms.cameraPosition,
j.position.x,j.position.y,j.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,j){if(e){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
m.__dirtyVertices=true;m.__dirtyElements=true}m.__dirtyVertices&&this.setLineBuffers(m,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements);j(v,0,m,r);m.__dirtyVertices=false;m.__dirtyElements=false}else if(r instanceof THREE.ParticleSystem){m.__webGLVertexBuffer||this.createParticleBuffers(m);j(v,0,m,r)}}};this.removeObject=function(f,j){var q,l;for(q=f.__webGLObjects.length-1;q>=0;q--){l=f.__webGLObjects[q].object;j==l&&f.__webGLObjects.splice(q,1)}};this.setupMatrices=function(f,j){f.autoUpdateMatrix&&
f.updateMatrix();y.multiply(j.matrix,f.matrix);x.set(y.flatten());z=THREE.Matrix4.makeInvert3x3(y).transpose();J.set(z.m);K.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,u);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,H);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,J);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,K)};this.loadCamera=function(f,j){b.uniform3f(f.uniforms.cameraPosition,
j.position.x,j.position.y,j.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,j){if(f){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
+89 -89
View File
@@ -5,61 +5,61 @@ THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,o){return h.distance-o.distance});return g},intersectObject:function(a){function c(K,p,V,F){F=F.clone().subSelf(p);V=V.clone().subSelf(p);var e=K.clone().subSelf(p);K=F.dot(F);p=F.dot(V);F=F.dot(e);var k=V.dot(V);V=V.dot(e);e=1/(K*k-p*p);k=(k*F-p*V)*e;K=(K*V-p*F)*e;return k>0&&K>0&&k+K<1}var d,f,g,h,o,b,j,i,y,z,
u,x=a.geometry,H=x.vertices,J=[];d=0;for(f=x.faces.length;d<f;d++){g=x.faces[d];z=this.origin.clone();u=this.direction.clone();h=a.matrix.multiplyVector3(H[g.a].position.clone());o=a.matrix.multiplyVector3(H[g.b].position.clone());b=a.matrix.multiplyVector3(H[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(H[g.d].position.clone()):null;i=a.rotationMatrix.multiplyVector3(g.normal.clone());y=u.dot(i);if(y<0){i=i.dot((new THREE.Vector3).sub(h,z))/y;z=z.addSelf(u.multiplyScalar(i));
THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,g=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,o){return h.distance-o.distance});return g},intersectObject:function(a){function c(K,p,V,F){F=F.clone().subSelf(p);V=V.clone().subSelf(p);var f=K.clone().subSelf(p);K=F.dot(F);p=F.dot(V);F=F.dot(f);var k=V.dot(V);V=V.dot(f);f=1/(K*k-p*p);k=(k*F-p*V)*f;K=(K*V-p*F)*f;return k>0&&K>0&&k+K<1}var d,e,g,h,o,b,j,i,y,z,
u,x=a.geometry,H=x.vertices,J=[];d=0;for(e=x.faces.length;d<e;d++){g=x.faces[d];z=this.origin.clone();u=this.direction.clone();h=a.matrix.multiplyVector3(H[g.a].position.clone());o=a.matrix.multiplyVector3(H[g.b].position.clone());b=a.matrix.multiplyVector3(H[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(H[g.d].position.clone()):null;i=a.rotationMatrix.multiplyVector3(g.normal.clone());y=u.dot(i);if(y<0){i=i.dot((new THREE.Vector3).sub(h,z))/y;z=z.addSelf(u.multiplyScalar(i));
if(g instanceof THREE.Face3){if(c(z,h,o,b)){g={distance:this.origin.distanceTo(z),point:z,face:g,object:a};J.push(g)}}else if(g instanceof THREE.Face4)if(c(z,h,o,j)||c(z,o,b,j)){g={distance:this.origin.distanceTo(z),point:z,face:g,object:a};J.push(g)}}}return J}};
THREE.Rectangle=function(){function a(){h=f-c;o=g-d}var c,d,f,g,h,o,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return o};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(j,i,y,z){b=false;c=j;d=i;f=y;g=z;a()};this.addPoint=function(j,i){if(b){b=false;c=j;d=i;f=j;g=i}else{c=c<j?c:j;d=d<i?d:i;f=f>j?f:j;g=g>i?
g:i}a()};this.add3Points=function(j,i,y,z,u,x){if(b){b=false;c=j<y?j<u?j:u:y<u?y:u;d=i<z?i<x?i:x:z<x?z:x;f=j>y?j>u?j:u:y>u?y:u;g=i>z?i>x?i:x:z>x?z:x}else{c=j<y?j<u?j<c?j:c:u<c?u:c:y<u?y<c?y:c:u<c?u:c;d=i<z?i<x?i<d?i:d:x<d?x:d:z<x?z<d?z:d:x<d?x:d;f=j>y?j>u?j>f?j:f:u>f?u:f:y>u?y>f?y:f:u>f?u:f;g=i>z?i>x?i>g?i:g:x>g?x:g:z>x?z>g?z:g:x>g?x:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();f=j.getRight();g=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();d=d<j.getTop()?d:j.getTop();
f=f>j.getRight()?f:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;f+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();f=f<j.getRight()?f:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(f,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+h+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
THREE.Matrix4=function(a,c,d,f,g,h,o,b,j,i,y,z,u,x,H,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=h||1;this.n23=o||0;this.n24=b||0;this.n31=j||0;this.n32=i||0;this.n33=y||1;this.n34=z||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,f,g,h,o,b,j,i,y,z,u,x,H,J){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=h;this.n23=o;this.n24=b;this.n31=j;this.n32=i;this.n33=y;this.n34=z;this.n41=u;this.n42=x;this.n43=H;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,c).normalize();f.cross(d,h).normalize();g.cross(h,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;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 d=a.n11,f=a.n12,g=a.n13,h=a.n14,o=a.n21,b=a.n22,j=a.n23,i=a.n24,y=a.n31,
z=a.n32,u=a.n33,x=a.n34,H=a.n41,J=a.n42,K=a.n43,p=a.n44,V=c.n11,F=c.n12,e=c.n13,k=c.n14,q=c.n21,l=c.n22,r=c.n23,C=c.n24,m=c.n31,t=c.n32,v=c.n33,s=c.n34,n=c.n41,E=c.n42,B=c.n43,O=c.n44;this.n11=d*V+f*q+g*m+h*n;this.n12=d*F+f*l+g*t+h*E;this.n13=d*e+f*r+g*v+h*B;this.n14=d*k+f*C+g*s+h*O;this.n21=o*V+b*q+j*m+i*n;this.n22=o*F+b*l+j*t+i*E;this.n23=o*e+b*r+j*v+i*B;this.n24=o*k+b*C+j*s+i*O;this.n31=y*V+z*q+u*m+x*n;this.n32=y*F+z*l+u*t+x*E;this.n33=y*e+z*r+u*v+x*B;this.n34=y*k+z*C+u*s+x*O;this.n41=H*V+J*q+
K*m+p*n;this.n42=H*F+J*l+K*t+p*E;this.n43=H*e+J*r+K*v+p*B;this.n44=H*k+J*C+K*s+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,h=this.n21,o=this.n22,b=this.n23,j=this.n24,i=this.n31,y=this.n32,z=this.n33,u=this.n34,x=this.n41,H=this.n42,J=this.n43,K=this.n44,p=a.n11,V=a.n21,F=a.n31,e=a.n41,k=a.n12,q=a.n22,l=a.n32,r=a.n42,C=a.n13,m=a.n23,t=a.n33,v=a.n43,s=a.n14,n=a.n24,E=a.n34;a=a.n44;this.n11=c*p+d*V+f*F+g*e;this.n12=c*k+d*q+f*l+g*r;this.n13=c*C+d*m+f*t+g*
v;this.n14=c*s+d*n+f*E+g*a;this.n21=h*p+o*V+b*F+j*e;this.n22=h*k+o*q+b*l+j*r;this.n23=h*C+o*m+b*t+j*v;this.n24=h*s+o*n+b*E+j*a;this.n31=i*p+y*V+z*F+u*e;this.n32=i*k+y*q+z*l+u*r;this.n33=i*C+y*m+z*t+u*v;this.n34=i*s+y*n+z*E+u*a;this.n41=x*p+H*V+J*F+K*e;this.n42=x*k+H*q+J*l+K*r;this.n43=x*C+H*m+J*t+K*v;this.n44=x*s+H*n+J*E+K*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,d=this.n13,f=this.n14,g=this.n21,h=this.n22,o=this.n23,b=this.n24,j=this.n31,i=this.n32,y=this.n33,z=this.n34,u=this.n41,x=this.n42,H=this.n43,J=this.n44;return f*o*i*u-d*b*i*u-f*h*y*u+c*b*y*u+d*h*z*u-c*o*z*u-f*o*j*x+d*b*j*x+f*g*y*x-a*b*y*x-d*g*z*x+a*o*z*x+f*h*j*H-c*b*j*H-f*g*i*H+a*b*i*H+c*g*z*H-a*h*z*H-d*h*j*J+c*o*j*J+d*g*i*J-a*o*i*J-c*g*y*J+a*h*y*J},transpose:function(){function a(c,d,
f){var g=c[d];c[d]=c[f];c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},
setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),g=1-d,h=a.x,o=a.y,b=a.z,j=g*h,i=g*o;this.set(j*h+d,j*o-f*b,j*b+f*o,0,j*o+f*b,i*o+d,i*b-f*h,0,j*b-f*o,i*b+f*h,g*b*b+d,0,0,
0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};
THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,o=a.n22,b=a.n23,j=a.n24,i=a.n31,y=a.n32,z=a.n33,u=a.n34,x=a.n41,H=a.n42,J=a.n43,K=a.n44,p=new THREE.Matrix4;p.n11=b*u*H-j*z*H+j*y*J-o*u*J-b*y*K+o*z*K;p.n12=g*z*H-f*u*H-g*y*J+d*u*J+f*y*K-d*z*K;p.n13=f*j*H-g*b*H+g*o*J-d*j*J-f*o*K+d*b*K;p.n14=g*b*y-f*j*y-g*o*z+d*j*z+f*o*u-d*b*u;p.n21=j*z*x-b*u*x-j*i*J+h*u*J+b*i*K-h*z*K;p.n22=f*u*x-g*z*x+g*i*J-c*u*J-f*i*K+c*z*K;p.n23=g*b*x-f*j*x-g*h*J+c*j*J+f*h*K-c*b*K;p.n24=f*j*i-g*b*i+
g*h*z-c*j*z-f*h*u+c*b*u;p.n31=o*u*x-j*y*x+j*i*H-h*u*H-o*i*K+h*y*K;p.n32=g*y*x-d*u*x-g*i*H+c*u*H+d*i*K-c*y*K;p.n33=f*j*x-g*o*x+g*h*H-c*j*H-d*h*K+c*o*K;p.n34=g*o*i-d*j*i-g*h*y+c*j*y+d*h*u-c*o*u;p.n41=b*y*x-o*z*x-b*i*H+h*z*H+o*i*J-h*y*J;p.n42=d*z*x-f*y*x+f*i*H-c*z*H-d*i*J+c*y*J;p.n43=f*o*x-d*b*x-f*h*H+c*b*H+d*h*J-c*o*J;p.n44=d*b*i-f*o*i+f*h*y-c*b*y-d*h*z+c*o*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],j=c[9]*c[4]-c[5]*c[8],i=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*h+c[2]*j;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*f;a.m[2]=c*g;a.m[3]=c*h;a.m[4]=c*o;a.m[5]=c*b;a.m[6]=c*j;a.m[7]=c*i;a.m[8]=c*y;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,f,g,h){var o,b,j;o=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(h+g)/(h-g);g=-2*h*g/(h-g);o.n11=b;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=j;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=f;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,g,h){var o,b,j,i;o=new THREE.Matrix4;b=c-a;j=d-f;i=h-g;a=(c+a)/b;d=(d+f)/j;g=(h+g)/i;o.n11=2/b;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/j;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/i;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Rectangle=function(){function a(){h=e-c;o=g-d}var c,d,e,g,h,o,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return o};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,i,y,z){b=false;c=j;d=i;e=y;g=z;a()};this.addPoint=function(j,i){if(b){b=false;c=j;d=i;e=j;g=i}else{c=c<j?c:j;d=d<i?d:i;e=e>j?e:j;g=g>i?
g:i}a()};this.add3Points=function(j,i,y,z,u,x){if(b){b=false;c=j<y?j<u?j:u:y<u?y:u;d=i<z?i<x?i:x:z<x?z:x;e=j>y?j>u?j:u:y>u?y:u;g=i>z?i>x?i:x:z>x?z:x}else{c=j<y?j<u?j<c?j:c:u<c?u:c:y<u?y<c?y:c:u<c?u:c;d=i<z?i<x?i<d?i:d:x<d?x:d:z<x?z<d?z:d:x<d?x:d;e=j>y?j>u?j>e?j:e:u>e?u:e:y>u?y>e?y:e:u>e?u:e;g=i>z?i>x?i>g?i:g:x>g?x:g:z>x?z>g?z:g:x>g?x:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();d=d<j.getTop()?d:j.getTop();
e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+h+", height: "+o+" )"}};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}};
THREE.Matrix4=function(a,c,d,e,g,h,o,b,j,i,y,z,u,x,H,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=o||0;this.n24=b||0;this.n31=j||0;this.n32=i||0;this.n33=y||1;this.n34=z||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,g,h,o,b,j,i,y,z,u,x,H,J){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=o;this.n24=b;this.n31=j;this.n32=i;this.n33=y;this.n34=z;this.n41=u;this.n42=x;this.n43=H;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,c).normalize();e.cross(d,h).normalize();g.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;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 d=a.n11,e=a.n12,g=a.n13,h=a.n14,o=a.n21,b=a.n22,j=a.n23,i=a.n24,y=a.n31,
z=a.n32,u=a.n33,x=a.n34,H=a.n41,J=a.n42,K=a.n43,p=a.n44,V=c.n11,F=c.n12,f=c.n13,k=c.n14,q=c.n21,l=c.n22,r=c.n23,C=c.n24,m=c.n31,t=c.n32,v=c.n33,s=c.n34,n=c.n41,E=c.n42,B=c.n43,O=c.n44;this.n11=d*V+e*q+g*m+h*n;this.n12=d*F+e*l+g*t+h*E;this.n13=d*f+e*r+g*v+h*B;this.n14=d*k+e*C+g*s+h*O;this.n21=o*V+b*q+j*m+i*n;this.n22=o*F+b*l+j*t+i*E;this.n23=o*f+b*r+j*v+i*B;this.n24=o*k+b*C+j*s+i*O;this.n31=y*V+z*q+u*m+x*n;this.n32=y*F+z*l+u*t+x*E;this.n33=y*f+z*r+u*v+x*B;this.n34=y*k+z*C+u*s+x*O;this.n41=H*V+J*q+
K*m+p*n;this.n42=H*F+J*l+K*t+p*E;this.n43=H*f+J*r+K*v+p*B;this.n44=H*k+J*C+K*s+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,o=this.n22,b=this.n23,j=this.n24,i=this.n31,y=this.n32,z=this.n33,u=this.n34,x=this.n41,H=this.n42,J=this.n43,K=this.n44,p=a.n11,V=a.n21,F=a.n31,f=a.n41,k=a.n12,q=a.n22,l=a.n32,r=a.n42,C=a.n13,m=a.n23,t=a.n33,v=a.n43,s=a.n14,n=a.n24,E=a.n34;a=a.n44;this.n11=c*p+d*V+e*F+g*f;this.n12=c*k+d*q+e*l+g*r;this.n13=c*C+d*m+e*t+g*
v;this.n14=c*s+d*n+e*E+g*a;this.n21=h*p+o*V+b*F+j*f;this.n22=h*k+o*q+b*l+j*r;this.n23=h*C+o*m+b*t+j*v;this.n24=h*s+o*n+b*E+j*a;this.n31=i*p+y*V+z*F+u*f;this.n32=i*k+y*q+z*l+u*r;this.n33=i*C+y*m+z*t+u*v;this.n34=i*s+y*n+z*E+u*a;this.n41=x*p+H*V+J*F+K*f;this.n42=x*k+H*q+J*l+K*r;this.n43=x*C+H*m+J*t+K*v;this.n44=x*s+H*n+J*E+K*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,d=this.n13,e=this.n14,g=this.n21,h=this.n22,o=this.n23,b=this.n24,j=this.n31,i=this.n32,y=this.n33,z=this.n34,u=this.n41,x=this.n42,H=this.n43,J=this.n44;return e*o*i*u-d*b*i*u-e*h*y*u+c*b*y*u+d*h*z*u-c*o*z*u-e*o*j*x+d*b*j*x+e*g*y*x-a*b*y*x-d*g*z*x+a*o*z*x+e*h*j*H-c*b*j*H-e*g*i*H+a*b*i*H+c*g*z*H-a*h*z*H-d*h*j*J+c*o*j*J+d*g*i*J-a*o*i*J-c*g*y*J+a*h*y*J},transpose:function(){function a(c,d,
e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,h=a.x,o=a.y,b=a.z,j=g*h,i=g*o;this.set(j*h+d,j*o-e*b,j*b+e*o,0,j*o+e*b,i*o+d,i*b-e*h,0,j*b-e*o,i*b+e*h,g*b*b+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,o=a.n22,b=a.n23,j=a.n24,i=a.n31,y=a.n32,z=a.n33,u=a.n34,x=a.n41,H=a.n42,J=a.n43,K=a.n44,p=new THREE.Matrix4;p.n11=b*u*H-j*z*H+j*y*J-o*u*J-b*y*K+o*z*K;p.n12=g*z*H-e*u*H-g*y*J+d*u*J+e*y*K-d*z*K;p.n13=e*j*H-g*b*H+g*o*J-d*j*J-e*o*K+d*b*K;p.n14=g*b*y-e*j*y-g*o*z+d*j*z+e*o*u-d*b*u;p.n21=j*z*x-b*u*x-j*i*J+h*u*J+b*i*K-h*z*K;p.n22=e*u*x-g*z*x+g*i*J-c*u*J-e*i*K+c*z*K;p.n23=g*b*x-e*j*x-g*h*J+c*j*J+e*h*K-c*b*K;p.n24=e*j*i-g*b*i+
g*h*z-c*j*z-e*h*u+c*b*u;p.n31=o*u*x-j*y*x+j*i*H-h*u*H-o*i*K+h*y*K;p.n32=g*y*x-d*u*x-g*i*H+c*u*H+d*i*K-c*y*K;p.n33=e*j*x-g*o*x+g*h*H-c*j*H-d*h*K+c*o*K;p.n34=g*o*i-d*j*i-g*h*y+c*j*y+d*h*u-c*o*u;p.n41=b*y*x-o*z*x-b*i*H+h*z*H+o*i*J-h*y*J;p.n42=d*z*x-e*y*x+e*i*H-c*z*H-d*i*J+c*y*J;p.n43=e*o*x-d*b*x-e*h*H+c*b*H+d*h*J-c*o*J;p.n44=d*b*i-e*o*i+e*h*y-c*b*y-d*h*z+c*o*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],g=-c[10]*c[1]+c[2]*c[9],h=c[6]*c[1]-c[2]*c[5],o=-c[10]*c[4]+c[6]*c[8],b=c[10]*c[0]-c[2]*c[8],j=-c[6]*c[0]+c[2]*c[4],i=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],z=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*o+c[2]*i;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*g;d[2]=c*h;d[3]=c*o;d[4]=c*b;d[5]=c*j;d[6]=c*i;d[7]=c*y;d[8]=c*z;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,e,g,h){var o,b,j;o=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(h+g)/(h-g);g=-2*h*g/(h-g);o.n11=b;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=j;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)};
THREE.Matrix4.makeOrtho=function(a,c,d,e,g,h){var o,b,j,i;o=new THREE.Matrix4;b=c-a;j=d-e;i=h-g;a=(c+a)/b;d=(d+e)/j;g=(h+g)/i;o.n11=2/b;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/j;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/i;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
THREE.Face3=function(a,c,d,f,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,g,h){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.Face3=function(a,c,d,e,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,e,g,h){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,h,o,b=new THREE.Vector3,j=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){h=this.vertices[f];h.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(a&&h.vertexNormals.length){b.set(0,0,0);c=0;for(d=h.normal.length;c<d;c++)b.addSelf(h.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[h.a];d=this.vertices[h.b];o=this.vertices[h.c];b.sub(o.position,
d.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();h.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(s,n,E,B,O,N,G){h=s.vertices[n].position;o=s.vertices[E].position;b=s.vertices[B].position;j=g[O];i=g[N];y=g[G];z=o.x-h.x;u=b.x-h.x;x=o.y-h.y;H=b.y-h.y;
J=o.z-h.z;K=b.z-h.z;p=i.u-j.u;V=y.u-j.u;F=i.v-j.v;e=y.v-j.v;k=1/(p*e-V*F);r.set((e*z-F*u)*k,(e*x-F*H)*k,(e*J-F*K)*k);C.set((p*u-V*z)*k,(p*H-V*x)*k,(p*K-V*J)*k);q[n].addSelf(r);q[E].addSelf(r);q[B].addSelf(r);l[n].addSelf(C);l[E].addSelf(C);l[B].addSelf(C)}var c,d,f,g,h,o,b,j,i,y,z,u,x,H,J,K,p,V,F,e,k,q=[],l=[],r=new THREE.Vector3,C=new THREE.Vector3,m=new THREE.Vector3,t=new THREE.Vector3,v=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;l[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){v.copy(this.vertices[c].normal);f=q[c];m.copy(f);m.subSelf(v.multiplyScalar(v.dot(f))).normalize();t.cross(this.vertices[c].normal,f);f=t.dot(l[c]);f=f<0?-1:1;this.vertices[c].tangent.set(m.x,m.y,m.z,f)}this.hasTangents=true},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],
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,h,o,b=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){b.set(0,0,0);c=0;for(d=h.normal.length;c<d;c++)b.addSelf(h.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[h.a];d=this.vertices[h.b];o=this.vertices[h.c];b.sub(o.position,
d.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();h.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(s,n,E,B,O,N,G){h=s.vertices[n].position;o=s.vertices[E].position;b=s.vertices[B].position;j=g[O];i=g[N];y=g[G];z=o.x-h.x;u=b.x-h.x;x=o.y-h.y;H=b.y-h.y;
J=o.z-h.z;K=b.z-h.z;p=i.u-j.u;V=y.u-j.u;F=i.v-j.v;f=y.v-j.v;k=1/(p*f-V*F);r.set((f*z-F*u)*k,(f*x-F*H)*k,(f*J-F*K)*k);C.set((p*u-V*z)*k,(p*H-V*x)*k,(p*K-V*J)*k);q[n].addSelf(r);q[E].addSelf(r);q[B].addSelf(r);l[n].addSelf(C);l[E].addSelf(C);l[B].addSelf(C)}var c,d,e,g,h,o,b,j,i,y,z,u,x,H,J,K,p,V,F,f,k,q=[],l=[],r=new THREE.Vector3,C=new THREE.Vector3,m=new THREE.Vector3,t=new THREE.Vector3,v=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;l[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){e=this.faces[c];g=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){v.copy(this.vertices[c].normal);e=q[c];m.copy(e);m.subSelf(v.multiplyScalar(v.dot(e))).normalize();t.cross(this.vertices[c].normal,e);e=t.dot(l[c]);e=e<0?-1:1;this.vertices[c].tangent.set(m.x,m.y,m.z,e)}this.hasTangents=true},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,d=this.vertices.length;c<d;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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var z=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?z.push("undefined"):z.push(y[c].toString());return z.join("_")}var c,d,f,g,h,o,b,j,i={};f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];
o=h.materials;b=a(o);if(i[b]==undefined)i[b]={hash:b,counter:0};j=i[b].hash+"_"+i[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:o,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+h>65535){i[b].counter+=1;j=i[b].hash+"_"+i[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:o,vertices:0}}this.geometryChunks[j].faces.push(f);this.geometryChunks[j].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var z=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?z.push("undefined"):z.push(y[c].toString());return z.join("_")}var c,d,e,g,h,o,b,j,i={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
o=h.materials;b=a(o);if(i[b]==undefined)i[b]={hash:b,counter:0};j=i[b].hash+"_"+i[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:o,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+h>65535){i[b].counter+=1;j=i[b].hash+"_"+i[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:o,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};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.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
@@ -89,101 +89,101 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
THREE.Texture=function(a,c,d,f,g,h){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture=function(a,c,d,e,g,h){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,d,f,g={};for(c in a){g[c]={};for(d in a[c]){f=a[c][d];g[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var c,d,f,g={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)g[d]=f[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]){e=a[c][d];g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var c,d,e,g={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)g[d]=e[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(l,r){return r.z-l.z}function c(l,r){var C=0,m=1,t=l.z+l.w,v=r.z+r.w,s=-l.z+l.w,n=-r.z+r.w;if(t>=0&&v>=0&&s>=0&&n>=0)return true;else if(t<0&&v<0||s<0&&n<0)return false;else{if(t<0)C=Math.max(C,t/(t-v));else if(v<0)m=Math.min(m,t/(t-v));if(s<0)C=Math.max(C,s/(s-n));else if(n<0)m=Math.min(m,s/(s-n));if(m<C)return false;else{l.lerpSelf(r,C);r.lerpSelf(l,1-m);return true}}}var d,f,g=[],h,o,b,j=[],i,y,z=[],u,x,H=[],J=new THREE.Vector4,K=new THREE.Vector4,p=new THREE.Matrix4,
V=new THREE.Matrix4,F=[],e=new THREE.Vector4,k=new THREE.Vector4,q;this.projectObjects=function(l,r,C){var m=[],t,v;f=0;p.multiply(r.projectionMatrix,r.matrix);F[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);F[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);F[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);F[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);F[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
THREE.Projector=function(){function a(l,r){return r.z-l.z}function c(l,r){var C=0,m=1,t=l.z+l.w,v=r.z+r.w,s=-l.z+l.w,n=-r.z+r.w;if(t>=0&&v>=0&&s>=0&&n>=0)return true;else if(t<0&&v<0||s<0&&n<0)return false;else{if(t<0)C=Math.max(C,t/(t-v));else if(v<0)m=Math.min(m,t/(t-v));if(s<0)C=Math.max(C,s/(s-n));else if(n<0)m=Math.min(m,s/(s-n));if(m<C)return false;else{l.lerpSelf(r,C);r.lerpSelf(l,1-m);return true}}}var d,e,g=[],h,o,b,j=[],i,y,z=[],u,x,H=[],J=new THREE.Vector4,K=new THREE.Vector4,p=new THREE.Matrix4,
V=new THREE.Matrix4,F=[],f=new THREE.Vector4,k=new THREE.Vector4,q;this.projectObjects=function(l,r,C){var m=[],t,v;e=0;p.multiply(r.projectionMatrix,r.matrix);F[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);F[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);F[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);F[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);F[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
p.n33,p.n44-p.n34);F[5]=new THREE.Vector4(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);r=0;for(t=F.length;r<t;r++){v=F[r];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}t=l.objects;l=0;for(r=t.length;l<r;l++){v=t[l];var s;if(!(s=!v.visible)){if(s=v instanceof THREE.Mesh){a:{s=void 0;for(var n=v.position,E=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),B=0;B<6;B++){s=F[B].x*n.x+F[B].y*n.y+F[B].z*n.z+F[B].w;if(s<=E){s=false;break a}}s=true}s=!s}s=s}if(!s){d=
g[f]=g[f]||new THREE.RenderableObject;J.copy(v.position);p.multiplyVector3(J);d.object=v;d.z=J.z;m.push(d);f++}}C&&m.sort(a);return m};this.projectScene=function(l,r,C){var m=[],t=r.near,v=r.far,s,n,E,B,O,N,G,W,P,I,L,T,Q,w,M,R;b=y=x=0;r.autoUpdateMatrix&&r.updateMatrix();p.multiply(r.projectionMatrix,r.matrix);N=this.projectObjects(l,r,true);l=0;for(s=N.length;l<s;l++){G=N[l].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();W=G.matrix;P=G.rotationMatrix;I=G.materials;L=G.overdraw;if(G instanceof
g[e]=g[e]||new THREE.RenderableObject;J.copy(v.position);p.multiplyVector3(J);d.object=v;d.z=J.z;m.push(d);e++}}C&&m.sort(a);return m};this.projectScene=function(l,r,C){var m=[],t=r.near,v=r.far,s,n,E,B,O,N,G,W,P,I,L,T,Q,w,M,R;b=y=x=0;r.autoUpdateMatrix&&r.updateMatrix();p.multiply(r.projectionMatrix,r.matrix);N=this.projectObjects(l,r,true);l=0;for(s=N.length;l<s;l++){G=N[l].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();W=G.matrix;P=G.rotationMatrix;I=G.materials;L=G.overdraw;if(G instanceof
THREE.Mesh){T=G.geometry;Q=T.vertices;n=0;for(E=Q.length;n<E;n++){w=Q[n];w.positionWorld.copy(w.position);W.multiplyVector3(w.positionWorld);B=w.positionScreen;B.copy(w.positionWorld);p.multiplyVector4(B);B.x/=B.w;B.y/=B.w;w.__visible=B.z>t&&B.z<v}T=T.faces;n=0;for(E=T.length;n<E;n++){w=T[n];if(w instanceof THREE.Face3){B=Q[w.a];O=Q[w.b];M=Q[w.c];if(B.__visible&&O.__visible&&M.__visible)if(G.doubleSided||G.flipSided!=(M.positionScreen.x-B.positionScreen.x)*(O.positionScreen.y-B.positionScreen.y)-
(M.positionScreen.y-B.positionScreen.y)*(O.positionScreen.x-B.positionScreen.x)<0){h=j[b]=j[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(B.positionWorld);h.v2.positionWorld.copy(O.positionWorld);h.v3.positionWorld.copy(M.positionWorld);h.v1.positionScreen.copy(B.positionScreen);h.v2.positionScreen.copy(O.positionScreen);h.v3.positionScreen.copy(M.positionScreen);h.normalWorld.copy(w.normal);P.multiplyVector3(h.normalWorld);h.centroidWorld.copy(w.centroid);W.multiplyVector3(h.centroidWorld);
h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);M=w.vertexNormals;q=h.vertexNormalsWorld;B=0;for(O=M.length;B<O;B++){R=q[B]=q[B]||new THREE.Vector3;R.copy(M[B]);P.multiplyVector3(R)}h.z=h.centroidScreen.z;h.meshMaterials=I;h.faceMaterials=w.materials;h.overdraw=L;if(G.geometry.uvs[n]){h.uvs[0]=G.geometry.uvs[n][0];h.uvs[1]=G.geometry.uvs[n][1];h.uvs[2]=G.geometry.uvs[n][2]}m.push(h);b++}}else if(w instanceof THREE.Face4){B=Q[w.a];O=Q[w.b];M=Q[w.c];R=Q[w.d];if(B.__visible&&
O.__visible&&M.__visible&&R.__visible)if(G.doubleSided||G.flipSided!=((R.positionScreen.x-B.positionScreen.x)*(O.positionScreen.y-B.positionScreen.y)-(R.positionScreen.y-B.positionScreen.y)*(O.positionScreen.x-B.positionScreen.x)<0||(O.positionScreen.x-M.positionScreen.x)*(R.positionScreen.y-M.positionScreen.y)-(O.positionScreen.y-M.positionScreen.y)*(R.positionScreen.x-M.positionScreen.x)<0)){h=j[b]=j[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(B.positionWorld);h.v2.positionWorld.copy(O.positionWorld);
h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(B.positionScreen);h.v2.positionScreen.copy(O.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(w.normal);P.multiplyVector3(h.normalWorld);h.centroidWorld.copy(w.centroid);W.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=I;h.faceMaterials=w.materials;h.overdraw=L;if(G.geometry.uvs[n]){h.uvs[0]=G.geometry.uvs[n][0];
h.uvs[1]=G.geometry.uvs[n][1];h.uvs[2]=G.geometry.uvs[n][3]}m.push(h);b++;o=j[b]=j[b]||new THREE.RenderableFace3;o.v1.positionWorld.copy(O.positionWorld);o.v2.positionWorld.copy(M.positionWorld);o.v3.positionWorld.copy(R.positionWorld);o.v1.positionScreen.copy(O.positionScreen);o.v2.positionScreen.copy(M.positionScreen);o.v3.positionScreen.copy(R.positionScreen);o.normalWorld.copy(h.normalWorld);o.centroidWorld.copy(h.centroidWorld);o.centroidScreen.copy(h.centroidScreen);o.z=o.centroidScreen.z;o.meshMaterials=
I;o.faceMaterials=w.materials;o.overdraw=L;if(G.geometry.uvs[n]){o.uvs[0]=G.geometry.uvs[n][1];o.uvs[1]=G.geometry.uvs[n][2];o.uvs[2]=G.geometry.uvs[n][3]}m.push(o);b++}}}}else if(G instanceof THREE.Line){V.multiply(p,W);Q=G.geometry.vertices;w=Q[0];w.positionScreen.copy(w.position);V.multiplyVector4(w.positionScreen);n=1;for(E=Q.length;n<E;n++){B=Q[n];B.positionScreen.copy(B.position);V.multiplyVector4(B.positionScreen);O=Q[n-1];e.copy(B.positionScreen);k.copy(O.positionScreen);if(c(e,k)){e.multiplyScalar(1/
e.w);k.multiplyScalar(1/k.w);i=z[y]=z[y]||new THREE.RenderableLine;i.v1.positionScreen.copy(e);i.v2.positionScreen.copy(k);i.z=Math.max(e.z,k.z);i.materials=G.materials;m.push(i);y++}}}else if(G instanceof THREE.Particle){K.set(G.position.x,G.position.y,G.position.z,1);p.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=K.x/K.w;u.y=K.y/K.w;u.z=K.z;u.rotation=G.rotation.z;u.scale.x=G.scale.x*Math.abs(u.x-(K.x+r.projectionMatrix.n11)/(K.w+r.projectionMatrix.n14));
u.scale.y=G.scale.y*Math.abs(u.y-(K.y+r.projectionMatrix.n22)/(K.w+r.projectionMatrix.n24));u.materials=G.materials;m.push(u);x++}}}}C&&m.sort(a);return m};this.unprojectVector=function(l,r){var C=new THREE.Matrix4;C.multiply(THREE.Matrix4.makeInvert(r.matrix),THREE.Matrix4.makeInvert(r.projectionMatrix));C.multiplyVector3(l);return l}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,h;this.domElement=document.createElement("div");this.setSize=function(o,b){d=o;f=b;g=d/2;h=f/2};this.render=function(o,b){var j,i,y,z,u,x,H,J;a=c.projectScene(o,b);j=0;for(i=a.length;j<i;j++){u=a[j];if(u instanceof THREE.RenderableParticle){H=u.x*g+g;J=u.y*h+h;y=0;for(z=u.material.length;y<z;y++){x=u.material[y];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=J+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(u!=da)i.globalAlpha=u=da}function c(da){if(x!=da){switch(da){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}x=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),h,o,b,j,i=g.getContext("2d"),y=null,z=null,u=1,x=0,H=null,J=null,K=1,p,V,F,e,k,q,l,r,C,m=new THREE.Color,
I;o.faceMaterials=w.materials;o.overdraw=L;if(G.geometry.uvs[n]){o.uvs[0]=G.geometry.uvs[n][1];o.uvs[1]=G.geometry.uvs[n][2];o.uvs[2]=G.geometry.uvs[n][3]}m.push(o);b++}}}}else if(G instanceof THREE.Line){V.multiply(p,W);Q=G.geometry.vertices;w=Q[0];w.positionScreen.copy(w.position);V.multiplyVector4(w.positionScreen);n=1;for(E=Q.length;n<E;n++){B=Q[n];B.positionScreen.copy(B.position);V.multiplyVector4(B.positionScreen);O=Q[n-1];f.copy(B.positionScreen);k.copy(O.positionScreen);if(c(f,k)){f.multiplyScalar(1/
f.w);k.multiplyScalar(1/k.w);i=z[y]=z[y]||new THREE.RenderableLine;i.v1.positionScreen.copy(f);i.v2.positionScreen.copy(k);i.z=Math.max(f.z,k.z);i.materials=G.materials;m.push(i);y++}}}else if(G instanceof THREE.Particle){K.set(G.position.x,G.position.y,G.position.z,1);p.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=K.x/K.w;u.y=K.y/K.w;u.z=K.z;u.rotation=G.rotation.z;u.scale.x=G.scale.x*Math.abs(u.x-(K.x+r.projectionMatrix.n11)/(K.w+r.projectionMatrix.n14));
u.scale.y=G.scale.y*Math.abs(u.y-(K.y+r.projectionMatrix.n22)/(K.w+r.projectionMatrix.n24));u.materials=G.materials;m.push(u);x++}}}}C&&m.sort(a);return m};this.unprojectVector=function(l,r){var C=THREE.Matrix4.makeInvert(r.matrix);C.multiplySelf(THREE.Matrix4.makeInvert(r.projectionMatrix));C.multiplyVector3(l);return l}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(o,b){d=o;e=b;g=d/2;h=e/2};this.render=function(o,b){var j,i,y,z,u,x,H,J;a=c.projectScene(o,b);j=0;for(i=a.length;j<i;j++){u=a[j];if(u instanceof THREE.RenderableParticle){H=u.x*g+g;J=u.y*h+h;y=0;for(z=u.material.length;y<z;y++){x=u.material[y];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=J+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(u!=da)i.globalAlpha=u=da}function c(da){if(x!=da){switch(da){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}x=da}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),h,o,b,j,i=g.getContext("2d"),y=null,z=null,u=1,x=0,H=null,J=null,K=1,p,V,F,f,k,q,l,r,C,m=new THREE.Color,
t=new THREE.Color,v=new THREE.Color,s=new THREE.Color,n=new THREE.Color,E,B,O,N,G,W,P,I,L,T=new THREE.Rectangle,Q=new THREE.Rectangle,w=new THREE.Rectangle,M=false,R=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Z=new THREE.Color,ja=Math.PI*2,Y=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){h=da;o=ra;b=h/2;j=o/2;g.width=h;g.height=o;T.set(-b,-j,b,j);u=1;x=0;J=H=null;K=1};this.setClearColor=function(da,ra){y=da!==null?new THREE.Color(da):null;z=ra;Q.set(-b,-j,b,j);i.setTransform(1,0,0,-1,b,j);this.clear()};this.clear=function(){if(!Q.isEmpty()){Q.inflate(1);Q.minSelf(T);if(y!==null){c(THREE.NormalBlending);
a(1);i.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+z+")";i.fillRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight())}else i.clearRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());Q.empty()}};this.render=function(da,ra){function Ma(A){var X,U,D,S=A.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Z.setRGB(0,0,0);A=0;for(X=S.length;A<X;A++){U=S[A];D=U.color;if(U instanceof THREE.AmbientLight){ea.r+=D.r;ea.g+=D.g;ea.b+=D.b}else if(U instanceof THREE.DirectionalLight){ba.r+=
D.r;ba.g+=D.g;ba.b+=D.b}else if(U instanceof THREE.PointLight){Z.r+=D.r;Z.g+=D.g;Z.b+=D.b}}}function Aa(A,X,U,D){var S,$,ca,ga,ia=A.lights;A=0;for(S=ia.length;A<S;A++){$=ia[A];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=U.dot($.position)*ga;if($>0){D.r+=ca.r*$;D.g+=ca.g*$;D.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=U.dot(Y)*ga;if($>0){D.r+=ca.r*$;D.g+=ca.g*$;D.b+=ca.b*$}}}}function Na(A,X,U){if(U.opacity!=0){a(U.opacity);c(U.blending);
var D,S,$,ca,ga,ia;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){ca=U.map;ga=ca.width>>1;ia=ca.height>>1;S=X.scale.x*b;$=X.scale.y*j;U=S*ga;D=$*ia;w.set(A.x-U,A.y-D,A.x+U,A.y+D);if(!T.instersects(w))return;i.save();i.translate(A.x,A.y);i.rotate(-X.rotation);i.scale(S,-$);i.translate(-ga,-ia);i.drawImage(ca,0,0);i.restore()}i.beginPath();i.moveTo(A.x-10,A.y);i.lineTo(A.x+10,A.y);i.moveTo(A.x,A.y-10);i.lineTo(A.x,A.y+10);i.closePath();i.strokeStyle="rgb(255,255,0)";i.stroke()}else if(U instanceof
THREE.ParticleCircleMaterial){if(M){R.r=ea.r+ba.r+Z.r;R.g=ea.g+ba.g+Z.g;R.b=ea.b+ba.b+Z.b;m.r=U.color.r*R.r;m.g=U.color.g*R.g;m.b=U.color.b*R.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;U=X.scale.x*b;D=X.scale.y*j;w.set(A.x-U,A.y-D,A.x+U,A.y+D);if(T.instersects(w)){S=m.__styleString;if(J!=S)i.fillStyle=J=S;i.save();i.translate(A.x,A.y);i.rotate(-X.rotation);i.scale(U,D);i.beginPath();i.arc(0,0,1,0,ja,true);i.closePath();i.fill();i.restore()}}}}function Oa(A,X,U,D){if(D.opacity!=
0){a(D.opacity);c(D.blending);i.beginPath();i.moveTo(A.positionScreen.x,A.positionScreen.y);i.lineTo(X.positionScreen.x,X.positionScreen.y);i.closePath();if(D instanceof THREE.LineBasicMaterial){m.__styleString=D.color.__styleString;A=D.linewidth;if(K!=A)i.lineWidth=K=A;A=m.__styleString;if(H!=A)i.strokeStyle=H=A;i.stroke();w.inflate(D.linewidth*2)}}}function Ia(A,X,U,D,S,$){if(S.opacity!=0){a(S.opacity);c(S.blending);e=A.positionScreen.x;k=A.positionScreen.y;q=X.positionScreen.x;l=X.positionScreen.y;
r=U.positionScreen.x;C=U.positionScreen.y;i.beginPath();i.moveTo(e,k);i.lineTo(q,l);i.lineTo(r,C);i.lineTo(e,k);i.closePath();if(S instanceof THREE.MeshBasicMaterial)if(S.map)S.map.image.loaded&&S.map.mapping instanceof THREE.UVMapping&&xa(e,k,q,l,r,C,S.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(S.env_map){if(S.env_map.image.loaded)if(S.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ra.matrix;Y.copy(D.vertexNormalsWorld[0]);N=(Y.x*A.n11+Y.y*
A.n12+Y.z*A.n13)*0.5+0.5;G=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[1]);W=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;P=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[2]);I=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;L=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;xa(e,k,q,l,r,C,S.env_map.image,N,G,W,P,I,L)}}else S.wireframe?Ba(S.color.__styleString,S.wireframe_linewidth):Ca(S.color.__styleString);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){S.map.mapping instanceof
THREE.UVMapping&&xa(e,k,q,l,r,C,S.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!S.wireframe&&S.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){t.r=v.r=s.r=ea.r;t.g=v.g=s.g=ea.g;t.b=v.b=s.b=ea.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],t);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],v);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],s);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(e,
0){a(D.opacity);c(D.blending);i.beginPath();i.moveTo(A.positionScreen.x,A.positionScreen.y);i.lineTo(X.positionScreen.x,X.positionScreen.y);i.closePath();if(D instanceof THREE.LineBasicMaterial){m.__styleString=D.color.__styleString;A=D.linewidth;if(K!=A)i.lineWidth=K=A;A=m.__styleString;if(H!=A)i.strokeStyle=H=A;i.stroke();w.inflate(D.linewidth*2)}}}function Ia(A,X,U,D,S,$){if(S.opacity!=0){a(S.opacity);c(S.blending);f=A.positionScreen.x;k=A.positionScreen.y;q=X.positionScreen.x;l=X.positionScreen.y;
r=U.positionScreen.x;C=U.positionScreen.y;i.beginPath();i.moveTo(f,k);i.lineTo(q,l);i.lineTo(r,C);i.lineTo(f,k);i.closePath();if(S instanceof THREE.MeshBasicMaterial)if(S.map)S.map.image.loaded&&S.map.mapping instanceof THREE.UVMapping&&xa(f,k,q,l,r,C,S.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(S.env_map){if(S.env_map.image.loaded)if(S.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ra.matrix;Y.copy(D.vertexNormalsWorld[0]);N=(Y.x*A.n11+Y.y*
A.n12+Y.z*A.n13)*0.5+0.5;G=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[1]);W=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;P=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(D.vertexNormalsWorld[2]);I=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;L=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;xa(f,k,q,l,r,C,S.env_map.image,N,G,W,P,I,L)}}else S.wireframe?Ba(S.color.__styleString,S.wireframe_linewidth):Ca(S.color.__styleString);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){S.map.mapping instanceof
THREE.UVMapping&&xa(f,k,q,l,r,C,S.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!S.wireframe&&S.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){t.r=v.r=s.r=ea.r;t.g=v.g=s.g=ea.g;t.b=v.b=s.b=ea.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],t);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],v);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],s);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(f,
k,q,l,r,C,O,0,0,1,0,0,1)}else{R.r=ea.r;R.g=ea.g;R.b=ea.b;Aa($,D.centroidWorld,D.normalWorld,R);m.r=S.color.r*R.r;m.g=S.color.g*R.g;m.b=S.color.b*R.b;m.updateStyleString();S.wireframe?Ba(m.__styleString,S.wireframe_linewidth):Ca(m.__styleString)}else S.wireframe?Ba(S.color.__styleString,S.wireframe_linewidth):Ca(S.color.__styleString)}else if(S instanceof THREE.MeshDepthMaterial){E=ra.near;B=ra.far;t.r=t.g=t.b=1-Ea(A.positionScreen.z,E,B);v.r=v.g=v.b=1-Ea(X.positionScreen.z,E,B);s.r=s.g=s.b=1-Ea(U.positionScreen.z,
E,B);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(e,k,q,l,r,C,O,0,0,1,0,0,1)}else if(S instanceof THREE.MeshNormalMaterial){m.r=Fa(D.normalWorld.x);m.g=Fa(D.normalWorld.y);m.b=Fa(D.normalWorld.z);m.updateStyleString();S.wireframe?Ba(m.__styleString,S.wireframe_linewidth):Ca(m.__styleString)}}}function Ba(A,X){if(H!=A)i.strokeStyle=H=A;if(K!=X)i.lineWidth=K=X;i.stroke();w.inflate(X*2)}function Ca(A){if(J!=A)i.fillStyle=J=A;i.fill()}function xa(A,X,U,D,S,$,ca,ga,ia,na,la,oa,
E,B);n.r=(v.r+s.r)*0.5;n.g=(v.g+s.g)*0.5;n.b=(v.b+s.b)*0.5;O=Ja(t,v,s,n);xa(f,k,q,l,r,C,O,0,0,1,0,0,1)}else if(S instanceof THREE.MeshNormalMaterial){m.r=Fa(D.normalWorld.x);m.g=Fa(D.normalWorld.y);m.b=Fa(D.normalWorld.z);m.updateStyleString();S.wireframe?Ba(m.__styleString,S.wireframe_linewidth):Ca(m.__styleString)}}}function Ba(A,X){if(H!=A)i.strokeStyle=H=A;if(K!=X)i.lineWidth=K=X;i.stroke();w.inflate(X*2)}function Ca(A){if(J!=A)i.fillStyle=J=A;i.fill()}function xa(A,X,U,D,S,$,ca,ga,ia,na,la,oa,
ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;U-=A;D-=X;S-=A;$-=X;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*U-la*S)*pa;la=(ya*D-la*$)*pa;U=(na*S-oa*U)*pa;D=(na*$-oa*D)*pa;A=A-ta*ga-U*ia;X=X-la*ga-D*ia;i.save();i.transform(ta,la,U,D,A,X);i.clip();i.drawImage(ca,0,0);i.restore()}function Ja(A,X,U,D){var S=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var ca=~~(X.r*255),ga=~~(X.g*255);X=~~(X.b*255);var ia=~~(U.r*255),na=~~(U.g*255);U=~~(U.b*255);var la=~~(D.r*
255),oa=~~(D.g*255);D=~~(D.b*255);ha[0]=S<0?0:S>255?255:S;ha[1]=$<0?0:$>255?255:$;ha[2]=A<0?0:A>255?255:A;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=X<0?0:X>255?255:X;ha[8]=ia<0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=U<0?0:U>255?255:U;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=D<0?0:D>255?255:D;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(A,X,U){A=(A-X)/(U-X);return A*A*(3-2*A)}function Fa(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ga(A,
X){var U=X.x-A.x,D=X.y-A.y,S=1/Math.sqrt(U*U+D*D);U*=S;D*=S;X.x+=U;X.y+=D;A.x-=U;A.y-=D}var Da,Ka,aa,ma,wa,Ha,La,za;i.setTransform(1,0,0,-1,b,j);this.autoClear&&this.clear();d=f.projectScene(da,ra,this.sortElements);i.fillStyle="rgba( 0, 255, 255, 0.5 )";i.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());(M=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];w.empty();if(aa instanceof THREE.RenderableParticle){p=aa;p.x*=b;p.y*=j;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(p,
X){var U=X.x-A.x,D=X.y-A.y,S=1/Math.sqrt(U*U+D*D);U*=S;D*=S;X.x+=U;X.y+=D;A.x-=U;A.y-=D}var Da,Ka,aa,ma,wa,Ha,La,za;i.setTransform(1,0,0,-1,b,j);this.autoClear&&this.clear();d=e.projectScene(da,ra,this.sortElements);i.fillStyle="rgba( 0, 255, 255, 0.5 )";i.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());(M=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];w.empty();if(aa instanceof THREE.RenderableParticle){p=aa;p.x*=b;p.y*=j;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(p,
aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){p=aa.v1;V=aa.v2;p.positionScreen.x*=b;p.positionScreen.y*=j;V.positionScreen.x*=b;V.positionScreen.y*=j;w.addPoint(p.positionScreen.x,p.positionScreen.y);w.addPoint(V.positionScreen.x,V.positionScreen.y);if(T.instersects(w)){ma=0;for(wa=aa.materials.length;ma<wa;)Oa(p,V,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){p=aa.v1;V=aa.v2;F=aa.v3;p.positionScreen.x*=b;p.positionScreen.y*=j;V.positionScreen.x*=b;
V.positionScreen.y*=j;F.positionScreen.x*=b;F.positionScreen.y*=j;if(aa.overdraw){Ga(p.positionScreen,V.positionScreen);Ga(V.positionScreen,F.positionScreen);Ga(F.positionScreen,p.positionScreen)}w.add3Points(p.positionScreen.x,p.positionScreen.y,V.positionScreen.x,V.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if(T.instersects(w)){ma=0;for(wa=aa.meshMaterials.length;ma<wa;){za=aa.meshMaterials[ma++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterials.length;Ha<La;)(za=
aa.faceMaterials[Ha++])&&Ia(p,V,F,aa,za,da)}else Ia(p,V,F,aa,za,da)}}}Q.addRectangle(w)}i.lineWidth=1;i.strokeStyle="rgba( 255, 0, 0, 0.5 )";i.strokeRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());i.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(N,G,W){var P,I,L,T;P=0;for(I=N.lights.length;P<I;P++){L=N.lights[P];if(L instanceof THREE.DirectionalLight){T=G.normalWorld.dot(L.position)*L.intensity;if(T>0){W.r+=L.color.r*T;W.g+=L.color.g*T;W.b+=L.color.b*T}}else if(L instanceof THREE.PointLight){C.sub(L.position,G.centroidWorld);C.normalize();T=G.normalWorld.dot(C)*L.intensity;if(T>0){W.r+=L.color.r*T;W.g+=L.color.g*T;W.b+=L.color.b*T}}}}function c(N,G,W,P,I,L){s=f(n++);s.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(V){e.r=k.r;e.g=k.g;e.b=k.b;a(L,P,e);F.r=I.color.r*e.r;F.g=I.color.g*e.g;F.b=I.color.b*e.b;F.updateStyleString()}else F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){r=1-I.__2near/(I.__farPlusNear-P.z*I.__farMinusNear);
F.setRGB(r,r,r)}else I instanceof THREE.MeshNormalMaterial&&F.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));I.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(s)}function d(N,G,W,P,I,L,T){s=f(n++);s.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(V){e.r=k.r;e.g=k.g;e.b=k.b;a(T,I,e);F.r=L.color.r*e.r;F.g=L.color.g*e.g;F.b=L.color.b*e.b;F.updateStyleString()}else F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){r=
THREE.SVGRenderer=function(){function a(N,G,W){var P,I,L,T;P=0;for(I=N.lights.length;P<I;P++){L=N.lights[P];if(L instanceof THREE.DirectionalLight){T=G.normalWorld.dot(L.position)*L.intensity;if(T>0){W.r+=L.color.r*T;W.g+=L.color.g*T;W.b+=L.color.b*T}}else if(L instanceof THREE.PointLight){C.sub(L.position,G.centroidWorld);C.normalize();T=G.normalWorld.dot(C)*L.intensity;if(T>0){W.r+=L.color.r*T;W.g+=L.color.g*T;W.b+=L.color.b*T}}}}function c(N,G,W,P,I,L){s=e(n++);s.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(V){f.r=k.r;f.g=k.g;f.b=k.b;a(L,P,f);F.r=I.color.r*f.r;F.g=I.color.g*f.g;F.b=I.color.b*f.b;F.updateStyleString()}else F.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){r=1-I.__2near/(I.__farPlusNear-P.z*I.__farMinusNear);
F.setRGB(r,r,r)}else I instanceof THREE.MeshNormalMaterial&&F.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));I.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(s)}function d(N,G,W,P,I,L,T){s=e(n++);s.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(V){f.r=k.r;f.g=k.g;f.b=k.b;a(T,I,f);F.r=L.color.r*f.r;F.g=L.color.g*f.g;F.b=L.color.b*f.b;F.updateStyleString()}else F.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){r=
1-L.__2near/(L.__farPlusNear-I.z*L.__farMinusNear);F.setRGB(r,r,r)}else L instanceof THREE.MeshNormalMaterial&&F.setRGB(g(I.normalWorld.x),g(I.normalWorld.y),g(I.normalWorld.z));L.wireframe?s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):s.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+L.opacity);b.appendChild(s)}
function f(N){if(m[N]==null){m[N]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&m[N].setAttribute("shape-rendering","crispEdges");return m[N]}return m[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var h=null,o=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,i,y,z,u,x,H,J,K=new THREE.Rectangle,p=new THREE.Rectangle,V=false,F=new THREE.Color(16777215),e=new THREE.Color(16777215),k=new THREE.Color(0),q=new THREE.Color(0),
function e(N){if(m[N]==null){m[N]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&m[N].setAttribute("shape-rendering","crispEdges");return m[N]}return m[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var h=null,o=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,i,y,z,u,x,H,J,K=new THREE.Rectangle,p=new THREE.Rectangle,V=false,F=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),q=new THREE.Color(0),
l=new THREE.Color(0),r,C=new THREE.Vector3,m=[],t=[],v=[],s,n,E,B,O=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(N){switch(N){case "high":O=1;break;case "low":O=0}};this.setSize=function(N,G){j=N;i=G;y=j/2;z=i/2;b.setAttribute("viewBox",-y+" "+-z+" "+j+" "+i);b.setAttribute("width",j);b.setAttribute("height",i);K.set(-y,-z,y,z)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(N,G){var W,P,
I,L,T,Q,w,M;this.autoClear&&this.clear();h=o.projectScene(N,G,this.sortElements);B=E=n=0;if(V=N.lights.length>0){w=N.lights;k.setRGB(0,0,0);q.setRGB(0,0,0);l.setRGB(0,0,0);W=0;for(P=w.length;W<P;W++){I=w[W];L=I.color;if(I instanceof THREE.AmbientLight){k.r+=L.r;k.g+=L.g;k.b+=L.b}else if(I instanceof THREE.DirectionalLight){q.r+=L.r;q.g+=L.g;q.b+=L.b}else if(I instanceof THREE.PointLight){l.r+=L.r;l.g+=L.g;l.b+=L.b}}}W=0;for(P=h.length;W<P;W++){w=h[W];p.empty();if(w instanceof THREE.RenderableParticle){u=
w;u.x*=y;u.y*=-z;I=0;for(L=w.materials.length;I<L;I++)if(M=w.materials[I]){T=u;Q=w;M=M;var R=E++;if(t[R]==null){t[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[R].setAttribute("shape-rendering","crispEdges")}s=t[R];s.setAttribute("cx",T.x);s.setAttribute("cy",T.y);s.setAttribute("r",Q.scale.x*y);if(M instanceof THREE.ParticleCircleMaterial){if(V){e.r=k.r+q.r+l.r;e.g=k.g+q.g+l.g;e.b=k.b+q.b+l.b;F.r=M.color.r*e.r;F.g=M.color.g*e.g;F.b=M.color.b*e.b;F.updateStyleString()}else F=
w;u.x*=y;u.y*=-z;I=0;for(L=w.materials.length;I<L;I++)if(M=w.materials[I]){T=u;Q=w;M=M;var R=E++;if(t[R]==null){t[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[R].setAttribute("shape-rendering","crispEdges")}s=t[R];s.setAttribute("cx",T.x);s.setAttribute("cy",T.y);s.setAttribute("r",Q.scale.x*y);if(M instanceof THREE.ParticleCircleMaterial){if(V){f.r=k.r+q.r+l.r;f.g=k.g+q.g+l.g;f.b=k.b+q.b+l.b;F.r=M.color.r*f.r;F.g=M.color.g*f.g;F.b=M.color.b*f.b;F.updateStyleString()}else F=
M.color;s.setAttribute("style","fill: "+F.__styleString)}b.appendChild(s)}}else if(w instanceof THREE.RenderableLine){u=w.v1;x=w.v2;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);if(K.instersects(p)){I=0;for(L=w.materials.length;I<L;)if(M=w.materials[I++]){T=u;Q=x;M=M;R=B++;if(v[R]==null){v[R]=document.createElementNS("http://www.w3.org/2000/svg","line");O==
0&&v[R].setAttribute("shape-rendering","crispEdges")}s=v[R];s.setAttribute("x1",T.positionScreen.x);s.setAttribute("y1",T.positionScreen.y);s.setAttribute("x2",Q.positionScreen.x);s.setAttribute("y2",Q.positionScreen.y);if(M instanceof THREE.LineBasicMaterial){F.__styleString=M.color.__styleString;s.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+M.linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.linecap+"; stroke-linejoin: "+M.linejoin);b.appendChild(s)}}}}else if(w instanceof
THREE.RenderableFace3){u=w.v1;x=w.v2;H=w.v3;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;H.positionScreen.x*=y;H.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);if(K.instersects(p)){I=0;for(L=w.meshMaterials.length;I<L;){M=w.meshMaterials[I++];if(M instanceof THREE.MeshFaceMaterial){T=0;for(Q=w.faceMaterials.length;T<Q;)(M=w.faceMaterials[T++])&&
c(u,x,H,w,M,N)}else M&&c(u,x,H,w,M,N)}}}else if(w instanceof THREE.RenderableFace4){u=w.v1;x=w.v2;H=w.v3;J=w.v4;u.positionScreen.x*=y;u.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;H.positionScreen.x*=y;H.positionScreen.y*=-z;J.positionScreen.x*=y;J.positionScreen.y*=-z;p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);p.addPoint(J.positionScreen.x,J.positionScreen.y);if(K.instersects(p)){I=
0;for(L=w.meshMaterials.length;I<L;){M=w.meshMaterials[I++];if(M instanceof THREE.MeshFaceMaterial){T=0;for(Q=w.faceMaterials.length;T<Q;)(M=w.faceMaterials[T++])&&d(u,x,H,J,w,M,N)}else M&&d(u,x,H,J,w,M,N)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,k){e.fragment_shader=k.fragment_shader;e.vertex_shader=k.vertex_shader;e.uniforms=Uniforms.clone(k.uniforms)}function d(e,k){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=
e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(k){e.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){e.uniforms.fogNear.value=k.near;e.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)e.uniforms.fogDensity.value=k.density}}function f(e,k){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(k){e.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){e.uniforms.fogNear.value=
k.near;e.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)e.uniforms.fogDensity.value=k.density}}function g(e,k){var q;if(e=="fragment")q=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")q=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,k);b.compileShader(q);if(!b.getShaderParameter(q,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(q));return null}return q}function h(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
THREE.WebGLRenderer=function(a){function c(f,k){f.fragment_shader=k.fragment_shader;f.vertex_shader=k.vertex_shader;f.uniforms=Uniforms.clone(k.uniforms)}function d(f,k){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;f.uniforms.map.texture=f.map;f.uniforms.env_map.texture=f.env_map;f.uniforms.reflectivity.value=f.reflectivity;f.uniforms.refraction_ratio.value=f.refraction_ratio;f.uniforms.combine.value=f.combine;f.uniforms.useRefract.value=
f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;if(k){f.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){f.uniforms.fogNear.value=k.near;f.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)f.uniforms.fogDensity.value=k.density}}function e(f,k){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;if(k){f.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){f.uniforms.fogNear.value=
k.near;f.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)f.uniforms.fogDensity.value=k.density}}function g(f,k){var q;if(f=="fragment")q=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")q=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,k);b.compileShader(q);if(!b.getShaderParameter(q,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(q));return null}return q}function h(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),b,j=null,i=null,y=new THREE.Matrix4,z,u=new Float32Array(16),x=new Float32Array(16),H=new Float32Array(16),J=new Float32Array(9),
K=new Float32Array(16),p=true,V=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&V.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(e,k,q){try{b=o.getContext("experimental-webgl",{antialias:e})}catch(l){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(k.r,k.g,k.b,q)})(p,V,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,k){o.width=e;o.height=k;b.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,k){var q=new THREE.Color(e);b.clearColor(q.r,q.g,q.b,k)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(e,k){var q,l,r,C=0,m=0,t=0,v,s,n,E=this.lights,B=E.directional.colors,O=E.directional.positions,N=E.point.colors,G=E.point.positions,W=0,P=0;q=0;for(l=k.length;q<l;q++){r=k[q];v=r.color;s=r.position;n=r.intensity;if(r instanceof THREE.AmbientLight){C+=v.r;m+=v.g;t+=v.b}else if(r instanceof THREE.DirectionalLight){B[W*3]=v.r*n;B[W*3+1]=v.g*n;B[W*3+2]=v.b*n;O[W*3]=s.x;O[W*3+1]=s.y;O[W*3+2]=s.z;W+=1}else if(r instanceof THREE.PointLight){N[P*3]=v.r*n;N[P*3+1]=v.g*n;N[P*3+2]=v.b*n;G[P*3]=s.x;
G[P*3+1]=s.y;G[P*3+2]=s.z;P+=1}}E.point.length=P;E.directional.length=W;E.ambient[0]=C;E.ambient[1]=m;E.ambient[2]=t};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLNormalBuffer=b.createBuffer();e.__webGLTangentBuffer=b.createBuffer();e.__webGLUVBuffer=
b.createBuffer();e.__webGLFaceBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(e){var k=e.vertices.length;e.__vertexArray=new Float32Array(k*3);e.__lineArray=new Uint16Array(k);e.__webGLLineCount=k};this.initMeshBuffers=function(e,k){var q,l,r=0,C=0,m=0,t=k.geometry.faces,v=e.faces;q=0;for(l=v.length;q<l;q++){fi=v[q];face=t[fi];if(face instanceof THREE.Face3){r+=3;C+=1;m+=3}else if(face instanceof THREE.Face4){r+=4;C+=2;m+=4}}e.__vertexArray=new Float32Array(r*
3);e.__normalArray=new Float32Array(r*3);e.__tangentArray=new Float32Array(r*4);e.__uvArray=new Float32Array(r*2);e.__faceArray=new Uint16Array(C*3);e.__lineArray=new Uint16Array(m*2);r=false;q=0;for(l=k.materials.length;q<l;q++){t=k.materials[q];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=e.materials.length;t<v;t++)if(e.materials[t]&&e.materials[t].shading!=undefined&&e.materials[t].shading==THREE.SmoothShading){r=true;break}}else if(t&&t.shading!=undefined&&t.shading==THREE.SmoothShading){r=
true;break}if(r)break}e.__needsSmoothNormals=r;e.__webGLFaceCount=C*3;e.__webGLLineCount=m*2};this.setMeshBuffers=function(e,k,q,l,r,C,m,t){var v,s,n,E,B,O,N,G,W,P=0,I=0,L=0,T=0,Q=0,w=0,M=0,R=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Z=e.__tangentArray,ja=e.__faceArray,Y=e.__lineArray,qa=e.__needsSmoothNormals,ka=k.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;k=0;for(v=ha.length;k<v;k++){s=ha[k];n=sa[s];s=ua[s];E=n.vertexNormals;B=n.normal;if(n instanceof THREE.Face3){if(l){O=
K=new Float32Array(16),p=true,V=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&V.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(f,k,q){try{b=o.getContext("experimental-webgl",{antialias:f})}catch(l){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(k.r,k.g,k.b,q)})(p,V,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,k){o.width=f;o.height=k;b.viewport(0,0,o.width,o.height)};this.setClearColor=function(f,k){var q=new THREE.Color(f);b.clearColor(q.r,q.g,q.b,k)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(f,k){var q,l,r,C=0,m=0,t=0,v,s,n,E=this.lights,B=E.directional.colors,O=E.directional.positions,N=E.point.colors,G=E.point.positions,W=0,P=0;q=0;for(l=k.length;q<l;q++){r=k[q];v=r.color;s=r.position;n=r.intensity;if(r instanceof THREE.AmbientLight){C+=v.r;m+=v.g;t+=v.b}else if(r instanceof THREE.DirectionalLight){B[W*3]=v.r*n;B[W*3+1]=v.g*n;B[W*3+2]=v.b*n;O[W*3]=s.x;O[W*3+1]=s.y;O[W*3+2]=s.z;W+=1}else if(r instanceof THREE.PointLight){N[P*3]=v.r*n;N[P*3+1]=v.g*n;N[P*3+2]=v.b*n;G[P*3]=s.x;
G[P*3+1]=s.y;G[P*3+2]=s.z;P+=1}}E.point.length=P;E.directional.length=W;E.ambient[0]=C;E.ambient[1]=m;E.ambient[2]=t};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=
b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__lineArray=new Uint16Array(k);f.__webGLLineCount=k};this.initMeshBuffers=function(f,k){var q,l,r=0,C=0,m=0,t=k.geometry.faces,v=f.faces;q=0;for(l=v.length;q<l;q++){fi=v[q];face=t[fi];if(face instanceof THREE.Face3){r+=3;C+=1;m+=3}else if(face instanceof THREE.Face4){r+=4;C+=2;m+=4}}f.__vertexArray=new Float32Array(r*
3);f.__normalArray=new Float32Array(r*3);f.__tangentArray=new Float32Array(r*4);f.__uvArray=new Float32Array(r*2);f.__faceArray=new Uint16Array(C*3);f.__lineArray=new Uint16Array(m*2);r=false;q=0;for(l=k.materials.length;q<l;q++){t=k.materials[q];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=f.materials.length;t<v;t++)if(f.materials[t]&&f.materials[t].shading!=undefined&&f.materials[t].shading==THREE.SmoothShading){r=true;break}}else if(t&&t.shading!=undefined&&t.shading==THREE.SmoothShading){r=
true;break}if(r)break}f.__needsSmoothNormals=r;f.__webGLFaceCount=C*3;f.__webGLLineCount=m*2};this.setMeshBuffers=function(f,k,q,l,r,C,m,t){var v,s,n,E,B,O,N,G,W,P=0,I=0,L=0,T=0,Q=0,w=0,M=0,R=f.__vertexArray,ea=f.__uvArray,ba=f.__normalArray,Z=f.__tangentArray,ja=f.__faceArray,Y=f.__lineArray,qa=f.__needsSmoothNormals,ka=k.geometry,fa=ka.vertices,ha=f.faces,sa=ka.faces,ua=ka.uvs;k=0;for(v=ha.length;k<v;k++){s=ha[k];n=sa[s];s=ua[s];E=n.vertexNormals;B=n.normal;if(n instanceof THREE.Face3){if(l){O=
fa[n.a].position;N=fa[n.b].position;G=fa[n.c].position;R[I]=O.x;R[I+1]=O.y;R[I+2]=O.z;R[I+3]=N.x;R[I+4]=N.y;R[I+5]=N.z;R[I+6]=G.x;R[I+7]=G.y;R[I+8]=G.z;I+=9}if(t&&ka.hasTangents){O=fa[n.a].tangent;N=fa[n.b].tangent;G=fa[n.c].tangent;Z[w]=O.x;Z[w+1]=O.y;Z[w+2]=O.z;Z[w+3]=O.w;Z[w+4]=N.x;Z[w+5]=N.y;Z[w+6]=N.z;Z[w+7]=N.w;Z[w+8]=G.x;Z[w+9]=G.y;Z[w+10]=G.z;Z[w+11]=G.w;w+=12}if(m)if(E.length==3&&qa)for(n=0;n<3;n++){B=E[n];ba[Q]=B.x;ba[Q+1]=B.y;ba[Q+2]=B.z;Q+=3}else for(n=0;n<3;n++){ba[Q]=B.x;ba[Q+1]=B.y;
ba[Q+2]=B.z;Q+=3}if(C&&s)for(n=0;n<3;n++){E=s[n];ea[L]=E.u;ea[L+1]=E.v;L+=2}if(r){ja[T]=P;ja[T+1]=P+1;ja[T+2]=P+2;T+=3;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+2;Y[M+4]=P+1;Y[M+5]=P+2;M+=6;P+=3}}else if(n instanceof THREE.Face4){if(l){O=fa[n.a].position;N=fa[n.b].position;G=fa[n.c].position;W=fa[n.d].position;R[I]=O.x;R[I+1]=O.y;R[I+2]=O.z;R[I+3]=N.x;R[I+4]=N.y;R[I+5]=N.z;R[I+6]=G.x;R[I+7]=G.y;R[I+8]=G.z;R[I+9]=W.x;R[I+10]=W.y;R[I+11]=W.z;I+=12}if(t&&ka.hasTangents){O=fa[n.a].tangent;N=fa[n.b].tangent;
G=fa[n.c].tangent;n=fa[n.d].tangent;Z[w]=O.x;Z[w+1]=O.y;Z[w+2]=O.z;Z[w+3]=O.w;Z[w+4]=N.x;Z[w+5]=N.y;Z[w+6]=N.z;Z[w+7]=N.w;Z[w+8]=G.x;Z[w+9]=G.y;Z[w+10]=G.z;Z[w+11]=G.w;Z[w+12]=n.x;Z[w+13]=n.y;Z[w+14]=n.z;Z[w+15]=n.w;w+=16}if(m)if(E.length==4&&qa)for(n=0;n<4;n++){B=E[n];ba[Q]=B.x;ba[Q+1]=B.y;ba[Q+2]=B.z;Q+=3}else for(n=0;n<4;n++){ba[Q]=B.x;ba[Q+1]=B.y;ba[Q+2]=B.z;Q+=3}if(C&&s)for(n=0;n<4;n++){E=s[n];ea[L]=E.u;ea[L+1]=E.v;L+=2}if(r){ja[T]=P;ja[T+1]=P+1;ja[T+2]=P+2;ja[T+3]=P;ja[T+4]=P+2;ja[T+5]=P+3;
T+=6;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+3;Y[M+4]=P+1;Y[M+5]=P+2;Y[M+6]=P+2;Y[M+7]=P+3;M+=8;P+=4}}}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,R,q)}if(m){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,q)}if(t&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,q)}if(C&&L>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,q)}if(r){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,q)}};this.setLineBuffers=function(e,k,q,l){var r,C,m=e.vertices,t=m.length,v=e.__vertexArray,s=e.__lineArray;if(q)for(q=0;q<t;q++){r=m[q].position;C=q*3;v[C]=r.x;v[C+1]=r.y;v[C+2]=r.z}if(l)for(q=0;q<t;q++)s[q]=q;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,k)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,k,q,l,r,C){var m,t,v,s;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){c(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=e.near;l.uniforms.mFar.value=e.far}else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){c(l,THREE.ShaderLib.basic);d(l,q)}else if(l instanceof THREE.MeshLambertMaterial){c(l,THREE.ShaderLib.lambert);
d(l,q)}else if(l instanceof THREE.MeshPhongMaterial){c(l,THREE.ShaderLib.phong);d(l,q)}else if(l instanceof THREE.LineBasicMaterial){c(l,THREE.ShaderLib.basic);f(l,q)}var n,E,B;n=s=t=0;for(E=k.length;n<E;n++){B=k[n];B instanceof THREE.DirectionalLight&&s++;B instanceof THREE.PointLight&&t++}if(t+s<=4){n=s;t=t}else{n=Math.ceil(4*s/(t+s));t=4-n}t={directional:n,point:t};s={fog:q,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;n=l.vertex_shader;E=b.createProgram();
T+=6;Y[M]=P;Y[M+1]=P+1;Y[M+2]=P;Y[M+3]=P+3;Y[M+4]=P+1;Y[M+5]=P+2;Y[M+6]=P+2;Y[M+7]=P+3;M+=8;P+=4}}}if(l){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,R,q)}if(m){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,q)}if(t&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,q)}if(C&&L>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,q)}if(r){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,q)}};this.setLineBuffers=function(f,k,q,l){var r,C,m=f.vertices,t=m.length,v=f.__vertexArray,s=f.__lineArray;if(q)for(q=0;q<t;q++){r=m[q].position;C=q*3;v[C]=r.x;v[C+1]=r.y;v[C+2]=r.z}if(l)for(q=0;q<t;q++)s[q]=q;b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,k)};this.setParticleBuffers=function(){};this.renderBuffer=function(f,k,q,l,r,C){var m,t,v,s;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){c(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=f.near;l.uniforms.mFar.value=f.far}else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){c(l,THREE.ShaderLib.basic);d(l,q)}else if(l instanceof THREE.MeshLambertMaterial){c(l,THREE.ShaderLib.lambert);
d(l,q)}else if(l instanceof THREE.MeshPhongMaterial){c(l,THREE.ShaderLib.phong);d(l,q)}else if(l instanceof THREE.LineBasicMaterial){c(l,THREE.ShaderLib.basic);e(l,q)}var n,E,B;n=s=t=0;for(E=k.length;n<E;n++){B=k[n];B instanceof THREE.DirectionalLight&&s++;B instanceof THREE.PointLight&&t++}if(t+s<=4){n=s;t=t}else{n=Math.ceil(4*s/(t+s));t=4-n}t={directional:n,point:t};s={fog:q,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;n=l.vertex_shader;E=b.createProgram();
B=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,s.fog?"#define USE_FOG":"",s.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");s=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+s.maxDirLights,"#define MAX_POINT_LIGHTS "+s.maxPointLights,
s.map?"#define USE_MAP":"",s.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");b.attachShader(E,g("fragment",B+t));b.attachShader(E,g("vertex",s+n));b.linkProgram(E);b.getProgramParameter(E,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
b.getProgramParameter(E,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");E.uniforms={};E.attributes={};l.program=E;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in l.uniforms)t.push(m);m=l.program;n=0;for(E=t.length;n<E;n++){B=t[n];m.uniforms[B]=b.getUniformLocation(m,B)}m=l.program;t=["position","normal","uv","tangent"];n=0;for(E=t.length;n<E;n++){B=t[n];m.attributes[B]=b.getAttribLocation(m,B)}}m=l.program;if(m!=j){b.useProgram(m);
j=m}this.loadCamera(m,e);this.loadMatrices(m);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(m,k);e=this.lights;l.uniforms.enableLighting.value=e.directional.length+e.point.length;l.uniforms.ambientLightColor.value=e.ambient;l.uniforms.directionalLightColor.value=e.directional.colors;l.uniforms.directionalLightDirection.value=e.directional.positions;l.uniforms.pointLightColor.value=e.point.colors;l.uniforms.pointLightPosition.value=e.point.positions}if(l instanceof
THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)d(l,q);l instanceof THREE.LineBasicMaterial&&f(l,q);if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);l.uniforms.shininess.value=l.shininess}q=l.uniforms;for(v in q)if(n=m.uniforms[v]){k=q[v];t=k.type;e=k.value;if(t=="i")b.uniform1i(n,e);else if(t=="f")b.uniform1f(n,
e);else if(t=="fv1")b.uniform1fv(n,e);else if(t=="fv")b.uniform3fv(n,e);else if(t=="v2")b.uniform2f(n,e.x,e.y);else if(t=="v3")b.uniform3f(n,e.x,e.y,e.z);else if(t=="c")b.uniform3f(n,e.r,e.g,e.b);else if(t=="t"){b.uniform1i(n,e);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;e=e;if(k.image.length==6){if(!k.image.__webGLTextureCube&&!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);
j=m}this.loadCamera(m,f);this.loadMatrices(m);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(m,k);f=this.lights;l.uniforms.enableLighting.value=f.directional.length+f.point.length;l.uniforms.ambientLightColor.value=f.ambient;l.uniforms.directionalLightColor.value=f.directional.colors;l.uniforms.directionalLightDirection.value=f.directional.positions;l.uniforms.pointLightColor.value=f.point.colors;l.uniforms.pointLightPosition.value=f.point.positions}if(l instanceof
THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)d(l,q);l instanceof THREE.LineBasicMaterial&&e(l,q);if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);l.uniforms.shininess.value=l.shininess}q=l.uniforms;for(v in q)if(n=m.uniforms[v]){k=q[v];t=k.type;f=k.value;if(t=="i")b.uniform1i(n,f);else if(t=="f")b.uniform1f(n,
f);else if(t=="fv1")b.uniform1fv(n,f);else if(t=="fv")b.uniform3fv(n,f);else if(t=="v2")b.uniform2f(n,f.x,f.y);else if(t=="v3")b.uniform3f(n,f.x,f.y,f.z);else if(t=="c")b.uniform3f(n,f.r,f.g,f.b);else if(t=="t"){b.uniform1i(n,f);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;f=f;if(k.image.length==6){if(!k.image.__webGLTextureCube&&!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);
b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[t]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+
e);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;e=e;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(k.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(k.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+e);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}v=m.attributes;b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.vertexAttribPointer(v.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.position);if(v.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.vertexAttribPointer(v.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.normal)}if(v.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);
f);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;f=f;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(k.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(k.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+f);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}v=m.attributes;b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.vertexAttribPointer(v.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.position);if(v.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.vertexAttribPointer(v.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.normal)}if(v.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);
b.vertexAttribPointer(v.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(r.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUVBuffer);b.vertexAttribPointer(v.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(v.uv)}else b.disableVertexAttribArray(v.uv);if(l.wireframe||l instanceof THREE.LineBasicMaterial){v=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&C.type==THREE.LineStrip?
b.LINE_STRIP:b.LINES;b.lineWidth(v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.drawElements(l,r.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,r.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,k,q,l,r,C,m){var t,v,s,n,E;s=0;for(n=l.materials.length;s<n;s++){t=l.materials[s];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=r.materials.length;t<v;t++)if((E=r.materials[t])&&E.blending==C&&
E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(e,k,q,E,r,l)}}else if((E=t)&&E.blending==C&&E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(e,k,q,E,r,l)}}};this.render=function(e,k,q,l){var r,C,m,t=e.lights,v=e.fog;this.initWebGLObjects(e);l=l!==undefined?l:true;if(q&&!q.__webGLFramebuffer){q.__webGLFramebuffer=b.createFramebuffer();q.__webGLRenderbuffer=b.createRenderbuffer();q.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,q.__webGLRenderbuffer);
b.LINE_STRIP:b.LINES;b.lineWidth(v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.drawElements(l,r.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,r.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,k,q,l,r,C,m){var t,v,s,n,E;s=0;for(n=l.materials.length;s<n;s++){t=l.materials[s];if(t instanceof THREE.MeshFaceMaterial){t=0;for(v=r.materials.length;t<v;t++)if((E=r.materials[t])&&E.blending==C&&
E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(f,k,q,E,r,l)}}else if((E=t)&&E.blending==C&&E.opacity<1==m){this.setBlending(E.blending);this.renderBuffer(f,k,q,E,r,l)}}};this.render=function(f,k,q,l){var r,C,m,t=f.lights,v=f.fog;this.initWebGLObjects(f);l=l!==undefined?l:true;if(q&&!q.__webGLFramebuffer){q.__webGLFramebuffer=b.createFramebuffer();q.__webGLRenderbuffer=b.createRenderbuffer();q.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,q.__webGLRenderbuffer);
b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,q.width,q.height);b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(q.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(q.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(q.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(q.min_filter));b.texImage2D(b.TEXTURE_2D,0,h(q.format),q.width,q.height,0,h(q.format),h(q.type),null);b.bindFramebuffer(b.FRAMEBUFFER,q.__webGLFramebuffer);
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,q.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,q.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(q){r=q.__webGLFramebuffer;m=q.width;C=q.height}else{r=null;m=o.width;C=o.height}if(r!=i){b.bindFramebuffer(b.FRAMEBUFFER,r);b.viewport(0,0,m,C);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);i=r}this.autoClear&&
this.clear();k.autoUpdateMatrix&&k.updateMatrix();u.set(k.matrix.flatten());H.set(k.projectionMatrix.flatten());l=0;for(r=e.__webGLObjects.length;l<r;l++){C=e.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,k);this.renderPass(k,t,v,m,C,THREE.NormalBlending,false)}}l=0;for(r=e.__webGLObjects.length;l<r;l++){C=e.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,k);if(m.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);m.flipSided?b.frontFace(b.CW):
this.clear();k.autoUpdateMatrix&&k.updateMatrix();u.set(k.matrix.flatten());H.set(k.projectionMatrix.flatten());l=0;for(r=f.__webGLObjects.length;l<r;l++){C=f.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,k);this.renderPass(k,t,v,m,C,THREE.NormalBlending,false)}}l=0;for(r=f.__webGLObjects.length;l<r;l++){C=f.__webGLObjects[l];m=C.object;C=C.buffer;if(m.visible){this.setupMatrices(m,k);if(m.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);m.flipSided?b.frontFace(b.CW):
b.frontFace(b.CCW)}this.renderPass(k,t,v,m,C,THREE.AdditiveBlending,false);this.renderPass(k,t,v,m,C,THREE.SubtractiveBlending,false);this.renderPass(k,t,v,m,C,THREE.AdditiveBlending,true);this.renderPass(k,t,v,m,C,THREE.SubtractiveBlending,true);this.renderPass(k,t,v,m,C,THREE.NormalBlending,true)}}if(q&&q.min_filter!==THREE.NearestFilter&&q.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
function(e){function k(s,n,E,B){if(s[n]==undefined){e.__webGLObjects.push({buffer:E,object:B});s[n]=1}}var q,l,r,C,m,t,v;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}q=0;for(l=e.objects.length;q<l;q++){r=e.objects[q];m=r.geometry;if(e.__webGLObjectsMap[r.id]==undefined)e.__webGLObjectsMap[r.id]={};v=e.__webGLObjectsMap[r.id];if(r instanceof THREE.Mesh){for(C in m.geometryChunks){t=m.geometryChunks[C];if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,r);
function(f){function k(s,n,E,B){if(s[n]==undefined){f.__webGLObjects.push({buffer:E,object:B});s[n]=1}}var q,l,r,C,m,t,v;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}q=0;for(l=f.objects.length;q<l;q++){r=f.objects[q];m=r.geometry;if(f.__webGLObjectsMap[r.id]==undefined)f.__webGLObjectsMap[r.id]={};v=f.__webGLObjectsMap[r.id];if(r instanceof THREE.Mesh){for(C in m.geometryChunks){t=m.geometryChunks[C];if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,r);
m.__dirtyVertices=true;m.__dirtyElements=true;m.__dirtyUvs=true;m.__dirtyNormals=true;m.__dirtyTangents=true}if(m.__dirtyVertices||m.__dirtyElements||m.__dirtyUvs)this.setMeshBuffers(t,r,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements,m.__dirtyUvs,m.__dirtyNormals,m.__dirtyTangents);k(v,C,t,r)}m.__dirtyVertices=false;m.__dirtyElements=false;m.__dirtyUvs=false;m.__dirtyNormals=false;m.__dirtyTangents=false}else if(r instanceof THREE.Line){if(!m.__webGLVertexBuffer){this.createLineBuffers(m);this.initLineBuffers(m);
m.__dirtyVertices=true;m.__dirtyElements=true}m.__dirtyVertices&&this.setLineBuffers(m,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements);k(v,0,m,r);m.__dirtyVertices=false;m.__dirtyElements=false}else if(r instanceof THREE.ParticleSystem){m.__webGLVertexBuffer||this.createParticleBuffers(m);k(v,0,m,r)}}};this.removeObject=function(e,k){var q,l;for(q=e.__webGLObjects.length-1;q>=0;q--){l=e.__webGLObjects[q].object;k==l&&e.__webGLObjects.splice(q,1)}};this.setupMatrices=function(e,k){e.autoUpdateMatrix&&
e.updateMatrix();y.multiply(k.matrix,e.matrix);x.set(y.flatten());z=THREE.Matrix4.makeInvert3x3(y).transpose();J.set(z.m);K.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,u);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,H);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,K)};this.loadCamera=function(e,k){b.uniform3f(e.uniforms.cameraPosition,
k.position.x,k.position.y,k.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,k){if(e){!k||k=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
m.__dirtyVertices=true;m.__dirtyElements=true}m.__dirtyVertices&&this.setLineBuffers(m,b.DYNAMIC_DRAW,m.__dirtyVertices,m.__dirtyElements);k(v,0,m,r);m.__dirtyVertices=false;m.__dirtyElements=false}else if(r instanceof THREE.ParticleSystem){m.__webGLVertexBuffer||this.createParticleBuffers(m);k(v,0,m,r)}}};this.removeObject=function(f,k){var q,l;for(q=f.__webGLObjects.length-1;q>=0;q--){l=f.__webGLObjects[q].object;k==l&&f.__webGLObjects.splice(q,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&
f.updateMatrix();y.multiply(k.matrix,f.matrix);x.set(y.flatten());z=THREE.Matrix4.makeInvert3x3(y).transpose();J.set(z.m);K.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,u);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,H);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,J);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,K)};this.loadCamera=function(f,k){b.uniform3f(f.uniforms.cameraPosition,
k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
+147 -147
View File
@@ -1,67 +1,67 @@
// ThreeExtras.js r32 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(h,j){return h.distance-j.distance});return f},intersectObject:function(a){function c(H,p,I,l){l=l.clone().subSelf(p);I=I.clone().subSelf(p);var g=H.clone().subSelf(p);H=l.dot(l);p=l.dot(I);l=l.dot(g);var m=I.dot(I);I=I.dot(g);g=1/(H*m-p*p);m=(m*l-p*I)*g;H=(H*I-p*l)*g;return m>0&&H>0&&m+H<1}var d,e,f,h,j,b,i,k,r,z,
n,u=a.geometry,x=u.vertices,y=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];z=this.origin.clone();n=this.direction.clone();h=a.matrix.multiplyVector3(x[f.a].position.clone());j=a.matrix.multiplyVector3(x[f.b].position.clone());b=a.matrix.multiplyVector3(x[f.c].position.clone());i=f instanceof THREE.Face4?a.matrix.multiplyVector3(x[f.d].position.clone()):null;k=a.rotationMatrix.multiplyVector3(f.normal.clone());r=n.dot(k);if(r<0){k=k.dot((new THREE.Vector3).sub(h,z))/r;z=z.addSelf(n.multiplyScalar(k));
if(f instanceof THREE.Face3){if(c(z,h,j,b)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}else if(f instanceof THREE.Face4)if(c(z,h,j,i)||c(z,j,b,i)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}}return y}};
THREE.Rectangle=function(){function a(){h=e-c;j=f-d}var c,d,e,f,h,j,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(i,k,r,z){b=false;c=i;d=k;e=r;f=z;a()};this.addPoint=function(i,k){if(b){b=false;c=i;d=k;e=i;f=k}else{c=c<i?c:i;d=d<k?d:k;e=e>i?e:i;f=f>k?
f:k}a()};this.add3Points=function(i,k,r,z,n,u){if(b){b=false;c=i<r?i<n?i:n:r<n?r:n;d=k<z?k<u?k:u:z<u?z:u;e=i>r?i>n?i:n:r>n?r:n;f=k>z?k>u?k:u:z>u?z:u}else{c=i<r?i<n?i<c?i:c:n<c?n:c:r<n?r<c?r:c:n<c?n:c;d=k<z?k<u?k<d?k:d:u<d?u:d:z<u?z<d?z:d:u<d?u:d;e=i>r?i>n?i>e?i:e:n>e?n:e:r>n?r>e?r:e:n>e?n:e;f=k>z?k>u?k>f?k:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f}a()};this.addRectangle=function(i){if(b){b=false;c=i.getLeft();d=i.getTop();e=i.getRight();f=i.getBottom()}else{c=c<i.getLeft()?c:i.getLeft();d=d<i.getTop()?d:i.getTop();
e=e>i.getRight()?e:i.getRight();f=f>i.getBottom()?f:i.getBottom()}a()};this.inflate=function(i){c-=i;d-=i;e+=i;f+=i;a()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e<i.getRight()?e:i.getRight();f=f<i.getBottom()?f:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(c,i.getLeft())>=0&&Math.min(f,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){b=true;f=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
THREE.Matrix4=function(a,c,d,e,f,h,j,b,i,k,r,z,n,u,x,y){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=h||1;this.n23=j||0;this.n24=b||0;this.n31=i||0;this.n32=k||0;this.n33=r||1;this.n34=z||0;this.n41=n||0;this.n42=u||0;this.n43=x||0;this.n44=y||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,f,h,j,b,i,k,r,z,n,u,x,y){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=j;this.n24=b;this.n31=i;this.n32=k;this.n33=r;this.n34=z;this.n41=n;this.n42=u;this.n43=x;this.n44=y;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,c).normalize();e.cross(d,h).normalize();f.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;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 d=a.n11,e=a.n12,f=a.n13,h=a.n14,j=a.n21,b=a.n22,i=a.n23,k=a.n24,r=a.n31,
z=a.n32,n=a.n33,u=a.n34,x=a.n41,y=a.n42,H=a.n43,p=a.n44,I=c.n11,l=c.n12,g=c.n13,m=c.n14,w=c.n21,o=c.n22,v=c.n23,J=c.n24,s=c.n31,A=c.n32,C=c.n33,B=c.n34,t=c.n41,L=c.n42,F=c.n43,R=c.n44;this.n11=d*I+e*w+f*s+h*t;this.n12=d*l+e*o+f*A+h*L;this.n13=d*g+e*v+f*C+h*F;this.n14=d*m+e*J+f*B+h*R;this.n21=j*I+b*w+i*s+k*t;this.n22=j*l+b*o+i*A+k*L;this.n23=j*g+b*v+i*C+k*F;this.n24=j*m+b*J+i*B+k*R;this.n31=r*I+z*w+n*s+u*t;this.n32=r*l+z*o+n*A+u*L;this.n33=r*g+z*v+n*C+u*F;this.n34=r*m+z*J+n*B+u*R;this.n41=x*I+y*w+
H*s+p*t;this.n42=x*l+y*o+H*A+p*L;this.n43=x*g+y*v+H*C+p*F;this.n44=x*m+y*J+H*B+p*R;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,h=this.n21,j=this.n22,b=this.n23,i=this.n24,k=this.n31,r=this.n32,z=this.n33,n=this.n34,u=this.n41,x=this.n42,y=this.n43,H=this.n44,p=a.n11,I=a.n21,l=a.n31,g=a.n41,m=a.n12,w=a.n22,o=a.n32,v=a.n42,J=a.n13,s=a.n23,A=a.n33,C=a.n43,B=a.n14,t=a.n24,L=a.n34;a=a.n44;this.n11=c*p+d*I+e*l+f*g;this.n12=c*m+d*w+e*o+f*v;this.n13=c*J+d*s+e*A+f*
C;this.n14=c*B+d*t+e*L+f*a;this.n21=h*p+j*I+b*l+i*g;this.n22=h*m+j*w+b*o+i*v;this.n23=h*J+j*s+b*A+i*C;this.n24=h*B+j*t+b*L+i*a;this.n31=k*p+r*I+z*l+n*g;this.n32=k*m+r*w+z*o+n*v;this.n33=k*J+r*s+z*A+n*C;this.n34=k*B+r*t+z*L+n*a;this.n41=u*p+x*I+y*l+H*g;this.n42=u*m+x*w+y*o+H*v;this.n43=u*J+x*s+y*A+H*C;this.n44=u*B+x*t+y*L+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,b=this.n24,i=this.n31,k=this.n32,r=this.n33,z=this.n34,n=this.n41,u=this.n42,x=this.n43,y=this.n44;return e*j*k*n-d*b*k*n-e*h*r*n+c*b*r*n+d*h*z*n-c*j*z*n-e*j*i*u+d*b*i*u+e*f*r*u-a*b*r*u-d*f*z*u+a*j*z*u+e*h*i*x-c*b*i*x-e*f*k*x+a*b*k*x+c*f*z*x-a*h*z*x-d*h*i*y+c*j*i*y+d*f*k*y-a*j*k*y-c*f*r*y+a*h*r*y},transpose:function(){function a(c,d,
e){var f=c[d];c[d]=c[e];c[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},
setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,h=a.x,j=a.y,b=a.z,i=f*h,k=f*j;this.set(i*h+d,i*j-e*b,i*b+e*j,0,i*j+e*b,k*j+d,k*b-e*h,0,i*b-e*j,k*b+e*h,f*b*b+d,0,0,
0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};
THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,b=a.n23,i=a.n24,k=a.n31,r=a.n32,z=a.n33,n=a.n34,u=a.n41,x=a.n42,y=a.n43,H=a.n44,p=new THREE.Matrix4;p.n11=b*n*x-i*z*x+i*r*y-j*n*y-b*r*H+j*z*H;p.n12=f*z*x-e*n*x-f*r*y+d*n*y+e*r*H-d*z*H;p.n13=e*i*x-f*b*x+f*j*y-d*i*y-e*j*H+d*b*H;p.n14=f*b*r-e*i*r-f*j*z+d*i*z+e*j*n-d*b*n;p.n21=i*z*u-b*n*u-i*k*y+h*n*y+b*k*H-h*z*H;p.n22=e*n*u-f*z*u+f*k*y-c*n*y-e*k*H+c*z*H;p.n23=f*b*u-e*i*u-f*h*y+c*i*y+e*h*H-c*b*H;p.n24=e*i*k-f*b*k+
f*h*z-c*i*z-e*h*n+c*b*n;p.n31=j*n*u-i*r*u+i*k*x-h*n*x-j*k*H+h*r*H;p.n32=f*r*u-d*n*u-f*k*x+c*n*x+d*k*H-c*r*H;p.n33=e*i*u-f*j*u+f*h*x-c*i*x-d*h*H+c*j*H;p.n34=f*j*k-d*i*k-f*h*r+c*i*r+d*h*n-c*j*n;p.n41=b*r*u-j*z*u-b*k*x+h*z*x+j*k*y-h*r*y;p.n42=d*z*u-e*r*u+e*k*x-c*z*x-d*k*y+c*r*y;p.n43=e*j*u-d*b*u-e*h*x+c*b*x+d*h*y-c*j*y;p.n44=d*b*k-e*j*k+e*h*r-c*b*r-d*h*z+c*j*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=c[10]*c[5]-c[6]*c[9],e=-c[10]*c[1]+c[2]*c[9],f=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],i=c[9]*c[4]-c[5]*c[8],k=-c[9]*c[0]+c[1]*c[8],r=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*h+c[2]*i;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*e;a.m[2]=c*f;a.m[3]=c*h;a.m[4]=c*j;a.m[5]=c*b;a.m[6]=c*i;a.m[7]=c*k;a.m[8]=c*r;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,e,f,h){var j,b,i;j=new THREE.Matrix4;b=2*f/(c-a);i=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(h+f)/(h-f);f=-2*h*f/(h-f);j.n11=b;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=i;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
THREE.Matrix4.makeOrtho=function(a,c,d,e,f,h){var j,b,i,k;j=new THREE.Matrix4;b=c-a;i=d-e;k=h-f;a=(c+a)/b;d=(d+e)/i;f=(h+f)/k;j.n11=2/b;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/i;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/k;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
THREE.Face3=function(a,c,d,e,f){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,e,f,h){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(h,j){return h.distance-j.distance});return f},intersectObject:function(a){function b(H,p,I,l){l=l.clone().subSelf(p);I=I.clone().subSelf(p);var g=H.clone().subSelf(p);H=l.dot(l);p=l.dot(I);l=l.dot(g);var m=I.dot(I);I=I.dot(g);g=1/(H*m-p*p);m=(m*l-p*I)*g;H=(H*I-p*l)*g;return m>0&&H>0&&m+H<1}var d,e,f,h,j,c,i,k,r,z,
n,u=a.geometry,x=u.vertices,y=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];z=this.origin.clone();n=this.direction.clone();h=a.matrix.multiplyVector3(x[f.a].position.clone());j=a.matrix.multiplyVector3(x[f.b].position.clone());c=a.matrix.multiplyVector3(x[f.c].position.clone());i=f instanceof THREE.Face4?a.matrix.multiplyVector3(x[f.d].position.clone()):null;k=a.rotationMatrix.multiplyVector3(f.normal.clone());r=n.dot(k);if(r<0){k=k.dot((new THREE.Vector3).sub(h,z))/r;z=z.addSelf(n.multiplyScalar(k));
if(f instanceof THREE.Face3){if(b(z,h,j,c)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}else if(f instanceof THREE.Face4)if(b(z,h,j,i)||b(z,j,c,i)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}}return y}};
THREE.Rectangle=function(){function a(){h=e-b;j=f-d}var b,d,e,f,h,j,c=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(i,k,r,z){c=false;b=i;d=k;e=r;f=z;a()};this.addPoint=function(i,k){if(c){c=false;b=i;d=k;e=i;f=k}else{b=b<i?b:i;d=d<k?d:k;e=e>i?e:i;f=f>k?
f:k}a()};this.add3Points=function(i,k,r,z,n,u){if(c){c=false;b=i<r?i<n?i:n:r<n?r:n;d=k<z?k<u?k:u:z<u?z:u;e=i>r?i>n?i:n:r>n?r:n;f=k>z?k>u?k:u:z>u?z:u}else{b=i<r?i<n?i<b?i:b:n<b?n:b:r<n?r<b?r:b:n<b?n:b;d=k<z?k<u?k<d?k:d:u<d?u:d:z<u?z<d?z:d:u<d?u:d;e=i>r?i>n?i>e?i:e:n>e?n:e:r>n?r>e?r:e:n>e?n:e;f=k>z?k>u?k>f?k:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();d=i.getTop();e=i.getRight();f=i.getBottom()}else{b=b<i.getLeft()?b:i.getLeft();d=d<i.getTop()?d:i.getTop();
e=e>i.getRight()?e:i.getRight();f=f>i.getBottom()?f:i.getBottom()}a()};this.inflate=function(i){b-=i;d-=i;e+=i;f+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e<i.getRight()?e:i.getRight();f=f<i.getBottom()?f:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(b,i.getLeft())>=0&&Math.min(f,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){c=true;f=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}};
THREE.Matrix4=function(a,b,d,e,f,h,j,c,i,k,r,z,n,u,x,y){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=k||0;this.n33=r||1;this.n34=z||0;this.n41=n||0;this.n42=u||0;this.n43=x||0;this.n44=y||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,f,h,j,c,i,k,r,z,n,u,x,y){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=k;this.n33=r;this.n34=z;this.n41=n;this.n42=u;this.n43=x;this.n44=y;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(d,h).normalize();f.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*
e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,k=a.n24,r=a.n31,
z=a.n32,n=a.n33,u=a.n34,x=a.n41,y=a.n42,H=a.n43,p=a.n44,I=b.n11,l=b.n12,g=b.n13,m=b.n14,w=b.n21,o=b.n22,v=b.n23,J=b.n24,s=b.n31,A=b.n32,C=b.n33,B=b.n34,t=b.n41,L=b.n42,F=b.n43,R=b.n44;this.n11=d*I+e*w+f*s+h*t;this.n12=d*l+e*o+f*A+h*L;this.n13=d*g+e*v+f*C+h*F;this.n14=d*m+e*J+f*B+h*R;this.n21=j*I+c*w+i*s+k*t;this.n22=j*l+c*o+i*A+k*L;this.n23=j*g+c*v+i*C+k*F;this.n24=j*m+c*J+i*B+k*R;this.n31=r*I+z*w+n*s+u*t;this.n32=r*l+z*o+n*A+u*L;this.n33=r*g+z*v+n*C+u*F;this.n34=r*m+z*J+n*B+u*R;this.n41=x*I+y*w+
H*s+p*t;this.n42=x*l+y*o+H*A+p*L;this.n43=x*g+y*v+H*C+p*F;this.n44=x*m+y*J+H*B+p*R;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,k=this.n31,r=this.n32,z=this.n33,n=this.n34,u=this.n41,x=this.n42,y=this.n43,H=this.n44,p=a.n11,I=a.n21,l=a.n31,g=a.n41,m=a.n12,w=a.n22,o=a.n32,v=a.n42,J=a.n13,s=a.n23,A=a.n33,C=a.n43,B=a.n14,t=a.n24,L=a.n34;a=a.n44;this.n11=b*p+d*I+e*l+f*g;this.n12=b*m+d*w+e*o+f*v;this.n13=b*J+d*s+e*A+f*
C;this.n14=b*B+d*t+e*L+f*a;this.n21=h*p+j*I+c*l+i*g;this.n22=h*m+j*w+c*o+i*v;this.n23=h*J+j*s+c*A+i*C;this.n24=h*B+j*t+c*L+i*a;this.n31=k*p+r*I+z*l+n*g;this.n32=k*m+r*w+z*o+n*v;this.n33=k*J+r*s+z*A+n*C;this.n34=k*B+r*t+z*L+n*a;this.n41=u*p+x*I+y*l+H*g;this.n42=u*m+x*w+y*o+H*v;this.n43=u*J+x*s+y*A+H*C;this.n44=u*B+x*t+y*L+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,c=this.n24,i=this.n31,k=this.n32,r=this.n33,z=this.n34,n=this.n41,u=this.n42,x=this.n43,y=this.n44;return e*j*k*n-d*c*k*n-e*h*r*n+b*c*r*n+d*h*z*n-b*j*z*n-e*j*i*u+d*c*i*u+e*f*r*u-a*c*r*u-d*f*z*u+a*j*z*u+e*h*i*x-b*c*i*x-e*f*k*x+a*c*k*x+b*f*z*x-a*h*z*x-d*h*i*y+b*j*i*y+d*f*k*y-a*j*k*y-b*f*r*y+a*h*r*y},transpose:function(){function a(b,d,
e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),f=1-d,h=a.x,j=a.y,c=a.z,i=f*h,k=f*j;this.set(i*h+d,i*j-e*c,i*c+e*j,0,i*j+e*c,k*j+d,k*c-e*h,0,i*c-e*j,k*c+e*h,f*c*c+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};
THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,c=a.n23,i=a.n24,k=a.n31,r=a.n32,z=a.n33,n=a.n34,u=a.n41,x=a.n42,y=a.n43,H=a.n44,p=new THREE.Matrix4;p.n11=c*n*x-i*z*x+i*r*y-j*n*y-c*r*H+j*z*H;p.n12=f*z*x-e*n*x-f*r*y+d*n*y+e*r*H-d*z*H;p.n13=e*i*x-f*c*x+f*j*y-d*i*y-e*j*H+d*c*H;p.n14=f*c*r-e*i*r-f*j*z+d*i*z+e*j*n-d*c*n;p.n21=i*z*u-c*n*u-i*k*y+h*n*y+c*k*H-h*z*H;p.n22=e*n*u-f*z*u+f*k*y-b*n*y-e*k*H+b*z*H;p.n23=f*c*u-e*i*u-f*h*y+b*i*y+e*h*H-b*c*H;p.n24=e*i*k-f*c*k+
f*h*z-b*i*z-e*h*n+b*c*n;p.n31=j*n*u-i*r*u+i*k*x-h*n*x-j*k*H+h*r*H;p.n32=f*r*u-d*n*u-f*k*x+b*n*x+d*k*H-b*r*H;p.n33=e*i*u-f*j*u+f*h*x-b*i*x-d*h*H+b*j*H;p.n34=f*j*k-d*i*k-f*h*r+b*i*r+d*h*n-b*j*n;p.n41=c*r*u-j*z*u-c*k*x+h*z*x+j*k*y-h*r*y;p.n42=d*z*u-e*r*u+e*k*x-b*z*x-d*k*y+b*r*y;p.n43=e*j*u-d*c*u-e*h*x+b*c*x+d*h*y-b*j*y;p.n44=d*c*k-e*j*k+e*h*r-b*c*r-d*h*z+b*j*z;p.multiplyScalar(1/a.determinant());return p};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],i=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],r=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*h;d[3]=b*j;d[4]=b*c;d[5]=b*i;d[6]=b*k;d[7]=b*r;d[8]=b*z;return a};
THREE.Matrix4.makeFrustum=function(a,b,d,e,f,h){var j,c,i;j=new THREE.Matrix4;c=2*f/(b-a);i=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(h+f)/(h-f);f=-2*h*f/(h-f);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=i;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
THREE.Matrix4.makeOrtho=function(a,b,d,e,f,h){var j,c,i,k;j=new THREE.Matrix4;c=b-a;i=d-e;k=h-f;a=(b+a)/c;d=(d+e)/i;f=(h+f)/k;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/i;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/k;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,d,e,f,h){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,h,j,b=new THREE.Vector3,i=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];if(a&&h.vertexNormals.length){b.set(0,0,0);c=0;for(d=h.normal.length;c<d;c++)b.addSelf(h.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[h.a];d=this.vertices[h.b];j=this.vertices[h.c];b.sub(j.position,
d.position);i.sub(c.position,d.position);b.crossSelf(i)}b.isZero()||b.normalize();h.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(B,t,L,F,R,T,M){h=B.vertices[t].position;j=B.vertices[L].position;b=B.vertices[F].position;i=f[R];k=f[T];r=f[M];z=j.x-h.x;n=b.x-h.x;u=j.y-h.y;x=b.y-h.y;
y=j.z-h.z;H=b.z-h.z;p=k.u-i.u;I=r.u-i.u;l=k.v-i.v;g=r.v-i.v;m=1/(p*g-I*l);v.set((g*z-l*n)*m,(g*u-l*x)*m,(g*y-l*H)*m);J.set((p*n-I*z)*m,(p*x-I*u)*m,(p*H-I*y)*m);w[t].addSelf(v);w[L].addSelf(v);w[F].addSelf(v);o[t].addSelf(J);o[L].addSelf(J);o[F].addSelf(J)}var c,d,e,f,h,j,b,i,k,r,z,n,u,x,y,H,p,I,l,g,m,w=[],o=[],v=new THREE.Vector3,J=new THREE.Vector3,s=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){w[c]=new THREE.Vector3;o[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){e=this.faces[c];f=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){C.copy(this.vertices[c].normal);e=w[c];s.copy(e);s.subSelf(C.multiplyScalar(C.dot(e))).normalize();A.cross(this.vertices[c].normal,e);e=A.dot(o[c]);e=e<0?-1:1;this.vertices[c].tangent.set(s.x,s.y,s.z,e)}this.hasTangents=true},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,d=this.vertices.length;c<d;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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(r){var z=[];c=0;for(d=r.length;c<d;c++)r[c]==undefined?z.push("undefined"):z.push(r[c].toString());return z.join("_")}var c,d,e,f,h,j,b,i,k={};e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];
j=h.materials;b=a(j);if(k[b]==undefined)k[b]={hash:b,counter:0};i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){k[b].counter+=1;i=k[b].hash+"_"+k[b].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(e);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,h,j,c=new THREE.Vector3,i=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];if(a&&h.vertexNormals.length){c.set(0,0,0);b=0;for(d=h.normal.length;b<d;b++)c.addSelf(h.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[h.a];d=this.vertices[h.b];j=this.vertices[h.c];c.sub(j.position,
d.position);i.sub(b.position,d.position);c.crossSelf(i)}c.isZero()||c.normalize();h.normal.copy(c)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(B,t,L,F,R,T,M){h=B.vertices[t].position;j=B.vertices[L].position;c=B.vertices[F].position;i=f[R];k=f[T];r=f[M];z=j.x-h.x;n=c.x-h.x;u=j.y-h.y;x=c.y-h.y;
y=j.z-h.z;H=c.z-h.z;p=k.u-i.u;I=r.u-i.u;l=k.v-i.v;g=r.v-i.v;m=1/(p*g-I*l);v.set((g*z-l*n)*m,(g*u-l*x)*m,(g*y-l*H)*m);J.set((p*n-I*z)*m,(p*x-I*u)*m,(p*H-I*y)*m);w[t].addSelf(v);w[L].addSelf(v);w[F].addSelf(v);o[t].addSelf(J);o[L].addSelf(J);o[F].addSelf(J)}var b,d,e,f,h,j,c,i,k,r,z,n,u,x,y,H,p,I,l,g,m,w=[],o=[],v=new THREE.Vector3,J=new THREE.Vector3,s=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){w[b]=new THREE.Vector3;o[b]=new THREE.Vector3}b=0;
for(d=this.faces.length;b<d;b++){e=this.faces[b];f=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){C.copy(this.vertices[b].normal);e=w[b];s.copy(e);s.subSelf(C.multiplyScalar(C.dot(e))).normalize();A.cross(this.vertices[b].normal,e);e=A.dot(o[b]);e=e<0?-1:1;this.vertices[b].tangent.set(s.x,s.y,s.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<d;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(r){var z=[];b=0;for(d=r.length;b<d;b++)r[b]==undefined?z.push("undefined"):z.push(r[b].toString());return z.join("_")}var b,d,e,f,h,j,c,i,k={};e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];
j=h.materials;c=a(j);if(k[c]==undefined)k[c]={hash:c,counter:0};i=k[c].hash+"_"+k[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){k[c].counter+=1;i=k[c].hash+"_"+k[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(e);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};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.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,b=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(b.x);if(b.y!=0){e.setRotY(b.y);this.rotationMatrix.multiplySelf(e)}if(b.z!=0){e.setRotZ(b.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}};
THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
@@ -89,101 +89,101 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
THREE.Texture=function(a,c,d,e,f,h){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture=function(a,b,d,e,f,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[c]={};for(d in a[c]){e=a[c][d];f[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var c,d,e,f={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)f[d]=e[d]}return f}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.RenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var b,d,e,f={};for(b in a){f[b]={};for(d in a[b]){e=a[b][d];f[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var b,d,e,f={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)f[d]=e[d]}return f}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
THREE.Projector=function(){function a(o,v){return v.z-o.z}function c(o,v){var J=0,s=1,A=o.z+o.w,C=v.z+v.w,B=-o.z+o.w,t=-v.z+v.w;if(A>=0&&C>=0&&B>=0&&t>=0)return true;else if(A<0&&C<0||B<0&&t<0)return false;else{if(A<0)J=Math.max(J,A/(A-C));else if(C<0)s=Math.min(s,A/(A-C));if(B<0)J=Math.max(J,B/(B-t));else if(t<0)s=Math.min(s,B/(B-t));if(s<J)return false;else{o.lerpSelf(v,J);v.lerpSelf(o,1-s);return true}}}var d,e,f=[],h,j,b,i=[],k,r,z=[],n,u,x=[],y=new THREE.Vector4,H=new THREE.Vector4,p=new THREE.Matrix4,
THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
THREE.Projector=function(){function a(o,v){return v.z-o.z}function b(o,v){var J=0,s=1,A=o.z+o.w,C=v.z+v.w,B=-o.z+o.w,t=-v.z+v.w;if(A>=0&&C>=0&&B>=0&&t>=0)return true;else if(A<0&&C<0||B<0&&t<0)return false;else{if(A<0)J=Math.max(J,A/(A-C));else if(C<0)s=Math.min(s,A/(A-C));if(B<0)J=Math.max(J,B/(B-t));else if(t<0)s=Math.min(s,B/(B-t));if(s<J)return false;else{o.lerpSelf(v,J);v.lerpSelf(o,1-s);return true}}}var d,e,f=[],h,j,c,i=[],k,r,z=[],n,u,x=[],y=new THREE.Vector4,H=new THREE.Vector4,p=new THREE.Matrix4,
I=new THREE.Matrix4,l=[],g=new THREE.Vector4,m=new THREE.Vector4,w;this.projectObjects=function(o,v,J){var s=[],A,C;e=0;p.multiply(v.projectionMatrix,v.matrix);l[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);l[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);l[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);l[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);l[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
p.n33,p.n44-p.n34);l[5]=new THREE.Vector4(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);v=0;for(A=l.length;v<A;v++){C=l[v];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}A=o.objects;o=0;for(v=A.length;o<v;o++){C=A[o];var B;if(!(B=!C.visible)){if(B=C instanceof THREE.Mesh){a:{B=void 0;for(var t=C.position,L=-C.geometry.boundingSphere.radius*Math.max(C.scale.x,Math.max(C.scale.y,C.scale.z)),F=0;F<6;F++){B=l[F].x*t.x+l[F].y*t.y+l[F].z*t.z+l[F].w;if(B<=L){B=false;break a}}B=true}B=!B}B=B}if(!B){d=
f[e]=f[e]||new THREE.RenderableObject;y.copy(C.position);p.multiplyVector3(y);d.object=C;d.z=y.z;s.push(d);e++}}J&&s.sort(a);return s};this.projectScene=function(o,v,J){var s=[],A=v.near,C=v.far,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S;b=r=u=0;v.autoUpdateMatrix&&v.updateMatrix();p.multiply(v.projectionMatrix,v.matrix);T=this.projectObjects(o,v,true);o=0;for(B=T.length;o<B;o++){M=T[o].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();aa=M.matrix;U=M.rotationMatrix;O=M.materials;Q=M.overdraw;if(M instanceof
f[e]=f[e]||new THREE.RenderableObject;y.copy(C.position);p.multiplyVector3(y);d.object=C;d.z=y.z;s.push(d);e++}}J&&s.sort(a);return s};this.projectScene=function(o,v,J){var s=[],A=v.near,C=v.far,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S;c=r=u=0;v.autoUpdateMatrix&&v.updateMatrix();p.multiply(v.projectionMatrix,v.matrix);T=this.projectObjects(o,v,true);o=0;for(B=T.length;o<B;o++){M=T[o].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();aa=M.matrix;U=M.rotationMatrix;O=M.materials;Q=M.overdraw;if(M instanceof
THREE.Mesh){Z=M.geometry;V=Z.vertices;t=0;for(L=V.length;t<L;t++){D=V[t];D.positionWorld.copy(D.position);aa.multiplyVector3(D.positionWorld);F=D.positionScreen;F.copy(D.positionWorld);p.multiplyVector4(F);F.x/=F.w;F.y/=F.w;D.__visible=F.z>A&&F.z<C}Z=Z.faces;t=0;for(L=Z.length;t<L;t++){D=Z[t];if(D instanceof THREE.Face3){F=V[D.a];R=V[D.b];P=V[D.c];if(F.__visible&&R.__visible&&P.__visible)if(M.doubleSided||M.flipSided!=(P.positionScreen.x-F.positionScreen.x)*(R.positionScreen.y-F.positionScreen.y)-
(P.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0){h=i[b]=i[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(D.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(D.centroid);aa.multiplyVector3(h.centroidWorld);
h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);P=D.vertexNormals;w=h.vertexNormalsWorld;F=0;for(R=P.length;F<R;F++){S=w[F]=w[F]||new THREE.Vector3;S.copy(P[F]);U.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=D.materials;h.overdraw=Q;if(M.geometry.uvs[t]){h.uvs[0]=M.geometry.uvs[t][0];h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][2]}s.push(h);b++}}else if(D instanceof THREE.Face4){F=V[D.a];R=V[D.b];P=V[D.c];S=V[D.d];if(F.__visible&&
R.__visible&&P.__visible&&S.__visible)if(M.doubleSided||M.flipSided!=((S.positionScreen.x-F.positionScreen.x)*(R.positionScreen.y-F.positionScreen.y)-(S.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0||(R.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(R.positionScreen.y-P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0)){h=i[b]=i[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);
(P.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(D.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(D.centroid);aa.multiplyVector3(h.centroidWorld);
h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);P=D.vertexNormals;w=h.vertexNormalsWorld;F=0;for(R=P.length;F<R;F++){S=w[F]=w[F]||new THREE.Vector3;S.copy(P[F]);U.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=D.materials;h.overdraw=Q;if(M.geometry.uvs[t]){h.uvs[0]=M.geometry.uvs[t][0];h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][2]}s.push(h);c++}}else if(D instanceof THREE.Face4){F=V[D.a];R=V[D.b];P=V[D.c];S=V[D.d];if(F.__visible&&
R.__visible&&P.__visible&&S.__visible)if(M.doubleSided||M.flipSided!=((S.positionScreen.x-F.positionScreen.x)*(R.positionScreen.y-F.positionScreen.y)-(S.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0||(R.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(R.positionScreen.y-P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0)){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);
h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(D.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(D.centroid);aa.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=D.materials;h.overdraw=Q;if(M.geometry.uvs[t]){h.uvs[0]=M.geometry.uvs[t][0];
h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][3]}s.push(h);b++;j=i[b]=i[b]||new THREE.RenderableFace3;j.v1.positionWorld.copy(R.positionWorld);j.v2.positionWorld.copy(P.positionWorld);j.v3.positionWorld.copy(S.positionWorld);j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(P.positionScreen);j.v3.positionScreen.copy(S.positionScreen);j.normalWorld.copy(h.normalWorld);j.centroidWorld.copy(h.centroidWorld);j.centroidScreen.copy(h.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
O;j.faceMaterials=D.materials;j.overdraw=Q;if(M.geometry.uvs[t]){j.uvs[0]=M.geometry.uvs[t][1];j.uvs[1]=M.geometry.uvs[t][2];j.uvs[2]=M.geometry.uvs[t][3]}s.push(j);b++}}}}else if(M instanceof THREE.Line){I.multiply(p,aa);V=M.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);I.multiplyVector4(D.positionScreen);t=1;for(L=V.length;t<L;t++){F=V[t];F.positionScreen.copy(F.position);I.multiplyVector4(F.positionScreen);R=V[t-1];g.copy(F.positionScreen);m.copy(R.positionScreen);if(c(g,m)){g.multiplyScalar(1/
h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][3]}s.push(h);c++;j=i[c]=i[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(R.positionWorld);j.v2.positionWorld.copy(P.positionWorld);j.v3.positionWorld.copy(S.positionWorld);j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(P.positionScreen);j.v3.positionScreen.copy(S.positionScreen);j.normalWorld.copy(h.normalWorld);j.centroidWorld.copy(h.centroidWorld);j.centroidScreen.copy(h.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
O;j.faceMaterials=D.materials;j.overdraw=Q;if(M.geometry.uvs[t]){j.uvs[0]=M.geometry.uvs[t][1];j.uvs[1]=M.geometry.uvs[t][2];j.uvs[2]=M.geometry.uvs[t][3]}s.push(j);c++}}}}else if(M instanceof THREE.Line){I.multiply(p,aa);V=M.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);I.multiplyVector4(D.positionScreen);t=1;for(L=V.length;t<L;t++){F=V[t];F.positionScreen.copy(F.position);I.multiplyVector4(F.positionScreen);R=V[t-1];g.copy(F.positionScreen);m.copy(R.positionScreen);if(b(g,m)){g.multiplyScalar(1/
g.w);m.multiplyScalar(1/m.w);k=z[r]=z[r]||new THREE.RenderableLine;k.v1.positionScreen.copy(g);k.v2.positionScreen.copy(m);k.z=Math.max(g.z,m.z);k.materials=M.materials;s.push(k);r++}}}else if(M instanceof THREE.Particle){H.set(M.position.x,M.position.y,M.position.z,1);p.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){n=x[u]=x[u]||new THREE.RenderableParticle;n.x=H.x/H.w;n.y=H.y/H.w;n.z=H.z;n.rotation=M.rotation.z;n.scale.x=M.scale.x*Math.abs(n.x-(H.x+v.projectionMatrix.n11)/(H.w+v.projectionMatrix.n14));
n.scale.y=M.scale.y*Math.abs(n.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));n.materials=M.materials;s.push(n);u++}}}}J&&s.sort(a);return s};this.unprojectVector=function(o,v){var J=new THREE.Matrix4;J.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));J.multiplyVector3(o);return o}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,h;this.domElement=document.createElement("div");this.setSize=function(j,b){d=j;e=b;f=d/2;h=e/2};this.render=function(j,b){var i,k,r,z,n,u,x,y;a=c.projectScene(j,b);i=0;for(k=a.length;i<k;i++){n=a[i];if(n instanceof THREE.RenderableParticle){x=n.x*f+f;y=n.y*h+h;r=0;for(z=n.material.length;r<z;r++){u=n.material[r];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=x+"px";u.style.top=y+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(n!=ja)k.globalAlpha=n=ja}function c(ja){if(u!=ja){switch(ja){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}u=ja}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),h,j,b,i,k=f.getContext("2d"),r=null,z=null,n=1,u=0,x=null,y=null,H=1,p,I,l,g,m,w,o,v,J,s=new THREE.Color,
n.scale.y=M.scale.y*Math.abs(n.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));n.materials=M.materials;s.push(n);u++}}}}J&&s.sort(a);return s};this.unprojectVector=function(o,v){var J=THREE.Matrix4.makeInvert(v.matrix);J.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));J.multiplyVector3(o);return o}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;f=d/2;h=e/2};this.render=function(j,c){var i,k,r,z,n,u,x,y;a=b.projectScene(j,c);i=0;for(k=a.length;i<k;i++){n=a[i];if(n instanceof THREE.RenderableParticle){x=n.x*f+f;y=n.y*h+h;r=0;for(z=n.material.length;r<z;r++){u=n.material[r];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=x+"px";u.style.top=y+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(n!=ja)k.globalAlpha=n=ja}function b(ja){if(u!=ja){switch(ja){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}u=ja}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),h,j,c,i,k=f.getContext("2d"),r=null,z=null,n=1,u=0,x=null,y=null,H=1,p,I,l,g,m,w,o,v,J,s=new THREE.Color,
A=new THREE.Color,C=new THREE.Color,B=new THREE.Color,t=new THREE.Color,L,F,R,T,M,aa,U,O,Q,Z=new THREE.Rectangle,V=new THREE.Rectangle,D=new THREE.Rectangle,P=false,S=new THREE.Color,fa=new THREE.Color,ea=new THREE.Color,q=new THREE.Color,G=Math.PI*2,E=new THREE.Vector3,W,$,da,ga,na,pa,va=16;W=document.createElement("canvas");W.width=W.height=2;$=W.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);da=$.getImageData(0,0,2,2);ga=da.data;na=document.createElement("canvas");na.width=na.height=
va;pa=na.getContext("2d");pa.translate(-va/2,-va/2);pa.scale(va,va);va--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;b=h/2;i=j/2;f.width=h;f.height=j;Z.set(-b,-i,b,i);n=1;u=0;y=x=null;H=1};this.setClearColor=function(ja,ta){r=ja!==null?new THREE.Color(ja):null;z=ta;V.set(-b,-i,b,i);k.setTransform(1,0,0,-1,b,i);this.clear()};this.clear=function(){if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(r!==null){c(THREE.NormalBlending);a(1);
va;pa=na.getContext("2d");pa.translate(-va/2,-va/2);pa.scale(va,va);va--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;c=h/2;i=j/2;f.width=h;f.height=j;Z.set(-c,-i,c,i);n=1;u=0;y=x=null;H=1};this.setClearColor=function(ja,ta){r=ja!==null?new THREE.Color(ja):null;z=ta;V.set(-c,-i,c,i);k.setTransform(1,0,0,-1,c,i);this.clear()};this.clear=function(){if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(r!==null){b(THREE.NormalBlending);a(1);
k.fillStyle="rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+z+")";k.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}else k.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());V.empty()}};this.render=function(ja,ta){function Ma(K){var ba,Y,N,X=K.lights;fa.setRGB(0,0,0);ea.setRGB(0,0,0);q.setRGB(0,0,0);K=0;for(ba=X.length;K<ba;K++){Y=X[K];N=Y.color;if(Y instanceof THREE.AmbientLight){fa.r+=N.r;fa.g+=N.g;fa.b+=N.b}else if(Y instanceof THREE.DirectionalLight){ea.r+=
N.r;ea.g+=N.g;ea.b+=N.b}else if(Y instanceof THREE.PointLight){q.r+=N.r;q.g+=N.g;q.b+=N.b}}}function Aa(K,ba,Y,N){var X,ca,ia,ka,la=K.lights;K=0;for(X=la.length;K<X;K++){ca=la[K];ia=ca.color;ka=ca.intensity;if(ca instanceof THREE.DirectionalLight){ca=Y.dot(ca.position)*ka;if(ca>0){N.r+=ia.r*ca;N.g+=ia.g*ca;N.b+=ia.b*ca}}else if(ca instanceof THREE.PointLight){E.sub(ca.position,ba);E.normalize();ca=Y.dot(E)*ka;if(ca>0){N.r+=ia.r*ca;N.g+=ia.g*ca;N.b+=ia.b*ca}}}}function Na(K,ba,Y){if(Y.opacity!=0){a(Y.opacity);
c(Y.blending);var N,X,ca,ia,ka,la;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ia=Y.map;ka=ia.width>>1;la=ia.height>>1;X=ba.scale.x*b;ca=ba.scale.y*i;Y=X*ka;N=ca*la;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(X,-ca);k.translate(-ka,-la);k.drawImage(ia,0,0);k.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+q.r;S.g=fa.g+ea.g+q.g;S.b=fa.b+ea.b+q.b;s.r=Y.color.r*S.r;s.g=Y.color.g*S.g;s.b=
Y.color.b*S.b;s.updateStyleString()}else s.__styleString=Y.color.__styleString;Y=ba.scale.x*b;N=ba.scale.y*i;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){X=s.__styleString;if(y!=X)k.fillStyle=y=X;k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(Y,N);k.beginPath();k.arc(0,0,1,0,G,true);k.closePath();k.fill();k.restore()}}}}function Oa(K,ba,Y,N){if(N.opacity!=0){a(N.opacity);c(N.blending);k.beginPath();k.moveTo(K.positionScreen.x,K.positionScreen.y);k.lineTo(ba.positionScreen.x,ba.positionScreen.y);
k.closePath();if(N instanceof THREE.LineBasicMaterial){s.__styleString=N.color.__styleString;K=N.linewidth;if(H!=K)k.lineWidth=H=K;K=s.__styleString;if(x!=K)k.strokeStyle=x=K;k.stroke();D.inflate(N.linewidth*2)}}}function Ia(K,ba,Y,N,X,ca){if(X.opacity!=0){a(X.opacity);c(X.blending);g=K.positionScreen.x;m=K.positionScreen.y;w=ba.positionScreen.x;o=ba.positionScreen.y;v=Y.positionScreen.x;J=Y.positionScreen.y;k.beginPath();k.moveTo(g,m);k.lineTo(w,o);k.lineTo(v,J);k.lineTo(g,m);k.closePath();if(X instanceof
b(Y.blending);var N,X,ca,ia,ka,la;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ia=Y.map;ka=ia.width>>1;la=ia.height>>1;X=ba.scale.x*c;ca=ba.scale.y*i;Y=X*ka;N=ca*la;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(X,-ca);k.translate(-ka,-la);k.drawImage(ia,0,0);k.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+q.r;S.g=fa.g+ea.g+q.g;S.b=fa.b+ea.b+q.b;s.r=Y.color.r*S.r;s.g=Y.color.g*S.g;s.b=
Y.color.b*S.b;s.updateStyleString()}else s.__styleString=Y.color.__styleString;Y=ba.scale.x*c;N=ba.scale.y*i;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){X=s.__styleString;if(y!=X)k.fillStyle=y=X;k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(Y,N);k.beginPath();k.arc(0,0,1,0,G,true);k.closePath();k.fill();k.restore()}}}}function Oa(K,ba,Y,N){if(N.opacity!=0){a(N.opacity);b(N.blending);k.beginPath();k.moveTo(K.positionScreen.x,K.positionScreen.y);k.lineTo(ba.positionScreen.x,ba.positionScreen.y);
k.closePath();if(N instanceof THREE.LineBasicMaterial){s.__styleString=N.color.__styleString;K=N.linewidth;if(H!=K)k.lineWidth=H=K;K=s.__styleString;if(x!=K)k.strokeStyle=x=K;k.stroke();D.inflate(N.linewidth*2)}}}function Ia(K,ba,Y,N,X,ca){if(X.opacity!=0){a(X.opacity);b(X.blending);g=K.positionScreen.x;m=K.positionScreen.y;w=ba.positionScreen.x;o=ba.positionScreen.y;v=Y.positionScreen.x;J=Y.positionScreen.y;k.beginPath();k.moveTo(g,m);k.lineTo(w,o);k.lineTo(v,J);k.lineTo(g,m);k.closePath();if(X instanceof
THREE.MeshBasicMaterial)if(X.map)X.map.image.loaded&&X.map.mapping instanceof THREE.UVMapping&&xa(g,m,w,o,v,J,X.map.image,N.uvs[0].u,N.uvs[0].v,N.uvs[1].u,N.uvs[1].v,N.uvs[2].u,N.uvs[2].v);else if(X.env_map){if(X.env_map.image.loaded)if(X.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=ta.matrix;E.copy(N.vertexNormalsWorld[0]);T=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;M=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;E.copy(N.vertexNormalsWorld[1]);aa=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;
U=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;E.copy(N.vertexNormalsWorld[2]);O=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;Q=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;xa(g,m,w,o,v,J,X.env_map.image,T,M,aa,U,O,Q)}}else X.wireframe?Ba(X.color.__styleString,X.wireframe_linewidth):Ca(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){X.map.mapping instanceof THREE.UVMapping&&xa(g,m,w,o,v,J,X.map.image,N.uvs[0].u,N.uvs[0].v,N.uvs[1].u,N.uvs[1].v,N.uvs[2].u,N.uvs[2].v);
c(THREE.SubtractiveBlending)}if(P)if(!X.wireframe&&X.shading==THREE.SmoothShading&&N.vertexNormalsWorld.length==3){A.r=C.r=B.r=fa.r;A.g=C.g=B.g=fa.g;A.b=C.b=B.b=fa.b;Aa(ca,N.v1.positionWorld,N.vertexNormalsWorld[0],A);Aa(ca,N.v2.positionWorld,N.vertexNormalsWorld[1],C);Aa(ca,N.v3.positionWorld,N.vertexNormalsWorld[2],B);t.r=(C.r+B.r)*0.5;t.g=(C.g+B.g)*0.5;t.b=(C.b+B.b)*0.5;R=Ja(A,C,B,t);xa(g,m,w,o,v,J,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,N.centroidWorld,N.normalWorld,S);s.r=X.color.r*
b(THREE.SubtractiveBlending)}if(P)if(!X.wireframe&&X.shading==THREE.SmoothShading&&N.vertexNormalsWorld.length==3){A.r=C.r=B.r=fa.r;A.g=C.g=B.g=fa.g;A.b=C.b=B.b=fa.b;Aa(ca,N.v1.positionWorld,N.vertexNormalsWorld[0],A);Aa(ca,N.v2.positionWorld,N.vertexNormalsWorld[1],C);Aa(ca,N.v3.positionWorld,N.vertexNormalsWorld[2],B);t.r=(C.r+B.r)*0.5;t.g=(C.g+B.g)*0.5;t.b=(C.b+B.b)*0.5;R=Ja(A,C,B,t);xa(g,m,w,o,v,J,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,N.centroidWorld,N.normalWorld,S);s.r=X.color.r*
S.r;s.g=X.color.g*S.g;s.b=X.color.b*S.b;s.updateStyleString();X.wireframe?Ba(s.__styleString,X.wireframe_linewidth):Ca(s.__styleString)}else X.wireframe?Ba(X.color.__styleString,X.wireframe_linewidth):Ca(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){L=ta.near;F=ta.far;A.r=A.g=A.b=1-Ea(K.positionScreen.z,L,F);C.r=C.g=C.b=1-Ea(ba.positionScreen.z,L,F);B.r=B.g=B.b=1-Ea(Y.positionScreen.z,L,F);t.r=(C.r+B.r)*0.5;t.g=(C.g+B.g)*0.5;t.b=(C.b+B.b)*0.5;R=Ja(A,C,B,t);xa(g,m,w,o,v,J,R,
0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){s.r=Fa(N.normalWorld.x);s.g=Fa(N.normalWorld.y);s.b=Fa(N.normalWorld.z);s.updateStyleString();X.wireframe?Ba(s.__styleString,X.wireframe_linewidth):Ca(s.__styleString)}}}function Ba(K,ba){if(x!=K)k.strokeStyle=x=K;if(H!=ba)k.lineWidth=H=ba;k.stroke();D.inflate(ba*2)}function Ca(K){if(y!=K)k.fillStyle=y=K;k.fill()}function xa(K,ba,Y,N,X,ca,ia,ka,la,qa,ma,ra,ya){var ua,sa;ua=ia.width-1;sa=ia.height-1;ka*=ua;la*=sa;qa*=ua;ma*=sa;ra*=ua;ya*=
sa;Y-=K;N-=ba;X-=K;ca-=ba;qa-=ka;ma-=la;ra-=ka;ya-=la;sa=1/(qa*ya-ra*ma);ua=(ya*Y-ma*X)*sa;ma=(ya*N-ma*ca)*sa;Y=(qa*X-ra*Y)*sa;N=(qa*ca-ra*N)*sa;K=K-ua*ka-Y*la;ba=ba-ma*ka-N*la;k.save();k.transform(ua,ma,Y,N,K,ba);k.clip();k.drawImage(ia,0,0);k.restore()}function Ja(K,ba,Y,N){var X=~~(K.r*255),ca=~~(K.g*255);K=~~(K.b*255);var ia=~~(ba.r*255),ka=~~(ba.g*255);ba=~~(ba.b*255);var la=~~(Y.r*255),qa=~~(Y.g*255);Y=~~(Y.b*255);var ma=~~(N.r*255),ra=~~(N.g*255);N=~~(N.b*255);ga[0]=X<0?0:X>255?255:X;ga[1]=
ca<0?0:ca>255?255:ca;ga[2]=K<0?0:K>255?255:K;ga[4]=ia<0?0:ia>255?255:ia;ga[5]=ka<0?0:ka>255?255:ka;ga[6]=ba<0?0:ba>255?255:ba;ga[8]=la<0?0:la>255?255:la;ga[9]=qa<0?0:qa>255?255:qa;ga[10]=Y<0?0:Y>255?255:Y;ga[12]=ma<0?0:ma>255?255:ma;ga[13]=ra<0?0:ra>255?255:ra;ga[14]=N<0?0:N>255?255:N;$.putImageData(da,0,0);pa.drawImage(W,0,0);return na}function Ea(K,ba,Y){K=(K-ba)/(Y-ba);return K*K*(3-2*K)}function Fa(K){K=(K+1)*0.5;return K<0?0:K>1?1:K}function Ga(K,ba){var Y=ba.x-K.x,N=ba.y-K.y,X=1/Math.sqrt(Y*
Y+N*N);Y*=X;N*=X;ba.x+=Y;ba.y+=N;K.x-=Y;K.y-=N}var Da,Ka,ha,oa,wa,Ha,La,za;k.setTransform(1,0,0,-1,b,i);this.autoClear&&this.clear();d=e.projectScene(ja,ta,this.sortElements);(P=ja.lights.length>0)&&Ma(ja);Da=0;for(Ka=d.length;Da<Ka;Da++){ha=d[Da];D.empty();if(ha instanceof THREE.RenderableParticle){p=ha;p.x*=b;p.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(p,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){p=ha.v1;I=ha.v2;p.positionScreen.x*=b;p.positionScreen.y*=i;I.positionScreen.x*=
b;I.positionScreen.y*=i;D.addPoint(p.positionScreen.x,p.positionScreen.y);D.addPoint(I.positionScreen.x,I.positionScreen.y);if(Z.instersects(D)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(p,I,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){p=ha.v1;I=ha.v2;l=ha.v3;p.positionScreen.x*=b;p.positionScreen.y*=i;I.positionScreen.x*=b;I.positionScreen.y*=i;l.positionScreen.x*=b;l.positionScreen.y*=i;if(ha.overdraw){Ga(p.positionScreen,I.positionScreen);Ga(I.positionScreen,l.positionScreen);
Y+N*N);Y*=X;N*=X;ba.x+=Y;ba.y+=N;K.x-=Y;K.y-=N}var Da,Ka,ha,oa,wa,Ha,La,za;k.setTransform(1,0,0,-1,c,i);this.autoClear&&this.clear();d=e.projectScene(ja,ta,this.sortElements);(P=ja.lights.length>0)&&Ma(ja);Da=0;for(Ka=d.length;Da<Ka;Da++){ha=d[Da];D.empty();if(ha instanceof THREE.RenderableParticle){p=ha;p.x*=c;p.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(p,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){p=ha.v1;I=ha.v2;p.positionScreen.x*=c;p.positionScreen.y*=i;I.positionScreen.x*=
c;I.positionScreen.y*=i;D.addPoint(p.positionScreen.x,p.positionScreen.y);D.addPoint(I.positionScreen.x,I.positionScreen.y);if(Z.instersects(D)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(p,I,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){p=ha.v1;I=ha.v2;l=ha.v3;p.positionScreen.x*=c;p.positionScreen.y*=i;I.positionScreen.x*=c;I.positionScreen.y*=i;l.positionScreen.x*=c;l.positionScreen.y*=i;if(ha.overdraw){Ga(p.positionScreen,I.positionScreen);Ga(I.positionScreen,l.positionScreen);
Ga(l.positionScreen,p.positionScreen)}D.add3Points(p.positionScreen.x,p.positionScreen.y,I.positionScreen.x,I.positionScreen.y,l.positionScreen.x,l.positionScreen.y);if(Z.instersects(D)){oa=0;for(wa=ha.meshMaterials.length;oa<wa;){za=ha.meshMaterials[oa++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=ha.faceMaterials.length;Ha<La;)(za=ha.faceMaterials[Ha++])&&Ia(p,I,l,ha,za,ja)}else Ia(p,I,l,ha,za,ja)}}}V.addRectangle(D)}k.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(T,M,aa){var U,O,Q,Z;U=0;for(O=T.lights.length;U<O;U++){Q=T.lights[U];if(Q instanceof THREE.DirectionalLight){Z=M.normalWorld.dot(Q.position)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}else if(Q instanceof THREE.PointLight){J.sub(Q.position,M.centroidWorld);J.normalize();Z=M.normalWorld.dot(J)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}}}function c(T,M,aa,U,O,Q){B=e(t++);B.setAttribute("d","M "+
THREE.SVGRenderer=function(){function a(T,M,aa){var U,O,Q,Z;U=0;for(O=T.lights.length;U<O;U++){Q=T.lights[U];if(Q instanceof THREE.DirectionalLight){Z=M.normalWorld.dot(Q.position)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}else if(Q instanceof THREE.PointLight){J.sub(Q.position,M.centroidWorld);J.normalize();Z=M.normalWorld.dot(J)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}}}function b(T,M,aa,U,O,Q){B=e(t++);B.setAttribute("d","M "+
T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)l.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(I){g.r=m.r;g.g=m.g;g.b=m.b;a(Q,U,g);l.r=O.color.r*g.r;l.g=O.color.g*g.g;l.b=O.color.b*g.b;l.updateStyleString()}else l.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){v=1-O.__2near/(O.__farPlusNear-
U.z*O.__farMinusNear);l.setRGB(v,v,v)}else O instanceof THREE.MeshNormalMaterial&&l.setRGB(f(U.normalWorld.x),f(U.normalWorld.y),f(U.normalWorld.z));O.wireframe?B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):B.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+O.opacity);b.appendChild(B)}function d(T,M,aa,U,O,Q,Z){B=
U.z*O.__farMinusNear);l.setRGB(v,v,v)}else O instanceof THREE.MeshNormalMaterial&&l.setRGB(f(U.normalWorld.x),f(U.normalWorld.y),f(U.normalWorld.z));O.wireframe?B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):B.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(B)}function d(T,M,aa,U,O,Q,Z){B=
e(t++);B.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)l.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(I){g.r=m.r;g.g=m.g;g.b=m.b;a(Z,O,g);l.r=Q.color.r*g.r;l.g=Q.color.g*g.g;l.b=Q.color.b*g.b;l.updateStyleString()}else l.__styleString=Q.color.__styleString;
else if(Q instanceof THREE.MeshDepthMaterial){v=1-Q.__2near/(Q.__farPlusNear-O.z*Q.__farMinusNear);l.setRGB(v,v,v)}else Q instanceof THREE.MeshNormalMaterial&&l.setRGB(f(O.normalWorld.x),f(O.normalWorld.y),f(O.normalWorld.z));Q.wireframe?B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):B.setAttribute("style","fill: "+l.__styleString+
"; fill-opacity: "+Q.opacity);b.appendChild(B)}function e(T){if(s[T]==null){s[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&s[T].setAttribute("shape-rendering","crispEdges");return s[T]}return s[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var h=null,j=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,k,r,z,n,u,x,y,H=new THREE.Rectangle,p=new THREE.Rectangle,I=false,l=new THREE.Color(16777215),g=new THREE.Color(16777215),
m=new THREE.Color(0),w=new THREE.Color(0),o=new THREE.Color(0),v,J=new THREE.Vector3,s=[],A=[],C=[],B,t,L,F,R=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":R=1;break;case "low":R=0}};this.setSize=function(T,M){i=T;k=M;r=i/2;z=k/2;b.setAttribute("viewBox",-r+" "+-z+" "+i+" "+k);b.setAttribute("width",i);b.setAttribute("height",k);H.set(-r,-z,r,z)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
"; fill-opacity: "+Q.opacity);c.appendChild(B)}function e(T){if(s[T]==null){s[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&s[T].setAttribute("shape-rendering","crispEdges");return s[T]}return s[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,k,r,z,n,u,x,y,H=new THREE.Rectangle,p=new THREE.Rectangle,I=false,l=new THREE.Color(16777215),g=new THREE.Color(16777215),
m=new THREE.Color(0),w=new THREE.Color(0),o=new THREE.Color(0),v,J=new THREE.Vector3,s=[],A=[],C=[],B,t,L,F,R=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":R=1;break;case "low":R=0}};this.setSize=function(T,M){i=T;k=M;r=i/2;z=k/2;c.setAttribute("viewBox",-r+" "+-z+" "+i+" "+k);c.setAttribute("width",i);c.setAttribute("height",k);H.set(-r,-z,r,z)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
this.render=function(T,M){var aa,U,O,Q,Z,V,D,P;this.autoClear&&this.clear();h=j.projectScene(T,M,this.sortElements);F=L=t=0;if(I=T.lights.length>0){D=T.lights;m.setRGB(0,0,0);w.setRGB(0,0,0);o.setRGB(0,0,0);aa=0;for(U=D.length;aa<U;aa++){O=D[aa];Q=O.color;if(O instanceof THREE.AmbientLight){m.r+=Q.r;m.g+=Q.g;m.b+=Q.b}else if(O instanceof THREE.DirectionalLight){w.r+=Q.r;w.g+=Q.g;w.b+=Q.b}else if(O instanceof THREE.PointLight){o.r+=Q.r;o.g+=Q.g;o.b+=Q.b}}}aa=0;for(U=h.length;aa<U;aa++){D=h[aa];p.empty();
if(D instanceof THREE.RenderableParticle){n=D;n.x*=r;n.y*=-z;O=0;for(Q=D.materials.length;O<Q;O++)if(P=D.materials[O]){Z=n;V=D;P=P;var S=L++;if(A[S]==null){A[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&A[S].setAttribute("shape-rendering","crispEdges")}B=A[S];B.setAttribute("cx",Z.x);B.setAttribute("cy",Z.y);B.setAttribute("r",V.scale.x*r);if(P instanceof THREE.ParticleCircleMaterial){if(I){g.r=m.r+w.r+o.r;g.g=m.g+w.g+o.g;g.b=m.b+w.b+o.b;l.r=P.color.r*g.r;l.g=P.color.g*
g.g;l.b=P.color.b*g.b;l.updateStyleString()}else l=P.color;B.setAttribute("style","fill: "+l.__styleString)}b.appendChild(B)}}else if(D instanceof THREE.RenderableLine){n=D.v1;u=D.v2;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(p)){O=0;for(Q=D.materials.length;O<Q;)if(P=D.materials[O++]){Z=n;V=u;P=P;S=F++;if(C[S]==null){C[S]=document.createElementNS("http://www.w3.org/2000/svg",
"line");R==0&&C[S].setAttribute("shape-rendering","crispEdges")}B=C[S];B.setAttribute("x1",Z.positionScreen.x);B.setAttribute("y1",Z.positionScreen.y);B.setAttribute("x2",V.positionScreen.x);B.setAttribute("y2",V.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){l.__styleString=P.color.__styleString;B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);b.appendChild(B)}}}}else if(D instanceof
g.g;l.b=P.color.b*g.b;l.updateStyleString()}else l=P.color;B.setAttribute("style","fill: "+l.__styleString)}c.appendChild(B)}}else if(D instanceof THREE.RenderableLine){n=D.v1;u=D.v2;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(p)){O=0;for(Q=D.materials.length;O<Q;)if(P=D.materials[O++]){Z=n;V=u;P=P;S=F++;if(C[S]==null){C[S]=document.createElementNS("http://www.w3.org/2000/svg",
"line");R==0&&C[S].setAttribute("shape-rendering","crispEdges")}B=C[S];B.setAttribute("x1",Z.positionScreen.x);B.setAttribute("y1",Z.positionScreen.y);B.setAttribute("x2",V.positionScreen.x);B.setAttribute("y2",V.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){l.__styleString=P.color.__styleString;B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);c.appendChild(B)}}}}else if(D instanceof
THREE.RenderableFace3){n=D.v1;u=D.v2;x=D.v3;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;x.positionScreen.x*=r;x.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(p)){O=0;for(Q=D.meshMaterials.length;O<Q;){P=D.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=D.faceMaterials.length;Z<V;)(P=D.faceMaterials[Z++])&&
c(n,u,x,D,P,T)}else P&&c(n,u,x,D,P,T)}}}else if(D instanceof THREE.RenderableFace4){n=D.v1;u=D.v2;x=D.v3;y=D.v4;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;x.positionScreen.x*=r;x.positionScreen.y*=-z;y.positionScreen.x*=r;y.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(p)){O=
b(n,u,x,D,P,T)}else P&&b(n,u,x,D,P,T)}}}else if(D instanceof THREE.RenderableFace4){n=D.v1;u=D.v2;x=D.v3;y=D.v4;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;x.positionScreen.x*=r;x.positionScreen.y*=-z;y.positionScreen.x*=r;y.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(p)){O=
0;for(Q=D.meshMaterials.length;O<Q;){P=D.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=D.faceMaterials.length;Z<V;)(P=D.faceMaterials[Z++])&&d(n,u,x,y,D,P,T)}else P&&d(n,u,x,y,D,P,T)}}}}}};
THREE.WebGLRenderer=function(a){function c(g,m){g.fragment_shader=m.fragment_shader;g.vertex_shader=m.vertex_shader;g.uniforms=Uniforms.clone(m.uniforms)}function d(g,m){g.uniforms.color.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=
THREE.WebGLRenderer=function(a){function b(g,m){g.fragment_shader=m.fragment_shader;g.vertex_shader=m.vertex_shader;g.uniforms=Uniforms.clone(m.uniforms)}function d(g,m){g.uniforms.color.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=
g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;if(m){g.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){g.uniforms.fogNear.value=m.near;g.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)g.uniforms.fogDensity.value=m.density}}function e(g,m){g.uniforms.color.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;if(m){g.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){g.uniforms.fogNear.value=
m.near;g.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)g.uniforms.fogDensity.value=m.density}}function f(g,m){var w;if(g=="fragment")w=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")w=b.createShader(b.VERTEX_SHADER);b.shaderSource(w,m);b.compileShader(w);if(!b.getShaderParameter(w,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(w));return null}return w}function h(g){switch(g){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),b,i=null,k=null,r=new THREE.Matrix4,z,n=new Float32Array(16),u=new Float32Array(16),x=new Float32Array(16),y=new Float32Array(9),
H=new Float32Array(16),p=true,I=new THREE.Color(0),l=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)l=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(g,m,w){try{b=j.getContext("experimental-webgl",{antialias:g})}catch(o){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(m.r,m.g,m.b,w)})(p,I,l);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,m){j.width=g;j.height=m;b.viewport(0,0,j.width,j.height)};this.setClearColor=function(g,m){var w=new THREE.Color(g);b.clearColor(w.r,w.g,w.b,m)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
m.near;g.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)g.uniforms.fogDensity.value=m.density}}function f(g,m){var w;if(g=="fragment")w=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")w=c.createShader(c.VERTEX_SHADER);c.shaderSource(w,m);c.compileShader(w);if(!c.getShaderParameter(w,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(w));return null}return w}function h(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),c,i=null,k=null,r=new THREE.Matrix4,z,n=new Float32Array(16),u=new Float32Array(16),x=new Float32Array(16),y=new Float32Array(9),
H=new Float32Array(16),p=true,I=new THREE.Color(0),l=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)l=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(g,m,w){try{c=j.getContext("experimental-webgl",{antialias:g})}catch(o){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);
c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(m.r,m.g,m.b,w)})(p,I,l);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,m){j.width=g;j.height=m;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(g,m){var w=new THREE.Color(g);c.clearColor(w.r,w.g,w.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
function(g,m){var w,o,v,J=0,s=0,A=0,C,B,t,L=this.lights,F=L.directional.colors,R=L.directional.positions,T=L.point.colors,M=L.point.positions,aa=0,U=0;w=0;for(o=m.length;w<o;w++){v=m[w];C=v.color;B=v.position;t=v.intensity;if(v instanceof THREE.AmbientLight){J+=C.r;s+=C.g;A+=C.b}else if(v instanceof THREE.DirectionalLight){F[aa*3]=C.r*t;F[aa*3+1]=C.g*t;F[aa*3+2]=C.b*t;R[aa*3]=B.x;R[aa*3+1]=B.y;R[aa*3+2]=B.z;aa+=1}else if(v instanceof THREE.PointLight){T[U*3]=C.r*t;T[U*3+1]=C.g*t;T[U*3+2]=C.b*t;M[U*
3]=B.x;M[U*3+1]=B.y;M[U*3+2]=B.z;U+=1}}L.point.length=U;L.directional.length=aa;L.ambient[0]=J;L.ambient[1]=s;L.ambient[2]=A};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLNormalBuffer=b.createBuffer();g.__webGLTangentBuffer=b.createBuffer();
g.__webGLUVBuffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(g){var m=g.vertices.length;g.__vertexArray=new Float32Array(m*3);g.__lineArray=new Uint16Array(m);g.__webGLLineCount=m};this.initMeshBuffers=function(g,m){var w,o,v=0,J=0,s=0,A=m.geometry.faces,C=g.faces;w=0;for(o=C.length;w<o;w++){fi=C[w];face=A[fi];if(face instanceof THREE.Face3){v+=3;J+=1;s+=3}else if(face instanceof THREE.Face4){v+=4;J+=2;s+=4}}g.__vertexArray=
3]=B.x;M[U*3+1]=B.y;M[U*3+2]=B.z;U+=1}}L.point.length=U;L.directional.length=aa;L.ambient[0]=J;L.ambient[1]=s;L.ambient[2]=A};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLNormalBuffer=c.createBuffer();g.__webGLTangentBuffer=c.createBuffer();
g.__webGLUVBuffer=c.createBuffer();g.__webGLFaceBuffer=c.createBuffer();g.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(g){var m=g.vertices.length;g.__vertexArray=new Float32Array(m*3);g.__lineArray=new Uint16Array(m);g.__webGLLineCount=m};this.initMeshBuffers=function(g,m){var w,o,v=0,J=0,s=0,A=m.geometry.faces,C=g.faces;w=0;for(o=C.length;w<o;w++){fi=C[w];face=A[fi];if(face instanceof THREE.Face3){v+=3;J+=1;s+=3}else if(face instanceof THREE.Face4){v+=4;J+=2;s+=4}}g.__vertexArray=
new Float32Array(v*3);g.__normalArray=new Float32Array(v*3);g.__tangentArray=new Float32Array(v*4);g.__uvArray=new Float32Array(v*2);g.__faceArray=new Uint16Array(J*3);g.__lineArray=new Uint16Array(s*2);v=false;w=0;for(o=m.materials.length;w<o;w++){A=m.materials[w];if(A instanceof THREE.MeshFaceMaterial){A=0;for(C=g.materials.length;A<C;A++)if(g.materials[A]&&g.materials[A].shading!=undefined&&g.materials[A].shading==THREE.SmoothShading){v=true;break}}else if(A&&A.shading!=undefined&&A.shading==THREE.SmoothShading){v=
true;break}if(v)break}g.__needsSmoothNormals=v;g.__webGLFaceCount=J*3;g.__webGLLineCount=s*2};this.setMeshBuffers=function(g,m,w,o,v,J,s,A){var C,B,t,L,F,R,T,M,aa,U=0,O=0,Q=0,Z=0,V=0,D=0,P=0,S=g.__vertexArray,fa=g.__uvArray,ea=g.__normalArray,q=g.__tangentArray,G=g.__faceArray,E=g.__lineArray,W=g.__needsSmoothNormals,$=m.geometry,da=$.vertices,ga=g.faces,na=$.faces,pa=$.uvs;m=0;for(C=ga.length;m<C;m++){B=ga[m];t=na[B];B=pa[B];L=t.vertexNormals;F=t.normal;if(t instanceof THREE.Face3){if(o){R=da[t.a].position;
T=da[t.b].position;M=da[t.c].position;S[O]=R.x;S[O+1]=R.y;S[O+2]=R.z;S[O+3]=T.x;S[O+4]=T.y;S[O+5]=T.z;S[O+6]=M.x;S[O+7]=M.y;S[O+8]=M.z;O+=9}if(A&&$.hasTangents){R=da[t.a].tangent;T=da[t.b].tangent;M=da[t.c].tangent;q[D]=R.x;q[D+1]=R.y;q[D+2]=R.z;q[D+3]=R.w;q[D+4]=T.x;q[D+5]=T.y;q[D+6]=T.z;q[D+7]=T.w;q[D+8]=M.x;q[D+9]=M.y;q[D+10]=M.z;q[D+11]=M.w;D+=12}if(s)if(L.length==3&&W)for(t=0;t<3;t++){F=L[t];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(t=0;t<3;t++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(J&&
B)for(t=0;t<3;t++){L=B[t];fa[Q]=L.u;fa[Q+1]=L.v;Q+=2}if(v){G[Z]=U;G[Z+1]=U+1;G[Z+2]=U+2;Z+=3;E[P]=U;E[P+1]=U+1;E[P+2]=U;E[P+3]=U+2;E[P+4]=U+1;E[P+5]=U+2;P+=6;U+=3}}else if(t instanceof THREE.Face4){if(o){R=da[t.a].position;T=da[t.b].position;M=da[t.c].position;aa=da[t.d].position;S[O]=R.x;S[O+1]=R.y;S[O+2]=R.z;S[O+3]=T.x;S[O+4]=T.y;S[O+5]=T.z;S[O+6]=M.x;S[O+7]=M.y;S[O+8]=M.z;S[O+9]=aa.x;S[O+10]=aa.y;S[O+11]=aa.z;O+=12}if(A&&$.hasTangents){R=da[t.a].tangent;T=da[t.b].tangent;M=da[t.c].tangent;t=da[t.d].tangent;
q[D]=R.x;q[D+1]=R.y;q[D+2]=R.z;q[D+3]=R.w;q[D+4]=T.x;q[D+5]=T.y;q[D+6]=T.z;q[D+7]=T.w;q[D+8]=M.x;q[D+9]=M.y;q[D+10]=M.z;q[D+11]=M.w;q[D+12]=t.x;q[D+13]=t.y;q[D+14]=t.z;q[D+15]=t.w;D+=16}if(s)if(L.length==4&&W)for(t=0;t<4;t++){F=L[t];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(t=0;t<4;t++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(J&&B)for(t=0;t<4;t++){L=B[t];fa[Q]=L.u;fa[Q+1]=L.v;Q+=2}if(v){G[Z]=U;G[Z+1]=U+1;G[Z+2]=U+2;G[Z+3]=U;G[Z+4]=U+2;G[Z+5]=U+3;Z+=6;E[P]=U;E[P+1]=U+1;E[P+2]=U;E[P+3]=U+3;
E[P+4]=U+1;E[P+5]=U+2;E[P+6]=U+2;E[P+7]=U+3;P+=8;U+=4}}}if(o){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,S,w)}if(s){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ea,w)}if(A&&$.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,q,w)}if(J&&Q>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,fa,w)}if(v){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,
G,w);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,w)}};this.setLineBuffers=function(g,m,w,o){var v,J,s=g.vertices,A=s.length,C=g.__vertexArray,B=g.__lineArray;if(w)for(w=0;w<A;w++){v=s[w].position;J=w*3;C[J]=v.x;C[J+1]=v.y;C[J+2]=v.z}if(o)for(w=0;w<A;w++)B[w]=w;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,C,m);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,m)};this.setParticleBuffers=
function(){};this.renderBuffer=function(g,m,w,o,v,J){var s,A,C,B;if(!o.program){if(o instanceof THREE.MeshDepthMaterial){c(o,THREE.ShaderLib.depth);o.uniforms.mNear.value=g.near;o.uniforms.mFar.value=g.far}else if(o instanceof THREE.MeshNormalMaterial)c(o,THREE.ShaderLib.normal);else if(o instanceof THREE.MeshBasicMaterial){c(o,THREE.ShaderLib.basic);d(o,w)}else if(o instanceof THREE.MeshLambertMaterial){c(o,THREE.ShaderLib.lambert);d(o,w)}else if(o instanceof THREE.MeshPhongMaterial){c(o,THREE.ShaderLib.phong);
d(o,w)}else if(o instanceof THREE.LineBasicMaterial){c(o,THREE.ShaderLib.basic);e(o,w)}var t,L,F;t=B=A=0;for(L=m.length;t<L;t++){F=m[t];F instanceof THREE.DirectionalLight&&B++;F instanceof THREE.PointLight&&A++}if(A+B<=4){t=B;A=A}else{t=Math.ceil(4*B/(A+B));A=4-t}A={directional:t,point:A};B={fog:w,map:o.map,env_map:o.env_map,maxDirLights:A.directional,maxPointLights:A.point};A=o.fragment_shader;t=o.vertex_shader;L=b.createProgram();F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.fog?"#define USE_FOG":"",B.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");B=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"",
"uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");b.attachShader(L,f("fragment",F+A));b.attachShader(L,f("vertex",B+t));b.linkProgram(L);b.getProgramParameter(L,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(L,b.VALIDATE_STATUS)+", gl error ["+
b.getError()+"]");L.uniforms={};L.attributes={};o.program=L;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(s in o.uniforms)A.push(s);s=o.program;t=0;for(L=A.length;t<L;t++){F=A[t];s.uniforms[F]=b.getUniformLocation(s,F)}s=o.program;A=["position","normal","uv","tangent"];t=0;for(L=A.length;t<L;t++){F=A[t];s.attributes[F]=b.getAttribLocation(s,F)}}s=o.program;if(s!=i){b.useProgram(s);i=s}this.loadCamera(s,g);this.loadMatrices(s);if(o instanceof
E[P+4]=U+1;E[P+5]=U+2;E[P+6]=U+2;E[P+7]=U+3;P+=8;U+=4}}}if(o){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,w)}if(s){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ea,w)}if(A&&$.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,q,w)}if(J&&Q>0){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,fa,w)}if(v){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
G,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,w)}};this.setLineBuffers=function(g,m,w,o){var v,J,s=g.vertices,A=s.length,C=g.__vertexArray,B=g.__lineArray;if(w)for(w=0;w<A;w++){v=s[w].position;J=w*3;C[J]=v.x;C[J+1]=v.y;C[J+2]=v.z}if(o)for(w=0;w<A;w++)B[w]=w;c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,C,m);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,B,m)};this.setParticleBuffers=
function(){};this.renderBuffer=function(g,m,w,o,v,J){var s,A,C,B;if(!o.program){if(o instanceof THREE.MeshDepthMaterial){b(o,THREE.ShaderLib.depth);o.uniforms.mNear.value=g.near;o.uniforms.mFar.value=g.far}else if(o instanceof THREE.MeshNormalMaterial)b(o,THREE.ShaderLib.normal);else if(o instanceof THREE.MeshBasicMaterial){b(o,THREE.ShaderLib.basic);d(o,w)}else if(o instanceof THREE.MeshLambertMaterial){b(o,THREE.ShaderLib.lambert);d(o,w)}else if(o instanceof THREE.MeshPhongMaterial){b(o,THREE.ShaderLib.phong);
d(o,w)}else if(o instanceof THREE.LineBasicMaterial){b(o,THREE.ShaderLib.basic);e(o,w)}var t,L,F;t=B=A=0;for(L=m.length;t<L;t++){F=m[t];F instanceof THREE.DirectionalLight&&B++;F instanceof THREE.PointLight&&A++}if(A+B<=4){t=B;A=A}else{t=Math.ceil(4*B/(A+B));A=4-t}A={directional:t,point:A};B={fog:w,map:o.map,env_map:o.env_map,maxDirLights:A.directional,maxPointLights:A.point};A=o.fragment_shader;t=o.vertex_shader;L=c.createProgram();F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.fog?"#define USE_FOG":"",B.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");B=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"",
"uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(L,f("fragment",F+A));c.attachShader(L,f("vertex",B+t));c.linkProgram(L);c.getProgramParameter(L,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(L,c.VALIDATE_STATUS)+", gl error ["+
c.getError()+"]");L.uniforms={};L.attributes={};o.program=L;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(s in o.uniforms)A.push(s);s=o.program;t=0;for(L=A.length;t<L;t++){F=A[t];s.uniforms[F]=c.getUniformLocation(s,F)}s=o.program;A=["position","normal","uv","tangent"];t=0;for(L=A.length;t<L;t++){F=A[t];s.attributes[F]=c.getAttribLocation(s,F)}}s=o.program;if(s!=i){c.useProgram(s);i=s}this.loadCamera(s,g);this.loadMatrices(s);if(o instanceof
THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial){this.setupLights(s,m);g=this.lights;o.uniforms.enableLighting.value=g.directional.length+g.point.length;o.uniforms.ambientLightColor.value=g.ambient;o.uniforms.directionalLightColor.value=g.directional.colors;o.uniforms.directionalLightDirection.value=g.directional.positions;o.uniforms.pointLightColor.value=g.point.colors;o.uniforms.pointLightPosition.value=g.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||
o instanceof THREE.MeshPhongMaterial)d(o,w);o instanceof THREE.LineBasicMaterial&&e(o,w);if(o instanceof THREE.MeshPhongMaterial){o.uniforms.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);o.uniforms.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);o.uniforms.shininess.value=o.shininess}w=o.uniforms;for(C in w)if(t=s.uniforms[C]){m=w[C];A=m.type;g=m.value;if(A=="i")b.uniform1i(t,g);else if(A=="f")b.uniform1f(t,g);else if(A=="fv1")b.uniform1fv(t,g);else if(A=="fv")b.uniform3fv(t,
g);else if(A=="v2")b.uniform2f(t,g.x,g.y);else if(A=="v3")b.uniform3f(t,g.x,g.y,g.z);else if(A=="c")b.uniform3f(t,g.r,g.g,g.b);else if(A=="t"){b.uniform1i(t,g);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;g=g;if(m.image.length==6){if(!m.image.__webGLTextureCube&&!m.image.__cubeMapInitialized&&m.image.loadCount==6){m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(A=0;A<6;++A)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[A]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=
m;g=g;if(!m.__webGLTexture&&m.image.loaded){m.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,
null)}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_2D,m.__webGLTexture)}}}C=s.attributes;b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.vertexAttribPointer(C.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(C.position);if(C.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.vertexAttribPointer(C.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(C.normal)}if(C.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLTangentBuffer);b.vertexAttribPointer(C.tangent,4,b.FLOAT,
false,0,0);b.enableVertexAttribArray(C.tangent)}if(C.uv>=0)if(v.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUVBuffer);b.vertexAttribPointer(C.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(C.uv)}else b.disableVertexAttribArray(C.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){C=o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&J.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(C);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
v.__webGLLineBuffer);b.drawElements(o,v.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,v.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,m,w,o,v,J,s){var A,C,B,t,L;B=0;for(t=o.materials.length;B<t;B++){A=o.materials[B];if(A instanceof THREE.MeshFaceMaterial){A=0;for(C=v.materials.length;A<C;A++)if((L=v.materials[A])&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,
v,o)}}else if((L=A)&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,v,o)}}};this.render=function(g,m,w,o){var v,J,s,A=g.lights,C=g.fog;this.initWebGLObjects(g);o=o!==undefined?o:true;if(w&&!w.__webGLFramebuffer){w.__webGLFramebuffer=b.createFramebuffer();w.__webGLRenderbuffer=b.createRenderbuffer();w.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,w.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,w.width,w.height);
b.bindTexture(b.TEXTURE_2D,w.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h(w.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h(w.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,h(w.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,h(w.min_filter));b.texImage2D(b.TEXTURE_2D,0,h(w.format),w.width,w.height,0,h(w.format),h(w.type),null);b.bindFramebuffer(b.FRAMEBUFFER,w.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,
w.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,w.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(w){v=w.__webGLFramebuffer;s=w.width;J=w.height}else{v=null;s=j.width;J=j.height}if(v!=k){b.bindFramebuffer(b.FRAMEBUFFER,v);b.viewport(0,0,s,J);o&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=v}this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();n.set(m.matrix.flatten());
x.set(m.projectionMatrix.flatten());o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);this.renderPass(m,A,C,s,J,THREE.NormalBlending,false)}}o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);if(s.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);s.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,
false);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,false);this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,true);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,true);this.renderPass(m,A,C,s,J,THREE.NormalBlending,true)}}if(w&&w.min_filter!==THREE.NearestFilter&&w.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,w.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(g){function m(B,t,L,F){if(B[t]==undefined){g.__webGLObjects.push({buffer:L,
o instanceof THREE.MeshPhongMaterial)d(o,w);o instanceof THREE.LineBasicMaterial&&e(o,w);if(o instanceof THREE.MeshPhongMaterial){o.uniforms.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);o.uniforms.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);o.uniforms.shininess.value=o.shininess}w=o.uniforms;for(C in w)if(t=s.uniforms[C]){m=w[C];A=m.type;g=m.value;if(A=="i")c.uniform1i(t,g);else if(A=="f")c.uniform1f(t,g);else if(A=="fv1")c.uniform1fv(t,g);else if(A=="fv")c.uniform3fv(t,
g);else if(A=="v2")c.uniform2f(t,g.x,g.y);else if(A=="v3")c.uniform3f(t,g.x,g.y,g.z);else if(A=="c")c.uniform3f(t,g.r,g.g,g.b);else if(A=="t"){c.uniform1i(t,g);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;g=g;if(m.image.length==6){if(!m.image.__webGLTextureCube&&!m.image.__cubeMapInitialized&&m.image.loadCount==6){m.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);
c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(A=0;A<6;++A)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[A]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=
m;g=g;if(!m.__webGLTexture&&m.image.loaded){m.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(m.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(m.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(m.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(m.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,m.__webGLTexture)}}}C=s.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(C.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.position);if(C.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.vertexAttribPointer(C.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.normal)}if(C.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.vertexAttribPointer(C.tangent,4,c.FLOAT,
false,0,0);c.enableVertexAttribArray(C.tangent)}if(C.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.vertexAttribPointer(C.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.uv)}else c.disableVertexAttribArray(C.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){C=o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&J.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
v.__webGLLineBuffer);c.drawElements(o,v.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,v.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,m,w,o,v,J,s){var A,C,B,t,L;B=0;for(t=o.materials.length;B<t;B++){A=o.materials[B];if(A instanceof THREE.MeshFaceMaterial){A=0;for(C=v.materials.length;A<C;A++)if((L=v.materials[A])&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,
v,o)}}else if((L=A)&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,v,o)}}};this.render=function(g,m,w,o){var v,J,s,A=g.lights,C=g.fog;this.initWebGLObjects(g);o=o!==undefined?o:true;if(w&&!w.__webGLFramebuffer){w.__webGLFramebuffer=c.createFramebuffer();w.__webGLRenderbuffer=c.createRenderbuffer();w.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,w.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,w.width,w.height);
c.bindTexture(c.TEXTURE_2D,w.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(w.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(w.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(w.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(w.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(w.format),w.width,w.height,0,h(w.format),h(w.type),null);c.bindFramebuffer(c.FRAMEBUFFER,w.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,
w.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,w.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(w){v=w.__webGLFramebuffer;s=w.width;J=w.height}else{v=null;s=j.width;J=j.height}if(v!=k){c.bindFramebuffer(c.FRAMEBUFFER,v);c.viewport(0,0,s,J);o&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);k=v}this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();n.set(m.matrix.flatten());
x.set(m.projectionMatrix.flatten());o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);this.renderPass(m,A,C,s,J,THREE.NormalBlending,false)}}o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);if(s.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);s.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW)}this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,
false);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,false);this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,true);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,true);this.renderPass(m,A,C,s,J,THREE.NormalBlending,true)}}if(w&&w.min_filter!==THREE.NearestFilter&&w.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,w.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(g){function m(B,t,L,F){if(B[t]==undefined){g.__webGLObjects.push({buffer:L,
object:F});B[t]=1}}var w,o,v,J,s,A,C;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}w=0;for(o=g.objects.length;w<o;w++){v=g.objects[w];s=v.geometry;if(g.__webGLObjectsMap[v.id]==undefined)g.__webGLObjectsMap[v.id]={};C=g.__webGLObjectsMap[v.id];if(v instanceof THREE.Mesh){for(J in s.geometryChunks){A=s.geometryChunks[J];if(!A.__webGLVertexBuffer){this.createMeshBuffers(A);this.initMeshBuffers(A,v);s.__dirtyVertices=true;s.__dirtyElements=true;s.__dirtyUvs=true;s.__dirtyNormals=true;
s.__dirtyTangents=true}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs)this.setMeshBuffers(A,v,b.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements,s.__dirtyUvs,s.__dirtyNormals,s.__dirtyTangents);m(C,J,A,v)}s.__dirtyVertices=false;s.__dirtyElements=false;s.__dirtyUvs=false;s.__dirtyNormals=false;s.__dirtyTangents=false}else if(v instanceof THREE.Line){if(!s.__webGLVertexBuffer){this.createLineBuffers(s);this.initLineBuffers(s);s.__dirtyVertices=true;s.__dirtyElements=true}s.__dirtyVertices&&
this.setLineBuffers(s,b.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements);m(C,0,s,v);s.__dirtyVertices=false;s.__dirtyElements=false}else if(v instanceof THREE.ParticleSystem){s.__webGLVertexBuffer||this.createParticleBuffers(s);m(C,0,s,v)}}};this.removeObject=function(g,m){var w,o;for(w=g.__webGLObjects.length-1;w>=0;w--){o=g.__webGLObjects[w].object;m==o&&g.__webGLObjects.splice(w,1)}};this.setupMatrices=function(g,m){g.autoUpdateMatrix&&g.updateMatrix();r.multiply(m.matrix,g.matrix);u.set(r.flatten());
z=THREE.Matrix4.makeInvert3x3(r).transpose();y.set(z.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,u);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,x);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,y);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,m){b.uniform3f(g.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=
function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,m){if(g){!m||m=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK);else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=
function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
s.__dirtyTangents=true}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs)this.setMeshBuffers(A,v,c.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements,s.__dirtyUvs,s.__dirtyNormals,s.__dirtyTangents);m(C,J,A,v)}s.__dirtyVertices=false;s.__dirtyElements=false;s.__dirtyUvs=false;s.__dirtyNormals=false;s.__dirtyTangents=false}else if(v instanceof THREE.Line){if(!s.__webGLVertexBuffer){this.createLineBuffers(s);this.initLineBuffers(s);s.__dirtyVertices=true;s.__dirtyElements=true}s.__dirtyVertices&&
this.setLineBuffers(s,c.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements);m(C,0,s,v);s.__dirtyVertices=false;s.__dirtyElements=false}else if(v instanceof THREE.ParticleSystem){s.__webGLVertexBuffer||this.createParticleBuffers(s);m(C,0,s,v)}}};this.removeObject=function(g,m){var w,o;for(w=g.__webGLObjects.length-1;w>=0;w--){o=g.__webGLObjects[w].object;m==o&&g.__webGLObjects.splice(w,1)}};this.setupMatrices=function(g,m){g.autoUpdateMatrix&&g.updateMatrix();r.multiply(m.matrix,g.matrix);u.set(r.flatten());
z=THREE.Matrix4.makeInvert3x3(r).transpose();y.set(z.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,n);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,x);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,y);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,m){c.uniform3f(g.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=
function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,m){if(g){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
@@ -200,50 +200,50 @@ shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform
"gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_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.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,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.Vertex;this.v2=new THREE.Vertex;this.materials=null};
var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,h=a.vertices,j=f.vertices,b=a.faces,i=f.faces,k=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var r=0,z=j.length;r<z;r++){var n=new THREE.Vertex(j[r].position.clone());d&&c.matrix.multiplyVector3(n.position);h.push(n)}r=0;for(z=i.length;r<z;r++){j=i[r];var u,x=j.vertexNormals;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)u=new THREE.Face4(j.a+
e,j.b+e,j.c+e,j.d+e);u.centroid.copy(j.centroid);u.normal.copy(j.normal);d=0;for(h=x.length;d<h;d++){n=x[d];u.vertexNormals.push(n.clone())}u.materials=j.materials.slice();b.push(u)}r=0;for(z=f.length;r<z;r++){e=f[r];b=[];d=0;for(h=e.length;d<h;d++)b.push(new THREE.UV(e[d].u,e[d].v));k.push(b)}}},ImageUtils={loadTexture:function(a,c){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,c)},loadArray:function(a){var c,d,e=[];c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=
new Image;e[c].loaded=0;e[c].onload=function(){e.loadCount+=1;this.loaded=true};e[c].src=a[c]}return e}},SceneUtils={addMesh:function(a,c,d,e,f,h,j,b,i,k){c=new THREE.Mesh(c,k);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=h;c.rotation.x=j;c.rotation.y=b;c.rotation.z=i;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,
uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));
c=new THREE.Mesh(new Cube(c,c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,h=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,
c,1,0,e,0,f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},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}},fragment_shader:"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}",
var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,h=a.vertices,j=f.vertices,c=a.faces,i=f.faces,k=a.uvs;f=f.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var r=0,z=j.length;r<z;r++){var n=new THREE.Vertex(j[r].position.clone());d&&b.matrix.multiplyVector3(n.position);h.push(n)}r=0;for(z=i.length;r<z;r++){j=i[r];var u,x=j.vertexNormals;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)u=new THREE.Face4(j.a+
e,j.b+e,j.c+e,j.d+e);u.centroid.copy(j.centroid);u.normal.copy(j.normal);d=0;for(h=x.length;d<h;d++){n=x[d];u.vertexNormals.push(n.clone())}u.materials=j.materials.slice();c.push(u)}r=0;for(z=f.length;r<z;r++){e=f[r];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));k.push(c)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,h,j,c,i,k){b=new THREE.Mesh(b,k);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=h;b.rotation.x=j;b.rotation.y=c;b.rotation.z=i;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,
uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));
b=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var f=Math.PI/2,h=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,
b,1,0,e,0,f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},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}},fragment_shader:"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}",
vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\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}},fragment_shader:"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}",
vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},basic:{uniforms:{},
vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,c,d,e,f,h,j,b){function i(y,H,p,I,l,g,m,w){var o,v,J=e||1,s=f||1,A=J+1,C=s+1,B=l/2,t=g/2;l=l/J;var L=g/s,F=k.vertices.length;if(y=="x"&&H=="y"||y=="y"&&H=="x")o="z";else if(y=="x"&&H=="z"||y=="z"&&H=="x")o="y";else if(y=="z"&&H=="y"||y=="y"&&H=="z")o="x";for(v=0;v<C;v++)for(g=0;g<A;g++){var R=new THREE.Vector3;
R[y]=(g*l-B)*p;R[H]=(v*L-t)*I;R[o]=m;k.vertices.push(new THREE.Vertex(R))}for(v=0;v<s;v++)for(g=0;g<J;g++){k.faces.push(new THREE.Face4(g+A*v+F,g+A*(v+1)+F,g+1+A*(v+1)+F,g+1+A*v+F,null,w));k.uvs.push([new THREE.UV(g/J,v/s),new THREE.UV(g/J,(v+1)/s),new THREE.UV((g+1)/J,(v+1)/s),new THREE.UV((g+1)/J,v/s)])}}THREE.Geometry.call(this);var k=this,r=a/2,z=c/2,n=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([h])}else this.materials=
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(b!=undefined)for(var x in b)if(this.sides[x]!=undefined)this.sides[x]=b[x];this.sides.px&&i("z","y",1*j,-1,d,c,-r,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,c,r,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,z,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-z,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,c,n,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,c,-n,this.materials[5]);(function(){for(var y=
vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,b,d,e,f,h,j,c){function i(y,H,p,I,l,g,m,w){var o,v,J=e||1,s=f||1,A=J+1,C=s+1,B=l/2,t=g/2;l=l/J;var L=g/s,F=k.vertices.length;if(y=="x"&&H=="y"||y=="y"&&H=="x")o="z";else if(y=="x"&&H=="z"||y=="z"&&H=="x")o="y";else if(y=="z"&&H=="y"||y=="y"&&H=="z")o="x";for(v=0;v<C;v++)for(g=0;g<A;g++){var R=new THREE.Vector3;
R[y]=(g*l-B)*p;R[H]=(v*L-t)*I;R[o]=m;k.vertices.push(new THREE.Vertex(R))}for(v=0;v<s;v++)for(g=0;g<J;g++){k.faces.push(new THREE.Face4(g+A*v+F,g+A*(v+1)+F,g+1+A*(v+1)+F,g+1+A*v+F,null,w));k.uvs.push([new THREE.UV(g/J,v/s),new THREE.UV(g/J,(v+1)/s),new THREE.UV((g+1)/J,(v+1)/s),new THREE.UV((g+1)/J,v/s)])}}THREE.Geometry.call(this);var k=this,r=a/2,z=b/2,n=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([h])}else this.materials=
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var x in c)if(this.sides[x]!=undefined)this.sides[x]=c[x];this.sides.px&&i("z","y",1*j,-1,d,b,-r,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,b,r,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,z,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-z,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,b,n,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,b,-n,this.materials[5]);(function(){for(var y=
[],H=[],p=0,I=k.vertices.length;p<I;p++){for(var l=k.vertices[p],g=false,m=0,w=y.length;m<w;m++){var o=y[m];if(l.position.x==o.position.x&&l.position.y==o.position.y&&l.position.z==o.position.z){H[p]=m;g=true;break}}if(!g){H[p]=y.length;y.push(new THREE.Vertex(l.position.clone()))}}p=0;for(I=k.faces.length;p<I;p++){l=k.faces[p];l.a=H[l.a];l.b=H[l.b];l.c=H[l.c];l.d=H[l.d]}k.vertices=y})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
Cube.prototype.constructor=Cube;
var Cylinder=function(a,c,d,e,f){function h(k,r,z){j.vertices.push(new THREE.Vertex(new THREE.Vector3(k,r,z)))}THREE.Geometry.call(this);var j=this,b=Math.PI,i;for(i=0;i<a;i++)h(Math.sin(2*b*i/a)*c,Math.cos(2*b*i/a)*c,0);for(i=0;i<a;i++)h(Math.sin(2*b*i/a)*d,Math.cos(2*b*i/a)*d,e);for(i=0;i<a;i++)j.faces.push(new THREE.Face4(i,i+a,a+(i+1)%a,(i+1)%a));if(d!=0){h(0,0,-f);for(i=a;i<a+a/2;i++)j.faces.push(new THREE.Face4(2*a,(2*i-2*a)%a,(2*i-2*a+1)%a,(2*i-2*a+2)%a))}if(c!=0){h(0,0,e+f);for(i=a+a/2;i<
var Cylinder=function(a,b,d,e,f){function h(k,r,z){j.vertices.push(new THREE.Vertex(new THREE.Vector3(k,r,z)))}THREE.Geometry.call(this);var j=this,c=Math.PI,i;for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*b,Math.cos(2*c*i/a)*b,0);for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*d,Math.cos(2*c*i/a)*d,e);for(i=0;i<a;i++)j.faces.push(new THREE.Face4(i,i+a,a+(i+1)%a,(i+1)%a));if(d!=0){h(0,0,-f);for(i=a;i<a+a/2;i++)j.faces.push(new THREE.Face4(2*a,(2*i-2*a)%a,(2*i-2*a+1)%a,(2*i-2*a+2)%a))}if(b!=0){h(0,0,e+f);for(i=a+a/2;i<
2*a;i++)j.faces.push(new THREE.Face4((2*i-2*a+2)%a+a,(2*i-2*a+1)%a+a,(2*i-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,h=a/2,j=c/2;d=d||1;e=e||1;var b=d+1,i=e+1;a=a/d;var k=c/e;for(f=0;f<i;f++)for(c=0;c<b;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-h,-(f*k-j),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+b*f,c+b*(f+1),c+1+b*(f+1),c+1+b*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
var Plane=function(a,b,d,e){THREE.Geometry.call(this);var f,h=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,i=e+1;a=a/d;var k=b/e;for(f=0;f<i;f++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*k-j),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+c*f,b+c*(f+1),b+1+c*(f+1),b+1+c*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,h=Math.max(3,c||8),j=Math.max(2,d||6);c=[];for(d=0;d<j+1;d++){e=d/j;var b=a*Math.cos(e*f),i=a*Math.sin(e*f),k=[],r=0;for(e=0;e<h;e++){var z=2*e/h,n=i*Math.sin(z*f);z=i*Math.cos(z*f);(d==0||d==j)&&e>0||(r=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,b,n)))-1);k.push(r)}c.push(k)}var u,x,y;f=c.length;for(d=0;d<f;d++){h=c[d].length;if(d>0)for(e=0;e<h;e++){k=e==h-1;j=c[d][k?0:e+1];b=c[d][k?h-1:e];i=c[d-1][k?h-1:e];k=c[d-1][k?
0:e+1];n=d/(f-1);u=(d-1)/(f-1);x=(e+1)/h;z=e/h;r=new THREE.UV(1-x,n);n=new THREE.UV(1-z,n);z=new THREE.UV(1-z,u);var H=new THREE.UV(1-x,u);if(d<c.length-1){u=this.vertices[j].position.clone();x=this.vertices[b].position.clone();y=this.vertices[i].position.clone();u.normalize();x.normalize();y.normalize();this.faces.push(new THREE.Face3(j,b,i,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)]));this.uvs.push([r,n,z])}if(d>1){u=this.vertices[j].position.clone();
var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=Math.PI,h=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var c=a*Math.cos(e*f),i=a*Math.sin(e*f),k=[],r=0;for(e=0;e<h;e++){var z=2*e/h,n=i*Math.sin(z*f);z=i*Math.cos(z*f);(d==0||d==j)&&e>0||(r=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,c,n)))-1);k.push(r)}b.push(k)}var u,x,y;f=b.length;for(d=0;d<f;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){k=e==h-1;j=b[d][k?0:e+1];c=b[d][k?h-1:e];i=b[d-1][k?h-1:e];k=b[d-1][k?
0:e+1];n=d/(f-1);u=(d-1)/(f-1);x=(e+1)/h;z=e/h;r=new THREE.UV(1-x,n);n=new THREE.UV(1-z,n);z=new THREE.UV(1-z,u);var H=new THREE.UV(1-x,u);if(d<b.length-1){u=this.vertices[j].position.clone();x=this.vertices[c].position.clone();y=this.vertices[i].position.clone();u.normalize();x.normalize();y.normalize();this.faces.push(new THREE.Face3(j,c,i,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)]));this.uvs.push([r,n,z])}if(d>1){u=this.vertices[j].position.clone();
x=this.vertices[i].position.clone();y=this.vertices[k].position.clone();u.normalize();x.normalize();y.normalize();this.faces.push(new THREE.Face3(j,i,k,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)]));this.uvs.push([r,z,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],h=[],j=[],b=0;b<a.length;b++){this.vertices.push(new THREE.Vertex(a[b]));f[b]=this.vertices.length-1;e[b]=new THREE.Vector3(a[b].x,a[b].y,a[b].z)}for(var i=THREE.Matrix4.rotationZMatrix(c),k=0;k<=d+0.0010;k+=c){for(b=0;b<e.length;b++)if(k<d){e[b]=i.multiplyVector3(e[b].clone());this.vertices.push(new THREE.Vertex(e[b]));h[b]=this.vertices.length-1}else h=j;if(k==0)j=f;for(b=0;b<f.length-1;b++){this.faces.push(new THREE.Face4(h[b],
h[b+1],f[b+1],f[b]));this.uvs.push([new THREE.UV(k/d,b/a.length),new THREE.UV(k/d,(b+1)/a.length),new THREE.UV((k-c)/d,(b+1)/a.length),new THREE.UV((k-c)/d,b/a.length)])}f=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.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},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,f,e,h)};c.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,h){var j=new XMLHttpRequest,b=e+"/"+a,i=0;
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,f,c):alert("Couldn't load ["+b+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",b,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
createBinModel:function(a,c,d,e){var f=function(h){function j(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2),da=r(q,G+3),ga=(da<<1&255|$>>7)-127;E=($&127)<<16|W<<8|E;if(E==0&&ga==-127)return 0;return(1-2*(da>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ga)}function b(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2);return(r(q,G+3)<<24)+($<<16)+(W<<8)+E}function i(q,G){var E=r(q,G);return(r(q,G+1)<<8)+E}function k(q,G){var E=r(q,G);return E>127?E-256:E}function r(q,G){return q.charCodeAt(G)&255}function z(q){var G,E,W;G=
b(a,q);E=b(a,q+w);W=b(a,q+o);q=i(a,q+v);THREE.Loader.prototype.f3(p,G,E,W,q)}function n(q){var G,E,W,$,da,ga;G=b(a,q);E=b(a,q+w);W=b(a,q+o);$=i(a,q+v);da=b(a,q+J);ga=b(a,q+s);q=b(a,q+A);THREE.Loader.prototype.f3n(p,g,G,E,W,$,da,ga,q)}function u(q){var G,E,W,$;G=b(a,q);E=b(a,q+C);W=b(a,q+B);$=b(a,q+t);q=i(a,q+L);THREE.Loader.prototype.f4(p,G,E,W,$,q)}function x(q){var G,E,W,$,da,ga,na,pa;G=b(a,q);E=b(a,q+C);W=b(a,q+B);$=b(a,q+t);da=i(a,q+L);ga=b(a,q+F);na=b(a,q+R);pa=b(a,q+T);q=b(a,q+M);THREE.Loader.prototype.f4n(p,
g,G,E,W,$,da,ga,na,pa,q)}function y(q){var G,E;G=b(a,q);E=b(a,q+aa);q=b(a,q+U);THREE.Loader.prototype.uv3(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[q*2],m[q*2+1])}function H(q){var G,E,W;G=b(a,q);E=b(a,q+O);W=b(a,q+Q);q=b(a,q+Z);THREE.Loader.prototype.uv4(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[W*2],m[W*2+1],m[q*2],m[q*2+1])}var p=this,I=0,l,g=[],m=[],w,o,v,J,s,A,C,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(p,e,h);l={signature:a.substr(I,8),header_bytes:r(a,
I+8),vertex_coordinate_bytes:r(a,I+9),normal_coordinate_bytes:r(a,I+10),uv_coordinate_bytes:r(a,I+11),vertex_index_bytes:r(a,I+12),normal_index_bytes:r(a,I+13),uv_index_bytes:r(a,I+14),material_index_bytes:r(a,I+15),nvertices:b(a,I+16),nnormals:b(a,I+16+4),nuvs:b(a,I+16+8),ntri_flat:b(a,I+16+12),ntri_smooth:b(a,I+16+16),ntri_flat_uv:b(a,I+16+20),ntri_smooth_uv:b(a,I+16+24),nquad_flat:b(a,I+16+28),nquad_smooth:b(a,I+16+32),nquad_flat_uv:b(a,I+16+36),nquad_smooth_uv:b(a,I+16+40)};I+=l.header_bytes;
function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],f=[],h=[],j=[],c=0;c<a.length;c++){this.vertices.push(new THREE.Vertex(a[c]));f[c]=this.vertices.length-1;e[c]=new THREE.Vector3(a[c].x,a[c].y,a[c].z)}for(var i=THREE.Matrix4.rotationZMatrix(b),k=0;k<=d+0.0010;k+=b){for(c=0;c<e.length;c++)if(k<d){e[c]=i.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));h[c]=this.vertices.length-1}else h=j;if(k==0)j=f;for(c=0;c<f.length-1;c++){this.faces.push(new THREE.Face4(h[c],
h[c+1],f[c+1],f[c]));this.uvs.push([new THREE.UV(k/d,c/a.length),new THREE.UV(k/d,(c+1)/a.length),new THREE.UV((k-b)/d,(c+1)/a.length),new THREE.UV((k-b)/d,c/a.length)])}f=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.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 b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,f,e,h)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,f,h){var j=new XMLHttpRequest,c=e+"/"+a,i=0;
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,f,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
createBinModel:function(a,b,d,e){var f=function(h){function j(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2),da=r(q,G+3),ga=(da<<1&255|$>>7)-127;E=($&127)<<16|W<<8|E;if(E==0&&ga==-127)return 0;return(1-2*(da>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ga)}function c(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2);return(r(q,G+3)<<24)+($<<16)+(W<<8)+E}function i(q,G){var E=r(q,G);return(r(q,G+1)<<8)+E}function k(q,G){var E=r(q,G);return E>127?E-256:E}function r(q,G){return q.charCodeAt(G)&255}function z(q){var G,E,W;G=
c(a,q);E=c(a,q+w);W=c(a,q+o);q=i(a,q+v);THREE.Loader.prototype.f3(p,G,E,W,q)}function n(q){var G,E,W,$,da,ga;G=c(a,q);E=c(a,q+w);W=c(a,q+o);$=i(a,q+v);da=c(a,q+J);ga=c(a,q+s);q=c(a,q+A);THREE.Loader.prototype.f3n(p,g,G,E,W,$,da,ga,q)}function u(q){var G,E,W,$;G=c(a,q);E=c(a,q+C);W=c(a,q+B);$=c(a,q+t);q=i(a,q+L);THREE.Loader.prototype.f4(p,G,E,W,$,q)}function x(q){var G,E,W,$,da,ga,na,pa;G=c(a,q);E=c(a,q+C);W=c(a,q+B);$=c(a,q+t);da=i(a,q+L);ga=c(a,q+F);na=c(a,q+R);pa=c(a,q+T);q=c(a,q+M);THREE.Loader.prototype.f4n(p,
g,G,E,W,$,da,ga,na,pa,q)}function y(q){var G,E;G=c(a,q);E=c(a,q+aa);q=c(a,q+U);THREE.Loader.prototype.uv3(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[q*2],m[q*2+1])}function H(q){var G,E,W;G=c(a,q);E=c(a,q+O);W=c(a,q+Q);q=c(a,q+Z);THREE.Loader.prototype.uv4(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[W*2],m[W*2+1],m[q*2],m[q*2+1])}var p=this,I=0,l,g=[],m=[],w,o,v,J,s,A,C,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(p,e,h);l={signature:a.substr(I,8),header_bytes:r(a,
I+8),vertex_coordinate_bytes:r(a,I+9),normal_coordinate_bytes:r(a,I+10),uv_coordinate_bytes:r(a,I+11),vertex_index_bytes:r(a,I+12),normal_index_bytes:r(a,I+13),uv_index_bytes:r(a,I+14),material_index_bytes:r(a,I+15),nvertices:c(a,I+16),nnormals:c(a,I+16+4),nuvs:c(a,I+16+8),ntri_flat:c(a,I+16+12),ntri_smooth:c(a,I+16+16),ntri_flat_uv:c(a,I+16+20),ntri_smooth_uv:c(a,I+16+24),nquad_flat:c(a,I+16+28),nquad_smooth:c(a,I+16+32),nquad_flat_uv:c(a,I+16+36),nquad_smooth_uv:c(a,I+16+40)};I+=l.header_bytes;
w=l.vertex_index_bytes;o=l.vertex_index_bytes*2;v=l.vertex_index_bytes*3;J=l.vertex_index_bytes*3+l.material_index_bytes;s=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;A=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;C=l.vertex_index_bytes;B=l.vertex_index_bytes*2;t=l.vertex_index_bytes*3;L=l.vertex_index_bytes*4;F=l.vertex_index_bytes*4+l.material_index_bytes;R=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;T=l.vertex_index_bytes*4+
l.material_index_bytes+l.normal_index_bytes*2;M=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;aa=l.uv_index_bytes;U=l.uv_index_bytes*2;O=l.uv_index_bytes;Q=l.uv_index_bytes*2;Z=l.uv_index_bytes*3;h=l.vertex_index_bytes*3+l.material_index_bytes;ea=l.vertex_index_bytes*4+l.material_index_bytes;V=l.ntri_flat*h;D=l.ntri_smooth*(h+l.normal_index_bytes*3);P=l.ntri_flat_uv*(h+l.uv_index_bytes*3);S=l.ntri_smooth_uv*(h+l.normal_index_bytes*3+l.uv_index_bytes*3);fa=l.nquad_flat*ea;h=
l.nquad_smooth*(ea+l.normal_index_bytes*4);ea=l.nquad_flat_uv*(ea+l.uv_index_bytes*4);I+=function(q){var G,E,W,$=l.vertex_coordinate_bytes*3,da=q+l.nvertices*$;for(q=q;q<da;q+=$){G=j(a,q);E=j(a,q+l.vertex_coordinate_bytes);W=j(a,q+l.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(p,G,E,W)}return l.nvertices*$}(I);I+=function(q){var G,E,W,$=l.normal_coordinate_bytes*3,da=q+l.nnormals*$;for(q=q;q<da;q+=$){G=k(a,q);E=k(a,q+l.normal_coordinate_bytes);W=k(a,q+l.normal_coordinate_bytes*2);g.push(G/
127,E/127,W/127)}return l.nnormals*$}(I);I+=function(q){var G,E,W=l.uv_coordinate_bytes*2,$=q+l.nuvs*W;for(q=q;q<$;q+=W){G=j(a,q);E=j(a,q+l.uv_coordinate_bytes);m.push(G,E)}return l.nuvs*W}(I);I=I;V=I+V;D=V+D;P=D+P;S=P+S;fa=S+fa;h=fa+h;ea=h+ea;(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes,W=E+l.uv_index_bytes*3,$=q+l.ntri_flat_uv*W;for(G=q;G<$;G+=W){z(G);y(G+E)}return $-q})(D);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,W=E+l.uv_index_bytes*
3,$=q+l.ntri_smooth_uv*W;for(G=q;G<$;G+=W){n(G);y(G+E)}return $-q})(P);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes,W=E+l.uv_index_bytes*4,$=q+l.nquad_flat_uv*W;for(G=q;G<$;G+=W){u(G);H(G+E)}return $-q})(h);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,W=E+l.uv_index_bytes*4,$=q+l.nquad_smooth_uv*W;for(G=q;G<$;G+=W){x(G);H(G+E)}return $-q})(ea);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes,W=q+l.ntri_flat*E;for(G=
q;G<W;G+=E)z(G);return W-q})(I);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,W=q+l.ntri_smooth*E;for(G=q;G<W;G+=E)n(G);return W-q})(V);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes,W=q+l.nquad_flat*E;for(G=q;G<W;G+=E)u(G);return W-q})(S);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,W=q+l.nquad_smooth*E;for(G=q;G<W;G+=E)x(G);return W-q})(fa);this.computeCentroids();this.computeFaceNormals();
this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,f);(function(){var j,b,i,k,r;j=0;for(b=a.vertices.length;j<b;j+=3){i=a.vertices[j];k=a.vertices[j+1];r=a.vertices[j+2];THREE.Loader.prototype.v(h,i,k,r)}})();(function(){function j(x,y){THREE.Loader.prototype.f3(h,x[y],x[y+1],x[y+2],x[y+3])}function b(x,y){THREE.Loader.prototype.f3n(h,
this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,f);(function(){var j,c,i,k,r;j=0;for(c=a.vertices.length;j<c;j+=3){i=a.vertices[j];k=a.vertices[j+1];r=a.vertices[j+2];THREE.Loader.prototype.v(h,i,k,r)}})();(function(){function j(x,y){THREE.Loader.prototype.f3(h,x[y],x[y+1],x[y+2],x[y+3])}function c(x,y){THREE.Loader.prototype.f3n(h,
a.normals,x[y],x[y+1],x[y+2],x[y+3],x[y+4],x[y+5],x[y+6])}function i(x,y){THREE.Loader.prototype.f4(h,x[y],x[y+1],x[y+2],x[y+3],x[y+4])}function k(x,y){THREE.Loader.prototype.f4n(h,a.normals,x[y],x[y+1],x[y+2],x[y+3],x[y+4],x[y+5],x[y+6],x[y+7],x[y+8])}function r(x,y){var H,p,I;H=x[y];p=x[y+1];I=x[y+2];THREE.Loader.prototype.uv3(h,a.uvs[H*2],a.uvs[H*2+1],a.uvs[p*2],a.uvs[p*2+1],a.uvs[I*2],a.uvs[I*2+1])}function z(x,y){var H,p,I,l;H=x[y];p=x[y+1];I=x[y+2];l=x[y+3];THREE.Loader.prototype.uv4(h,a.uvs[H*
2],a.uvs[H*2+1],a.uvs[p*2],a.uvs[p*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[l*2],a.uvs[l*2+1])}var n,u;n=0;for(u=a.triangles_uv.length;n<u;n+=7){j(a.triangles_uv,n);r(a.triangles_uv,n+4)}n=0;for(u=a.triangles_n_uv.length;n<u;n+=10){b(a.triangles_n_uv,n);r(a.triangles_n_uv,n+7)}n=0;for(u=a.quads_uv.length;n<u;n+=9){i(a.quads_uv,n);z(a.quads_uv,n+5)}n=0;for(u=a.quads_n_uv.length;n<u;n+=13){k(a.quads_n_uv,n);z(a.quads_n_uv,n+9)}n=0;for(u=a.triangles.length;n<u;n+=4)j(a.triangles,n);n=0;for(u=a.triangles_n.length;n<
u;n+=7)b(a.triangles_n,n);n=0;for(u=a.quads.length;n<u;n+=5)i(a.quads,n);n=0;for(u=a.quads_n.length;n<u;n+=9)k(a.quads_n,n)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,h){a.faces.push(new THREE.Face4(c,d,e,f,null,
a.materials[h]))},f3n:function(a,c,d,e,f,h,j,b,i){h=a.materials[h];var k=c[b*3],r=c[b*3+1];b=c[b*3+2];var z=c[i*3],n=c[i*3+1];i=c[i*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(k,r,b),new THREE.Vector3(z,n,i)],h))},f4n:function(a,c,d,e,f,h,j,b,i,k,r){j=a.materials[j];var z=c[i*3],n=c[i*3+1];i=c[i*3+2];var u=c[k*3],x=c[k*3+1];k=c[k*3+2];var y=c[r*3],H=c[r*3+1];r=c[r*3+2];a.faces.push(new THREE.Face4(d,e,f,h,[new THREE.Vector3(c[b*3],c[b*3+1],
c[b*3+2]),new THREE.Vector3(z,n,i),new THREE.Vector3(u,x,k),new THREE.Vector3(y,H,r)],j))},uv3:function(a,c,d,e,f,h,j){var b=[];b.push(new THREE.UV(c,d));b.push(new THREE.UV(e,f));b.push(new THREE.UV(h,j));a.uvs.push(b)},uv4:function(a,c,d,e,f,h,j,b,i){var k=[];k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,f));k.push(new THREE.UV(h,j));k.push(new THREE.UV(b,i));a.uvs.push(k)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
d)]},createMaterial:function(a,c){function d(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}var e,f;if(a.map_diffuse&&c){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||!d(this.height)){var h=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),j=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=h;e.map.image.height=j;e.map.image.getContext("2d").drawImage(this,0,0,h,j)}else e.map.image=
this;e.map.image.loaded=1};f.src=c+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return e},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
2],a.uvs[H*2+1],a.uvs[p*2],a.uvs[p*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[l*2],a.uvs[l*2+1])}var n,u;n=0;for(u=a.triangles_uv.length;n<u;n+=7){j(a.triangles_uv,n);r(a.triangles_uv,n+4)}n=0;for(u=a.triangles_n_uv.length;n<u;n+=10){c(a.triangles_n_uv,n);r(a.triangles_n_uv,n+7)}n=0;for(u=a.quads_uv.length;n<u;n+=9){i(a.quads_uv,n);z(a.quads_uv,n+5)}n=0;for(u=a.quads_n_uv.length;n<u;n+=13){k(a.quads_n_uv,n);z(a.quads_n_uv,n+9)}n=0;for(u=a.triangles.length;n<u;n+=4)j(a.triangles,n);n=0;for(u=a.triangles_n.length;n<
u;n+=7)c(a.triangles_n,n);n=0;for(u=a.quads.length;n<u;n+=5)i(a.quads,n);n=0;for(u=a.quads_n.length;n<u;n+=9)k(a.quads_n,n)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,h){a.faces.push(new THREE.Face4(b,d,e,f,null,
a.materials[h]))},f3n:function(a,b,d,e,f,h,j,c,i){h=a.materials[h];var k=b[c*3],r=b[c*3+1];c=b[c*3+2];var z=b[i*3],n=b[i*3+1];i=b[i*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(k,r,c),new THREE.Vector3(z,n,i)],h))},f4n:function(a,b,d,e,f,h,j,c,i,k,r){j=a.materials[j];var z=b[i*3],n=b[i*3+1];i=b[i*3+2];var u=b[k*3],x=b[k*3+1];k=b[k*3+2];var y=b[r*3],H=b[r*3+1];r=b[r*3+2];a.faces.push(new THREE.Face4(d,e,f,h,[new THREE.Vector3(b[c*3],b[c*3+1],
b[c*3+2]),new THREE.Vector3(z,n,i),new THREE.Vector3(u,x,k),new THREE.Vector3(y,H,r)],j))},uv3:function(a,b,d,e,f,h,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(h,j));a.uvs.push(c)},uv4:function(a,b,d,e,f,h,j,c,i){var k=[];k.push(new THREE.UV(b,d));k.push(new THREE.UV(e,f));k.push(new THREE.UV(h,j));k.push(new THREE.UV(c,i));a.uvs.push(k)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],
d)]},createMaterial:function(a,b){function d(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}var e,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||!d(this.height)){var h=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),j=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=h;e.map.image.height=j;e.map.image.getContext("2d").drawImage(this,0,0,h,j)}else e.map.image=
this;e.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return e},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+1 -1
View File
@@ -8,7 +8,7 @@ THREE.Matrix3.prototype = {
transpose: function () {
var tmp, m = this.m;
var tmp, m = this.m;
tmp = m[1]; m[1] = m[3]; m[3] = tmp;
tmp = m[2]; m[2] = m[6]; m[6] = tmp;
+24 -19
View File
@@ -13,6 +13,9 @@ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33
this.n31 = n31 || 0; this.n32 = n32 || 0; this.n33 = n33 || 1; this.n34 = n34 || 0;
this.n41 = n41 || 0; this.n42 = n42 || 0; this.n43 = n43 || 0; this.n44 = n44 || 1;
this.flat = new Array( 16 );
this.m33 = new THREE.Matrix3();
};
THREE.Matrix4.prototype = {
@@ -267,8 +270,8 @@ THREE.Matrix4.prototype = {
flatten: function() {
var flat = THREE.Matrix4.__flat;
var flat = this.flat;
flat[ 0 ] = this.n11;
flat[ 1 ] = this.n21;
flat[ 2 ] = this.n31;
@@ -477,24 +480,27 @@ THREE.Matrix4.makeInvert = function ( m1 ) {
};
THREE.Matrix4.makeInvert3x3 = function ( m1, m2 ) {
THREE.Matrix4.makeInvert3x3 = function ( m1 ) {
// input: m1: THREE.Matrix4, m2: THREE.Matrix3; output: THREE.Matrix3 (m2)
// input: THREE.Matrix4, output: THREE.Matrix3
// ( based on http://code.google.com/p/webgl-mjs/ )
var m = m1.flatten(),
m2m = m2.m,
var m = m1.flatten(),
m33 = m1.m33,
m33m = m33.m,
a11 = m[ 10 ] * m[ 5 ] - m[ 6 ] * m[ 9 ],
a11 = m[ 10 ] * m[ 5 ] - m[ 6 ] * m[ 9 ],
a21 = - m[ 10 ] * m[ 1 ] + m[ 2 ] * m[ 9 ],
a31 = m[ 6 ] * m[ 1 ] - m[ 2 ] * m[ 5 ],
a31 = m[ 6 ] * m[ 1 ] - m[ 2 ] * m[ 5 ],
a12 = - m[ 10 ] * m[ 4 ] + m[ 6 ] * m[ 8 ],
a22 = m[ 10 ] * m[ 0 ] - m[ 2 ] * m[ 8 ],
a32 = - m[ 6 ] * m[ 0 ] + m[ 2 ] * m[ 4 ],
a13 = m[ 9 ] * m[ 4 ] - m[ 5 ] * m[ 8 ],
a23 = - m[ 9 ] * m[ 0 ] + m[ 1 ] * m[ 8 ],
a33 = m[ 5 ] * m[ 0 ] - m[ 1 ] * m[ 4 ],
det = m[ 0 ] * ( a11 ) + m[ 1 ] * ( a12 ) + m[ 2 ] * ( a13 ),
a22 = m[ 10 ] * m[ 0 ] - m[ 2 ] * m[ 8 ],
a32 = - m[ 6 ] * m[ 0 ] + m[ 2 ] * m[ 4 ],
a13 = m[ 9 ] * m[ 4 ] - m[ 5 ] * m[ 8 ],
a23 = - m[ 9 ] * m[ 0 ] + m[ 1 ] * m[ 8 ],
a33 = m[ 5 ] * m[ 0 ] - m[ 1 ] * m[ 4 ],
det = m[ 0 ] * a11 + m[ 1 ] * a12 + m[ 2 ] * a13,
idet;
// no inverse
@@ -502,11 +508,11 @@ THREE.Matrix4.makeInvert3x3 = function ( m1, m2 ) {
idet = 1.0 / det;
m2m[ 0 ] = idet * a11; m2m[ 1 ] = idet * a21; m2m[ 2 ] = idet * a31;
m2m[ 3 ] = idet * a12; m2m[ 4 ] = idet * a22; m2m[ 5 ] = idet * a32;
m2m[ 6 ] = idet * a13; m2m[ 7 ] = idet * a23; m2m[ 8 ] = idet * a33;
m33m[ 0 ] = idet * a11; m33m[ 1 ] = idet * a21; m33m[ 2 ] = idet * a31;
m33m[ 3 ] = idet * a12; m33m[ 4 ] = idet * a22; m33m[ 5 ] = idet * a32;
m33m[ 6 ] = idet * a13; m33m[ 7 ] = idet * a23; m33m[ 8 ] = idet * a33;
return m2;
return m33;
}
@@ -568,4 +574,3 @@ THREE.Matrix4.makeOrtho = function ( left, right, top, bottom, near, far ) {
THREE.Matrix4.__tmpVec1 = new THREE.Vector3();
THREE.Matrix4.__tmpVec2 = new THREE.Vector3();
THREE.Matrix4.__tmpVec3 = new THREE.Vector3();
THREE.Matrix4.__flat = new Array( 16 );
+1 -1
View File
@@ -364,7 +364,7 @@ THREE.Projector = function() {
this.unprojectVector = function ( vector, camera ) {
var matrix = THREE.Matrix4.makeInvert( camera.matrix );
var matrix = THREE.Matrix4.makeInvert( camera.matrix );
matrix.multiplySelf( THREE.Matrix4.makeInvert( camera.projectionMatrix ) );
+1 -3
View File
@@ -1166,8 +1166,6 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this._m33 = new THREE.Matrix3();
this.setupMatrices = function ( object, camera ) {
object.autoUpdateMatrix && object.updateMatrix();
@@ -1175,7 +1173,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_modelViewMatrix.multiply( camera.matrix, object.matrix );
_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix, this._m33 ).transpose();
_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
_normalMatrixArray.set( _normalMatrix.m );
_objectMatrixArray.set( object.matrix.flatten() );
+1 -3
View File
@@ -68,8 +68,6 @@ THREE.WebGLRenderer2 = function ( antialias ) {
};
this._m33 = new THREE.Matrix3();
this.render = function( scene, camera ) {
var o, ol;
@@ -115,7 +113,7 @@ THREE.WebGLRenderer2 = function ( antialias ) {
_modelViewMatrix.multiply( camera.matrix, object.matrix );
_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix, this._m33 ).transpose();
_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
_normalMatrixArray.set( _normalMatrix.m );
if ( object instanceof THREE.Mesh ) {