Updated builds.

This commit is contained in:
Mr.doob
2011-01-18 07:06:07 +00:00
parent 2a7262ccd9
commit ecedea4be1
3 changed files with 659 additions and 663 deletions
+203 -205
View File
@@ -1,205 +1,203 @@
// Three.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,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/=
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;
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,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(i,q){return i.distance-q.distance});return h},intersectObject:function(a){function c(T,u,R,D){D=D.clone().subSelf(u);R=R.clone().subSelf(u);var e=T.clone().subSelf(u);T=D.dot(D);u=D.dot(R);D=D.dot(e);var g=R.dot(R);R=R.dot(e);e=1/(T*g-u*u);g=(g*D-u*R)*e;T=(T*R-u*D)*e;return g>0&&T>0&&g+T<1}var d,f,h,i,q,b,m,p,E,H,
x,A=a.geometry,S=A.vertices,V=[];d=0;for(f=A.faces.length;d<f;d++){h=A.faces[d];H=this.origin.clone();x=this.direction.clone();i=a.matrix.multiplyVector3(S[h.a].position.clone());q=a.matrix.multiplyVector3(S[h.b].position.clone());b=a.matrix.multiplyVector3(S[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(S[h.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(h.normal.clone());E=x.dot(p);if(E<0){p=p.dot((new THREE.Vector3).sub(i,H))/E;H=H.addSelf(x.multiplyScalar(p));
if(h instanceof THREE.Face3){if(c(H,i,q,b)){h={distance:this.origin.distanceTo(H),point:H,face:h,object:a};V.push(h)}}else if(h instanceof THREE.Face4)if(c(H,i,q,m)||c(H,q,b,m)){h={distance:this.origin.distanceTo(H),point:H,face:h,object:a};V.push(h)}}}return V}};
THREE.Rectangle=function(){function a(){i=f-c;q=h-d}var c,d,f,h,i,q,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(m,p,E,H){b=false;c=m;d=p;f=E;h=H;a()};this.addPoint=function(m,p){if(b){b=false;c=m;d=p;f=m;h=p}else{c=c<m?c:m;d=d<p?d:p;f=f>m?f:m;h=h>p?
h:p}a()};this.add3Points=function(m,p,E,H,x,A){if(b){b=false;c=m<E?m<x?m:x:E<x?E:x;d=p<H?p<A?p:A:H<A?H:A;f=m>E?m>x?m:x:E>x?E:x;h=p>H?p>A?p:A:H>A?H:A}else{c=m<E?m<x?m<c?m:c:x<c?x:c:E<x?E<c?E:c:x<c?x:c;d=p<H?p<A?p<d?p:d:A<d?A:d:H<A?H<d?H:d:A<d?A:d;f=m>E?m>x?m>f?m:f:x>f?x:f:E>x?E>f?E:f:x>f?x:f;h=p>H?p>A?p>h?p:h:A>h?A:h:H>A?H>h?H:h:A>h?A:h}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();h=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
f=f>m.getRight()?f:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){c-=m;d-=m;f+=m;h+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();d=d>m.getTop()?d:m.getTop();f=f<m.getRight()?f:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){b=true;h=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+i+", height: "+q+" )"}};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,h,i,q,b,m,p,E,H,x,A,S,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=p||0;this.n33=E||1;this.n34=H||0;this.n41=x||0;this.n42=A||0;this.n43=S||0;this.n44=V||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,h,i,q,b,m,p,E,H,x,A,S,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=p;this.n33=E;this.n34=H;this.n41=x;this.n42=A;this.n43=S;this.n44=V;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,h=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,c).normalize();f.cross(d,i).normalize();h.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=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)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;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,h=a.n13,i=a.n14,q=a.n21,b=a.n22,m=a.n23,p=a.n24,E=a.n31,
H=a.n32,x=a.n33,A=a.n34,S=a.n41,V=a.n42,T=a.n43,u=a.n44,R=c.n11,D=c.n12,e=c.n13,g=c.n14,n=c.n21,j=c.n22,o=c.n23,z=c.n24,k=c.n31,s=c.n32,t=c.n33,r=c.n34,l=c.n41,C=c.n42,w=c.n43,L=c.n44;this.n11=d*R+f*n+h*k+i*l;this.n12=d*D+f*j+h*s+i*C;this.n13=d*e+f*o+h*t+i*w;this.n14=d*g+f*z+h*r+i*L;this.n21=q*R+b*n+m*k+p*l;this.n22=q*D+b*j+m*s+p*C;this.n23=q*e+b*o+m*t+p*w;this.n24=q*g+b*z+m*r+p*L;this.n31=E*R+H*n+x*k+A*l;this.n32=E*D+H*j+x*s+A*C;this.n33=E*e+H*o+x*t+A*w;this.n34=E*g+H*z+x*r+A*L;this.n41=S*R+V*n+
T*k+u*l;this.n42=S*D+V*j+T*s+u*C;this.n43=S*e+V*o+T*t+u*w;this.n44=S*g+V*z+T*r+u*L;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,p=this.n31,E=this.n32,H=this.n33,x=this.n34,A=this.n41,S=this.n42,V=this.n43,T=this.n44,u=a.n11,R=a.n21,D=a.n31,e=a.n41,g=a.n12,n=a.n22,j=a.n32,o=a.n42,z=a.n13,k=a.n23,s=a.n33,t=a.n43,r=a.n14,l=a.n24,C=a.n34;a=a.n44;this.n11=c*u+d*R+f*D+h*e;this.n12=c*g+d*n+f*j+h*o;this.n13=c*z+d*k+f*s+h*
t;this.n14=c*r+d*l+f*C+h*a;this.n21=i*u+q*R+b*D+m*e;this.n22=i*g+q*n+b*j+m*o;this.n23=i*z+q*k+b*s+m*t;this.n24=i*r+q*l+b*C+m*a;this.n31=p*u+E*R+H*D+x*e;this.n32=p*g+E*n+H*j+x*o;this.n33=p*z+E*k+H*s+x*t;this.n34=p*r+E*l+H*C+x*a;this.n41=A*u+S*R+V*D+T*e;this.n42=A*g+S*n+V*j+T*o;this.n43=A*z+S*k+V*s+T*t;this.n44=A*r+S*l+V*C+T*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*
this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(c,d,f){var h=c[d];
c[d]=c[f];c[f]=h}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},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.n14=a;f.n24=c;f.n34=d;return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.n11=a;f.n22=c;f.n33=d;return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};
THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4,f=Math.cos(c),h=Math.sin(c),i=1-f,q=a.x,b=a.y,m=a.z;d.n11=i*q*q+f;d.n12=i*q*b-h*m;d.n13=i*q*m+h*b;d.n21=i*q*b+h*m;d.n22=i*b*b+f;d.n23=i*b*m-h*q;d.n31=i*q*m-h*b;d.n32=i*b*m+h*q;d.n33=i*m*m+f;return d};
THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;c.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;c.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;c.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
a.n23*a.n34;c.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;c.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;c.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;c.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;c.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;c.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;c.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;c.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;c.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
a.n31*a.n43-a.n21*a.n32*a.n43;c.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;c.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;c.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;c.multiplyScalar(1/a.determinant());return c};
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],h=c[6]*c[1]-c[2]*c[5],i=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],p=-c[9]*c[0]+c[1]*c[8],E=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*i+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*f;a.m[2]=c*h;a.m[3]=c*i;a.m[4]=c*q;a.m[5]=c*b;a.m[6]=c*m;a.m[7]=c*p;a.m[8]=c*E;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,f,h,i){var q,b,m;q=new THREE.Matrix4;b=2*h/(c-a);m=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(i+h)/(i-h);h=-2*i*h/(i-h);q.n11=b;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=m;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,h,i){var q,b,m,p;q=new THREE.Matrix4;b=c-a;m=d-f;p=i-h;a=(c+a)/b;d=(d+f)/m;h=(i+h)/p;q.n11=2/b;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/m;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/p;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};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,h){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=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,h,i){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,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,h,i,q,b=new THREE.Vector3,m=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);c=0;for(d=i.normal.length;c<d;c++)b.addSelf(i.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[i.a];d=this.vertices[i.b];q=this.vertices[i.c];b.sub(q.position,
d.position);m.sub(c.position,d.position);b.crossSelf(m)}b.isZero()||b.normalize();i.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(r,l,C,w,L,K,F){i=r.vertices[l].position;q=r.vertices[C].position;b=r.vertices[w].position;m=h[L];p=h[K];E=h[F];H=q.x-i.x;x=b.x-i.x;A=q.y-i.y;S=b.y-i.y;
V=q.z-i.z;T=b.z-i.z;u=p.u-m.u;R=E.u-m.u;D=p.v-m.v;e=E.v-m.v;g=1/(u*e-R*D);o.set((e*H-D*x)*g,(e*A-D*S)*g,(e*V-D*T)*g);z.set((u*x-R*H)*g,(u*S-R*A)*g,(u*T-R*V)*g);n[l].addSelf(o);n[C].addSelf(o);n[w].addSelf(o);j[l].addSelf(z);j[C].addSelf(z);j[w].addSelf(z)}var c,d,f,h,i,q,b,m,p,E,H,x,A,S,V,T,u,R,D,e,g,n=[],j=[],o=new THREE.Vector3,z=new THREE.Vector3,k=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){n[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){f=this.faces[c];h=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++){t.copy(this.vertices[c].normal);f=n[c];k.copy(f);k.subSelf(t.multiplyScalar(t.dot(f))).normalize();s.cross(this.vertices[c].normal,f);f=s.dot(j[c]);f=f<0?-1:1;this.vertices[c].tangent.set(k.x,k.y,k.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],
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(E){var H=[];c=0;for(d=E.length;c<d;c++)E[c]==undefined?H.push("undefined"):H.push(E[c].toString());return H.join("_")}var c,d,f,h,i,q,b,m,p={};f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];
q=i.materials;b=a(q);if(p[b]==undefined)p[b]={hash:b,counter:0};m=p[b].hash+"_"+p[b].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:q,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+i>65535){p[b].counter+=1;m=p[b].hash+"_"+p[b].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:q,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=i}},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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};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;
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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,h,i){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=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};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(j,o){return o.z-j.z}function c(j,o){var z=0,k=1,s=j.z+j.w,t=o.z+o.w,r=-j.z+j.w,l=-o.z+o.w;if(s>=0&&t>=0&&r>=0&&l>=0)return true;else if(s<0&&t<0||r<0&&l<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)k=Math.min(k,s/(s-t));if(r<0)z=Math.max(z,r/(r-l));else if(l<0)k=Math.min(k,r/(r-l));if(k<z)return false;else{j.lerpSelf(o,z);o.lerpSelf(j,1-k);return true}}}var d,f,h=[],i,q,b,m=[],p,E,H=[],x,A,S=[],V=new THREE.Vector4,T=new THREE.Vector4,u=new THREE.Matrix4,
R=new THREE.Matrix4,D=[],e=new THREE.Vector4,g=new THREE.Vector4,n;this.projectObjects=function(j,o,z){var k=[],s,t;f=0;u.multiply(o.projectionMatrix,o.matrix);D[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);D[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);D[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);D[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);D[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
u.n33,u.n44-u.n34);D[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);o=0;for(s=D.length;o<s;o++){t=D[o];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(o=s.length;j<o;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var l=t.position,C=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),w=0;w<6;w++){r=D[w].x*l.x+D[w].y*l.y+D[w].z*l.z+D[w].w;if(r<=C){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
h[f]=h[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;k.push(d);f++}}z&&k.sort(a);return k};this.projectScene=function(j,o,z){var k=[],s=o.near,t=o.far,r,l,C,w,L,K,F,W,M,G,I,U,P,v,J,N;b=E=A=0;o.autoUpdateMatrix&&o.updateMatrix();u.multiply(o.projectionMatrix,o.matrix);K=this.projectObjects(j,o,true);j=0;for(r=K.length;j<r;j++){F=K[j].object;if(F.visible){F.autoUpdateMatrix&&F.updateMatrix();W=F.matrix;M=F.rotationMatrix;G=F.materials;I=F.overdraw;if(F instanceof
THREE.Mesh){U=F.geometry;P=U.vertices;l=0;for(C=P.length;l<C;l++){v=P[l];v.positionWorld.copy(v.position);W.multiplyVector3(v.positionWorld);w=v.positionScreen;w.copy(v.positionWorld);u.multiplyVector4(w);w.x/=w.w;w.y/=w.w;v.__visible=w.z>s&&w.z<t}U=U.faces;l=0;for(C=U.length;l<C;l++){v=U[l];if(v instanceof THREE.Face3){w=P[v.a];L=P[v.b];J=P[v.c];if(w.__visible&&L.__visible&&J.__visible)if(F.doubleSided||F.flipSided!=(J.positionScreen.x-w.positionScreen.x)*(L.positionScreen.y-w.positionScreen.y)-
(J.positionScreen.y-w.positionScreen.y)*(L.positionScreen.x-w.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(w.positionWorld);i.v2.positionWorld.copy(L.positionWorld);i.v3.positionWorld.copy(J.positionWorld);i.v1.positionScreen.copy(w.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(J.positionScreen);i.normalWorld.copy(v.normal);M.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);W.multiplyVector3(i.centroidWorld);
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);J=v.vertexNormals;n=i.vertexNormalsWorld;w=0;for(L=J.length;w<L;w++){N=n[w]=n[w]||new THREE.Vector3;N.copy(J[w]);M.multiplyVector3(N)}i.z=i.centroidScreen.z;i.meshMaterials=G;i.faceMaterials=v.materials;i.overdraw=I;if(F.geometry.uvs[l]){i.uvs[0]=F.geometry.uvs[l][0];i.uvs[1]=F.geometry.uvs[l][1];i.uvs[2]=F.geometry.uvs[l][2]}k.push(i);b++}}else if(v instanceof THREE.Face4){w=P[v.a];L=P[v.b];J=P[v.c];N=P[v.d];if(w.__visible&&
L.__visible&&J.__visible&&N.__visible)if(F.doubleSided||F.flipSided!=((N.positionScreen.x-w.positionScreen.x)*(L.positionScreen.y-w.positionScreen.y)-(N.positionScreen.y-w.positionScreen.y)*(L.positionScreen.x-w.positionScreen.x)<0||(L.positionScreen.x-J.positionScreen.x)*(N.positionScreen.y-J.positionScreen.y)-(L.positionScreen.y-J.positionScreen.y)*(N.positionScreen.x-J.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(w.positionWorld);i.v2.positionWorld.copy(L.positionWorld);
i.v3.positionWorld.copy(N.positionWorld);i.v1.positionScreen.copy(w.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(N.positionScreen);i.normalWorld.copy(v.normal);M.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);W.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=G;i.faceMaterials=v.materials;i.overdraw=I;if(F.geometry.uvs[l]){i.uvs[0]=F.geometry.uvs[l][0];
i.uvs[1]=F.geometry.uvs[l][1];i.uvs[2]=F.geometry.uvs[l][3]}k.push(i);b++;q=m[b]=m[b]||new THREE.RenderableFace3;q.v1.positionWorld.copy(L.positionWorld);q.v2.positionWorld.copy(J.positionWorld);q.v3.positionWorld.copy(N.positionWorld);q.v1.positionScreen.copy(L.positionScreen);q.v2.positionScreen.copy(J.positionScreen);q.v3.positionScreen.copy(N.positionScreen);q.normalWorld.copy(i.normalWorld);q.centroidWorld.copy(i.centroidWorld);q.centroidScreen.copy(i.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
G;q.faceMaterials=v.materials;q.overdraw=I;if(F.geometry.uvs[l]){q.uvs[0]=F.geometry.uvs[l][1];q.uvs[1]=F.geometry.uvs[l][2];q.uvs[2]=F.geometry.uvs[l][3]}k.push(q);b++}}}}else if(F instanceof THREE.Line){R.multiply(u,W);P=F.geometry.vertices;v=P[0];v.positionScreen.copy(v.position);R.multiplyVector4(v.positionScreen);l=1;for(C=P.length;l<C;l++){w=P[l];w.positionScreen.copy(w.position);R.multiplyVector4(w.positionScreen);L=P[l-1];e.copy(w.positionScreen);g.copy(L.positionScreen);if(c(e,g)){e.multiplyScalar(1/
e.w);g.multiplyScalar(1/g.w);p=H[E]=H[E]||new THREE.RenderableLine;p.v1.positionScreen.copy(e);p.v2.positionScreen.copy(g);p.z=Math.max(e.z,g.z);p.materials=F.materials;k.push(p);E++}}}else if(F instanceof THREE.Particle){T.set(F.position.x,F.position.y,F.position.z,1);u.multiplyVector4(T);T.z/=T.w;if(T.z>0&&T.z<1){x=S[A]=S[A]||new THREE.RenderableParticle;x.x=T.x/T.w;x.y=T.y/T.w;x.z=T.z;x.rotation=F.rotation.z;x.scale.x=F.scale.x*Math.abs(x.x-(T.x+o.projectionMatrix.n11)/(T.w+o.projectionMatrix.n14));
x.scale.y=F.scale.y*Math.abs(x.y-(T.y+o.projectionMatrix.n22)/(T.w+o.projectionMatrix.n24));x.materials=F.materials;k.push(x);A++}}}}z&&k.sort(a);return k};this.unprojectVector=function(j,o){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));z.multiplyVector3(j);return j}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;h=d/2;i=f/2};this.render=function(q,b){var m,p,E,H,x,A,S,V;a=c.projectScene(q,b);m=0;for(p=a.length;m<p;m++){x=a[m];if(x instanceof THREE.RenderableParticle){S=x.x*h+h;V=x.y*i+i;E=0;for(H=x.material.length;E<H;E++){A=x.material[E];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=S+"px";A.style.top=V+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(x!=da)p.globalAlpha=x=da}function c(da){if(A!=da){switch(da){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}A=da}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),i,q,b,m,p=h.getContext("2d"),E=null,H=null,x=1,A=0,S=null,V=null,T=1,u,R,D,e,g,n,j,o,z,k=new THREE.Color,
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,l=new THREE.Color,C,w,L,K,F,W,M,G,I,U=new THREE.Rectangle,P=new THREE.Rectangle,v=new THREE.Rectangle,J=false,N=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=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;h.width=i;h.height=q;U.set(-b,-m,b,m);x=1;A=0;V=S=null;T=1};this.setClearColor=function(da,ra){E=da!==null?new THREE.Color(da):null;H=ra;P.set(-b,-m,b,m);p.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!P.isEmpty()){P.inflate(1);P.minSelf(U);if(E!==null){c(THREE.NormalBlending);
a(1);p.fillStyle="rgba("+Math.floor(E.r*255)+","+Math.floor(E.g*255)+","+Math.floor(E.b*255)+","+H+")";p.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight())}else p.clearRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());P.empty()}};this.render=function(da,ra){function Ma(y){var X,Q,B,O=y.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Z.setRGB(0,0,0);y=0;for(X=O.length;y<X;y++){Q=O[y];B=Q.color;if(Q instanceof THREE.AmbientLight){ea.r+=B.r;ea.g+=B.g;ea.b+=B.b}else if(Q instanceof THREE.DirectionalLight){ba.r+=
B.r;ba.g+=B.g;ba.b+=B.b}else if(Q instanceof THREE.PointLight){Z.r+=B.r;Z.g+=B.g;Z.b+=B.b}}}function Aa(y,X,Q,B){var O,$,ca,ga,ia=y.lights;y=0;for(O=ia.length;y<O;y++){$=ia[y];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=Q.dot($.position)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=Q.dot(Y)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(y,X,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);
var B,O,$,ca,ga,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ca=Q.map;ga=ca.width>>1;ia=ca.height>>1;O=X.scale.x*b;$=X.scale.y*m;Q=O*ga;B=$*ia;v.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(U.instersects(v)){p.save();p.translate(y.x,y.y);p.rotate(-X.rotation);p.scale(O,-$);p.translate(-ga,-ia);p.drawImage(ca,0,0);p.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(J){N.r=ea.r+ba.r+Z.r;N.g=ea.g+ba.g+Z.g;N.b=ea.b+ba.b+Z.b;k.r=Q.color.r*N.r;k.g=Q.color.g*N.g;k.b=Q.color.b*N.b;k.updateStyleString()}else k.__styleString=
Q.color.__styleString;Q=X.scale.x*b;B=X.scale.y*m;v.set(y.x-Q,y.y-B,y.x+Q,y.y+B);if(U.instersects(v)){O=k.__styleString;if(V!=O)p.fillStyle=V=O;p.save();p.translate(y.x,y.y);p.rotate(-X.rotation);p.scale(Q,B);p.beginPath();p.arc(0,0,1,0,ja,true);p.closePath();p.fill();p.restore()}}}}function Oa(y,X,Q,B){if(B.opacity!=0){a(B.opacity);c(B.blending);p.beginPath();p.moveTo(y.positionScreen.x,y.positionScreen.y);p.lineTo(X.positionScreen.x,X.positionScreen.y);p.closePath();if(B instanceof THREE.LineBasicMaterial){k.__styleString=
B.color.__styleString;y=B.linewidth;if(T!=y)p.lineWidth=T=y;y=k.__styleString;if(S!=y)p.strokeStyle=S=y;p.stroke();v.inflate(B.linewidth*2)}}}function Ia(y,X,Q,B,O,$){if(O.opacity!=0){a(O.opacity);c(O.blending);e=y.positionScreen.x;g=y.positionScreen.y;n=X.positionScreen.x;j=X.positionScreen.y;o=Q.positionScreen.x;z=Q.positionScreen.y;p.beginPath();p.moveTo(e,g);p.lineTo(n,j);p.lineTo(o,z);p.lineTo(e,g);p.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof
THREE.UVMapping&&xa(e,g,n,j,o,z,O.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof THREE.SphericalReflectionMapping){y=ra.matrix;Y.copy(B.vertexNormalsWorld[0]);K=(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;F=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);W=(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;M=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);G=
(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;I=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;xa(e,g,n,j,o,z,O.env_map.image,K,F,W,M,G,I)}}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&xa(e,g,n,j,o,z,O.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);c(THREE.SubtractiveBlending)}if(J)if(!O.wireframe&&O.shading==THREE.SmoothShading&&
B.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,B.v1.positionWorld,B.vertexNormalsWorld[0],s);Aa($,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa($,B.v3.positionWorld,B.vertexNormalsWorld[2],r);l.r=(t.r+r.r)*0.5;l.g=(t.g+r.g)*0.5;l.b=(t.b+r.b)*0.5;L=Ja(s,t,r,l);xa(e,g,n,j,o,z,L,0,0,1,0,0,1)}else{N.r=ea.r;N.g=ea.g;N.b=ea.b;Aa($,B.centroidWorld,B.normalWorld,N);k.r=O.color.r*N.r;k.g=O.color.g*N.g;k.b=O.color.b*N.b;k.updateStyleString();O.wireframe?Ba(k.__styleString,
O.wireframe_linewidth):Ca(k.__styleString)}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){C=ra.near;w=ra.far;s.r=s.g=s.b=1-Ea(y.positionScreen.z,C,w);t.r=t.g=t.b=1-Ea(X.positionScreen.z,C,w);r.r=r.g=r.b=1-Ea(Q.positionScreen.z,C,w);l.r=(t.r+r.r)*0.5;l.g=(t.g+r.g)*0.5;l.b=(t.b+r.b)*0.5;L=Ja(s,t,r,l);xa(e,g,n,j,o,z,L,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){k.r=Fa(B.normalWorld.x);k.g=Fa(B.normalWorld.y);
k.b=Fa(B.normalWorld.z);k.updateStyleString();O.wireframe?Ba(k.__styleString,O.wireframe_linewidth):Ca(k.__styleString)}}}function Ba(y,X){if(S!=y)p.strokeStyle=S=y;if(T!=X)p.lineWidth=T=X;p.stroke();v.inflate(X*2)}function Ca(y){if(V!=y)p.fillStyle=V=y;p.fill()}function xa(y,X,Q,B,O,$,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;Q-=y;B-=X;O-=y;$-=X;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*Q-la*O)*pa;la=(ya*B-la*$)*pa;Q=(na*O-
oa*Q)*pa;B=(na*$-oa*B)*pa;y=y-ta*ga-Q*ia;X=X-la*ga-B*ia;p.save();p.transform(ta,la,Q,B,y,X);p.clip();p.drawImage(ca,0,0);p.restore()}function Ja(y,X,Q,B){var O=~~(y.r*255),$=~~(y.g*255);y=~~(y.b*255);var ca=~~(X.r*255),ga=~~(X.g*255);X=~~(X.b*255);var ia=~~(Q.r*255),na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ha[0]=O<0?0:O>255?255:O;ha[1]=$<0?0:$>255?255:$;ha[2]=y<0?0:y>255?255:y;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]=Q<0?0:Q>255?255:Q;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=B<0?0:B>255?255:B;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(y,X,Q){y=(y-X)/(Q-X);return y*y*(3-2*y)}function Fa(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Ga(y,X){var Q=X.x-y.x,B=X.y-y.y,O=1/Math.sqrt(Q*Q+B*B);Q*=O;B*=O;X.x+=Q;X.y+=B;y.x-=Q;y.y-=B}var Da,Ka,aa,ma,wa,Ha,La,za;p.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,
ra,this.sortElements);(J=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;R=aa.v2;u.positionScreen.x*=b;u.positionScreen.y*=m;R.positionScreen.x*=b;R.positionScreen.y*=m;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(R.positionScreen.x,R.positionScreen.y);if(U.instersects(v)){ma=
0;for(wa=aa.materials.length;ma<wa;)Oa(u,R,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){u=aa.v1;R=aa.v2;D=aa.v3;u.positionScreen.x*=b;u.positionScreen.y*=m;R.positionScreen.x*=b;R.positionScreen.y*=m;D.positionScreen.x*=b;D.positionScreen.y*=m;if(aa.overdraw){Ga(u.positionScreen,R.positionScreen);Ga(R.positionScreen,D.positionScreen);Ga(D.positionScreen,u.positionScreen)}v.add3Points(u.positionScreen.x,u.positionScreen.y,R.positionScreen.x,R.positionScreen.y,D.positionScreen.x,
D.positionScreen.y);if(U.instersects(v)){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(u,R,D,aa,za,da)}else Ia(u,R,D,aa,za,da)}}}P.addRectangle(v)}p.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(K,F,W){var M,G,I,U;M=0;for(G=K.lights.length;M<G;M++){I=K.lights[M];if(I instanceof THREE.DirectionalLight){U=F.normalWorld.dot(I.position)*I.intensity;if(U>0){W.r+=I.color.r*U;W.g+=I.color.g*U;W.b+=I.color.b*U}}else if(I instanceof THREE.PointLight){z.sub(I.position,F.centroidWorld);z.normalize();U=F.normalWorld.dot(z)*I.intensity;if(U>0){W.r+=I.color.r*U;W.g+=I.color.g*U;W.b+=I.color.b*U}}}}function c(K,F,W,M,G,I){r=f(l++);r.setAttribute("d","M "+K.positionScreen.x+
" "+K.positionScreen.y+" L "+F.positionScreen.x+" "+F.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)D.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(R){e.r=g.r;e.g=g.g;e.b=g.b;a(I,M,e);D.r=G.color.r*e.r;D.g=G.color.g*e.g;D.b=G.color.b*e.b;D.updateStyleString()}else D.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){o=1-G.__2near/(G.__farPlusNear-M.z*G.__farMinusNear);
D.setRGB(o,o,o)}else G instanceof THREE.MeshNormalMaterial&&D.setRGB(h(M.normalWorld.x),h(M.normalWorld.y),h(M.normalWorld.z));G.wireframe?r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):r.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+G.opacity);b.appendChild(r)}function d(K,F,W,M,G,I,U){r=f(l++);r.setAttribute("d",
"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+F.positionScreen.x+" "+F.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)D.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(R){e.r=g.r;e.g=g.g;e.b=g.b;a(U,G,e);D.r=I.color.r*e.r;D.g=I.color.g*e.g;D.b=I.color.b*e.b;D.updateStyleString()}else D.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){o=
1-I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear);D.setRGB(o,o,o)}else I instanceof THREE.MeshNormalMaterial&&D.setRGB(h(G.normalWorld.x),h(G.normalWorld.y),h(G.normalWorld.z));I.wireframe?r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):r.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(r)}
function f(K){if(k[K]==null){k[K]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&k[K].setAttribute("shape-rendering","crispEdges");return k[K]}return k[K]}function h(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,E,H,x,A,S,V,T=new THREE.Rectangle,u=new THREE.Rectangle,R=false,D=new THREE.Color(16777215),e=new THREE.Color(16777215),g=new THREE.Color(0),n=new THREE.Color(0),
j=new THREE.Color(0),o,z=new THREE.Vector3,k=[],s=[],t=[],r,l,C,w,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":L=1;break;case "low":L=0}};this.setSize=function(K,F){m=K;p=F;E=m/2;H=p/2;b.setAttribute("viewBox",-E+" "+-H+" "+m+" "+p);b.setAttribute("width",m);b.setAttribute("height",p);T.set(-E,-H,E,H)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,F){var W,M,
G,I,U,P,v,J;this.autoClear&&this.clear();i=q.projectScene(K,F,this.sortElements);w=C=l=0;if(R=K.lights.length>0){v=K.lights;g.setRGB(0,0,0);n.setRGB(0,0,0);j.setRGB(0,0,0);W=0;for(M=v.length;W<M;W++){G=v[W];I=G.color;if(G instanceof THREE.AmbientLight){g.r+=I.r;g.g+=I.g;g.b+=I.b}else if(G instanceof THREE.DirectionalLight){n.r+=I.r;n.g+=I.g;n.b+=I.b}else if(G instanceof THREE.PointLight){j.r+=I.r;j.g+=I.g;j.b+=I.b}}}W=0;for(M=i.length;W<M;W++){v=i[W];u.empty();if(v instanceof THREE.RenderableParticle){x=
v;x.x*=E;x.y*=-H;G=0;for(I=v.materials.length;G<I;G++)if(J=v.materials[G]){U=x;P=v;J=J;var N=C++;if(s[N]==null){s[N]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&s[N].setAttribute("shape-rendering","crispEdges")}r=s[N];r.setAttribute("cx",U.x);r.setAttribute("cy",U.y);r.setAttribute("r",P.scale.x*E);if(J instanceof THREE.ParticleCircleMaterial){if(R){e.r=g.r+n.r+j.r;e.g=g.g+n.g+j.g;e.b=g.b+n.b+j.b;D.r=J.color.r*e.r;D.g=J.color.g*e.g;D.b=J.color.b*e.b;D.updateStyleString()}else D=
J.color;r.setAttribute("style","fill: "+D.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){x=v.v1;A=v.v2;x.positionScreen.x*=E;x.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);if(T.instersects(u)){G=0;for(I=v.materials.length;G<I;)if(J=v.materials[G++]){U=x;P=A;J=J;N=w++;if(t[N]==null){t[N]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
0&&t[N].setAttribute("shape-rendering","crispEdges")}r=t[N];r.setAttribute("x1",U.positionScreen.x);r.setAttribute("y1",U.positionScreen.y);r.setAttribute("x2",P.positionScreen.x);r.setAttribute("y2",P.positionScreen.y);if(J instanceof THREE.LineBasicMaterial){D.__styleString=J.color.__styleString;r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+J.linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.linecap+"; stroke-linejoin: "+J.linejoin);b.appendChild(r)}}}}else if(v instanceof
THREE.RenderableFace3){x=v.v1;A=v.v2;S=v.v3;x.positionScreen.x*=E;x.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;S.positionScreen.x*=E;S.positionScreen.y*=-H;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);if(T.instersects(u)){G=0;for(I=v.meshMaterials.length;G<I;){J=v.meshMaterials[G++];if(J instanceof THREE.MeshFaceMaterial){U=0;for(P=v.faceMaterials.length;U<P;)(J=v.faceMaterials[U++])&&
c(x,A,S,v,J,K)}else J&&c(x,A,S,v,J,K)}}}else if(v instanceof THREE.RenderableFace4){x=v.v1;A=v.v2;S=v.v3;V=v.v4;x.positionScreen.x*=E;x.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;S.positionScreen.x*=E;S.positionScreen.y*=-H;V.positionScreen.x*=E;V.positionScreen.y*=-H;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(T.instersects(u)){G=
0;for(I=v.meshMaterials.length;G<I;){J=v.meshMaterials[G++];if(J instanceof THREE.MeshFaceMaterial){U=0;for(P=v.faceMaterials.length;U<P;)(J=v.faceMaterials[U++])&&d(x,A,S,V,v,J,K)}else J&&d(x,A,S,V,v,J,K)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,g){e.fragment_shader=g.fragment_shader;e.vertex_shader=g.vertex_shader;e.uniforms=Uniforms.clone(g.uniforms)}function d(e,g){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(g){e.uniforms.fogColor.value.setHex(g.color.hex);if(g instanceof THREE.Fog){e.uniforms.fogNear.value=g.near;e.uniforms.fogFar.value=g.far}else if(g instanceof THREE.FogExp2)e.uniforms.fogDensity.value=g.density}}function f(e,g){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(g){e.uniforms.fogColor.value.setHex(g.color.hex);if(g instanceof THREE.Fog){e.uniforms.fogNear.value=
g.near;e.uniforms.fogFar.value=g.far}else if(g instanceof THREE.FogExp2)e.uniforms.fogDensity.value=g.density}}function h(e,g){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,g);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function i(e){switch(e){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 q=document.createElement("canvas"),b,m=null,p=null,E=new THREE.Matrix4,H,x=new Float32Array(16),A=new Float32Array(16),S=new Float32Array(16),V=new Float32Array(9),
T=new Float32Array(16),u=true,R=new THREE.Color(0),D=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)D=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(e,g,n){try{b=q.getContext("experimental-webgl",{antialias:e})}catch(j){}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(g.r,g.g,g.b,n)})(u,R,D);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,g){q.width=e;q.height=g;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,g){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,g)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(e,g){var n,j,o,z=0,k=0,s=0,t,r,l,C=this.lights,w=C.directional.colors,L=C.directional.positions,K=C.point.colors,F=C.point.positions,W=0,M=0;n=0;for(j=g.length;n<j;n++){o=g[n];t=o.color;r=o.position;l=o.intensity;if(o instanceof THREE.AmbientLight){z+=t.r;k+=t.g;s+=t.b}else if(o instanceof THREE.DirectionalLight){w[W*3]=t.r*l;w[W*3+1]=t.g*l;w[W*3+2]=t.b*l;L[W*3]=r.x;L[W*3+1]=r.y;L[W*3+2]=r.z;W+=1}else if(o instanceof THREE.PointLight){K[M*3]=t.r*l;K[M*3+1]=t.g*l;K[M*3+2]=t.b*l;F[M*3]=r.x;
F[M*3+1]=r.y;F[M*3+2]=r.z;M+=1}}C.point.length=M;C.directional.length=W;C.ambient[0]=z;C.ambient[1]=k;C.ambient[2]=s};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 g=e.vertices.length;e.__vertexArray=new Float32Array(g*3);e.__lineArray=new Uint16Array(g);e.__webGLLineCount=g};this.initMeshBuffers=function(e,g){var n,j,o=0,z=0,k=0,s=g.geometry.faces,t=e.faces;n=0;for(j=t.length;n<j;n++){fi=t[n];face=s[fi];if(face instanceof THREE.Face3){o+=3;z+=1;k+=3}else if(face instanceof THREE.Face4){o+=4;z+=2;k+=4}}e.__vertexArray=new Float32Array(o*
3);e.__normalArray=new Float32Array(o*3);e.__tangentArray=new Float32Array(o*4);e.__uvArray=new Float32Array(o*2);e.__faceArray=new Uint16Array(z*3);e.__lineArray=new Uint16Array(k*2);o=false;n=0;for(j=g.materials.length;n<j;n++){s=g.materials[n];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){o=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){o=
true;break}if(o)break}e.__needsSmoothNormals=o;e.__webGLFaceCount=z*3;e.__webGLLineCount=k*2};this.setMeshBuffers=function(e,g,n,j,o,z,k,s){var t,r,l,C,w,L,K,F,W,M=0,G=0,I=0,U=0,P=0,v=0,J=0,N=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Z=e.__tangentArray,ja=e.__faceArray,Y=e.__lineArray,qa=e.__needsSmoothNormals,ka=g.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;g=0;for(t=ha.length;g<t;g++){r=ha[g];l=sa[r];r=ua[r];C=l.vertexNormals;w=l.normal;if(l instanceof THREE.Face3){if(j){L=
fa[l.a].position;K=fa[l.b].position;F=fa[l.c].position;N[G]=L.x;N[G+1]=L.y;N[G+2]=L.z;N[G+3]=K.x;N[G+4]=K.y;N[G+5]=K.z;N[G+6]=F.x;N[G+7]=F.y;N[G+8]=F.z;G+=9}if(s&&ka.hasTangents){L=fa[l.a].tangent;K=fa[l.b].tangent;F=fa[l.c].tangent;Z[v]=L.x;Z[v+1]=L.y;Z[v+2]=L.z;Z[v+3]=L.w;Z[v+4]=K.x;Z[v+5]=K.y;Z[v+6]=K.z;Z[v+7]=K.w;Z[v+8]=F.x;Z[v+9]=F.y;Z[v+10]=F.z;Z[v+11]=F.w;v+=12}if(k)if(C.length==3&&qa)for(l=0;l<3;l++){w=C[l];ba[P]=w.x;ba[P+1]=w.y;ba[P+2]=w.z;P+=3}else for(l=0;l<3;l++){ba[P]=w.x;ba[P+1]=w.y;
ba[P+2]=w.z;P+=3}if(z&&r)for(l=0;l<3;l++){C=r[l];ea[I]=C.u;ea[I+1]=C.v;I+=2}if(o){ja[U]=M;ja[U+1]=M+1;ja[U+2]=M+2;U+=3;Y[J]=M;Y[J+1]=M+1;Y[J+2]=M;Y[J+3]=M+2;Y[J+4]=M+1;Y[J+5]=M+2;J+=6;M+=3}}else if(l instanceof THREE.Face4){if(j){L=fa[l.a].position;K=fa[l.b].position;F=fa[l.c].position;W=fa[l.d].position;N[G]=L.x;N[G+1]=L.y;N[G+2]=L.z;N[G+3]=K.x;N[G+4]=K.y;N[G+5]=K.z;N[G+6]=F.x;N[G+7]=F.y;N[G+8]=F.z;N[G+9]=W.x;N[G+10]=W.y;N[G+11]=W.z;G+=12}if(s&&ka.hasTangents){L=fa[l.a].tangent;K=fa[l.b].tangent;
F=fa[l.c].tangent;l=fa[l.d].tangent;Z[v]=L.x;Z[v+1]=L.y;Z[v+2]=L.z;Z[v+3]=L.w;Z[v+4]=K.x;Z[v+5]=K.y;Z[v+6]=K.z;Z[v+7]=K.w;Z[v+8]=F.x;Z[v+9]=F.y;Z[v+10]=F.z;Z[v+11]=F.w;Z[v+12]=l.x;Z[v+13]=l.y;Z[v+14]=l.z;Z[v+15]=l.w;v+=16}if(k)if(C.length==4&&qa)for(l=0;l<4;l++){w=C[l];ba[P]=w.x;ba[P+1]=w.y;ba[P+2]=w.z;P+=3}else for(l=0;l<4;l++){ba[P]=w.x;ba[P+1]=w.y;ba[P+2]=w.z;P+=3}if(z&&r)for(l=0;l<4;l++){C=r[l];ea[I]=C.u;ea[I+1]=C.v;I+=2}if(o){ja[U]=M;ja[U+1]=M+1;ja[U+2]=M+2;ja[U+3]=M;ja[U+4]=M+2;ja[U+5]=M+3;
U+=6;Y[J]=M;Y[J+1]=M+1;Y[J+2]=M;Y[J+3]=M+3;Y[J+4]=M+1;Y[J+5]=M+2;Y[J+6]=M+2;Y[J+7]=M+3;J+=8;M+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,N,n)}if(k){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,n)}if(s&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,n)}if(z&&I>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,n)}if(o){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,n)}};this.setLineBuffers=function(e,g,n,j){var o,z,k=e.vertices,s=k.length,t=e.__vertexArray,r=e.__lineArray;if(n)for(n=0;n<s;n++){o=k[n].position;z=n*3;t[z]=o.x;t[z+1]=o.y;t[z+2]=o.z}if(j)for(n=0;n<s;n++)r[n]=n;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,t,g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,r,g)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,g,n,j,o,z){var k,s,t,r;if(!j.program){if(j instanceof THREE.MeshDepthMaterial){c(j,THREE.ShaderLib.depth);j.uniforms.mNear.value=e.near;j.uniforms.mFar.value=e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,n)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);
d(j,n)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,n)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,n)}var l,C,w;l=r=s=0;for(C=g.length;l<C;l++){w=g[l];w instanceof THREE.DirectionalLight&&r++;w instanceof THREE.PointLight&&s++}if(s+r<=4){l=r;s=s}else{l=Math.ceil(4*r/(s+r));s=4-l}s={directional:l,point:s};r={fog:n,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;l=j.vertex_shader;C=b.createProgram();
w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");r=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,
r.map?"#define USE_MAP":"",r.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(C,h("fragment",w+s));b.attachShader(C,h("vertex",r+l));b.linkProgram(C);b.getProgramParameter(C,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
b.getProgramParameter(C,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");C.uniforms={};C.attributes={};j.program=C;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in j.uniforms)s.push(k);k=j.program;l=0;for(C=s.length;l<C;l++){w=s[l];k.uniforms[w]=b.getUniformLocation(k,w)}k=j.program;s=["position","normal","uv","tangent"];l=0;for(C=s.length;l<C;l++){w=s[l];k.attributes[w]=b.getAttribLocation(k,w)}}k=j.program;if(k!=m){b.useProgram(k);
m=k}this.loadCamera(k,e);this.loadMatrices(k);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(k,g);e=this.lights;j.uniforms.enableLighting.value=e.directional.length+e.point.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;j.uniforms.directionalLightDirection.value=e.directional.positions;j.uniforms.pointLightColor.value=e.point.colors;j.uniforms.pointLightPosition.value=e.point.positions}if(j instanceof
THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)d(j,n);j instanceof THREE.LineBasicMaterial&&f(j,n);if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);j.uniforms.shininess.value=j.shininess}n=j.uniforms;for(t in n)if(l=k.uniforms[t]){g=n[t];s=g.type;e=g.value;if(s=="i")b.uniform1i(l,e);else if(s=="f")b.uniform1f(l,
e);else if(s=="fv1")b.uniform1fv(l,e);else if(s=="fv")b.uniform3fv(l,e);else if(s=="v2")b.uniform2f(l,e.x,e.y);else if(s=="v3")b.uniform3f(l,e.x,e.y,e.z);else if(s=="c")b.uniform3f(l,e.r,e.g,e.b);else if(s=="t"){b.uniform1i(l,e);if(g=g.texture)if(g.image instanceof Array&&g.image.length==6){g=g;e=e;if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,g.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,g.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+
e);b.bindTexture(b.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube)}}else{g=g;e=e;if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,g.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,g.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(g.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(g.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(g.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(g.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+e);b.bindTexture(b.TEXTURE_2D,g.__webGLTexture)}}}t=k.attributes;b.bindBuffer(b.ARRAY_BUFFER,o.__webGLVertexBuffer);b.vertexAttribPointer(t.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.position);if(t.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLNormalBuffer);b.vertexAttribPointer(t.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.normal)}if(t.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLTangentBuffer);
b.vertexAttribPointer(t.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.tangent)}if(t.uv>=0)if(o.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUVBuffer);b.vertexAttribPointer(t.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.uv)}else b.disableVertexAttribArray(t.uv);if(j.wireframe||j instanceof THREE.LineBasicMaterial){t=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&z.type==THREE.LineStrip?
b.LINE_STRIP:b.LINES;b.lineWidth(t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);b.drawElements(j,o.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,o.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,n,j,o,z,k){var s,t,r,l,C;r=0;for(l=j.materials.length;r<l;r++){s=j.materials[r];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=o.materials.length;s<t;s++)if((C=o.materials[s])&&C.blending==z&&
C.opacity<1==k){this.setBlending(C.blending);this.renderBuffer(e,g,n,C,o,j)}}else if((C=s)&&C.blending==z&&C.opacity<1==k){this.setBlending(C.blending);this.renderBuffer(e,g,n,C,o,j)}}};this.render=function(e,g,n,j){var o,z,k,s=e.lights,t=e.fog;this.initWebGLObjects(e);j=j!==undefined?j:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);
b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(n.format),n.width,n.height,0,i(n.format),i(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){o=n.__webGLFramebuffer;k=n.width;z=n.height}else{o=null;k=q.width;z=q.height}if(o!=p){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,k,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);p=o}this.autoClear&&
this.clear();g.autoUpdateMatrix&&g.updateMatrix();x.set(g.matrix.flatten());S.set(g.projectionMatrix.flatten());j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];k=z.object;z=z.buffer;if(k.visible){this.setupMatrices(k,g);this.renderPass(g,s,t,k,z,THREE.NormalBlending,false)}}j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];k=z.object;z=z.buffer;if(k.visible){this.setupMatrices(k,g);if(k.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);k.flipSided?b.frontFace(b.CW):
b.frontFace(b.CCW)}this.renderPass(g,s,t,k,z,THREE.AdditiveBlending,false);this.renderPass(g,s,t,k,z,THREE.SubtractiveBlending,false);this.renderPass(g,s,t,k,z,THREE.AdditiveBlending,true);this.renderPass(g,s,t,k,z,THREE.SubtractiveBlending,true);this.renderPass(g,s,t,k,z,THREE.NormalBlending,true)}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
function(e){function g(r,l,C,w){if(r[l]==undefined){e.__webGLObjects.push({buffer:C,object:w});r[l]=1}}var n,j,o,z,k,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}n=0;for(j=e.objects.length;n<j;n++){o=e.objects[n];k=o.geometry;if(e.__webGLObjectsMap[o.id]==undefined)e.__webGLObjectsMap[o.id]={};t=e.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(z in k.geometryChunks){s=k.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,o);
k.__dirtyVertices=true;k.__dirtyElements=true;k.__dirtyUvs=true;k.__dirtyNormals=true;k.__dirtyTangents=true}if(k.__dirtyVertices||k.__dirtyElements||k.__dirtyUvs)this.setMeshBuffers(s,o,b.DYNAMIC_DRAW,k.__dirtyVertices,k.__dirtyElements,k.__dirtyUvs,k.__dirtyNormals,k.__dirtyTangents);g(t,z,s,o)}k.__dirtyVertices=false;k.__dirtyElements=false;k.__dirtyUvs=false;k.__dirtyNormals=false;k.__dirtyTangents=false}else if(o instanceof THREE.Line){if(!k.__webGLVertexBuffer){this.createLineBuffers(k);this.initLineBuffers(k);
k.__dirtyVertices=true;k.__dirtyElements=true}k.__dirtyVertices&&this.setLineBuffers(k,b.DYNAMIC_DRAW,k.__dirtyVertices,k.__dirtyElements);g(t,0,k,o);k.__dirtyVertices=false;k.__dirtyElements=false}else if(o instanceof THREE.ParticleSystem){k.__webGLVertexBuffer||this.createParticleBuffers(k);g(t,0,k,o)}}};this.removeObject=function(e,g){var n,j;for(n=e.__webGLObjects.length-1;n>=0;n--){j=e.__webGLObjects[n].object;g==j&&e.__webGLObjects.splice(n,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&
e.updateMatrix();E.multiply(g.matrix,e.matrix);A.set(E.flatten());H=THREE.Matrix4.makeInvert3x3(E).transpose();V.set(H.m);T.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,x);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,A);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,S);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,T)};this.loadCamera=function(e,g){b.uniform3f(e.uniforms.cameraPosition,
g.position.x,g.position.y,g.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,g){if(e){!g||g=="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);
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",
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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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};
// Three.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,d,e){this.r=a;this.g=d;this.b=e;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,d){this.x=a||0;this.y=d||0};
THREE.Vector2.prototype={set:function(a,d){this.x=a;this.y=d;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,d){this.x=a.x+d.x;this.y=a.y+d.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,d){this.x=a.x-d.x;this.y=a.y-d.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,d,e){this.x=a||0;this.y=d||0;this.z=e||0};
THREE.Vector3.prototype={set:function(a,d,e){this.x=a;this.y=d;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,d){this.x=a.x+d.x;this.y=a.y+d.y;this.z=a.z+d.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,d){this.x=a.x-d.x;this.y=a.y-d.y;this.z=a.z-d.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,d){this.x=a.y*d.z-a.z*d.y;this.y=a.z*d.x-a.x*d.z;this.z=a.x*d.y-a.y*d.x;return this},crossSelf:function(a){var d=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-d*a.z;this.z=d*a.y-e*a.x;return this},multiply:function(a,d){this.x=a.x*d.x;this.y=a.y*d.y;this.z=a.z*d.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 d=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(d*d+e*e+a*a)},distanceToSquared:function(a){var d=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return d*d+e*e+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,d,e,f){this.x=a||0;this.y=d||0;this.z=e||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,d,e,f){this.x=a;this.y=d;this.z=e;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,d){this.x=a.x+d.x;this.y=a.y+d.y;this.z=a.z+d.z;this.w=a.w+d.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,d){this.x=a.x-d.x;this.y=a.y-d.y;this.z=a.z-d.z;this.w=a.w-d.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,d){this.x+=(a.x-this.x)*d;this.y+=(a.y-this.y)*d;this.z+=(a.z-this.z)*d;this.w+=(a.w-this.w)*d},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,d){this.origin=a||new THREE.Vector3;this.direction=d||new THREE.Vector3};
THREE.Ray.prototype={intersectScene:function(a){var d,e,f=a.objects,h=[];a=0;for(d=f.length;a<d;a++){e=f[a];if(e instanceof THREE.Mesh)h=h.concat(this.intersectObject(e))}h.sort(function(i,p){return i.distance-p.distance});return h},intersectObject:function(a){function d(Q,q,$,L){L=L.clone().subSelf(q);$=$.clone().subSelf(q);var g=Q.clone().subSelf(q);Q=L.dot(L);q=L.dot($);L=L.dot(g);var k=$.dot($);$=$.dot(g);g=1/(Q*k-q*q);k=(k*L-q*$)*g;Q=(Q*$-q*L)*g;return k>0&&Q>0&&k+Q<1}var e,f,h,i,p,b,j,l,C,F,
A,E=a.geometry,N=E.vertices,P=[];e=0;for(f=E.faces.length;e<f;e++){h=E.faces[e];F=this.origin.clone();A=this.direction.clone();i=a.matrix.multiplyVector3(N[h.a].position.clone());p=a.matrix.multiplyVector3(N[h.b].position.clone());b=a.matrix.multiplyVector3(N[h.c].position.clone());j=h instanceof THREE.Face4?a.matrix.multiplyVector3(N[h.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(h.normal.clone());C=A.dot(l);if(C<0){l=l.dot((new THREE.Vector3).sub(i,F))/C;F=F.addSelf(A.multiplyScalar(l));
if(h instanceof THREE.Face3){if(d(F,i,p,b)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};P.push(h)}}else if(h instanceof THREE.Face4)if(d(F,i,p,j)||d(F,p,b,j)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};P.push(h)}}}return P}};
THREE.Rectangle=function(){function a(){i=f-d;p=h-e}var d,e,f,h,i,p,b=true;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return p};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(j,l,C,F){b=false;d=j;e=l;f=C;h=F;a()};this.addPoint=function(j,l){if(b){b=false;d=j;e=l;f=j;h=l}else{d=d<j?d:j;e=e<l?e:l;f=f>j?f:j;h=h>l?
h:l}a()};this.add3Points=function(j,l,C,F,A,E){if(b){b=false;d=j<C?j<A?j:A:C<A?C:A;e=l<F?l<E?l:E:F<E?F:E;f=j>C?j>A?j:A:C>A?C:A;h=l>F?l>E?l:E:F>E?F:E}else{d=j<C?j<A?j<d?j:d:A<d?A:d:C<A?C<d?C:d:A<d?A:d;e=l<F?l<E?l<e?l:e:E<e?E:e:F<E?F<e?F:e:E<e?E:e;f=j>C?j>A?j>f?j:f:A>f?A:f:C>A?C>f?C:f:A>f?A:f;h=l>F?l>E?l>h?l:h:E>h?E:h:F>E?F>h?F:h:E>h?E:h}a()};this.addRectangle=function(j){if(b){b=false;d=j.getLeft();e=j.getTop();f=j.getRight();h=j.getBottom()}else{d=d<j.getLeft()?d:j.getLeft();e=e<j.getTop()?e:j.getTop();
f=f>j.getRight()?f:j.getRight();h=h>j.getBottom()?h:j.getBottom()}a()};this.inflate=function(j){d-=j;e-=j;f+=j;h+=j;a()};this.minSelf=function(j){d=d>j.getLeft()?d:j.getLeft();e=e>j.getTop()?e:j.getTop();f=f<j.getRight()?f:j.getRight();h=h<j.getBottom()?h:j.getBottom();a()};this.instersects=function(j){return Math.min(f,j.getRight())-Math.max(d,j.getLeft())>=0&&Math.min(h,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){b=true;h=f=e=d=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+d+", right: "+f+", top: "+e+", bottom: "+h+", width: "+i+", height: "+p+" )"}};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,d,e,f,h,i,p,b,j,l,C,F,A,E,N,P){this.n11=a||1;this.n12=d||0;this.n13=e||0;this.n14=f||0;this.n21=h||0;this.n22=i||1;this.n23=p||0;this.n24=b||0;this.n31=j||0;this.n32=l||0;this.n33=C||1;this.n34=F||0;this.n41=A||0;this.n42=E||0;this.n43=N||0;this.n44=P||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,d,e,f,h,i,p,b,j,l,C,F,A,E,N,P){this.n11=a;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=p;this.n24=b;this.n31=j;this.n32=l;this.n33=C;this.n34=F;this.n41=A;this.n42=E;this.n43=N;this.n44=P;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,d,e){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,d).normalize();f.cross(e,i).normalize();h.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var d=a.x,e=a.y,f=a.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h;a.y=(this.n21*d+this.n22*e+this.n23*f+this.n24)*h;a.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var d=a.x,e=a.y,f=a.z,h=a.w;a.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;a.y=this.n21*d+this.n22*e+this.n23*
f+this.n24*h;a.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;a.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return a},crossVector:function(a){var d=new THREE.Vector4;d.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;d.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;d.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;d.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return d},multiply:function(a,d){var e=a.n11,f=a.n12,h=a.n13,i=a.n14,p=a.n21,b=a.n22,j=a.n23,l=a.n24,C=a.n31,
F=a.n32,A=a.n33,E=a.n34,N=a.n41,P=a.n42,Q=a.n43,q=a.n44,$=d.n11,L=d.n12,g=d.n13,k=d.n14,r=d.n21,m=d.n22,u=d.n23,I=d.n24,n=d.n31,w=d.n32,B=d.n33,v=d.n34,o=d.n41,K=d.n42,G=d.n43,U=d.n44;this.n11=e*$+f*r+h*n+i*o;this.n12=e*L+f*m+h*w+i*K;this.n13=e*g+f*u+h*B+i*G;this.n14=e*k+f*I+h*v+i*U;this.n21=p*$+b*r+j*n+l*o;this.n22=p*L+b*m+j*w+l*K;this.n23=p*g+b*u+j*B+l*G;this.n24=p*k+b*I+j*v+l*U;this.n31=C*$+F*r+A*n+E*o;this.n32=C*L+F*m+A*w+E*K;this.n33=C*g+F*u+A*B+E*G;this.n34=C*k+F*I+A*v+E*U;this.n41=N*$+P*r+
Q*n+q*o;this.n42=N*L+P*m+Q*w+q*K;this.n43=N*g+P*u+Q*B+q*G;this.n44=N*k+P*I+Q*v+q*U;return this},multiplySelf:function(a){var d=this.n11,e=this.n12,f=this.n13,h=this.n14,i=this.n21,p=this.n22,b=this.n23,j=this.n24,l=this.n31,C=this.n32,F=this.n33,A=this.n34,E=this.n41,N=this.n42,P=this.n43,Q=this.n44,q=a.n11,$=a.n21,L=a.n31,g=a.n41,k=a.n12,r=a.n22,m=a.n32,u=a.n42,I=a.n13,n=a.n23,w=a.n33,B=a.n43,v=a.n14,o=a.n24,K=a.n34;a=a.n44;this.n11=d*q+e*$+f*L+h*g;this.n12=d*k+e*r+f*m+h*u;this.n13=d*I+e*n+f*w+h*
B;this.n14=d*v+e*o+f*K+h*a;this.n21=i*q+p*$+b*L+j*g;this.n22=i*k+p*r+b*m+j*u;this.n23=i*I+p*n+b*w+j*B;this.n24=i*v+p*o+b*K+j*a;this.n31=l*q+C*$+F*L+A*g;this.n32=l*k+C*r+F*m+A*u;this.n33=l*I+C*n+F*w+A*B;this.n34=l*v+C*o+F*K+A*a;this.n41=E*q+N*$+P*L+Q*g;this.n42=E*k+N*r+P*m+Q*u;this.n43=E*I+N*n+P*w+Q*B;this.n44=E*v+N*o+P*K+Q*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,d=this.n12,e=this.n13,f=this.n14,h=this.n21,i=this.n22,p=this.n23,b=this.n24,j=this.n31,l=this.n32,C=this.n33,F=this.n34,A=this.n41,E=this.n42,N=this.n43,P=this.n44;return f*p*l*A-e*b*l*A-f*i*C*A+d*b*C*A+e*i*F*A-d*p*F*A-f*p*j*E+e*b*j*E+f*h*C*E-a*b*C*E-e*h*F*E+a*p*F*E+f*i*j*N-d*b*j*N-f*h*l*N+a*b*l*N+d*h*F*N-a*i*F*N-e*i*j*P+d*p*j*P+e*h*l*P-a*p*l*P-d*h*C*P+a*i*C*P},transpose:function(){function a(d,e,
f){var h=d[e];d[e]=d[f];d[f]=h}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,d,e){this.set(1,0,0,a,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(a,d,e){this.set(a,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},
setRotX:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,d,-a,0,0,a,d,0,0,0,0,1);return this},setRotY:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(d,0,a,0,0,1,0,0,-a,0,d,0,0,0,0,1);return this},setRotZ:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(d,-a,0,0,a,d,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,d){c=Math.cos(d);s=Math.sin(d);t=1-c;x=a.x;y=a.y;z=a.z;tx=t*x;ty=t*y;this.set(tx*x+c,tx*y-s*z,tx*z+s*y,0,tx*y+s*z,ty*y+c,ty*z-s*x,0,tx*z-s*y,ty*z+s*x,t*z*z+
c,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,d,e){var f=new THREE.Matrix4;f.n14=a;f.n24=d;f.n34=e;return f};THREE.Matrix4.scaleMatrix=function(a,d,e){var f=new THREE.Matrix4;f.n11=a;f.n22=d;f.n33=e;return f};
THREE.Matrix4.rotationXMatrix=function(a){var d=new THREE.Matrix4;d.n22=d.n33=Math.cos(a);d.n32=Math.sin(a);d.n23=-d.n32;return d};THREE.Matrix4.rotationYMatrix=function(a){var d=new THREE.Matrix4;d.n11=d.n33=Math.cos(a);d.n13=Math.sin(a);d.n31=-d.n13;return d};THREE.Matrix4.rotationZMatrix=function(a){var d=new THREE.Matrix4;d.n11=d.n22=Math.cos(a);d.n21=Math.sin(a);d.n12=-d.n21;return d};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,d){var e=new THREE.Matrix4,f=Math.cos(d),h=Math.sin(d),i=1-f,p=a.x,b=a.y,j=a.z,l=i*p,C=i*b;e.n11=l*p+f;e.n12=l*b-h*j;e.n13=l*j+h*b;e.n21=l*b+h*j;e.n22=C*b+f;e.n23=C*j-h*p;e.n31=l*j-h*b;e.n32=C*j+h*p;e.n33=i*j*j+f;return e};
THREE.Matrix4.makeInvert=function(a){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,i=a.n21,p=a.n22,b=a.n23,j=a.n24,l=a.n31,C=a.n32,F=a.n33,A=a.n34,E=a.n41,N=a.n42,P=a.n43,Q=a.n44,q=new THREE.Matrix4;q.n11=b*A*N-j*F*N+j*C*P-p*A*P-b*C*Q+p*F*Q;q.n12=h*F*N-f*A*N-h*C*P+e*A*P+f*C*Q-e*F*Q;q.n13=f*j*N-h*b*N+h*p*P-e*j*P-f*p*Q+e*b*Q;q.n14=h*b*C-f*j*C-h*p*F+e*j*F+f*p*A-e*b*A;q.n21=j*F*E-b*A*E-j*l*P+i*A*P+b*l*Q-i*F*Q;q.n22=f*A*E-h*F*E+h*l*P-d*A*P-f*l*Q+d*F*Q;q.n23=h*b*E-f*j*E-h*i*P+d*j*P+f*i*Q-d*b*Q;q.n24=f*j*l-h*b*l+
h*i*F-d*j*F-f*i*A+d*b*A;q.n31=p*A*E-j*C*E+j*l*N-i*A*N-p*l*Q+i*C*Q;q.n32=h*C*E-e*A*E-h*l*N+d*A*N+e*l*Q-d*C*Q;q.n33=f*j*E-h*p*E+h*i*N-d*j*N-e*i*Q+d*p*Q;q.n34=h*p*l-e*j*l-h*i*C+d*j*C+e*i*A-d*p*A;q.n41=b*C*E-p*F*E-b*l*N+i*F*N+p*l*P-i*C*P;q.n42=e*F*E-f*C*E+f*l*N-d*F*N-e*l*P+d*C*P;q.n43=f*p*E-e*b*E-f*i*N+d*b*N+e*i*P-d*p*P;q.n44=e*b*l-f*p*l+f*i*C-d*b*C-e*i*F+d*p*F;q.multiplyScalar(1/a.determinant());return q};
THREE.Matrix4.makeInvert3x3=function(a){var d=a.flatten();a=a.m33;var e=d[10]*d[5]-d[6]*d[9],f=-d[10]*d[1]+d[2]*d[9],h=d[6]*d[1]-d[2]*d[5],i=-d[10]*d[4]+d[6]*d[8],p=d[10]*d[0]-d[2]*d[8],b=-d[6]*d[0]+d[2]*d[4],j=d[9]*d[4]-d[5]*d[8],l=-d[9]*d[0]+d[1]*d[8],C=d[5]*d[0]-d[1]*d[4];d=d[0]*e+d[1]*i+d[2]*j;if(d==0)throw"matrix not invertible";d=1/d;a.m[0]=d*e;a.m[1]=d*f;a.m[2]=d*h;a.m[3]=d*i;a.m[4]=d*p;a.m[5]=d*b;a.m[6]=d*j;a.m[7]=d*l;a.m[8]=d*C;return a};
THREE.Matrix4.makeFrustum=function(a,d,e,f,h,i){var p,b,j;p=new THREE.Matrix4;b=2*h/(d-a);j=2*h/(f-e);a=(d+a)/(d-a);e=(f+e)/(f-e);f=-(i+h)/(i-h);h=-2*i*h/(i-h);p.n11=b;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=j;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,d,e,f){var h;a=e*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*d,a*d,h,a,e,f)};
THREE.Matrix4.makeOrtho=function(a,d,e,f,h,i){var p,b,j,l;p=new THREE.Matrix4;b=d-a;j=e-f;l=i-h;a=(d+a)/b;e=(e+f)/j;h=(i+h)/l;p.n11=2/b;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/j;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/l;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,d){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=d||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,d,e,f,h){this.a=a;this.b=d;this.c=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.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,d,e,f,h,i){this.a=a;this.b=d;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,d){this.u=a||0;this.v=d||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,d,e;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var d,e,f,h,i,p,b=new THREE.Vector3,j=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);d=0;for(e=i.normal.length;d<e;d++)b.addSelf(i.vertexNormals[d]);b.divideScalar(3)}else{d=this.vertices[i.a];e=this.vertices[i.b];p=this.vertices[i.c];b.sub(p.position,
e.position);j.sub(d.position,e.position);b.crossSelf(j)}b.isZero()||b.normalize();i.normal.copy(b)}},computeVertexNormals:function(){var a,d,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(d=this.vertices.length;a<d;a++)f[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(d=this.vertices.length;a<d;a++)f[a].set(0,0,0)}a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(d=this.vertices.length;a<d;a++)f[a].normalize();a=0;for(d=this.faces.length;a<
d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(v,o,K,G,U,T,M){i=v.vertices[o].position;p=v.vertices[K].position;b=v.vertices[G].position;j=h[U];l=h[T];C=h[M];F=p.x-i.x;A=b.x-i.x;E=p.y-i.y;N=b.y-i.y;
P=p.z-i.z;Q=b.z-i.z;q=l.u-j.u;$=C.u-j.u;L=l.v-j.v;g=C.v-j.v;k=1/(q*g-$*L);u.set((g*F-L*A)*k,(g*E-L*N)*k,(g*P-L*Q)*k);I.set((q*A-$*F)*k,(q*N-$*E)*k,(q*Q-$*P)*k);r[o].addSelf(u);r[K].addSelf(u);r[G].addSelf(u);m[o].addSelf(I);m[K].addSelf(I);m[G].addSelf(I)}var d,e,f,h,i,p,b,j,l,C,F,A,E,N,P,Q,q,$,L,g,k,r=[],m=[],u=new THREE.Vector3,I=new THREE.Vector3,n=new THREE.Vector3,w=new THREE.Vector3,B=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){r[d]=new THREE.Vector3;m[d]=new THREE.Vector3}d=0;
for(e=this.faces.length;d<e;d++){f=this.faces[d];h=this.uvs[d];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])}}d=0;for(e=this.vertices.length;d<e;d++){B.copy(this.vertices[d].normal);f=r[d];n.copy(f);n.subSelf(B.multiplyScalar(B.dot(f))).normalize();w.cross(this.vertices[d].normal,f);f=w.dot(m[d]);f=f<0?-1:1;this.vertices[d].tangent.set(n.x,n.y,n.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],
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){a=this.vertices[d];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,d=0,e=this.vertices.length;d<e;d++)a=Math.max(a,this.vertices[d].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var F=[];d=0;for(e=C.length;d<e;d++)C[d]==undefined?F.push("undefined"):F.push(C[d].toString());return F.join("_")}var d,e,f,h,i,p,b,j,l={};f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];
p=i.materials;b=a(p);if(l[b]==undefined)l[b]={hash:b,counter:0};j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:p,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+i>65535){l[b].counter+=1;j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:p,vertices:0}}this.geometryChunks[j].faces.push(f);this.geometryChunks[j].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,d,e,f){this.fov=a;this.aspect=d;this.near=e;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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,d){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=d||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.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,d=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);if(d.x!=0){f.setRotX(d.x);this.matrix.multiplySelf(f)}if(d.y!=0){f.setRotY(d.y);this.matrix.multiplySelf(f)}if(d.z!=0){f.setRotZ(d.z);this.matrix.multiplySelf(f)}if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};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,d){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];this.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,d,e){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,d){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,d,e,f,h,i){this.image=a;this.mapping=d!==undefined?d:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,d,e){this.width=a;this.height=d;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var d,e,f,h={};for(d in a){h[d]={};for(e in a[d]){f=a[d][e];h[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var d,e,f,h={};for(d=0;d<a.length;d++){f=this.clone(a[d]);for(e in f)h[e]=f[e]}return h}};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,d,e){this.color=new THREE.Color(a);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(a,d){this.color=new THREE.Color(a);this.density=d||2.5E-4};
THREE.Projector=function(){function a(m,u){return u.z-m.z}function d(m,u){var I=0,n=1,w=m.z+m.w,B=u.z+u.w,v=-m.z+m.w,o=-u.z+u.w;if(w>=0&&B>=0&&v>=0&&o>=0)return true;else if(w<0&&B<0||v<0&&o<0)return false;else{if(w<0)I=Math.max(I,w/(w-B));else if(B<0)n=Math.min(n,w/(w-B));if(v<0)I=Math.max(I,v/(v-o));else if(o<0)n=Math.min(n,v/(v-o));if(n<I)return false;else{m.lerpSelf(u,I);u.lerpSelf(m,1-n);return true}}}var e,f,h=[],i,p,b,j=[],l,C,F=[],A,E,N=[],P=new THREE.Vector4,Q=new THREE.Vector4,q=new THREE.Matrix4,
$=new THREE.Matrix4,L=[],g=new THREE.Vector4,k=new THREE.Vector4,r;this.projectObjects=function(m,u,I){var n=[],w,B;f=0;q.multiply(u.projectionMatrix,u.matrix);L[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);L[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);L[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);L[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);L[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
q.n33,q.n44-q.n34);L[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);u=0;for(w=L.length;u<w;u++){B=L[u];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}w=m.objects;m=0;for(u=w.length;m<u;m++){B=w[m];var v;if(!(v=!B.visible)){if(v=B instanceof THREE.Mesh){a:{v=void 0;for(var o=B.position,K=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),G=0;G<6;G++){v=L[G].x*o.x+L[G].y*o.y+L[G].z*o.z+L[G].w;if(v<=K){v=false;break a}}v=true}v=!v}v=v}if(!v){e=
h[f]=h[f]||new THREE.RenderableObject;P.copy(B.position);q.multiplyVector3(P);e.object=B;e.z=P.z;n.push(e);f++}}I&&n.sort(a);return n};this.projectScene=function(m,u,I){var n=[],w=u.near,B=u.far,v,o,K,G,U,T,M,ba,V,O,R,aa,Y,D,S,W;b=C=E=0;u.autoUpdateMatrix&&u.updateMatrix();q.multiply(u.projectionMatrix,u.matrix);T=this.projectObjects(m,u,true);m=0;for(v=T.length;m<v;m++){M=T[m].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();ba=M.matrix;V=M.rotationMatrix;O=M.materials;R=M.overdraw;if(M instanceof
THREE.Mesh){aa=M.geometry;Y=aa.vertices;o=0;for(K=Y.length;o<K;o++){D=Y[o];D.positionWorld.copy(D.position);ba.multiplyVector3(D.positionWorld);G=D.positionScreen;G.copy(D.positionWorld);q.multiplyVector4(G);G.x/=G.w;G.y/=G.w;D.__visible=G.z>w&&G.z<B}aa=aa.faces;o=0;for(K=aa.length;o<K;o++){D=aa[o];if(D instanceof THREE.Face3){G=Y[D.a];U=Y[D.b];S=Y[D.c];if(G.__visible&&U.__visible&&S.__visible)if(M.doubleSided||M.flipSided!=(S.positionScreen.x-G.positionScreen.x)*(U.positionScreen.y-G.positionScreen.y)-
(S.positionScreen.y-G.positionScreen.y)*(U.positionScreen.x-G.positionScreen.x)<0){i=j[b]=j[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(G.positionWorld);i.v2.positionWorld.copy(U.positionWorld);i.v3.positionWorld.copy(S.positionWorld);i.v1.positionScreen.copy(G.positionScreen);i.v2.positionScreen.copy(U.positionScreen);i.v3.positionScreen.copy(S.positionScreen);i.normalWorld.copy(D.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(D.centroid);ba.multiplyVector3(i.centroidWorld);
i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);S=D.vertexNormals;r=i.vertexNormalsWorld;G=0;for(U=S.length;G<U;G++){W=r[G]=r[G]||new THREE.Vector3;W.copy(S[G]);V.multiplyVector3(W)}i.z=i.centroidScreen.z;i.meshMaterials=O;i.faceMaterials=D.materials;i.overdraw=R;if(M.geometry.uvs[o]){i.uvs[0]=M.geometry.uvs[o][0];i.uvs[1]=M.geometry.uvs[o][1];i.uvs[2]=M.geometry.uvs[o][2]}n.push(i);b++}}else if(D instanceof THREE.Face4){G=Y[D.a];U=Y[D.b];S=Y[D.c];W=Y[D.d];if(G.__visible&&
U.__visible&&S.__visible&&W.__visible)if(M.doubleSided||M.flipSided!=((W.positionScreen.x-G.positionScreen.x)*(U.positionScreen.y-G.positionScreen.y)-(W.positionScreen.y-G.positionScreen.y)*(U.positionScreen.x-G.positionScreen.x)<0||(U.positionScreen.x-S.positionScreen.x)*(W.positionScreen.y-S.positionScreen.y)-(U.positionScreen.y-S.positionScreen.y)*(W.positionScreen.x-S.positionScreen.x)<0)){i=j[b]=j[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(G.positionWorld);i.v2.positionWorld.copy(U.positionWorld);
i.v3.positionWorld.copy(W.positionWorld);i.v1.positionScreen.copy(G.positionScreen);i.v2.positionScreen.copy(U.positionScreen);i.v3.positionScreen.copy(W.positionScreen);i.normalWorld.copy(D.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(D.centroid);ba.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=O;i.faceMaterials=D.materials;i.overdraw=R;if(M.geometry.uvs[o]){i.uvs[0]=M.geometry.uvs[o][0];
i.uvs[1]=M.geometry.uvs[o][1];i.uvs[2]=M.geometry.uvs[o][3]}n.push(i);b++;p=j[b]=j[b]||new THREE.RenderableFace3;p.v1.positionWorld.copy(U.positionWorld);p.v2.positionWorld.copy(S.positionWorld);p.v3.positionWorld.copy(W.positionWorld);p.v1.positionScreen.copy(U.positionScreen);p.v2.positionScreen.copy(S.positionScreen);p.v3.positionScreen.copy(W.positionScreen);p.normalWorld.copy(i.normalWorld);p.centroidWorld.copy(i.centroidWorld);p.centroidScreen.copy(i.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
O;p.faceMaterials=D.materials;p.overdraw=R;if(M.geometry.uvs[o]){p.uvs[0]=M.geometry.uvs[o][1];p.uvs[1]=M.geometry.uvs[o][2];p.uvs[2]=M.geometry.uvs[o][3]}n.push(p);b++}}}}else if(M instanceof THREE.Line){$.multiply(q,ba);Y=M.geometry.vertices;D=Y[0];D.positionScreen.copy(D.position);$.multiplyVector4(D.positionScreen);o=1;for(K=Y.length;o<K;o++){G=Y[o];G.positionScreen.copy(G.position);$.multiplyVector4(G.positionScreen);U=Y[o-1];g.copy(G.positionScreen);k.copy(U.positionScreen);if(d(g,k)){g.multiplyScalar(1/
g.w);k.multiplyScalar(1/k.w);l=F[C]=F[C]||new THREE.RenderableLine;l.v1.positionScreen.copy(g);l.v2.positionScreen.copy(k);l.z=Math.max(g.z,k.z);l.materials=M.materials;n.push(l);C++}}}else if(M instanceof THREE.Particle){Q.set(M.position.x,M.position.y,M.position.z,1);q.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){A=N[E]=N[E]||new THREE.RenderableParticle;A.x=Q.x/Q.w;A.y=Q.y/Q.w;A.z=Q.z;A.rotation=M.rotation.z;A.scale.x=M.scale.x*Math.abs(A.x-(Q.x+u.projectionMatrix.n11)/(Q.w+u.projectionMatrix.n14));
A.scale.y=M.scale.y*Math.abs(A.y-(Q.y+u.projectionMatrix.n22)/(Q.w+u.projectionMatrix.n24));A.materials=M.materials;n.push(A);E++}}}}I&&n.sort(a);return n};this.unprojectVector=function(m,u){var I=new THREE.Matrix4;I.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));I.multiplyVector3(m);return m}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,d=new THREE.Projector,e,f,h,i;this.domElement=document.createElement("div");this.setSize=function(p,b){e=p;f=b;h=e/2;i=f/2};this.render=function(p,b){var j,l,C,F,A,E,N,P;a=d.projectScene(p,b);j=0;for(l=a.length;j<l;j++){A=a[j];if(A instanceof THREE.RenderableParticle){N=A.x*h+h;P=A.y*i+i;C=0;for(F=A.material.length;C<F;C++){E=A.material[C];if(E instanceof THREE.ParticleDOMMaterial){E=E.domElement;E.style.left=N+"px";E.style.top=P+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(A!=ja)l.globalAlpha=A=ja}function d(ja){if(E!=ja){switch(ja){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}E=ja}}var e=null,f=new THREE.Projector,h=document.createElement("canvas"),i,p,b,j,l=h.getContext("2d"),C=null,F=null,A=1,E=0,N=null,P=null,Q=1,q,$,L,g,k,r,m,u,I,n=new THREE.Color,
w=new THREE.Color,B=new THREE.Color,v=new THREE.Color,o=new THREE.Color,K,G,U,T,M,ba,V,O,R,aa=new THREE.Rectangle,Y=new THREE.Rectangle,D=new THREE.Rectangle,S=false,W=new THREE.Color,ka=new THREE.Color,ha=new THREE.Color,ea=new THREE.Color,pa=Math.PI*2,da=new THREE.Vector3,wa,qa,la,na,ya,Aa,Ba=16;wa=document.createElement("canvas");wa.width=wa.height=2;qa=wa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);la=qa.getImageData(0,0,2,2);na=la.data;ya=document.createElement("canvas");
ya.width=ya.height=Ba;Aa=ya.getContext("2d");Aa.translate(-Ba/2,-Ba/2);Aa.scale(Ba,Ba);Ba--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,xa){i=ja;p=xa;b=i/2;j=p/2;h.width=i;h.height=p;aa.set(-b,-j,b,j);A=1;E=0;P=N=null;Q=1};this.setClearColor=function(ja,xa){C=ja!==null?new THREE.Color(ja):null;F=xa;Y.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.clear=function(){if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(aa);if(C!==null){d(THREE.NormalBlending);
a(1);l.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+F+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}else l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());Y.empty()}};this.render=function(ja,xa){function Sa(H){var ca,Z,J,X=H.lights;ka.setRGB(0,0,0);ha.setRGB(0,0,0);ea.setRGB(0,0,0);H=0;for(ca=X.length;H<ca;H++){Z=X[H];J=Z.color;if(Z instanceof THREE.AmbientLight){ka.r+=J.r;ka.g+=J.g;ka.b+=J.b}else if(Z instanceof THREE.DirectionalLight){ha.r+=
J.r;ha.g+=J.g;ha.b+=J.b}else if(Z instanceof THREE.PointLight){ea.r+=J.r;ea.g+=J.g;ea.b+=J.b}}}function Ga(H,ca,Z,J){var X,fa,ia,ma,oa=H.lights;H=0;for(X=oa.length;H<X;H++){fa=oa[H];ia=fa.color;ma=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=Z.dot(fa.position)*ma;if(fa>0){J.r+=ia.r*fa;J.g+=ia.g*fa;J.b+=ia.b*fa}}else if(fa instanceof THREE.PointLight){da.sub(fa.position,ca);da.normalize();fa=Z.dot(da)*ma;if(fa>0){J.r+=ia.r*fa;J.g+=ia.g*fa;J.b+=ia.b*fa}}}}function Ta(H,ca,Z){if(Z.opacity!=
0){a(Z.opacity);d(Z.blending);var J,X,fa,ia,ma,oa;if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){ia=Z.map;ma=ia.width>>1;oa=ia.height>>1;X=ca.scale.x*b;fa=ca.scale.y*j;Z=X*ma;J=fa*oa;D.set(H.x-Z,H.y-J,H.x+Z,H.y+J);if(aa.instersects(D)){l.save();l.translate(H.x,H.y);l.rotate(-ca.rotation);l.scale(X,-fa);l.translate(-ma,-oa);l.drawImage(ia,0,0);l.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(S){W.r=ka.r+ha.r+ea.r;W.g=ka.g+ha.g+ea.g;W.b=ka.b+ha.b+ea.b;n.r=Z.color.r*W.r;n.g=
Z.color.g*W.g;n.b=Z.color.b*W.b;n.updateStyleString()}else n.__styleString=Z.color.__styleString;Z=ca.scale.x*b;J=ca.scale.y*j;D.set(H.x-Z,H.y-J,H.x+Z,H.y+J);if(aa.instersects(D)){X=n.__styleString;if(P!=X)l.fillStyle=P=X;l.save();l.translate(H.x,H.y);l.rotate(-ca.rotation);l.scale(Z,J);l.beginPath();l.arc(0,0,1,0,pa,true);l.closePath();l.fill();l.restore()}}}}function Ua(H,ca,Z,J){if(J.opacity!=0){a(J.opacity);d(J.blending);l.beginPath();l.moveTo(H.positionScreen.x,H.positionScreen.y);l.lineTo(ca.positionScreen.x,
ca.positionScreen.y);l.closePath();if(J instanceof THREE.LineBasicMaterial){n.__styleString=J.color.__styleString;H=J.linewidth;if(Q!=H)l.lineWidth=Q=H;H=n.__styleString;if(N!=H)l.strokeStyle=N=H;l.stroke();D.inflate(J.linewidth*2)}}}function Oa(H,ca,Z,J,X,fa){if(X.opacity!=0){a(X.opacity);d(X.blending);g=H.positionScreen.x;k=H.positionScreen.y;r=ca.positionScreen.x;m=ca.positionScreen.y;u=Z.positionScreen.x;I=Z.positionScreen.y;l.beginPath();l.moveTo(g,k);l.lineTo(r,m);l.lineTo(u,I);l.lineTo(g,k);
l.closePath();if(X instanceof THREE.MeshBasicMaterial)if(X.map)X.map.image.loaded&&X.map.mapping instanceof THREE.UVMapping&&Da(g,k,r,m,u,I,X.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);else if(X.env_map){if(X.env_map.image.loaded)if(X.env_map.mapping instanceof THREE.SphericalReflectionMapping){H=xa.matrix;da.copy(J.vertexNormalsWorld[0]);T=(da.x*H.n11+da.y*H.n12+da.z*H.n13)*0.5+0.5;M=-(da.x*H.n21+da.y*H.n22+da.z*H.n23)*0.5+0.5;da.copy(J.vertexNormalsWorld[1]);ba=
(da.x*H.n11+da.y*H.n12+da.z*H.n13)*0.5+0.5;V=-(da.x*H.n21+da.y*H.n22+da.z*H.n23)*0.5+0.5;da.copy(J.vertexNormalsWorld[2]);O=(da.x*H.n11+da.y*H.n12+da.z*H.n13)*0.5+0.5;R=-(da.x*H.n21+da.y*H.n22+da.z*H.n23)*0.5+0.5;Da(g,k,r,m,u,I,X.env_map.image,T,M,ba,V,O,R)}}else X.wireframe?Ha(X.color.__styleString,X.wireframe_linewidth):Ia(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){X.map.mapping instanceof THREE.UVMapping&&Da(g,k,r,m,u,I,X.map.image,J.uvs[0].u,
J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);d(THREE.SubtractiveBlending)}if(S)if(!X.wireframe&&X.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){w.r=B.r=v.r=ka.r;w.g=B.g=v.g=ka.g;w.b=B.b=v.b=ka.b;Ga(fa,J.v1.positionWorld,J.vertexNormalsWorld[0],w);Ga(fa,J.v2.positionWorld,J.vertexNormalsWorld[1],B);Ga(fa,J.v3.positionWorld,J.vertexNormalsWorld[2],v);o.r=(B.r+v.r)*0.5;o.g=(B.g+v.g)*0.5;o.b=(B.b+v.b)*0.5;U=Pa(w,B,v,o);Da(g,k,r,m,u,I,U,0,0,1,0,0,1)}else{W.r=ka.r;W.g=ka.g;W.b=
ka.b;Ga(fa,J.centroidWorld,J.normalWorld,W);n.r=X.color.r*W.r;n.g=X.color.g*W.g;n.b=X.color.b*W.b;n.updateStyleString();X.wireframe?Ha(n.__styleString,X.wireframe_linewidth):Ia(n.__styleString)}else X.wireframe?Ha(X.color.__styleString,X.wireframe_linewidth):Ia(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){K=xa.near;G=xa.far;w.r=w.g=w.b=1-Ka(H.positionScreen.z,K,G);B.r=B.g=B.b=1-Ka(ca.positionScreen.z,K,G);v.r=v.g=v.b=1-Ka(Z.positionScreen.z,K,G);o.r=(B.r+v.r)*0.5;o.g=(B.g+
v.g)*0.5;o.b=(B.b+v.b)*0.5;U=Pa(w,B,v,o);Da(g,k,r,m,u,I,U,0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){n.r=La(J.normalWorld.x);n.g=La(J.normalWorld.y);n.b=La(J.normalWorld.z);n.updateStyleString();X.wireframe?Ha(n.__styleString,X.wireframe_linewidth):Ia(n.__styleString)}}}function Ha(H,ca){if(N!=H)l.strokeStyle=N=H;if(Q!=ca)l.lineWidth=Q=ca;l.stroke();D.inflate(ca*2)}function Ia(H){if(P!=H)l.fillStyle=P=H;l.fill()}function Da(H,ca,Z,J,X,fa,ia,ma,oa,ta,ra,ua,Ea){var za,va;za=ia.width-
1;va=ia.height-1;ma*=za;oa*=va;ta*=za;ra*=va;ua*=za;Ea*=va;Z-=H;J-=ca;X-=H;fa-=ca;ta-=ma;ra-=oa;ua-=ma;Ea-=oa;va=1/(ta*Ea-ua*ra);za=(Ea*Z-ra*X)*va;ra=(Ea*J-ra*fa)*va;Z=(ta*X-ua*Z)*va;J=(ta*fa-ua*J)*va;H=H-za*ma-Z*oa;ca=ca-ra*ma-J*oa;l.save();l.transform(za,ra,Z,J,H,ca);l.clip();l.drawImage(ia,0,0);l.restore()}function Pa(H,ca,Z,J){var X=~~(H.r*255),fa=~~(H.g*255);H=~~(H.b*255);var ia=~~(ca.r*255),ma=~~(ca.g*255);ca=~~(ca.b*255);var oa=~~(Z.r*255),ta=~~(Z.g*255);Z=~~(Z.b*255);var ra=~~(J.r*255),ua=
~~(J.g*255);J=~~(J.b*255);na[0]=X<0?0:X>255?255:X;na[1]=fa<0?0:fa>255?255:fa;na[2]=H<0?0:H>255?255:H;na[4]=ia<0?0:ia>255?255:ia;na[5]=ma<0?0:ma>255?255:ma;na[6]=ca<0?0:ca>255?255:ca;na[8]=oa<0?0:oa>255?255:oa;na[9]=ta<0?0:ta>255?255:ta;na[10]=Z<0?0:Z>255?255:Z;na[12]=ra<0?0:ra>255?255:ra;na[13]=ua<0?0:ua>255?255:ua;na[14]=J<0?0:J>255?255:J;qa.putImageData(la,0,0);Aa.drawImage(wa,0,0);return ya}function Ka(H,ca,Z){H=(H-ca)/(Z-ca);return H*H*(3-2*H)}function La(H){H=(H+1)*0.5;return H<0?0:H>1?1:H}function Ma(H,
ca){var Z=ca.x-H.x,J=ca.y-H.y,X=1/Math.sqrt(Z*Z+J*J);Z*=X;J*=X;ca.x+=Z;ca.y+=J;H.x-=Z;H.y-=J}var Ja,Qa,ga,sa,Ca,Na,Ra,Fa;l.setTransform(1,0,0,-1,b,j);this.autoClear&&this.clear();e=f.projectScene(ja,xa,this.sortElements);(S=ja.lights.length>0)&&Sa(ja);Ja=0;for(Qa=e.length;Ja<Qa;Ja++){ga=e[Ja];D.empty();if(ga instanceof THREE.RenderableParticle){q=ga;q.x*=b;q.y*=j;sa=0;for(Ca=ga.materials.length;sa<Ca;sa++)Ta(q,ga,ga.materials[sa],ja)}else if(ga instanceof THREE.RenderableLine){q=ga.v1;$=ga.v2;q.positionScreen.x*=
b;q.positionScreen.y*=j;$.positionScreen.x*=b;$.positionScreen.y*=j;D.addPoint(q.positionScreen.x,q.positionScreen.y);D.addPoint($.positionScreen.x,$.positionScreen.y);if(aa.instersects(D)){sa=0;for(Ca=ga.materials.length;sa<Ca;)Ua(q,$,ga,ga.materials[sa++],ja)}}else if(ga instanceof THREE.RenderableFace3){q=ga.v1;$=ga.v2;L=ga.v3;q.positionScreen.x*=b;q.positionScreen.y*=j;$.positionScreen.x*=b;$.positionScreen.y*=j;L.positionScreen.x*=b;L.positionScreen.y*=j;if(ga.overdraw){Ma(q.positionScreen,$.positionScreen);
Ma($.positionScreen,L.positionScreen);Ma(L.positionScreen,q.positionScreen)}D.add3Points(q.positionScreen.x,q.positionScreen.y,$.positionScreen.x,$.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(aa.instersects(D)){sa=0;for(Ca=ga.meshMaterials.length;sa<Ca;){Fa=ga.meshMaterials[sa++];if(Fa instanceof THREE.MeshFaceMaterial){Na=0;for(Ra=ga.faceMaterials.length;Na<Ra;)(Fa=ga.faceMaterials[Na++])&&Oa(q,$,L,ga,Fa,ja)}else Oa(q,$,L,ga,Fa,ja)}}}Y.addRectangle(D)}l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(T,M,ba){var V,O,R,aa;V=0;for(O=T.lights.length;V<O;V++){R=T.lights[V];if(R instanceof THREE.DirectionalLight){aa=M.normalWorld.dot(R.position)*R.intensity;if(aa>0){ba.r+=R.color.r*aa;ba.g+=R.color.g*aa;ba.b+=R.color.b*aa}}else if(R instanceof THREE.PointLight){I.sub(R.position,M.centroidWorld);I.normalize();aa=M.normalWorld.dot(I)*R.intensity;if(aa>0){ba.r+=R.color.r*aa;ba.g+=R.color.g*aa;ba.b+=R.color.b*aa}}}}function d(T,M,ba,V,O,R){v=f(o++);v.setAttribute("d",
"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)L.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if($){g.r=k.r;g.g=k.g;g.b=k.b;a(R,V,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){u=1-O.__2near/(O.__farPlusNear-
V.z*O.__farMinusNear);L.setRGB(u,u,u)}else O instanceof THREE.MeshNormalMaterial&&L.setRGB(h(V.normalWorld.x),h(V.normalWorld.y),h(V.normalWorld.z));O.wireframe?v.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):v.setAttribute("style","fill: "+L.__styleString+"; fill-opacity: "+O.opacity);b.appendChild(v)}function e(T,M,ba,V,O,R,aa){v=
f(o++);v.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)L.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if($){g.r=k.r;g.g=k.g;g.b=k.b;a(aa,O,g);L.r=R.color.r*g.r;L.g=R.color.g*g.g;L.b=R.color.b*g.b;L.updateStyleString()}else L.__styleString=R.color.__styleString;
else if(R instanceof THREE.MeshDepthMaterial){u=1-R.__2near/(R.__farPlusNear-O.z*R.__farMinusNear);L.setRGB(u,u,u)}else R instanceof THREE.MeshNormalMaterial&&L.setRGB(h(O.normalWorld.x),h(O.normalWorld.y),h(O.normalWorld.z));R.wireframe?v.setAttribute("style","fill: none; stroke: "+L.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):v.setAttribute("style","fill: "+L.__styleString+
"; fill-opacity: "+R.opacity);b.appendChild(v)}function f(T){if(n[T]==null){n[T]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&n[T].setAttribute("shape-rendering","crispEdges");return n[T]}return n[T]}function h(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var i=null,p=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,C,F,A,E,N,P,Q=new THREE.Rectangle,q=new THREE.Rectangle,$=false,L=new THREE.Color(16777215),g=new THREE.Color(16777215),
k=new THREE.Color(0),r=new THREE.Color(0),m=new THREE.Color(0),u,I=new THREE.Vector3,n=[],w=[],B=[],v,o,K,G,U=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":U=1;break;case "low":U=0}};this.setSize=function(T,M){j=T;l=M;C=j/2;F=l/2;b.setAttribute("viewBox",-C+" "+-F+" "+j+" "+l);b.setAttribute("width",j);b.setAttribute("height",l);Q.set(-C,-F,C,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
this.render=function(T,M){var ba,V,O,R,aa,Y,D,S;this.autoClear&&this.clear();i=p.projectScene(T,M,this.sortElements);G=K=o=0;if($=T.lights.length>0){D=T.lights;k.setRGB(0,0,0);r.setRGB(0,0,0);m.setRGB(0,0,0);ba=0;for(V=D.length;ba<V;ba++){O=D[ba];R=O.color;if(O instanceof THREE.AmbientLight){k.r+=R.r;k.g+=R.g;k.b+=R.b}else if(O instanceof THREE.DirectionalLight){r.r+=R.r;r.g+=R.g;r.b+=R.b}else if(O instanceof THREE.PointLight){m.r+=R.r;m.g+=R.g;m.b+=R.b}}}ba=0;for(V=i.length;ba<V;ba++){D=i[ba];q.empty();
if(D instanceof THREE.RenderableParticle){A=D;A.x*=C;A.y*=-F;O=0;for(R=D.materials.length;O<R;O++)if(S=D.materials[O]){aa=A;Y=D;S=S;var W=K++;if(w[W]==null){w[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&w[W].setAttribute("shape-rendering","crispEdges")}v=w[W];v.setAttribute("cx",aa.x);v.setAttribute("cy",aa.y);v.setAttribute("r",Y.scale.x*C);if(S instanceof THREE.ParticleCircleMaterial){if($){g.r=k.r+r.r+m.r;g.g=k.g+r.g+m.g;g.b=k.b+r.b+m.b;L.r=S.color.r*g.r;L.g=S.color.g*
g.g;L.b=S.color.b*g.b;L.updateStyleString()}else L=S.color;v.setAttribute("style","fill: "+L.__styleString)}b.appendChild(v)}}else if(D instanceof THREE.RenderableLine){A=D.v1;E=D.v2;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);if(Q.instersects(q)){O=0;for(R=D.materials.length;O<R;)if(S=D.materials[O++]){aa=A;Y=E;S=S;W=G++;if(B[W]==null){B[W]=document.createElementNS("http://www.w3.org/2000/svg",
"line");U==0&&B[W].setAttribute("shape-rendering","crispEdges")}v=B[W];v.setAttribute("x1",aa.positionScreen.x);v.setAttribute("y1",aa.positionScreen.y);v.setAttribute("x2",Y.positionScreen.x);v.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){L.__styleString=S.color.__styleString;v.setAttribute("style","fill: none; stroke: "+L.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);
b.appendChild(v)}}}}else if(D instanceof THREE.RenderableFace3){A=D.v1;E=D.v2;N=D.v3;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;N.positionScreen.x*=C;N.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);q.addPoint(N.positionScreen.x,N.positionScreen.y);if(Q.instersects(q)){O=0;for(R=D.meshMaterials.length;O<R;){S=D.meshMaterials[O++];if(S instanceof THREE.MeshFaceMaterial){aa=0;for(Y=
D.faceMaterials.length;aa<Y;)(S=D.faceMaterials[aa++])&&d(A,E,N,D,S,T)}else S&&d(A,E,N,D,S,T)}}}else if(D instanceof THREE.RenderableFace4){A=D.v1;E=D.v2;N=D.v3;P=D.v4;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;N.positionScreen.x*=C;N.positionScreen.y*=-F;P.positionScreen.x*=C;P.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);q.addPoint(N.positionScreen.x,N.positionScreen.y);q.addPoint(P.positionScreen.x,
P.positionScreen.y);if(Q.instersects(q)){O=0;for(R=D.meshMaterials.length;O<R;){S=D.meshMaterials[O++];if(S instanceof THREE.MeshFaceMaterial){aa=0;for(Y=D.faceMaterials.length;aa<Y;)(S=D.faceMaterials[aa++])&&e(A,E,N,P,D,S,T)}else S&&e(A,E,N,P,D,S,T)}}}}}};
THREE.WebGLRenderer=function(a){function d(g,k){g.fragment_shader=k.fragment_shader;g.vertex_shader=k.vertex_shader;g.uniforms=Uniforms.clone(k.uniforms)}function e(g,k){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(k){g.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){g.uniforms.fogNear.value=k.near;g.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)g.uniforms.fogDensity.value=k.density}}function f(g,k){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(k){g.uniforms.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){g.uniforms.fogNear.value=
k.near;g.uniforms.fogFar.value=k.far}else if(k instanceof THREE.FogExp2)g.uniforms.fogDensity.value=k.density}}function h(g,k){var r;if(g=="fragment")r=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")r=b.createShader(b.VERTEX_SHADER);b.shaderSource(r,k);b.compileShader(r);if(!b.getShaderParameter(r,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(r));return null}return r}function i(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 p=document.createElement("canvas"),b,j=null,l=null,C=new THREE.Matrix4,F,A=new Float32Array(16),E=new Float32Array(16),N=new Float32Array(16),P=new Float32Array(9),
Q=new Float32Array(16),q=true,$=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)q=a.antialias;a.clearColor!==undefined&&$.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=p;this.autoClear=true;(function(g,k,r){try{b=p.getContext("experimental-webgl",{antialias:g})}catch(m){}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,r)})(q,$,L);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,k){p.width=g;p.height=k;b.viewport(0,0,p.width,p.height)};this.setClearColor=function(g,k){var r=new THREE.Color(g);b.clearColor(r.r,r.g,r.b,k)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(g,k){var r,m,u,I=0,n=0,w=0,B,v,o,K=this.lights,G=K.directional.colors,U=K.directional.positions,T=K.point.colors,M=K.point.positions,ba=0,V=0;r=0;for(m=k.length;r<m;r++){u=k[r];B=u.color;v=u.position;o=u.intensity;if(u instanceof THREE.AmbientLight){I+=B.r;n+=B.g;w+=B.b}else if(u instanceof THREE.DirectionalLight){G[ba*3]=B.r*o;G[ba*3+1]=B.g*o;G[ba*3+2]=B.b*o;U[ba*3]=v.x;U[ba*3+1]=v.y;U[ba*3+2]=v.z;ba+=1}else if(u instanceof THREE.PointLight){T[V*3]=B.r*o;T[V*3+1]=B.g*o;T[V*3+2]=B.b*o;M[V*
3]=v.x;M[V*3+1]=v.y;M[V*3+2]=v.z;V+=1}}K.point.length=V;K.directional.length=ba;K.ambient[0]=I;K.ambient[1]=n;K.ambient[2]=w};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 k=g.vertices.length;g.__vertexArray=new Float32Array(k*3);g.__lineArray=new Uint16Array(k);g.__webGLLineCount=k};this.initMeshBuffers=function(g,k){var r,m,u=0,I=0,n=0,w=k.geometry.faces,B=g.faces;r=0;for(m=B.length;r<m;r++){fi=B[r];face=w[fi];if(face instanceof THREE.Face3){u+=3;I+=1;n+=3}else if(face instanceof THREE.Face4){u+=4;I+=2;n+=4}}g.__vertexArray=
new Float32Array(u*3);g.__normalArray=new Float32Array(u*3);g.__tangentArray=new Float32Array(u*4);g.__uvArray=new Float32Array(u*2);g.__faceArray=new Uint16Array(I*3);g.__lineArray=new Uint16Array(n*2);u=false;r=0;for(m=k.materials.length;r<m;r++){w=k.materials[r];if(w instanceof THREE.MeshFaceMaterial){w=0;for(B=g.materials.length;w<B;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){u=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){u=
true;break}if(u)break}g.__needsSmoothNormals=u;g.__webGLFaceCount=I*3;g.__webGLLineCount=n*2};this.setMeshBuffers=function(g,k,r,m,u,I,n,w){var B,v,o,K,G,U,T,M,ba,V=0,O=0,R=0,aa=0,Y=0,D=0,S=0,W=g.__vertexArray,ka=g.__uvArray,ha=g.__normalArray,ea=g.__tangentArray,pa=g.__faceArray,da=g.__lineArray,wa=g.__needsSmoothNormals,qa=k.geometry,la=qa.vertices,na=g.faces,ya=qa.faces,Aa=qa.uvs;k=0;for(B=na.length;k<B;k++){v=na[k];o=ya[v];v=Aa[v];K=o.vertexNormals;G=o.normal;if(o instanceof THREE.Face3){if(m){U=
la[o.a].position;T=la[o.b].position;M=la[o.c].position;W[O]=U.x;W[O+1]=U.y;W[O+2]=U.z;W[O+3]=T.x;W[O+4]=T.y;W[O+5]=T.z;W[O+6]=M.x;W[O+7]=M.y;W[O+8]=M.z;O+=9}if(w&&qa.hasTangents){U=la[o.a].tangent;T=la[o.b].tangent;M=la[o.c].tangent;ea[D]=U.x;ea[D+1]=U.y;ea[D+2]=U.z;ea[D+3]=U.w;ea[D+4]=T.x;ea[D+5]=T.y;ea[D+6]=T.z;ea[D+7]=T.w;ea[D+8]=M.x;ea[D+9]=M.y;ea[D+10]=M.z;ea[D+11]=M.w;D+=12}if(n)if(K.length==3&&wa)for(o=0;o<3;o++){G=K[o];ha[Y]=G.x;ha[Y+1]=G.y;ha[Y+2]=G.z;Y+=3}else for(o=0;o<3;o++){ha[Y]=G.x;
ha[Y+1]=G.y;ha[Y+2]=G.z;Y+=3}if(I&&v)for(o=0;o<3;o++){K=v[o];ka[R]=K.u;ka[R+1]=K.v;R+=2}if(u){pa[aa]=V;pa[aa+1]=V+1;pa[aa+2]=V+2;aa+=3;da[S]=V;da[S+1]=V+1;da[S+2]=V;da[S+3]=V+2;da[S+4]=V+1;da[S+5]=V+2;S+=6;V+=3}}else if(o instanceof THREE.Face4){if(m){U=la[o.a].position;T=la[o.b].position;M=la[o.c].position;ba=la[o.d].position;W[O]=U.x;W[O+1]=U.y;W[O+2]=U.z;W[O+3]=T.x;W[O+4]=T.y;W[O+5]=T.z;W[O+6]=M.x;W[O+7]=M.y;W[O+8]=M.z;W[O+9]=ba.x;W[O+10]=ba.y;W[O+11]=ba.z;O+=12}if(w&&qa.hasTangents){U=la[o.a].tangent;
T=la[o.b].tangent;M=la[o.c].tangent;o=la[o.d].tangent;ea[D]=U.x;ea[D+1]=U.y;ea[D+2]=U.z;ea[D+3]=U.w;ea[D+4]=T.x;ea[D+5]=T.y;ea[D+6]=T.z;ea[D+7]=T.w;ea[D+8]=M.x;ea[D+9]=M.y;ea[D+10]=M.z;ea[D+11]=M.w;ea[D+12]=o.x;ea[D+13]=o.y;ea[D+14]=o.z;ea[D+15]=o.w;D+=16}if(n)if(K.length==4&&wa)for(o=0;o<4;o++){G=K[o];ha[Y]=G.x;ha[Y+1]=G.y;ha[Y+2]=G.z;Y+=3}else for(o=0;o<4;o++){ha[Y]=G.x;ha[Y+1]=G.y;ha[Y+2]=G.z;Y+=3}if(I&&v)for(o=0;o<4;o++){K=v[o];ka[R]=K.u;ka[R+1]=K.v;R+=2}if(u){pa[aa]=V;pa[aa+1]=V+1;pa[aa+2]=V+
2;pa[aa+3]=V;pa[aa+4]=V+2;pa[aa+5]=V+3;aa+=6;da[S]=V;da[S+1]=V+1;da[S+2]=V;da[S+3]=V+3;da[S+4]=V+1;da[S+5]=V+2;da[S+6]=V+2;da[S+7]=V+3;S+=8;V+=4}}}if(m){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,W,r)}if(n){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,r)}if(w&&qa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ea,r)}if(I&&R>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,
ka,r)}if(u){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,pa,r);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,da,r)}};this.setLineBuffers=function(g,k,r,m){var u,I,n=g.vertices,w=n.length,B=g.__vertexArray,v=g.__lineArray;if(r)for(r=0;r<w;r++){u=n[r].position;I=r*3;B[I]=u.x;B[I+1]=u.y;B[I+2]=u.z}if(m)for(r=0;r<w;r++)v[r]=r;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,k);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,v,k)};this.setParticleBuffers=function(){};this.renderBuffer=function(g,k,r,m,u,I){var n,w,B,v;if(!m.program){if(m instanceof THREE.MeshDepthMaterial){d(m,THREE.ShaderLib.depth);m.uniforms.mNear.value=g.near;m.uniforms.mFar.value=g.far}else if(m instanceof THREE.MeshNormalMaterial)d(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial){d(m,THREE.ShaderLib.basic);e(m,r)}else if(m instanceof
THREE.MeshLambertMaterial){d(m,THREE.ShaderLib.lambert);e(m,r)}else if(m instanceof THREE.MeshPhongMaterial){d(m,THREE.ShaderLib.phong);e(m,r)}else if(m instanceof THREE.LineBasicMaterial){d(m,THREE.ShaderLib.basic);f(m,r)}var o,K,G;o=v=w=0;for(K=k.length;o<K;o++){G=k[o];G instanceof THREE.DirectionalLight&&v++;G instanceof THREE.PointLight&&w++}if(w+v<=4){o=v;w=w}else{o=Math.ceil(4*v/(w+v));w=4-o}w={directional:o,point:w};v={fog:r,map:m.map,env_map:m.env_map,maxDirLights:w.directional,maxPointLights:w.point};
w=m.fragment_shader;o=m.vertex_shader;K=b.createProgram();G=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+
v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.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(K,h("fragment",G+w));b.attachShader(K,h("vertex",v+o));b.linkProgram(K);b.getProgramParameter(K,b.LINK_STATUS)||
alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(K,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");K.uniforms={};K.attributes={};m.program=K;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(n in m.uniforms)w.push(n);n=m.program;o=0;for(K=w.length;o<K;o++){G=w[o];n.uniforms[G]=b.getUniformLocation(n,G)}n=m.program;w=["position","normal","uv","tangent"];o=0;for(K=w.length;o<K;o++){G=w[o];n.attributes[G]=b.getAttribLocation(n,
G)}}n=m.program;if(n!=j){b.useProgram(n);j=n}this.loadCamera(n,g);this.loadMatrices(n);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){this.setupLights(n,k);g=this.lights;m.uniforms.enableLighting.value=g.directional.length+g.point.length;m.uniforms.ambientLightColor.value=g.ambient;m.uniforms.directionalLightColor.value=g.directional.colors;m.uniforms.directionalLightDirection.value=g.directional.positions;m.uniforms.pointLightColor.value=g.point.colors;m.uniforms.pointLightPosition.value=
g.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)e(m,r);m instanceof THREE.LineBasicMaterial&&f(m,r);if(m instanceof THREE.MeshPhongMaterial){m.uniforms.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);m.uniforms.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);m.uniforms.shininess.value=m.shininess}r=m.uniforms;for(B in r)if(o=n.uniforms[B]){k=r[B];w=k.type;g=k.value;if(w=="i")b.uniform1i(o,
g);else if(w=="f")b.uniform1f(o,g);else if(w=="fv1")b.uniform1fv(o,g);else if(w=="fv")b.uniform3fv(o,g);else if(w=="v2")b.uniform2f(o,g.x,g.y);else if(w=="v3")b.uniform3f(o,g.x,g.y,g.z);else if(w=="c")b.uniform3f(o,g.r,g.g,g.b);else if(w=="t"){b.uniform1i(o,g);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;g=g;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(w=0;w<6;++w)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[w]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=
true}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;g=g;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,i(k.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(k.mag_filter));b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_MIN_FILTER,i(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}B=n.attributes;b.bindBuffer(b.ARRAY_BUFFER,u.__webGLVertexBuffer);b.vertexAttribPointer(B.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.position);if(B.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLNormalBuffer);b.vertexAttribPointer(B.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.normal)}if(B.tangent>=
0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLTangentBuffer);b.vertexAttribPointer(B.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.tangent)}if(B.uv>=0)if(u.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer);b.vertexAttribPointer(B.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.uv)}else b.disableVertexAttribArray(B.uv);if(m.wireframe||m instanceof THREE.LineBasicMaterial){B=m.wireframe_linewidth!==undefined?m.wireframe_linewidth:m.linewidth!==undefined?m.linewidth:1;m=m instanceof
THREE.LineBasicMaterial&&I.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(B);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.drawElements(m,u.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,u.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,k,r,m,u,I,n){var w,B,v,o,K;v=0;for(o=m.materials.length;v<o;v++){w=m.materials[v];if(w instanceof THREE.MeshFaceMaterial){w=0;for(B=u.materials.length;w<
B;w++)if((K=u.materials[w])&&K.blending==I&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(g,k,r,K,u,m)}}else if((K=w)&&K.blending==I&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(g,k,r,K,u,m)}}};this.render=function(g,k,r,m){var u,I,n,w=g.lights,B=g.fog;this.initWebGLObjects(g);m=m!==undefined?m:true;if(r&&!r.__webGLFramebuffer){r.__webGLFramebuffer=b.createFramebuffer();r.__webGLRenderbuffer=b.createRenderbuffer();r.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,
r.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,r.width,r.height);b.bindTexture(b.TEXTURE_2D,r.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(r.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(r.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(r.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(r.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(r.format),r.width,r.height,0,i(r.format),i(r.type),null);b.bindFramebuffer(b.FRAMEBUFFER,
r.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,r.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,r.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(r){u=r.__webGLFramebuffer;n=r.width;I=r.height}else{u=null;n=p.width;I=p.height}if(u!=l){b.bindFramebuffer(b.FRAMEBUFFER,u);b.viewport(0,0,n,I);m&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);
l=u}this.autoClear&&this.clear();k.autoUpdateMatrix&&k.updateMatrix();A.set(k.matrix.flatten());N.set(k.projectionMatrix.flatten());m=0;for(u=g.__webGLObjects.length;m<u;m++){I=g.__webGLObjects[m];n=I.object;I=I.buffer;if(n.visible){this.setupMatrices(n,k);this.renderPass(k,w,B,n,I,THREE.NormalBlending,false)}}m=0;for(u=g.__webGLObjects.length;m<u;m++){I=g.__webGLObjects[m];n=I.object;I=I.buffer;if(n.visible){this.setupMatrices(n,k);if(n.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
n.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}this.renderPass(k,w,B,n,I,THREE.AdditiveBlending,false);this.renderPass(k,w,B,n,I,THREE.SubtractiveBlending,false);this.renderPass(k,w,B,n,I,THREE.AdditiveBlending,true);this.renderPass(k,w,B,n,I,THREE.SubtractiveBlending,true);this.renderPass(k,w,B,n,I,THREE.NormalBlending,true)}}if(r&&r.min_filter!==THREE.NearestFilter&&r.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,r.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,
null)}};this.initWebGLObjects=function(g){function k(v,o,K,G){if(v[o]==undefined){g.__webGLObjects.push({buffer:K,object:G});v[o]=1}}var r,m,u,I,n,w,B;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}r=0;for(m=g.objects.length;r<m;r++){u=g.objects[r];n=u.geometry;if(g.__webGLObjectsMap[u.id]==undefined)g.__webGLObjectsMap[u.id]={};B=g.__webGLObjectsMap[u.id];if(u instanceof THREE.Mesh){for(I in n.geometryChunks){w=n.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);
this.initMeshBuffers(w,u);n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs)this.setMeshBuffers(w,u,b.DYNAMIC_DRAW,n.__dirtyVertices,n.__dirtyElements,n.__dirtyUvs,n.__dirtyNormals,n.__dirtyTangents);k(B,I,w,u)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false}else if(u instanceof THREE.Line){if(!n.__webGLVertexBuffer){this.createLineBuffers(n);
this.initLineBuffers(n);n.__dirtyVertices=true;n.__dirtyElements=true}n.__dirtyVertices&&this.setLineBuffers(n,b.DYNAMIC_DRAW,n.__dirtyVertices,n.__dirtyElements);k(B,0,n,u);n.__dirtyVertices=false;n.__dirtyElements=false}else if(u instanceof THREE.ParticleSystem){n.__webGLVertexBuffer||this.createParticleBuffers(n);k(B,0,n,u)}}};this.removeObject=function(g,k){var r,m;for(r=g.__webGLObjects.length-1;r>=0;r--){m=g.__webGLObjects[r].object;k==m&&g.__webGLObjects.splice(r,1)}};this.setupMatrices=function(g,
k){g.autoUpdateMatrix&&g.updateMatrix();C.multiply(k.matrix,g.matrix);E.set(C.flatten());F=THREE.Matrix4.makeInvert3x3(C).transpose();P.set(F.m);Q.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,A);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,E);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,N);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,P);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,Q)};this.loadCamera=function(g,k){b.uniform3f(g.uniforms.cameraPosition,
k.position.x,k.position.y,k.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,k){if(g){!k||k=="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}};
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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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};
+204 -206
View File
@@ -1,206 +1,204 @@
// ThreeDebug.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,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/=
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;
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,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(i,q){return i.distance-q.distance});return h},intersectObject:function(a){function c(U,u,S,D){D=D.clone().subSelf(u);S=S.clone().subSelf(u);var e=U.clone().subSelf(u);U=D.dot(D);u=D.dot(S);D=D.dot(e);var g=S.dot(S);S=S.dot(e);e=1/(U*g-u*u);g=(g*D-u*S)*e;U=(U*S-u*D)*e;return g>0&&U>0&&g+U<1}var d,f,h,i,q,b,m,n,E,H,
y,A=a.geometry,T=A.vertices,V=[];d=0;for(f=A.faces.length;d<f;d++){h=A.faces[d];H=this.origin.clone();y=this.direction.clone();i=a.matrix.multiplyVector3(T[h.a].position.clone());q=a.matrix.multiplyVector3(T[h.b].position.clone());b=a.matrix.multiplyVector3(T[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(T[h.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(h.normal.clone());E=y.dot(n);if(E<0){n=n.dot((new THREE.Vector3).sub(i,H))/E;H=H.addSelf(y.multiplyScalar(n));
if(h instanceof THREE.Face3){if(c(H,i,q,b)){h={distance:this.origin.distanceTo(H),point:H,face:h,object:a};V.push(h)}}else if(h instanceof THREE.Face4)if(c(H,i,q,m)||c(H,q,b,m)){h={distance:this.origin.distanceTo(H),point:H,face:h,object:a};V.push(h)}}}return V}};
THREE.Rectangle=function(){function a(){i=f-c;q=h-d}var c,d,f,h,i,q,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(m,n,E,H){b=false;c=m;d=n;f=E;h=H;a()};this.addPoint=function(m,n){if(b){b=false;c=m;d=n;f=m;h=n}else{c=c<m?c:m;d=d<n?d:n;f=f>m?f:m;h=h>n?
h:n}a()};this.add3Points=function(m,n,E,H,y,A){if(b){b=false;c=m<E?m<y?m:y:E<y?E:y;d=n<H?n<A?n:A:H<A?H:A;f=m>E?m>y?m:y:E>y?E:y;h=n>H?n>A?n:A:H>A?H:A}else{c=m<E?m<y?m<c?m:c:y<c?y:c:E<y?E<c?E:c:y<c?y:c;d=n<H?n<A?n<d?n:d:A<d?A:d:H<A?H<d?H:d:A<d?A:d;f=m>E?m>y?m>f?m:f:y>f?y:f:E>y?E>f?E:f:y>f?y:f;h=n>H?n>A?n>h?n:h:A>h?A:h:H>A?H>h?H:h:A>h?A:h}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();h=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
f=f>m.getRight()?f:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){c-=m;d-=m;f+=m;h+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();d=d>m.getTop()?d:m.getTop();f=f<m.getRight()?f:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){b=true;h=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+i+", height: "+q+" )"}};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,h,i,q,b,m,n,E,H,y,A,T,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=n||0;this.n33=E||1;this.n34=H||0;this.n41=y||0;this.n42=A||0;this.n43=T||0;this.n44=V||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,h,i,q,b,m,n,E,H,y,A,T,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=n;this.n33=E;this.n34=H;this.n41=y;this.n42=A;this.n43=T;this.n44=V;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,h=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,c).normalize();f.cross(d,i).normalize();h.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=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)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;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,h=a.n13,i=a.n14,q=a.n21,b=a.n22,m=a.n23,n=a.n24,E=a.n31,
H=a.n32,y=a.n33,A=a.n34,T=a.n41,V=a.n42,U=a.n43,u=a.n44,S=c.n11,D=c.n12,e=c.n13,g=c.n14,o=c.n21,j=c.n22,p=c.n23,z=c.n24,k=c.n31,s=c.n32,t=c.n33,r=c.n34,l=c.n41,C=c.n42,x=c.n43,L=c.n44;this.n11=d*S+f*o+h*k+i*l;this.n12=d*D+f*j+h*s+i*C;this.n13=d*e+f*p+h*t+i*x;this.n14=d*g+f*z+h*r+i*L;this.n21=q*S+b*o+m*k+n*l;this.n22=q*D+b*j+m*s+n*C;this.n23=q*e+b*p+m*t+n*x;this.n24=q*g+b*z+m*r+n*L;this.n31=E*S+H*o+y*k+A*l;this.n32=E*D+H*j+y*s+A*C;this.n33=E*e+H*p+y*t+A*x;this.n34=E*g+H*z+y*r+A*L;this.n41=T*S+V*o+
U*k+u*l;this.n42=T*D+V*j+U*s+u*C;this.n43=T*e+V*p+U*t+u*x;this.n44=T*g+V*z+U*r+u*L;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,n=this.n31,E=this.n32,H=this.n33,y=this.n34,A=this.n41,T=this.n42,V=this.n43,U=this.n44,u=a.n11,S=a.n21,D=a.n31,e=a.n41,g=a.n12,o=a.n22,j=a.n32,p=a.n42,z=a.n13,k=a.n23,s=a.n33,t=a.n43,r=a.n14,l=a.n24,C=a.n34;a=a.n44;this.n11=c*u+d*S+f*D+h*e;this.n12=c*g+d*o+f*j+h*p;this.n13=c*z+d*k+f*s+h*
t;this.n14=c*r+d*l+f*C+h*a;this.n21=i*u+q*S+b*D+m*e;this.n22=i*g+q*o+b*j+m*p;this.n23=i*z+q*k+b*s+m*t;this.n24=i*r+q*l+b*C+m*a;this.n31=n*u+E*S+H*D+y*e;this.n32=n*g+E*o+H*j+y*p;this.n33=n*z+E*k+H*s+y*t;this.n34=n*r+E*l+H*C+y*a;this.n41=A*u+T*S+V*D+U*e;this.n42=A*g+T*o+V*j+U*p;this.n43=A*z+T*k+V*s+U*t;this.n44=A*r+T*l+V*C+U*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*
this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(c,d,f){var h=c[d];
c[d]=c[f];c[f]=h}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},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.n14=a;f.n24=c;f.n34=d;return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.n11=a;f.n22=c;f.n33=d;return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};
THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4,f=Math.cos(c),h=Math.sin(c),i=1-f,q=a.x,b=a.y,m=a.z;d.n11=i*q*q+f;d.n12=i*q*b-h*m;d.n13=i*q*m+h*b;d.n21=i*q*b+h*m;d.n22=i*b*b+f;d.n23=i*b*m-h*q;d.n31=i*q*m-h*b;d.n32=i*b*m+h*q;d.n33=i*m*m+f;return d};
THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;c.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;c.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;c.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
a.n23*a.n34;c.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;c.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;c.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;c.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;c.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;c.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;c.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;c.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;c.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
a.n31*a.n43-a.n21*a.n32*a.n43;c.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;c.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;c.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;c.multiplyScalar(1/a.determinant());return c};
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],h=c[6]*c[1]-c[2]*c[5],i=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],E=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*i+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*f;a.m[2]=c*h;a.m[3]=c*i;a.m[4]=c*q;a.m[5]=c*b;a.m[6]=c*m;a.m[7]=c*n;a.m[8]=c*E;return a};
THREE.Matrix4.makeFrustum=function(a,c,d,f,h,i){var q,b,m;q=new THREE.Matrix4;b=2*h/(c-a);m=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(i+h)/(i-h);h=-2*i*h/(i-h);q.n11=b;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=m;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
THREE.Matrix4.makeOrtho=function(a,c,d,f,h,i){var q,b,m,n;q=new THREE.Matrix4;b=c-a;m=d-f;n=i-h;a=(c+a)/b;d=(d+f)/m;h=(i+h)/n;q.n11=2/b;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/m;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};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,h){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=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,c,d,f,h,i){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,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,h,i,q,b=new THREE.Vector3,m=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);c=0;for(d=i.normal.length;c<d;c++)b.addSelf(i.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[i.a];d=this.vertices[i.b];q=this.vertices[i.c];b.sub(q.position,
d.position);m.sub(c.position,d.position);b.crossSelf(m)}b.isZero()||b.normalize();i.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(r,l,C,x,L,K,F){i=r.vertices[l].position;q=r.vertices[C].position;b=r.vertices[x].position;m=h[L];n=h[K];E=h[F];H=q.x-i.x;y=b.x-i.x;A=q.y-i.y;T=b.y-i.y;
V=q.z-i.z;U=b.z-i.z;u=n.u-m.u;S=E.u-m.u;D=n.v-m.v;e=E.v-m.v;g=1/(u*e-S*D);p.set((e*H-D*y)*g,(e*A-D*T)*g,(e*V-D*U)*g);z.set((u*y-S*H)*g,(u*T-S*A)*g,(u*U-S*V)*g);o[l].addSelf(p);o[C].addSelf(p);o[x].addSelf(p);j[l].addSelf(z);j[C].addSelf(z);j[x].addSelf(z)}var c,d,f,h,i,q,b,m,n,E,H,y,A,T,V,U,u,S,D,e,g,o=[],j=[],p=new THREE.Vector3,z=new THREE.Vector3,k=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){o[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
for(d=this.faces.length;c<d;c++){f=this.faces[c];h=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++){t.copy(this.vertices[c].normal);f=o[c];k.copy(f);k.subSelf(t.multiplyScalar(t.dot(f))).normalize();s.cross(this.vertices[c].normal,f);f=s.dot(j[c]);f=f<0?-1:1;this.vertices[c].tangent.set(k.x,k.y,k.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],
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(E){var H=[];c=0;for(d=E.length;c<d;c++)E[c]==undefined?H.push("undefined"):H.push(E[c].toString());return H.join("_")}var c,d,f,h,i,q,b,m,n={};f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];
q=i.materials;b=a(q);if(n[b]==undefined)n[b]={hash:b,counter:0};m=n[b].hash+"_"+n[b].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:q,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+i>65535){n[b].counter+=1;m=n[b].hash+"_"+n[b].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:q,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=i}},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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};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;
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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,h,i){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=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};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(j,p){return p.z-j.z}function c(j,p){var z=0,k=1,s=j.z+j.w,t=p.z+p.w,r=-j.z+j.w,l=-p.z+p.w;if(s>=0&&t>=0&&r>=0&&l>=0)return true;else if(s<0&&t<0||r<0&&l<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)k=Math.min(k,s/(s-t));if(r<0)z=Math.max(z,r/(r-l));else if(l<0)k=Math.min(k,r/(r-l));if(k<z)return false;else{j.lerpSelf(p,z);p.lerpSelf(j,1-k);return true}}}var d,f,h=[],i,q,b,m=[],n,E,H=[],y,A,T=[],V=new THREE.Vector4,U=new THREE.Vector4,u=new THREE.Matrix4,
S=new THREE.Matrix4,D=[],e=new THREE.Vector4,g=new THREE.Vector4,o;this.projectObjects=function(j,p,z){var k=[],s,t;f=0;u.multiply(p.projectionMatrix,p.matrix);D[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);D[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);D[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);D[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);D[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
u.n33,u.n44-u.n34);D[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);p=0;for(s=D.length;p<s;p++){t=D[p];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(p=s.length;j<p;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var l=t.position,C=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),x=0;x<6;x++){r=D[x].x*l.x+D[x].y*l.y+D[x].z*l.z+D[x].w;if(r<=C){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
h[f]=h[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;k.push(d);f++}}z&&k.sort(a);return k};this.projectScene=function(j,p,z){var k=[],s=p.near,t=p.far,r,l,C,x,L,K,F,W,M,G,I,Q,N,v,J,O;b=E=A=0;p.autoUpdateMatrix&&p.updateMatrix();u.multiply(p.projectionMatrix,p.matrix);K=this.projectObjects(j,p,true);j=0;for(r=K.length;j<r;j++){F=K[j].object;if(F.visible){F.autoUpdateMatrix&&F.updateMatrix();W=F.matrix;M=F.rotationMatrix;G=F.materials;I=F.overdraw;if(F instanceof
THREE.Mesh){Q=F.geometry;N=Q.vertices;l=0;for(C=N.length;l<C;l++){v=N[l];v.positionWorld.copy(v.position);W.multiplyVector3(v.positionWorld);x=v.positionScreen;x.copy(v.positionWorld);u.multiplyVector4(x);x.x/=x.w;x.y/=x.w;v.__visible=x.z>s&&x.z<t}Q=Q.faces;l=0;for(C=Q.length;l<C;l++){v=Q[l];if(v instanceof THREE.Face3){x=N[v.a];L=N[v.b];J=N[v.c];if(x.__visible&&L.__visible&&J.__visible)if(F.doubleSided||F.flipSided!=(J.positionScreen.x-x.positionScreen.x)*(L.positionScreen.y-x.positionScreen.y)-
(J.positionScreen.y-x.positionScreen.y)*(L.positionScreen.x-x.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(L.positionWorld);i.v3.positionWorld.copy(J.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(J.positionScreen);i.normalWorld.copy(v.normal);M.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);W.multiplyVector3(i.centroidWorld);
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);J=v.vertexNormals;o=i.vertexNormalsWorld;x=0;for(L=J.length;x<L;x++){O=o[x]=o[x]||new THREE.Vector3;O.copy(J[x]);M.multiplyVector3(O)}i.z=i.centroidScreen.z;i.meshMaterials=G;i.faceMaterials=v.materials;i.overdraw=I;if(F.geometry.uvs[l]){i.uvs[0]=F.geometry.uvs[l][0];i.uvs[1]=F.geometry.uvs[l][1];i.uvs[2]=F.geometry.uvs[l][2]}k.push(i);b++}}else if(v instanceof THREE.Face4){x=N[v.a];L=N[v.b];J=N[v.c];O=N[v.d];if(x.__visible&&
L.__visible&&J.__visible&&O.__visible)if(F.doubleSided||F.flipSided!=((O.positionScreen.x-x.positionScreen.x)*(L.positionScreen.y-x.positionScreen.y)-(O.positionScreen.y-x.positionScreen.y)*(L.positionScreen.x-x.positionScreen.x)<0||(L.positionScreen.x-J.positionScreen.x)*(O.positionScreen.y-J.positionScreen.y)-(L.positionScreen.y-J.positionScreen.y)*(O.positionScreen.x-J.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(L.positionWorld);
i.v3.positionWorld.copy(O.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(O.positionScreen);i.normalWorld.copy(v.normal);M.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);W.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=G;i.faceMaterials=v.materials;i.overdraw=I;if(F.geometry.uvs[l]){i.uvs[0]=F.geometry.uvs[l][0];
i.uvs[1]=F.geometry.uvs[l][1];i.uvs[2]=F.geometry.uvs[l][3]}k.push(i);b++;q=m[b]=m[b]||new THREE.RenderableFace3;q.v1.positionWorld.copy(L.positionWorld);q.v2.positionWorld.copy(J.positionWorld);q.v3.positionWorld.copy(O.positionWorld);q.v1.positionScreen.copy(L.positionScreen);q.v2.positionScreen.copy(J.positionScreen);q.v3.positionScreen.copy(O.positionScreen);q.normalWorld.copy(i.normalWorld);q.centroidWorld.copy(i.centroidWorld);q.centroidScreen.copy(i.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
G;q.faceMaterials=v.materials;q.overdraw=I;if(F.geometry.uvs[l]){q.uvs[0]=F.geometry.uvs[l][1];q.uvs[1]=F.geometry.uvs[l][2];q.uvs[2]=F.geometry.uvs[l][3]}k.push(q);b++}}}}else if(F instanceof THREE.Line){S.multiply(u,W);N=F.geometry.vertices;v=N[0];v.positionScreen.copy(v.position);S.multiplyVector4(v.positionScreen);l=1;for(C=N.length;l<C;l++){x=N[l];x.positionScreen.copy(x.position);S.multiplyVector4(x.positionScreen);L=N[l-1];e.copy(x.positionScreen);g.copy(L.positionScreen);if(c(e,g)){e.multiplyScalar(1/
e.w);g.multiplyScalar(1/g.w);n=H[E]=H[E]||new THREE.RenderableLine;n.v1.positionScreen.copy(e);n.v2.positionScreen.copy(g);n.z=Math.max(e.z,g.z);n.materials=F.materials;k.push(n);E++}}}else if(F instanceof THREE.Particle){U.set(F.position.x,F.position.y,F.position.z,1);u.multiplyVector4(U);U.z/=U.w;if(U.z>0&&U.z<1){y=T[A]=T[A]||new THREE.RenderableParticle;y.x=U.x/U.w;y.y=U.y/U.w;y.z=U.z;y.rotation=F.rotation.z;y.scale.x=F.scale.x*Math.abs(y.x-(U.x+p.projectionMatrix.n11)/(U.w+p.projectionMatrix.n14));
y.scale.y=F.scale.y*Math.abs(y.y-(U.y+p.projectionMatrix.n22)/(U.w+p.projectionMatrix.n24));y.materials=F.materials;k.push(y);A++}}}}z&&k.sort(a);return k};this.unprojectVector=function(j,p){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));z.multiplyVector3(j);return j}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;h=d/2;i=f/2};this.render=function(q,b){var m,n,E,H,y,A,T,V;a=c.projectScene(q,b);m=0;for(n=a.length;m<n;m++){y=a[m];if(y instanceof THREE.RenderableParticle){T=y.x*h+h;V=y.y*i+i;E=0;for(H=y.material.length;E<H;E++){A=y.material[E];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=T+"px";A.style.top=V+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(da){if(y!=da)n.globalAlpha=y=da}function c(da){if(A!=da){switch(da){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}A=da}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),i,q,b,m,n=h.getContext("2d"),E=null,H=null,y=1,A=0,T=null,V=null,U=1,u,S,D,e,g,o,j,p,z,k=new THREE.Color,
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,l=new THREE.Color,C,x,L,K,F,W,M,G,I,Q=new THREE.Rectangle,N=new THREE.Rectangle,v=new THREE.Rectangle,J=false,O=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=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;h.width=i;h.height=q;Q.set(-b,-m,b,m);y=1;A=0;V=T=null;U=1};this.setClearColor=function(da,ra){E=da!==null?new THREE.Color(da):null;H=ra;N.set(-b,-m,b,m);n.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!N.isEmpty()){N.inflate(1);N.minSelf(Q);if(E!==null){c(THREE.NormalBlending);
a(1);n.fillStyle="rgba("+Math.floor(E.r*255)+","+Math.floor(E.g*255)+","+Math.floor(E.b*255)+","+H+")";n.fillRect(N.getX(),N.getY(),N.getWidth(),N.getHeight())}else n.clearRect(N.getX(),N.getY(),N.getWidth(),N.getHeight());N.empty()}};this.render=function(da,ra){function Ma(w){var X,R,B,P=w.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Z.setRGB(0,0,0);w=0;for(X=P.length;w<X;w++){R=P[w];B=R.color;if(R instanceof THREE.AmbientLight){ea.r+=B.r;ea.g+=B.g;ea.b+=B.b}else if(R instanceof THREE.DirectionalLight){ba.r+=
B.r;ba.g+=B.g;ba.b+=B.b}else if(R instanceof THREE.PointLight){Z.r+=B.r;Z.g+=B.g;Z.b+=B.b}}}function Aa(w,X,R,B){var P,$,ca,ga,ia=w.lights;w=0;for(P=ia.length;w<P;w++){$=ia[w];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=R.dot($.position)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=R.dot(Y)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(w,X,R){if(R.opacity!=0){a(R.opacity);c(R.blending);
var B,P,$,ca,ga,ia;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ca=R.map;ga=ca.width>>1;ia=ca.height>>1;P=X.scale.x*b;$=X.scale.y*m;R=P*ga;B=$*ia;v.set(w.x-R,w.y-B,w.x+R,w.y+B);if(!Q.instersects(v))return;n.save();n.translate(w.x,w.y);n.rotate(-X.rotation);n.scale(P,-$);n.translate(-ga,-ia);n.drawImage(ca,0,0);n.restore()}n.beginPath();n.moveTo(w.x-10,w.y);n.lineTo(w.x+10,w.y);n.moveTo(w.x,w.y-10);n.lineTo(w.x,w.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(R instanceof
THREE.ParticleCircleMaterial){if(J){O.r=ea.r+ba.r+Z.r;O.g=ea.g+ba.g+Z.g;O.b=ea.b+ba.b+Z.b;k.r=R.color.r*O.r;k.g=R.color.g*O.g;k.b=R.color.b*O.b;k.updateStyleString()}else k.__styleString=R.color.__styleString;R=X.scale.x*b;B=X.scale.y*m;v.set(w.x-R,w.y-B,w.x+R,w.y+B);if(Q.instersects(v)){P=k.__styleString;if(V!=P)n.fillStyle=V=P;n.save();n.translate(w.x,w.y);n.rotate(-X.rotation);n.scale(R,B);n.beginPath();n.arc(0,0,1,0,ja,true);n.closePath();n.fill();n.restore()}}}}function Oa(w,X,R,B){if(B.opacity!=
0){a(B.opacity);c(B.blending);n.beginPath();n.moveTo(w.positionScreen.x,w.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);n.closePath();if(B instanceof THREE.LineBasicMaterial){k.__styleString=B.color.__styleString;w=B.linewidth;if(U!=w)n.lineWidth=U=w;w=k.__styleString;if(T!=w)n.strokeStyle=T=w;n.stroke();v.inflate(B.linewidth*2)}}}function Ia(w,X,R,B,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);e=w.positionScreen.x;g=w.positionScreen.y;o=X.positionScreen.x;j=X.positionScreen.y;
p=R.positionScreen.x;z=R.positionScreen.y;n.beginPath();n.moveTo(e,g);n.lineTo(o,j);n.lineTo(p,z);n.lineTo(e,g);n.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&xa(e,g,o,j,p,z,P.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=ra.matrix;Y.copy(B.vertexNormalsWorld[0]);K=(Y.x*w.n11+Y.y*
w.n12+Y.z*w.n13)*0.5+0.5;F=-(Y.x*w.n21+Y.y*w.n22+Y.z*w.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);W=(Y.x*w.n11+Y.y*w.n12+Y.z*w.n13)*0.5+0.5;M=-(Y.x*w.n21+Y.y*w.n22+Y.z*w.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);G=(Y.x*w.n11+Y.y*w.n12+Y.z*w.n13)*0.5+0.5;I=-(Y.x*w.n21+Y.y*w.n22+Y.z*w.n23)*0.5+0.5;xa(e,g,o,j,p,z,P.env_map.image,K,F,W,M,G,I)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof
THREE.UVMapping&&xa(e,g,o,j,p,z,P.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);c(THREE.SubtractiveBlending)}if(J)if(!P.wireframe&&P.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,B.v1.positionWorld,B.vertexNormalsWorld[0],s);Aa($,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa($,B.v3.positionWorld,B.vertexNormalsWorld[2],r);l.r=(t.r+r.r)*0.5;l.g=(t.g+r.g)*0.5;l.b=(t.b+r.b)*0.5;L=Ja(s,t,r,l);xa(e,
g,o,j,p,z,L,0,0,1,0,0,1)}else{O.r=ea.r;O.g=ea.g;O.b=ea.b;Aa($,B.centroidWorld,B.normalWorld,O);k.r=P.color.r*O.r;k.g=P.color.g*O.g;k.b=P.color.b*O.b;k.updateStyleString();P.wireframe?Ba(k.__styleString,P.wireframe_linewidth):Ca(k.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){C=ra.near;x=ra.far;s.r=s.g=s.b=1-Ea(w.positionScreen.z,C,x);t.r=t.g=t.b=1-Ea(X.positionScreen.z,C,x);r.r=r.g=r.b=1-Ea(R.positionScreen.z,
C,x);l.r=(t.r+r.r)*0.5;l.g=(t.g+r.g)*0.5;l.b=(t.b+r.b)*0.5;L=Ja(s,t,r,l);xa(e,g,o,j,p,z,L,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){k.r=Fa(B.normalWorld.x);k.g=Fa(B.normalWorld.y);k.b=Fa(B.normalWorld.z);k.updateStyleString();P.wireframe?Ba(k.__styleString,P.wireframe_linewidth):Ca(k.__styleString)}}}function Ba(w,X){if(T!=w)n.strokeStyle=T=w;if(U!=X)n.lineWidth=U=X;n.stroke();v.inflate(X*2)}function Ca(w){if(V!=w)n.fillStyle=V=w;n.fill()}function xa(w,X,R,B,P,$,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;R-=w;B-=X;P-=w;$-=X;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*R-la*P)*pa;la=(ya*B-la*$)*pa;R=(na*P-oa*R)*pa;B=(na*$-oa*B)*pa;w=w-ta*ga-R*ia;X=X-la*ga-B*ia;n.save();n.transform(ta,la,R,B,w,X);n.clip();n.drawImage(ca,0,0);n.restore()}function Ja(w,X,R,B){var P=~~(w.r*255),$=~~(w.g*255);w=~~(w.b*255);var ca=~~(X.r*255),ga=~~(X.g*255);X=~~(X.b*255);var ia=~~(R.r*255),na=~~(R.g*255);R=~~(R.b*255);var la=~~(B.r*
255),oa=~~(B.g*255);B=~~(B.b*255);ha[0]=P<0?0:P>255?255:P;ha[1]=$<0?0:$>255?255:$;ha[2]=w<0?0:w>255?255:w;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]=R<0?0:R>255?255:R;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=B<0?0:B>255?255:B;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(w,X,R){w=(w-X)/(R-X);return w*w*(3-2*w)}function Fa(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Ga(w,
X){var R=X.x-w.x,B=X.y-w.y,P=1/Math.sqrt(R*R+B*B);R*=P;B*=P;X.x+=R;X.y+=B;w.x-=R;w.y-=B}var Da,Ka,aa,ma,wa,Ha,La,za;n.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,ra,this.sortElements);n.fillStyle="rgba( 0, 255, 255, 0.5 )";n.fillRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());(J=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,
aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;S=aa.v2;u.positionScreen.x*=b;u.positionScreen.y*=m;S.positionScreen.x*=b;S.positionScreen.y*=m;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(S.positionScreen.x,S.positionScreen.y);if(Q.instersects(v)){ma=0;for(wa=aa.materials.length;ma<wa;)Oa(u,S,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){u=aa.v1;S=aa.v2;D=aa.v3;u.positionScreen.x*=b;u.positionScreen.y*=m;S.positionScreen.x*=b;
S.positionScreen.y*=m;D.positionScreen.x*=b;D.positionScreen.y*=m;if(aa.overdraw){Ga(u.positionScreen,S.positionScreen);Ga(S.positionScreen,D.positionScreen);Ga(D.positionScreen,u.positionScreen)}v.add3Points(u.positionScreen.x,u.positionScreen.y,S.positionScreen.x,S.positionScreen.y,D.positionScreen.x,D.positionScreen.y);if(Q.instersects(v)){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(u,S,D,aa,za,da)}else Ia(u,S,D,aa,za,da)}}}N.addRectangle(v)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(N.getX(),N.getY(),N.getWidth(),N.getHeight());n.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(K,F,W){var M,G,I,Q;M=0;for(G=K.lights.length;M<G;M++){I=K.lights[M];if(I instanceof THREE.DirectionalLight){Q=F.normalWorld.dot(I.position)*I.intensity;if(Q>0){W.r+=I.color.r*Q;W.g+=I.color.g*Q;W.b+=I.color.b*Q}}else if(I instanceof THREE.PointLight){z.sub(I.position,F.centroidWorld);z.normalize();Q=F.normalWorld.dot(z)*I.intensity;if(Q>0){W.r+=I.color.r*Q;W.g+=I.color.g*Q;W.b+=I.color.b*Q}}}}function c(K,F,W,M,G,I){r=f(l++);r.setAttribute("d","M "+K.positionScreen.x+
" "+K.positionScreen.y+" L "+F.positionScreen.x+" "+F.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)D.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(S){e.r=g.r;e.g=g.g;e.b=g.b;a(I,M,e);D.r=G.color.r*e.r;D.g=G.color.g*e.g;D.b=G.color.b*e.b;D.updateStyleString()}else D.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){p=1-G.__2near/(G.__farPlusNear-M.z*G.__farMinusNear);
D.setRGB(p,p,p)}else G instanceof THREE.MeshNormalMaterial&&D.setRGB(h(M.normalWorld.x),h(M.normalWorld.y),h(M.normalWorld.z));G.wireframe?r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):r.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+G.opacity);b.appendChild(r)}function d(K,F,W,M,G,I,Q){r=f(l++);r.setAttribute("d",
"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+F.positionScreen.x+" "+F.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)D.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(S){e.r=g.r;e.g=g.g;e.b=g.b;a(Q,G,e);D.r=I.color.r*e.r;D.g=I.color.g*e.g;D.b=I.color.b*e.b;D.updateStyleString()}else D.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){p=
1-I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear);D.setRGB(p,p,p)}else I instanceof THREE.MeshNormalMaterial&&D.setRGB(h(G.normalWorld.x),h(G.normalWorld.y),h(G.normalWorld.z));I.wireframe?r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):r.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+I.opacity);b.appendChild(r)}
function f(K){if(k[K]==null){k[K]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&k[K].setAttribute("shape-rendering","crispEdges");return k[K]}return k[K]}function h(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,E,H,y,A,T,V,U=new THREE.Rectangle,u=new THREE.Rectangle,S=false,D=new THREE.Color(16777215),e=new THREE.Color(16777215),g=new THREE.Color(0),o=new THREE.Color(0),
j=new THREE.Color(0),p,z=new THREE.Vector3,k=[],s=[],t=[],r,l,C,x,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":L=1;break;case "low":L=0}};this.setSize=function(K,F){m=K;n=F;E=m/2;H=n/2;b.setAttribute("viewBox",-E+" "+-H+" "+m+" "+n);b.setAttribute("width",m);b.setAttribute("height",n);U.set(-E,-H,E,H)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,F){var W,M,
G,I,Q,N,v,J;this.autoClear&&this.clear();i=q.projectScene(K,F,this.sortElements);x=C=l=0;if(S=K.lights.length>0){v=K.lights;g.setRGB(0,0,0);o.setRGB(0,0,0);j.setRGB(0,0,0);W=0;for(M=v.length;W<M;W++){G=v[W];I=G.color;if(G instanceof THREE.AmbientLight){g.r+=I.r;g.g+=I.g;g.b+=I.b}else if(G instanceof THREE.DirectionalLight){o.r+=I.r;o.g+=I.g;o.b+=I.b}else if(G instanceof THREE.PointLight){j.r+=I.r;j.g+=I.g;j.b+=I.b}}}W=0;for(M=i.length;W<M;W++){v=i[W];u.empty();if(v instanceof THREE.RenderableParticle){y=
v;y.x*=E;y.y*=-H;G=0;for(I=v.materials.length;G<I;G++)if(J=v.materials[G]){Q=y;N=v;J=J;var O=C++;if(s[O]==null){s[O]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&s[O].setAttribute("shape-rendering","crispEdges")}r=s[O];r.setAttribute("cx",Q.x);r.setAttribute("cy",Q.y);r.setAttribute("r",N.scale.x*E);if(J instanceof THREE.ParticleCircleMaterial){if(S){e.r=g.r+o.r+j.r;e.g=g.g+o.g+j.g;e.b=g.b+o.b+j.b;D.r=J.color.r*e.r;D.g=J.color.g*e.g;D.b=J.color.b*e.b;D.updateStyleString()}else D=
J.color;r.setAttribute("style","fill: "+D.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){y=v.v1;A=v.v2;y.positionScreen.x*=E;y.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);if(U.instersects(u)){G=0;for(I=v.materials.length;G<I;)if(J=v.materials[G++]){Q=y;N=A;J=J;O=x++;if(t[O]==null){t[O]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
0&&t[O].setAttribute("shape-rendering","crispEdges")}r=t[O];r.setAttribute("x1",Q.positionScreen.x);r.setAttribute("y1",Q.positionScreen.y);r.setAttribute("x2",N.positionScreen.x);r.setAttribute("y2",N.positionScreen.y);if(J instanceof THREE.LineBasicMaterial){D.__styleString=J.color.__styleString;r.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+J.linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.linecap+"; stroke-linejoin: "+J.linejoin);b.appendChild(r)}}}}else if(v instanceof
THREE.RenderableFace3){y=v.v1;A=v.v2;T=v.v3;y.positionScreen.x*=E;y.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;T.positionScreen.x*=E;T.positionScreen.y*=-H;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);if(U.instersects(u)){G=0;for(I=v.meshMaterials.length;G<I;){J=v.meshMaterials[G++];if(J instanceof THREE.MeshFaceMaterial){Q=0;for(N=v.faceMaterials.length;Q<N;)(J=v.faceMaterials[Q++])&&
c(y,A,T,v,J,K)}else J&&c(y,A,T,v,J,K)}}}else if(v instanceof THREE.RenderableFace4){y=v.v1;A=v.v2;T=v.v3;V=v.v4;y.positionScreen.x*=E;y.positionScreen.y*=-H;A.positionScreen.x*=E;A.positionScreen.y*=-H;T.positionScreen.x*=E;T.positionScreen.y*=-H;V.positionScreen.x*=E;V.positionScreen.y*=-H;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(U.instersects(u)){G=
0;for(I=v.meshMaterials.length;G<I;){J=v.meshMaterials[G++];if(J instanceof THREE.MeshFaceMaterial){Q=0;for(N=v.faceMaterials.length;Q<N;)(J=v.faceMaterials[Q++])&&d(y,A,T,V,v,J,K)}else J&&d(y,A,T,V,v,J,K)}}}}}};
THREE.WebGLRenderer=function(a){function c(e,g){e.fragment_shader=g.fragment_shader;e.vertex_shader=g.vertex_shader;e.uniforms=Uniforms.clone(g.uniforms)}function d(e,g){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(g){e.uniforms.fogColor.value.setHex(g.color.hex);if(g instanceof THREE.Fog){e.uniforms.fogNear.value=g.near;e.uniforms.fogFar.value=g.far}else if(g instanceof THREE.FogExp2)e.uniforms.fogDensity.value=g.density}}function f(e,g){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(g){e.uniforms.fogColor.value.setHex(g.color.hex);if(g instanceof THREE.Fog){e.uniforms.fogNear.value=
g.near;e.uniforms.fogFar.value=g.far}else if(g instanceof THREE.FogExp2)e.uniforms.fogDensity.value=g.density}}function h(e,g){var o;if(e=="fragment")o=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")o=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,g);b.compileShader(o);if(!b.getShaderParameter(o,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(o));return null}return o}function i(e){switch(e){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 q=document.createElement("canvas"),b,m=null,n=null,E=new THREE.Matrix4,H,y=new Float32Array(16),A=new Float32Array(16),T=new Float32Array(16),V=new Float32Array(9),
U=new Float32Array(16),u=true,S=new THREE.Color(0),D=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&S.setHex(a.clearColor);if(a.clearAlpha!==undefined)D=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(e,g,o){try{b=q.getContext("experimental-webgl",{antialias:e})}catch(j){}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(g.r,g.g,g.b,o)})(u,S,D);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,g){q.width=e;q.height=g;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,g){var o=new THREE.Color(e);b.clearColor(o.r,o.g,o.b,g)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(e,g){var o,j,p,z=0,k=0,s=0,t,r,l,C=this.lights,x=C.directional.colors,L=C.directional.positions,K=C.point.colors,F=C.point.positions,W=0,M=0;o=0;for(j=g.length;o<j;o++){p=g[o];t=p.color;r=p.position;l=p.intensity;if(p instanceof THREE.AmbientLight){z+=t.r;k+=t.g;s+=t.b}else if(p instanceof THREE.DirectionalLight){x[W*3]=t.r*l;x[W*3+1]=t.g*l;x[W*3+2]=t.b*l;L[W*3]=r.x;L[W*3+1]=r.y;L[W*3+2]=r.z;W+=1}else if(p instanceof THREE.PointLight){K[M*3]=t.r*l;K[M*3+1]=t.g*l;K[M*3+2]=t.b*l;F[M*3]=r.x;
F[M*3+1]=r.y;F[M*3+2]=r.z;M+=1}}C.point.length=M;C.directional.length=W;C.ambient[0]=z;C.ambient[1]=k;C.ambient[2]=s};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 g=e.vertices.length;e.__vertexArray=new Float32Array(g*3);e.__lineArray=new Uint16Array(g);e.__webGLLineCount=g};this.initMeshBuffers=function(e,g){var o,j,p=0,z=0,k=0,s=g.geometry.faces,t=e.faces;o=0;for(j=t.length;o<j;o++){fi=t[o];face=s[fi];if(face instanceof THREE.Face3){p+=3;z+=1;k+=3}else if(face instanceof THREE.Face4){p+=4;z+=2;k+=4}}e.__vertexArray=new Float32Array(p*
3);e.__normalArray=new Float32Array(p*3);e.__tangentArray=new Float32Array(p*4);e.__uvArray=new Float32Array(p*2);e.__faceArray=new Uint16Array(z*3);e.__lineArray=new Uint16Array(k*2);p=false;o=0;for(j=g.materials.length;o<j;o++){s=g.materials[o];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){p=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){p=
true;break}if(p)break}e.__needsSmoothNormals=p;e.__webGLFaceCount=z*3;e.__webGLLineCount=k*2};this.setMeshBuffers=function(e,g,o,j,p,z,k,s){var t,r,l,C,x,L,K,F,W,M=0,G=0,I=0,Q=0,N=0,v=0,J=0,O=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Z=e.__tangentArray,ja=e.__faceArray,Y=e.__lineArray,qa=e.__needsSmoothNormals,ka=g.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;g=0;for(t=ha.length;g<t;g++){r=ha[g];l=sa[r];r=ua[r];C=l.vertexNormals;x=l.normal;if(l instanceof THREE.Face3){if(j){L=
fa[l.a].position;K=fa[l.b].position;F=fa[l.c].position;O[G]=L.x;O[G+1]=L.y;O[G+2]=L.z;O[G+3]=K.x;O[G+4]=K.y;O[G+5]=K.z;O[G+6]=F.x;O[G+7]=F.y;O[G+8]=F.z;G+=9}if(s&&ka.hasTangents){L=fa[l.a].tangent;K=fa[l.b].tangent;F=fa[l.c].tangent;Z[v]=L.x;Z[v+1]=L.y;Z[v+2]=L.z;Z[v+3]=L.w;Z[v+4]=K.x;Z[v+5]=K.y;Z[v+6]=K.z;Z[v+7]=K.w;Z[v+8]=F.x;Z[v+9]=F.y;Z[v+10]=F.z;Z[v+11]=F.w;v+=12}if(k)if(C.length==3&&qa)for(l=0;l<3;l++){x=C[l];ba[N]=x.x;ba[N+1]=x.y;ba[N+2]=x.z;N+=3}else for(l=0;l<3;l++){ba[N]=x.x;ba[N+1]=x.y;
ba[N+2]=x.z;N+=3}if(z&&r)for(l=0;l<3;l++){C=r[l];ea[I]=C.u;ea[I+1]=C.v;I+=2}if(p){ja[Q]=M;ja[Q+1]=M+1;ja[Q+2]=M+2;Q+=3;Y[J]=M;Y[J+1]=M+1;Y[J+2]=M;Y[J+3]=M+2;Y[J+4]=M+1;Y[J+5]=M+2;J+=6;M+=3}}else if(l instanceof THREE.Face4){if(j){L=fa[l.a].position;K=fa[l.b].position;F=fa[l.c].position;W=fa[l.d].position;O[G]=L.x;O[G+1]=L.y;O[G+2]=L.z;O[G+3]=K.x;O[G+4]=K.y;O[G+5]=K.z;O[G+6]=F.x;O[G+7]=F.y;O[G+8]=F.z;O[G+9]=W.x;O[G+10]=W.y;O[G+11]=W.z;G+=12}if(s&&ka.hasTangents){L=fa[l.a].tangent;K=fa[l.b].tangent;
F=fa[l.c].tangent;l=fa[l.d].tangent;Z[v]=L.x;Z[v+1]=L.y;Z[v+2]=L.z;Z[v+3]=L.w;Z[v+4]=K.x;Z[v+5]=K.y;Z[v+6]=K.z;Z[v+7]=K.w;Z[v+8]=F.x;Z[v+9]=F.y;Z[v+10]=F.z;Z[v+11]=F.w;Z[v+12]=l.x;Z[v+13]=l.y;Z[v+14]=l.z;Z[v+15]=l.w;v+=16}if(k)if(C.length==4&&qa)for(l=0;l<4;l++){x=C[l];ba[N]=x.x;ba[N+1]=x.y;ba[N+2]=x.z;N+=3}else for(l=0;l<4;l++){ba[N]=x.x;ba[N+1]=x.y;ba[N+2]=x.z;N+=3}if(z&&r)for(l=0;l<4;l++){C=r[l];ea[I]=C.u;ea[I+1]=C.v;I+=2}if(p){ja[Q]=M;ja[Q+1]=M+1;ja[Q+2]=M+2;ja[Q+3]=M;ja[Q+4]=M+2;ja[Q+5]=M+3;
Q+=6;Y[J]=M;Y[J+1]=M+1;Y[J+2]=M;Y[J+3]=M+3;Y[J+4]=M+1;Y[J+5]=M+2;Y[J+6]=M+2;Y[J+7]=M+3;J+=8;M+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,o)}if(k){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,o)}if(s&&ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Z,o)}if(z&&I>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,o)}if(p){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,o)}};this.setLineBuffers=function(e,g,o,j){var p,z,k=e.vertices,s=k.length,t=e.__vertexArray,r=e.__lineArray;if(o)for(o=0;o<s;o++){p=k[o].position;z=o*3;t[z]=p.x;t[z+1]=p.y;t[z+2]=p.z}if(j)for(o=0;o<s;o++)r[o]=o;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,t,g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);
b.bufferData(b.ELEMENT_ARRAY_BUFFER,r,g)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,g,o,j,p,z){var k,s,t,r;if(!j.program){if(j instanceof THREE.MeshDepthMaterial){c(j,THREE.ShaderLib.depth);j.uniforms.mNear.value=e.near;j.uniforms.mFar.value=e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,o)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);
d(j,o)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,o)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,o)}var l,C,x;l=r=s=0;for(C=g.length;l<C;l++){x=g[l];x instanceof THREE.DirectionalLight&&r++;x instanceof THREE.PointLight&&s++}if(s+r<=4){l=r;s=s}else{l=Math.ceil(4*r/(s+r));s=4-l}s={directional:l,point:s};r={fog:o,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;l=j.vertex_shader;C=b.createProgram();
x=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");r=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,
r.map?"#define USE_MAP":"",r.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(C,h("fragment",x+s));b.attachShader(C,h("vertex",r+l));b.linkProgram(C);b.getProgramParameter(C,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
b.getProgramParameter(C,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");C.uniforms={};C.attributes={};j.program=C;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in j.uniforms)s.push(k);k=j.program;l=0;for(C=s.length;l<C;l++){x=s[l];k.uniforms[x]=b.getUniformLocation(k,x)}k=j.program;s=["position","normal","uv","tangent"];l=0;for(C=s.length;l<C;l++){x=s[l];k.attributes[x]=b.getAttribLocation(k,x)}}k=j.program;if(k!=m){b.useProgram(k);
m=k}this.loadCamera(k,e);this.loadMatrices(k);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(k,g);e=this.lights;j.uniforms.enableLighting.value=e.directional.length+e.point.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;j.uniforms.directionalLightDirection.value=e.directional.positions;j.uniforms.pointLightColor.value=e.point.colors;j.uniforms.pointLightPosition.value=e.point.positions}if(j instanceof
THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)d(j,o);j instanceof THREE.LineBasicMaterial&&f(j,o);if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);j.uniforms.shininess.value=j.shininess}o=j.uniforms;for(t in o)if(l=k.uniforms[t]){g=o[t];s=g.type;e=g.value;if(s=="i")b.uniform1i(l,e);else if(s=="f")b.uniform1f(l,
e);else if(s=="fv1")b.uniform1fv(l,e);else if(s=="fv")b.uniform3fv(l,e);else if(s=="v2")b.uniform2f(l,e.x,e.y);else if(s=="v3")b.uniform3f(l,e.x,e.y,e.z);else if(s=="c")b.uniform3f(l,e.r,e.g,e.b);else if(s=="t"){b.uniform1i(l,e);if(g=g.texture)if(g.image instanceof Array&&g.image.length==6){g=g;e=e;if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,g.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,g.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+
e);b.bindTexture(b.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube)}}else{g=g;e=e;if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,g.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,g.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(g.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(g.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(g.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(g.min_filter));
b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+e);b.bindTexture(b.TEXTURE_2D,g.__webGLTexture)}}}t=k.attributes;b.bindBuffer(b.ARRAY_BUFFER,p.__webGLVertexBuffer);b.vertexAttribPointer(t.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.position);if(t.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLNormalBuffer);b.vertexAttribPointer(t.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.normal)}if(t.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLTangentBuffer);
b.vertexAttribPointer(t.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.tangent)}if(t.uv>=0)if(p.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLUVBuffer);b.vertexAttribPointer(t.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(t.uv)}else b.disableVertexAttribArray(t.uv);if(j.wireframe||j instanceof THREE.LineBasicMaterial){t=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&z.type==THREE.LineStrip?
b.LINE_STRIP:b.LINES;b.lineWidth(t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);b.drawElements(j,p.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,p.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,o,j,p,z,k){var s,t,r,l,C;r=0;for(l=j.materials.length;r<l;r++){s=j.materials[r];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=p.materials.length;s<t;s++)if((C=p.materials[s])&&C.blending==z&&
C.opacity<1==k){this.setBlending(C.blending);this.renderBuffer(e,g,o,C,p,j)}}else if((C=s)&&C.blending==z&&C.opacity<1==k){this.setBlending(C.blending);this.renderBuffer(e,g,o,C,p,j)}}};this.render=function(e,g,o,j){var p,z,k,s=e.lights,t=e.fog;this.initWebGLObjects(e);j=j!==undefined?j:true;if(o&&!o.__webGLFramebuffer){o.__webGLFramebuffer=b.createFramebuffer();o.__webGLRenderbuffer=b.createRenderbuffer();o.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,o.__webGLRenderbuffer);
b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,o.width,o.height);b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(o.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(o.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(o.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(o.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(o.format),o.width,o.height,0,i(o.format),i(o.type),null);b.bindFramebuffer(b.FRAMEBUFFER,o.__webGLFramebuffer);
b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,o.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,o.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(o){p=o.__webGLFramebuffer;k=o.width;z=o.height}else{p=null;k=q.width;z=q.height}if(p!=n){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(0,0,k,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);n=p}this.autoClear&&
this.clear();g.autoUpdateMatrix&&g.updateMatrix();y.set(g.matrix.flatten());T.set(g.projectionMatrix.flatten());j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];k=z.object;z=z.buffer;if(k.visible){this.setupMatrices(k,g);this.renderPass(g,s,t,k,z,THREE.NormalBlending,false)}}j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];k=z.object;z=z.buffer;if(k.visible){this.setupMatrices(k,g);if(k.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);k.flipSided?b.frontFace(b.CW):
b.frontFace(b.CCW)}this.renderPass(g,s,t,k,z,THREE.AdditiveBlending,false);this.renderPass(g,s,t,k,z,THREE.SubtractiveBlending,false);this.renderPass(g,s,t,k,z,THREE.AdditiveBlending,true);this.renderPass(g,s,t,k,z,THREE.SubtractiveBlending,true);this.renderPass(g,s,t,k,z,THREE.NormalBlending,true)}}if(o&&o.min_filter!==THREE.NearestFilter&&o.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
function(e){function g(r,l,C,x){if(r[l]==undefined){e.__webGLObjects.push({buffer:C,object:x});r[l]=1}}var o,j,p,z,k,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}o=0;for(j=e.objects.length;o<j;o++){p=e.objects[o];k=p.geometry;if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};t=e.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(z in k.geometryChunks){s=k.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,p);
k.__dirtyVertices=true;k.__dirtyElements=true;k.__dirtyUvs=true;k.__dirtyNormals=true;k.__dirtyTangents=true}if(k.__dirtyVertices||k.__dirtyElements||k.__dirtyUvs)this.setMeshBuffers(s,p,b.DYNAMIC_DRAW,k.__dirtyVertices,k.__dirtyElements,k.__dirtyUvs,k.__dirtyNormals,k.__dirtyTangents);g(t,z,s,p)}k.__dirtyVertices=false;k.__dirtyElements=false;k.__dirtyUvs=false;k.__dirtyNormals=false;k.__dirtyTangents=false}else if(p instanceof THREE.Line){if(!k.__webGLVertexBuffer){this.createLineBuffers(k);this.initLineBuffers(k);
k.__dirtyVertices=true;k.__dirtyElements=true}k.__dirtyVertices&&this.setLineBuffers(k,b.DYNAMIC_DRAW,k.__dirtyVertices,k.__dirtyElements);g(t,0,k,p);k.__dirtyVertices=false;k.__dirtyElements=false}else if(p instanceof THREE.ParticleSystem){k.__webGLVertexBuffer||this.createParticleBuffers(k);g(t,0,k,p)}}};this.removeObject=function(e,g){var o,j;for(o=e.__webGLObjects.length-1;o>=0;o--){j=e.__webGLObjects[o].object;g==j&&e.__webGLObjects.splice(o,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&
e.updateMatrix();E.multiply(g.matrix,e.matrix);A.set(E.flatten());H=THREE.Matrix4.makeInvert3x3(E).transpose();V.set(H.m);U.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,A);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,T);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,U)};this.loadCamera=function(e,g){b.uniform3f(e.uniforms.cameraPosition,
g.position.x,g.position.y,g.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,g){if(e){!g||g=="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);
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",
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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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};
// ThreeDebug.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,d,e){this.r=a;this.g=d;this.b=e;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,d){this.x=a||0;this.y=d||0};
THREE.Vector2.prototype={set:function(a,d){this.x=a;this.y=d;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,d){this.x=a.x+d.x;this.y=a.y+d.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,d){this.x=a.x-d.x;this.y=a.y-d.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,d,e){this.x=a||0;this.y=d||0;this.z=e||0};
THREE.Vector3.prototype={set:function(a,d,e){this.x=a;this.y=d;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,d){this.x=a.x+d.x;this.y=a.y+d.y;this.z=a.z+d.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,d){this.x=a.x-d.x;this.y=a.y-d.y;this.z=a.z-d.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
cross:function(a,d){this.x=a.y*d.z-a.z*d.y;this.y=a.z*d.x-a.x*d.z;this.z=a.x*d.y-a.y*d.x;return this},crossSelf:function(a){var d=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-d*a.z;this.z=d*a.y-e*a.x;return this},multiply:function(a,d){this.x=a.x*d.x;this.y=a.y*d.y;this.z=a.z*d.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 d=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(d*d+e*e+a*a)},distanceToSquared:function(a){var d=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return d*d+e*e+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,d,e,f){this.x=a||0;this.y=d||0;this.z=e||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,d,e,f){this.x=a;this.y=d;this.z=e;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,d){this.x=a.x+d.x;this.y=a.y+d.y;this.z=a.z+d.z;this.w=a.w+d.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,d){this.x=a.x-d.x;this.y=a.y-d.y;this.z=a.z-d.z;this.w=a.w-d.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,d){this.x+=(a.x-this.x)*d;this.y+=(a.y-this.y)*d;this.z+=(a.z-this.z)*d;this.w+=(a.w-this.w)*d},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,d){this.origin=a||new THREE.Vector3;this.direction=d||new THREE.Vector3};
THREE.Ray.prototype={intersectScene:function(a){var d,e,f=a.objects,h=[];a=0;for(d=f.length;a<d;a++){e=f[a];if(e instanceof THREE.Mesh)h=h.concat(this.intersectObject(e))}h.sort(function(i,p){return i.distance-p.distance});return h},intersectObject:function(a){function d(Q,q,aa,L){L=L.clone().subSelf(q);aa=aa.clone().subSelf(q);var g=Q.clone().subSelf(q);Q=L.dot(L);q=L.dot(aa);L=L.dot(g);var l=aa.dot(aa);aa=aa.dot(g);g=1/(Q*l-q*q);l=(l*L-q*aa)*g;Q=(Q*aa-q*L)*g;return l>0&&Q>0&&l+Q<1}var e,f,h,i,p,
b,k,j,C,F,A,E=a.geometry,N=E.vertices,P=[];e=0;for(f=E.faces.length;e<f;e++){h=E.faces[e];F=this.origin.clone();A=this.direction.clone();i=a.matrix.multiplyVector3(N[h.a].position.clone());p=a.matrix.multiplyVector3(N[h.b].position.clone());b=a.matrix.multiplyVector3(N[h.c].position.clone());k=h instanceof THREE.Face4?a.matrix.multiplyVector3(N[h.d].position.clone()):null;j=a.rotationMatrix.multiplyVector3(h.normal.clone());C=A.dot(j);if(C<0){j=j.dot((new THREE.Vector3).sub(i,F))/C;F=F.addSelf(A.multiplyScalar(j));
if(h instanceof THREE.Face3){if(d(F,i,p,b)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};P.push(h)}}else if(h instanceof THREE.Face4)if(d(F,i,p,k)||d(F,p,b,k)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};P.push(h)}}}return P}};
THREE.Rectangle=function(){function a(){i=f-d;p=h-e}var d,e,f,h,i,p,b=true;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return p};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(k,j,C,F){b=false;d=k;e=j;f=C;h=F;a()};this.addPoint=function(k,j){if(b){b=false;d=k;e=j;f=k;h=j}else{d=d<k?d:k;e=e<j?e:j;f=f>k?f:k;h=h>j?
h:j}a()};this.add3Points=function(k,j,C,F,A,E){if(b){b=false;d=k<C?k<A?k:A:C<A?C:A;e=j<F?j<E?j:E:F<E?F:E;f=k>C?k>A?k:A:C>A?C:A;h=j>F?j>E?j:E:F>E?F:E}else{d=k<C?k<A?k<d?k:d:A<d?A:d:C<A?C<d?C:d:A<d?A:d;e=j<F?j<E?j<e?j:e:E<e?E:e:F<E?F<e?F:e:E<e?E:e;f=k>C?k>A?k>f?k:f:A>f?A:f:C>A?C>f?C:f:A>f?A:f;h=j>F?j>E?j>h?j:h:E>h?E:h:F>E?F>h?F:h:E>h?E:h}a()};this.addRectangle=function(k){if(b){b=false;d=k.getLeft();e=k.getTop();f=k.getRight();h=k.getBottom()}else{d=d<k.getLeft()?d:k.getLeft();e=e<k.getTop()?e:k.getTop();
f=f>k.getRight()?f:k.getRight();h=h>k.getBottom()?h:k.getBottom()}a()};this.inflate=function(k){d-=k;e-=k;f+=k;h+=k;a()};this.minSelf=function(k){d=d>k.getLeft()?d:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f<k.getRight()?f:k.getRight();h=h<k.getBottom()?h:k.getBottom();a()};this.instersects=function(k){return Math.min(f,k.getRight())-Math.max(d,k.getLeft())>=0&&Math.min(h,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){b=true;h=f=e=d=0;a()};this.isEmpty=function(){return b};this.toString=
function(){return"THREE.Rectangle ( left: "+d+", right: "+f+", top: "+e+", bottom: "+h+", width: "+i+", height: "+p+" )"}};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,d,e,f,h,i,p,b,k,j,C,F,A,E,N,P){this.n11=a||1;this.n12=d||0;this.n13=e||0;this.n14=f||0;this.n21=h||0;this.n22=i||1;this.n23=p||0;this.n24=b||0;this.n31=k||0;this.n32=j||0;this.n33=C||1;this.n34=F||0;this.n41=A||0;this.n42=E||0;this.n43=N||0;this.n44=P||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,d,e,f,h,i,p,b,k,j,C,F,A,E,N,P){this.n11=a;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=p;this.n24=b;this.n31=k;this.n32=j;this.n33=C;this.n34=F;this.n41=A;this.n42=E;this.n43=N;this.n44=P;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,d,e){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,d).normalize();f.cross(e,i).normalize();h.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var d=a.x,e=a.y,f=a.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h;a.y=(this.n21*d+this.n22*e+this.n23*f+this.n24)*h;a.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var d=a.x,e=a.y,f=a.z,h=a.w;a.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;a.y=this.n21*d+this.n22*e+this.n23*
f+this.n24*h;a.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;a.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return a},crossVector:function(a){var d=new THREE.Vector4;d.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;d.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;d.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;d.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return d},multiply:function(a,d){var e=a.n11,f=a.n12,h=a.n13,i=a.n14,p=a.n21,b=a.n22,k=a.n23,j=a.n24,C=a.n31,
F=a.n32,A=a.n33,E=a.n34,N=a.n41,P=a.n42,Q=a.n43,q=a.n44,aa=d.n11,L=d.n12,g=d.n13,l=d.n14,r=d.n21,m=d.n22,u=d.n23,I=d.n24,n=d.n31,w=d.n32,B=d.n33,v=d.n34,o=d.n41,K=d.n42,H=d.n43,U=d.n44;this.n11=e*aa+f*r+h*n+i*o;this.n12=e*L+f*m+h*w+i*K;this.n13=e*g+f*u+h*B+i*H;this.n14=e*l+f*I+h*v+i*U;this.n21=p*aa+b*r+k*n+j*o;this.n22=p*L+b*m+k*w+j*K;this.n23=p*g+b*u+k*B+j*H;this.n24=p*l+b*I+k*v+j*U;this.n31=C*aa+F*r+A*n+E*o;this.n32=C*L+F*m+A*w+E*K;this.n33=C*g+F*u+A*B+E*H;this.n34=C*l+F*I+A*v+E*U;this.n41=N*aa+
P*r+Q*n+q*o;this.n42=N*L+P*m+Q*w+q*K;this.n43=N*g+P*u+Q*B+q*H;this.n44=N*l+P*I+Q*v+q*U;return this},multiplySelf:function(a){var d=this.n11,e=this.n12,f=this.n13,h=this.n14,i=this.n21,p=this.n22,b=this.n23,k=this.n24,j=this.n31,C=this.n32,F=this.n33,A=this.n34,E=this.n41,N=this.n42,P=this.n43,Q=this.n44,q=a.n11,aa=a.n21,L=a.n31,g=a.n41,l=a.n12,r=a.n22,m=a.n32,u=a.n42,I=a.n13,n=a.n23,w=a.n33,B=a.n43,v=a.n14,o=a.n24,K=a.n34;a=a.n44;this.n11=d*q+e*aa+f*L+h*g;this.n12=d*l+e*r+f*m+h*u;this.n13=d*I+e*n+
f*w+h*B;this.n14=d*v+e*o+f*K+h*a;this.n21=i*q+p*aa+b*L+k*g;this.n22=i*l+p*r+b*m+k*u;this.n23=i*I+p*n+b*w+k*B;this.n24=i*v+p*o+b*K+k*a;this.n31=j*q+C*aa+F*L+A*g;this.n32=j*l+C*r+F*m+A*u;this.n33=j*I+C*n+F*w+A*B;this.n34=j*v+C*o+F*K+A*a;this.n41=E*q+N*aa+P*L+Q*g;this.n42=E*l+N*r+P*m+Q*u;this.n43=E*I+N*n+P*w+Q*B;this.n44=E*v+N*o+P*K+Q*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,d=this.n12,e=this.n13,f=this.n14,h=this.n21,i=this.n22,p=this.n23,b=this.n24,k=this.n31,j=this.n32,C=this.n33,F=this.n34,A=this.n41,E=this.n42,N=this.n43,P=this.n44;return f*p*j*A-e*b*j*A-f*i*C*A+d*b*C*A+e*i*F*A-d*p*F*A-f*p*k*E+e*b*k*E+f*h*C*E-a*b*C*E-e*h*F*E+a*p*F*E+f*i*k*N-d*b*k*N-f*h*j*N+a*b*j*N+d*h*F*N-a*i*F*N-e*i*k*P+d*p*k*P+e*h*j*P-a*p*j*P-d*h*C*P+a*i*C*P},transpose:function(){function a(d,
e,f){var h=d[e];d[e]=d[f];d[f]=h}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,d,e){this.set(1,0,0,a,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(a,d,e){this.set(a,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},
setRotX:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,d,-a,0,0,a,d,0,0,0,0,1);return this},setRotY:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(d,0,a,0,0,1,0,0,-a,0,d,0,0,0,0,1);return this},setRotZ:function(a){var d=Math.cos(a);a=Math.sin(a);this.set(d,-a,0,0,a,d,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,d){c=Math.cos(d);s=Math.sin(d);t=1-c;x=a.x;y=a.y;z=a.z;tx=t*x;ty=t*y;this.set(tx*x+c,tx*y-s*z,tx*z+s*y,0,tx*y+s*z,ty*y+c,ty*z-s*x,0,tx*z-s*y,ty*z+s*x,t*z*z+
c,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,d,e){var f=new THREE.Matrix4;f.n14=a;f.n24=d;f.n34=e;return f};THREE.Matrix4.scaleMatrix=function(a,d,e){var f=new THREE.Matrix4;f.n11=a;f.n22=d;f.n33=e;return f};
THREE.Matrix4.rotationXMatrix=function(a){var d=new THREE.Matrix4;d.n22=d.n33=Math.cos(a);d.n32=Math.sin(a);d.n23=-d.n32;return d};THREE.Matrix4.rotationYMatrix=function(a){var d=new THREE.Matrix4;d.n11=d.n33=Math.cos(a);d.n13=Math.sin(a);d.n31=-d.n13;return d};THREE.Matrix4.rotationZMatrix=function(a){var d=new THREE.Matrix4;d.n11=d.n22=Math.cos(a);d.n21=Math.sin(a);d.n12=-d.n21;return d};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,d){var e=new THREE.Matrix4,f=Math.cos(d),h=Math.sin(d),i=1-f,p=a.x,b=a.y,k=a.z,j=i*p,C=i*b;e.n11=j*p+f;e.n12=j*b-h*k;e.n13=j*k+h*b;e.n21=j*b+h*k;e.n22=C*b+f;e.n23=C*k-h*p;e.n31=j*k-h*b;e.n32=C*k+h*p;e.n33=i*k*k+f;return e};
THREE.Matrix4.makeInvert=function(a){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,i=a.n21,p=a.n22,b=a.n23,k=a.n24,j=a.n31,C=a.n32,F=a.n33,A=a.n34,E=a.n41,N=a.n42,P=a.n43,Q=a.n44,q=new THREE.Matrix4;q.n11=b*A*N-k*F*N+k*C*P-p*A*P-b*C*Q+p*F*Q;q.n12=h*F*N-f*A*N-h*C*P+e*A*P+f*C*Q-e*F*Q;q.n13=f*k*N-h*b*N+h*p*P-e*k*P-f*p*Q+e*b*Q;q.n14=h*b*C-f*k*C-h*p*F+e*k*F+f*p*A-e*b*A;q.n21=k*F*E-b*A*E-k*j*P+i*A*P+b*j*Q-i*F*Q;q.n22=f*A*E-h*F*E+h*j*P-d*A*P-f*j*Q+d*F*Q;q.n23=h*b*E-f*k*E-h*i*P+d*k*P+f*i*Q-d*b*Q;q.n24=f*k*j-h*b*j+
h*i*F-d*k*F-f*i*A+d*b*A;q.n31=p*A*E-k*C*E+k*j*N-i*A*N-p*j*Q+i*C*Q;q.n32=h*C*E-e*A*E-h*j*N+d*A*N+e*j*Q-d*C*Q;q.n33=f*k*E-h*p*E+h*i*N-d*k*N-e*i*Q+d*p*Q;q.n34=h*p*j-e*k*j-h*i*C+d*k*C+e*i*A-d*p*A;q.n41=b*C*E-p*F*E-b*j*N+i*F*N+p*j*P-i*C*P;q.n42=e*F*E-f*C*E+f*j*N-d*F*N-e*j*P+d*C*P;q.n43=f*p*E-e*b*E-f*i*N+d*b*N+e*i*P-d*p*P;q.n44=e*b*j-f*p*j+f*i*C-d*b*C-e*i*F+d*p*F;q.multiplyScalar(1/a.determinant());return q};
THREE.Matrix4.makeInvert3x3=function(a){var d=a.flatten();a=a.m33;var e=d[10]*d[5]-d[6]*d[9],f=-d[10]*d[1]+d[2]*d[9],h=d[6]*d[1]-d[2]*d[5],i=-d[10]*d[4]+d[6]*d[8],p=d[10]*d[0]-d[2]*d[8],b=-d[6]*d[0]+d[2]*d[4],k=d[9]*d[4]-d[5]*d[8],j=-d[9]*d[0]+d[1]*d[8],C=d[5]*d[0]-d[1]*d[4];d=d[0]*e+d[1]*i+d[2]*k;if(d==0)throw"matrix not invertible";d=1/d;a.m[0]=d*e;a.m[1]=d*f;a.m[2]=d*h;a.m[3]=d*i;a.m[4]=d*p;a.m[5]=d*b;a.m[6]=d*k;a.m[7]=d*j;a.m[8]=d*C;return a};
THREE.Matrix4.makeFrustum=function(a,d,e,f,h,i){var p,b,k;p=new THREE.Matrix4;b=2*h/(d-a);k=2*h/(f-e);a=(d+a)/(d-a);e=(f+e)/(f-e);f=-(i+h)/(i-h);h=-2*i*h/(i-h);p.n11=b;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,d,e,f){var h;a=e*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*d,a*d,h,a,e,f)};
THREE.Matrix4.makeOrtho=function(a,d,e,f,h,i){var p,b,k,j;p=new THREE.Matrix4;b=d-a;k=e-f;j=i-h;a=(d+a)/b;e=(e+f)/k;h=(i+h)/j;p.n11=2/b;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/j;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
THREE.Vertex=function(a,d){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=d||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,d,e,f,h){this.a=a;this.b=d;this.c=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.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,d,e,f,h,i){this.a=a;this.b=d;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,d){this.u=a||0;this.v=d||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,d,e;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var d,e,f,h,i,p,b=new THREE.Vector3,k=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);d=0;for(e=i.normal.length;d<e;d++)b.addSelf(i.vertexNormals[d]);b.divideScalar(3)}else{d=this.vertices[i.a];e=this.vertices[i.b];p=this.vertices[i.c];b.sub(p.position,
e.position);k.sub(d.position,e.position);b.crossSelf(k)}b.isZero()||b.normalize();i.normal.copy(b)}},computeVertexNormals:function(){var a,d,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(d=this.vertices.length;a<d;a++)f[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(d=this.vertices.length;a<d;a++)f[a].set(0,0,0)}a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(d=this.vertices.length;a<d;a++)f[a].normalize();a=0;for(d=this.faces.length;a<
d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(v,o,K,H,U,T,M){i=v.vertices[o].position;p=v.vertices[K].position;b=v.vertices[H].position;k=h[U];j=h[T];C=h[M];F=p.x-i.x;A=b.x-i.x;E=p.y-i.y;N=b.y-i.y;
P=p.z-i.z;Q=b.z-i.z;q=j.u-k.u;aa=C.u-k.u;L=j.v-k.v;g=C.v-k.v;l=1/(q*g-aa*L);u.set((g*F-L*A)*l,(g*E-L*N)*l,(g*P-L*Q)*l);I.set((q*A-aa*F)*l,(q*N-aa*E)*l,(q*Q-aa*P)*l);r[o].addSelf(u);r[K].addSelf(u);r[H].addSelf(u);m[o].addSelf(I);m[K].addSelf(I);m[H].addSelf(I)}var d,e,f,h,i,p,b,k,j,C,F,A,E,N,P,Q,q,aa,L,g,l,r=[],m=[],u=new THREE.Vector3,I=new THREE.Vector3,n=new THREE.Vector3,w=new THREE.Vector3,B=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){r[d]=new THREE.Vector3;m[d]=new THREE.Vector3}d=
0;for(e=this.faces.length;d<e;d++){f=this.faces[d];h=this.uvs[d];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])}}d=0;for(e=this.vertices.length;d<e;d++){B.copy(this.vertices[d].normal);f=r[d];n.copy(f);n.subSelf(B.multiplyScalar(B.dot(f))).normalize();w.cross(this.vertices[d].normal,f);f=w.dot(m[d]);f=f<0?-1:1;this.vertices[d].tangent.set(n.x,n.y,n.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],
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){a=this.vertices[d];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,d=0,e=this.vertices.length;d<e;d++)a=Math.max(a,this.vertices[d].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var F=[];d=0;for(e=C.length;d<e;d++)C[d]==undefined?F.push("undefined"):F.push(C[d].toString());return F.join("_")}var d,e,f,h,i,p,b,k,j={};f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];
p=i.materials;b=a(p);if(j[b]==undefined)j[b]={hash:b,counter:0};k=j[b].hash+"_"+j[b].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+i>65535){j[b].counter+=1;k=j[b].hash+"_"+j[b].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(f);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,d,e,f){this.fov=a;this.aspect=d;this.near=e;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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1};THREE.DirectionalLight.prototype=new THREE.Light;
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,d){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=d||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.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,d=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);if(d.x!=0){f.setRotX(d.x);this.matrix.multiplySelf(f)}if(d.y!=0){f.setRotY(d.y);this.matrix.multiplySelf(f)}if(d.z!=0){f.setRotZ(d.z);this.matrix.multiplySelf(f)}if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};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,d){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];this.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
THREE.Line=function(a,d,e){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,d){THREE.Object3D.call(this);this.geometry=a;this.materials=d instanceof Array?d:[d];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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,d,e,f,h,i){this.image=a;this.mapping=d!==undefined?d:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,d,e){this.width=a;this.height=d;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var d,e,f,h={};for(d in a){h[d]={};for(e in a[d]){f=a[d][e];h[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var d,e,f,h={};for(d=0;d<a.length;d++){f=this.clone(a[d]);for(e in f)h[e]=f[e]}return h}};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,d,e){this.color=new THREE.Color(a);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(a,d){this.color=new THREE.Color(a);this.density=d||2.5E-4};
THREE.Projector=function(){function a(m,u){return u.z-m.z}function d(m,u){var I=0,n=1,w=m.z+m.w,B=u.z+u.w,v=-m.z+m.w,o=-u.z+u.w;if(w>=0&&B>=0&&v>=0&&o>=0)return true;else if(w<0&&B<0||v<0&&o<0)return false;else{if(w<0)I=Math.max(I,w/(w-B));else if(B<0)n=Math.min(n,w/(w-B));if(v<0)I=Math.max(I,v/(v-o));else if(o<0)n=Math.min(n,v/(v-o));if(n<I)return false;else{m.lerpSelf(u,I);u.lerpSelf(m,1-n);return true}}}var e,f,h=[],i,p,b,k=[],j,C,F=[],A,E,N=[],P=new THREE.Vector4,Q=new THREE.Vector4,q=new THREE.Matrix4,
aa=new THREE.Matrix4,L=[],g=new THREE.Vector4,l=new THREE.Vector4,r;this.projectObjects=function(m,u,I){var n=[],w,B;f=0;q.multiply(u.projectionMatrix,u.matrix);L[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);L[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);L[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);L[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);L[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
q.n33,q.n44-q.n34);L[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);u=0;for(w=L.length;u<w;u++){B=L[u];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}w=m.objects;m=0;for(u=w.length;m<u;m++){B=w[m];var v;if(!(v=!B.visible)){if(v=B instanceof THREE.Mesh){a:{v=void 0;for(var o=B.position,K=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),H=0;H<6;H++){v=L[H].x*o.x+L[H].y*o.y+L[H].z*o.z+L[H].w;if(v<=K){v=false;break a}}v=true}v=!v}v=v}if(!v){e=
h[f]=h[f]||new THREE.RenderableObject;P.copy(B.position);q.multiplyVector3(P);e.object=B;e.z=P.z;n.push(e);f++}}I&&n.sort(a);return n};this.projectScene=function(m,u,I){var n=[],w=u.near,B=u.far,v,o,K,H,U,T,M,ba,V,O,R,Z,W,D,S,X;b=C=E=0;u.autoUpdateMatrix&&u.updateMatrix();q.multiply(u.projectionMatrix,u.matrix);T=this.projectObjects(m,u,true);m=0;for(v=T.length;m<v;m++){M=T[m].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();ba=M.matrix;V=M.rotationMatrix;O=M.materials;R=M.overdraw;if(M instanceof
THREE.Mesh){Z=M.geometry;W=Z.vertices;o=0;for(K=W.length;o<K;o++){D=W[o];D.positionWorld.copy(D.position);ba.multiplyVector3(D.positionWorld);H=D.positionScreen;H.copy(D.positionWorld);q.multiplyVector4(H);H.x/=H.w;H.y/=H.w;D.__visible=H.z>w&&H.z<B}Z=Z.faces;o=0;for(K=Z.length;o<K;o++){D=Z[o];if(D instanceof THREE.Face3){H=W[D.a];U=W[D.b];S=W[D.c];if(H.__visible&&U.__visible&&S.__visible)if(M.doubleSided||M.flipSided!=(S.positionScreen.x-H.positionScreen.x)*(U.positionScreen.y-H.positionScreen.y)-
(S.positionScreen.y-H.positionScreen.y)*(U.positionScreen.x-H.positionScreen.x)<0){i=k[b]=k[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(H.positionWorld);i.v2.positionWorld.copy(U.positionWorld);i.v3.positionWorld.copy(S.positionWorld);i.v1.positionScreen.copy(H.positionScreen);i.v2.positionScreen.copy(U.positionScreen);i.v3.positionScreen.copy(S.positionScreen);i.normalWorld.copy(D.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(D.centroid);ba.multiplyVector3(i.centroidWorld);
i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);S=D.vertexNormals;r=i.vertexNormalsWorld;H=0;for(U=S.length;H<U;H++){X=r[H]=r[H]||new THREE.Vector3;X.copy(S[H]);V.multiplyVector3(X)}i.z=i.centroidScreen.z;i.meshMaterials=O;i.faceMaterials=D.materials;i.overdraw=R;if(M.geometry.uvs[o]){i.uvs[0]=M.geometry.uvs[o][0];i.uvs[1]=M.geometry.uvs[o][1];i.uvs[2]=M.geometry.uvs[o][2]}n.push(i);b++}}else if(D instanceof THREE.Face4){H=W[D.a];U=W[D.b];S=W[D.c];X=W[D.d];if(H.__visible&&
U.__visible&&S.__visible&&X.__visible)if(M.doubleSided||M.flipSided!=((X.positionScreen.x-H.positionScreen.x)*(U.positionScreen.y-H.positionScreen.y)-(X.positionScreen.y-H.positionScreen.y)*(U.positionScreen.x-H.positionScreen.x)<0||(U.positionScreen.x-S.positionScreen.x)*(X.positionScreen.y-S.positionScreen.y)-(U.positionScreen.y-S.positionScreen.y)*(X.positionScreen.x-S.positionScreen.x)<0)){i=k[b]=k[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(H.positionWorld);i.v2.positionWorld.copy(U.positionWorld);
i.v3.positionWorld.copy(X.positionWorld);i.v1.positionScreen.copy(H.positionScreen);i.v2.positionScreen.copy(U.positionScreen);i.v3.positionScreen.copy(X.positionScreen);i.normalWorld.copy(D.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(D.centroid);ba.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=O;i.faceMaterials=D.materials;i.overdraw=R;if(M.geometry.uvs[o]){i.uvs[0]=M.geometry.uvs[o][0];
i.uvs[1]=M.geometry.uvs[o][1];i.uvs[2]=M.geometry.uvs[o][3]}n.push(i);b++;p=k[b]=k[b]||new THREE.RenderableFace3;p.v1.positionWorld.copy(U.positionWorld);p.v2.positionWorld.copy(S.positionWorld);p.v3.positionWorld.copy(X.positionWorld);p.v1.positionScreen.copy(U.positionScreen);p.v2.positionScreen.copy(S.positionScreen);p.v3.positionScreen.copy(X.positionScreen);p.normalWorld.copy(i.normalWorld);p.centroidWorld.copy(i.centroidWorld);p.centroidScreen.copy(i.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
O;p.faceMaterials=D.materials;p.overdraw=R;if(M.geometry.uvs[o]){p.uvs[0]=M.geometry.uvs[o][1];p.uvs[1]=M.geometry.uvs[o][2];p.uvs[2]=M.geometry.uvs[o][3]}n.push(p);b++}}}}else if(M instanceof THREE.Line){aa.multiply(q,ba);W=M.geometry.vertices;D=W[0];D.positionScreen.copy(D.position);aa.multiplyVector4(D.positionScreen);o=1;for(K=W.length;o<K;o++){H=W[o];H.positionScreen.copy(H.position);aa.multiplyVector4(H.positionScreen);U=W[o-1];g.copy(H.positionScreen);l.copy(U.positionScreen);if(d(g,l)){g.multiplyScalar(1/
g.w);l.multiplyScalar(1/l.w);j=F[C]=F[C]||new THREE.RenderableLine;j.v1.positionScreen.copy(g);j.v2.positionScreen.copy(l);j.z=Math.max(g.z,l.z);j.materials=M.materials;n.push(j);C++}}}else if(M instanceof THREE.Particle){Q.set(M.position.x,M.position.y,M.position.z,1);q.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){A=N[E]=N[E]||new THREE.RenderableParticle;A.x=Q.x/Q.w;A.y=Q.y/Q.w;A.z=Q.z;A.rotation=M.rotation.z;A.scale.x=M.scale.x*Math.abs(A.x-(Q.x+u.projectionMatrix.n11)/(Q.w+u.projectionMatrix.n14));
A.scale.y=M.scale.y*Math.abs(A.y-(Q.y+u.projectionMatrix.n22)/(Q.w+u.projectionMatrix.n24));A.materials=M.materials;n.push(A);E++}}}}I&&n.sort(a);return n};this.unprojectVector=function(m,u){var I=new THREE.Matrix4;I.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));I.multiplyVector3(m);return m}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,d=new THREE.Projector,e,f,h,i;this.domElement=document.createElement("div");this.setSize=function(p,b){e=p;f=b;h=e/2;i=f/2};this.render=function(p,b){var k,j,C,F,A,E,N,P;a=d.projectScene(p,b);k=0;for(j=a.length;k<j;k++){A=a[k];if(A instanceof THREE.RenderableParticle){N=A.x*h+h;P=A.y*i+i;C=0;for(F=A.material.length;C<F;C++){E=A.material[C];if(E instanceof THREE.ParticleDOMMaterial){E=E.domElement;E.style.left=N+"px";E.style.top=P+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(A!=ja)j.globalAlpha=A=ja}function d(ja){if(E!=ja){switch(ja){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}E=ja}}var e=null,f=new THREE.Projector,h=document.createElement("canvas"),i,p,b,k,j=h.getContext("2d"),C=null,F=null,A=1,E=0,N=null,P=null,Q=1,q,aa,L,g,l,r,m,u,I,n=new THREE.Color,
w=new THREE.Color,B=new THREE.Color,v=new THREE.Color,o=new THREE.Color,K,H,U,T,M,ba,V,O,R,Z=new THREE.Rectangle,W=new THREE.Rectangle,D=new THREE.Rectangle,S=false,X=new THREE.Color,ka=new THREE.Color,ha=new THREE.Color,ea=new THREE.Color,pa=Math.PI*2,da=new THREE.Vector3,wa,qa,la,na,ya,Aa,Ba=16;wa=document.createElement("canvas");wa.width=wa.height=2;qa=wa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);la=qa.getImageData(0,0,2,2);na=la.data;ya=document.createElement("canvas");
ya.width=ya.height=Ba;Aa=ya.getContext("2d");Aa.translate(-Ba/2,-Ba/2);Aa.scale(Ba,Ba);Ba--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,xa){i=ja;p=xa;b=i/2;k=p/2;h.width=i;h.height=p;Z.set(-b,-k,b,k);A=1;E=0;P=N=null;Q=1};this.setClearColor=function(ja,xa){C=ja!==null?new THREE.Color(ja):null;F=xa;W.set(-b,-k,b,k);j.setTransform(1,0,0,-1,b,k);this.clear()};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(Z);if(C!==null){d(THREE.NormalBlending);
a(1);j.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+F+")";j.fillRect(W.getX(),W.getY(),W.getWidth(),W.getHeight())}else j.clearRect(W.getX(),W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ja,xa){function Sa(G){var ca,$,J,Y=G.lights;ka.setRGB(0,0,0);ha.setRGB(0,0,0);ea.setRGB(0,0,0);G=0;for(ca=Y.length;G<ca;G++){$=Y[G];J=$.color;if($ instanceof THREE.AmbientLight){ka.r+=J.r;ka.g+=J.g;ka.b+=J.b}else if($ instanceof THREE.DirectionalLight){ha.r+=
J.r;ha.g+=J.g;ha.b+=J.b}else if($ instanceof THREE.PointLight){ea.r+=J.r;ea.g+=J.g;ea.b+=J.b}}}function Ga(G,ca,$,J){var Y,fa,ia,ma,oa=G.lights;G=0;for(Y=oa.length;G<Y;G++){fa=oa[G];ia=fa.color;ma=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*ma;if(fa>0){J.r+=ia.r*fa;J.g+=ia.g*fa;J.b+=ia.b*fa}}else if(fa instanceof THREE.PointLight){da.sub(fa.position,ca);da.normalize();fa=$.dot(da)*ma;if(fa>0){J.r+=ia.r*fa;J.g+=ia.g*fa;J.b+=ia.b*fa}}}}function Ta(G,ca,$){if($.opacity!=
0){a($.opacity);d($.blending);var J,Y,fa,ia,ma,oa;if($ instanceof THREE.ParticleBasicMaterial){if($.map){ia=$.map;ma=ia.width>>1;oa=ia.height>>1;Y=ca.scale.x*b;fa=ca.scale.y*k;$=Y*ma;J=fa*oa;D.set(G.x-$,G.y-J,G.x+$,G.y+J);if(!Z.instersects(D))return;j.save();j.translate(G.x,G.y);j.rotate(-ca.rotation);j.scale(Y,-fa);j.translate(-ma,-oa);j.drawImage(ia,0,0);j.restore()}j.beginPath();j.moveTo(G.x-10,G.y);j.lineTo(G.x+10,G.y);j.moveTo(G.x,G.y-10);j.lineTo(G.x,G.y+10);j.closePath();j.strokeStyle="rgb(255,255,0)";
j.stroke()}else if($ instanceof THREE.ParticleCircleMaterial){if(S){X.r=ka.r+ha.r+ea.r;X.g=ka.g+ha.g+ea.g;X.b=ka.b+ha.b+ea.b;n.r=$.color.r*X.r;n.g=$.color.g*X.g;n.b=$.color.b*X.b;n.updateStyleString()}else n.__styleString=$.color.__styleString;$=ca.scale.x*b;J=ca.scale.y*k;D.set(G.x-$,G.y-J,G.x+$,G.y+J);if(Z.instersects(D)){Y=n.__styleString;if(P!=Y)j.fillStyle=P=Y;j.save();j.translate(G.x,G.y);j.rotate(-ca.rotation);j.scale($,J);j.beginPath();j.arc(0,0,1,0,pa,true);j.closePath();j.fill();j.restore()}}}}
function Ua(G,ca,$,J){if(J.opacity!=0){a(J.opacity);d(J.blending);j.beginPath();j.moveTo(G.positionScreen.x,G.positionScreen.y);j.lineTo(ca.positionScreen.x,ca.positionScreen.y);j.closePath();if(J instanceof THREE.LineBasicMaterial){n.__styleString=J.color.__styleString;G=J.linewidth;if(Q!=G)j.lineWidth=Q=G;G=n.__styleString;if(N!=G)j.strokeStyle=N=G;j.stroke();D.inflate(J.linewidth*2)}}}function Oa(G,ca,$,J,Y,fa){if(Y.opacity!=0){a(Y.opacity);d(Y.blending);g=G.positionScreen.x;l=G.positionScreen.y;
r=ca.positionScreen.x;m=ca.positionScreen.y;u=$.positionScreen.x;I=$.positionScreen.y;j.beginPath();j.moveTo(g,l);j.lineTo(r,m);j.lineTo(u,I);j.lineTo(g,l);j.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Da(g,l,r,m,u,I,Y.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){G=xa.matrix;da.copy(J.vertexNormalsWorld[0]);
T=(da.x*G.n11+da.y*G.n12+da.z*G.n13)*0.5+0.5;M=-(da.x*G.n21+da.y*G.n22+da.z*G.n23)*0.5+0.5;da.copy(J.vertexNormalsWorld[1]);ba=(da.x*G.n11+da.y*G.n12+da.z*G.n13)*0.5+0.5;V=-(da.x*G.n21+da.y*G.n22+da.z*G.n23)*0.5+0.5;da.copy(J.vertexNormalsWorld[2]);O=(da.x*G.n11+da.y*G.n12+da.z*G.n13)*0.5+0.5;R=-(da.x*G.n21+da.y*G.n22+da.z*G.n23)*0.5+0.5;Da(g,l,r,m,u,I,Y.env_map.image,T,M,ba,V,O,R)}}else Y.wireframe?Ha(Y.color.__styleString,Y.wireframe_linewidth):Ia(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&
!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Da(g,l,r,m,u,I,Y.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);d(THREE.SubtractiveBlending)}if(S)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){w.r=B.r=v.r=ka.r;w.g=B.g=v.g=ka.g;w.b=B.b=v.b=ka.b;Ga(fa,J.v1.positionWorld,J.vertexNormalsWorld[0],w);Ga(fa,J.v2.positionWorld,J.vertexNormalsWorld[1],B);Ga(fa,J.v3.positionWorld,J.vertexNormalsWorld[2],v);o.r=(B.r+v.r)*0.5;o.g=(B.g+v.g)*
0.5;o.b=(B.b+v.b)*0.5;U=Pa(w,B,v,o);Da(g,l,r,m,u,I,U,0,0,1,0,0,1)}else{X.r=ka.r;X.g=ka.g;X.b=ka.b;Ga(fa,J.centroidWorld,J.normalWorld,X);n.r=Y.color.r*X.r;n.g=Y.color.g*X.g;n.b=Y.color.b*X.b;n.updateStyleString();Y.wireframe?Ha(n.__styleString,Y.wireframe_linewidth):Ia(n.__styleString)}else Y.wireframe?Ha(Y.color.__styleString,Y.wireframe_linewidth):Ia(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){K=xa.near;H=xa.far;w.r=w.g=w.b=1-Ka(G.positionScreen.z,K,H);B.r=B.g=B.b=1-Ka(ca.positionScreen.z,
K,H);v.r=v.g=v.b=1-Ka($.positionScreen.z,K,H);o.r=(B.r+v.r)*0.5;o.g=(B.g+v.g)*0.5;o.b=(B.b+v.b)*0.5;U=Pa(w,B,v,o);Da(g,l,r,m,u,I,U,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){n.r=La(J.normalWorld.x);n.g=La(J.normalWorld.y);n.b=La(J.normalWorld.z);n.updateStyleString();Y.wireframe?Ha(n.__styleString,Y.wireframe_linewidth):Ia(n.__styleString)}}}function Ha(G,ca){if(N!=G)j.strokeStyle=N=G;if(Q!=ca)j.lineWidth=Q=ca;j.stroke();D.inflate(ca*2)}function Ia(G){if(P!=G)j.fillStyle=P=G;j.fill()}
function Da(G,ca,$,J,Y,fa,ia,ma,oa,ta,ra,ua,Ea){var za,va;za=ia.width-1;va=ia.height-1;ma*=za;oa*=va;ta*=za;ra*=va;ua*=za;Ea*=va;$-=G;J-=ca;Y-=G;fa-=ca;ta-=ma;ra-=oa;ua-=ma;Ea-=oa;va=1/(ta*Ea-ua*ra);za=(Ea*$-ra*Y)*va;ra=(Ea*J-ra*fa)*va;$=(ta*Y-ua*$)*va;J=(ta*fa-ua*J)*va;G=G-za*ma-$*oa;ca=ca-ra*ma-J*oa;j.save();j.transform(za,ra,$,J,G,ca);j.clip();j.drawImage(ia,0,0);j.restore()}function Pa(G,ca,$,J){var Y=~~(G.r*255),fa=~~(G.g*255);G=~~(G.b*255);var ia=~~(ca.r*255),ma=~~(ca.g*255);ca=~~(ca.b*255);
var oa=~~($.r*255),ta=~~($.g*255);$=~~($.b*255);var ra=~~(J.r*255),ua=~~(J.g*255);J=~~(J.b*255);na[0]=Y<0?0:Y>255?255:Y;na[1]=fa<0?0:fa>255?255:fa;na[2]=G<0?0:G>255?255:G;na[4]=ia<0?0:ia>255?255:ia;na[5]=ma<0?0:ma>255?255:ma;na[6]=ca<0?0:ca>255?255:ca;na[8]=oa<0?0:oa>255?255:oa;na[9]=ta<0?0:ta>255?255:ta;na[10]=$<0?0:$>255?255:$;na[12]=ra<0?0:ra>255?255:ra;na[13]=ua<0?0:ua>255?255:ua;na[14]=J<0?0:J>255?255:J;qa.putImageData(la,0,0);Aa.drawImage(wa,0,0);return ya}function Ka(G,ca,$){G=(G-ca)/($-ca);
return G*G*(3-2*G)}function La(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ma(G,ca){var $=ca.x-G.x,J=ca.y-G.y,Y=1/Math.sqrt($*$+J*J);$*=Y;J*=Y;ca.x+=$;ca.y+=J;G.x-=$;G.y-=J}var Ja,Qa,ga,sa,Ca,Na,Ra,Fa;j.setTransform(1,0,0,-1,b,k);this.autoClear&&this.clear();e=f.projectScene(ja,xa,this.sortElements);j.fillStyle="rgba( 0, 255, 255, 0.5 )";j.fillRect(Z.getX(),Z.getY(),Z.getWidth(),Z.getHeight());(S=ja.lights.length>0)&&Sa(ja);Ja=0;for(Qa=e.length;Ja<Qa;Ja++){ga=e[Ja];D.empty();if(ga instanceof THREE.RenderableParticle){q=
ga;q.x*=b;q.y*=k;sa=0;for(Ca=ga.materials.length;sa<Ca;sa++)Ta(q,ga,ga.materials[sa],ja)}else if(ga instanceof THREE.RenderableLine){q=ga.v1;aa=ga.v2;q.positionScreen.x*=b;q.positionScreen.y*=k;aa.positionScreen.x*=b;aa.positionScreen.y*=k;D.addPoint(q.positionScreen.x,q.positionScreen.y);D.addPoint(aa.positionScreen.x,aa.positionScreen.y);if(Z.instersects(D)){sa=0;for(Ca=ga.materials.length;sa<Ca;)Ua(q,aa,ga,ga.materials[sa++],ja)}}else if(ga instanceof THREE.RenderableFace3){q=ga.v1;aa=ga.v2;L=
ga.v3;q.positionScreen.x*=b;q.positionScreen.y*=k;aa.positionScreen.x*=b;aa.positionScreen.y*=k;L.positionScreen.x*=b;L.positionScreen.y*=k;if(ga.overdraw){Ma(q.positionScreen,aa.positionScreen);Ma(aa.positionScreen,L.positionScreen);Ma(L.positionScreen,q.positionScreen)}D.add3Points(q.positionScreen.x,q.positionScreen.y,aa.positionScreen.x,aa.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(Z.instersects(D)){sa=0;for(Ca=ga.meshMaterials.length;sa<Ca;){Fa=ga.meshMaterials[sa++];if(Fa instanceof
THREE.MeshFaceMaterial){Na=0;for(Ra=ga.faceMaterials.length;Na<Ra;)(Fa=ga.faceMaterials[Na++])&&Oa(q,aa,L,ga,Fa,ja)}else Oa(q,aa,L,ga,Fa,ja)}}}W.addRectangle(D)}j.lineWidth=1;j.strokeStyle="rgba( 255, 0, 0, 0.5 )";j.strokeRect(W.getX(),W.getY(),W.getWidth(),W.getHeight());j.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(T,M,ba){var V,O,R,Z;V=0;for(O=T.lights.length;V<O;V++){R=T.lights[V];if(R instanceof THREE.DirectionalLight){Z=M.normalWorld.dot(R.position)*R.intensity;if(Z>0){ba.r+=R.color.r*Z;ba.g+=R.color.g*Z;ba.b+=R.color.b*Z}}else if(R instanceof THREE.PointLight){I.sub(R.position,M.centroidWorld);I.normalize();Z=M.normalWorld.dot(I)*R.intensity;if(Z>0){ba.r+=R.color.r*Z;ba.g+=R.color.g*Z;ba.b+=R.color.b*Z}}}}function d(T,M,ba,V,O,R){v=f(o++);v.setAttribute("d","M "+
T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)L.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(aa){g.r=l.r;g.g=l.g;g.b=l.b;a(R,V,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){u=1-O.__2near/(O.__farPlusNear-
V.z*O.__farMinusNear);L.setRGB(u,u,u)}else O instanceof THREE.MeshNormalMaterial&&L.setRGB(h(V.normalWorld.x),h(V.normalWorld.y),h(V.normalWorld.z));O.wireframe?v.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):v.setAttribute("style","fill: "+L.__styleString+"; fill-opacity: "+O.opacity);b.appendChild(v)}function e(T,M,ba,V,O,R,Z){v=
f(o++);v.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)L.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(aa){g.r=l.r;g.g=l.g;g.b=l.b;a(Z,O,g);L.r=R.color.r*g.r;L.g=R.color.g*g.g;L.b=R.color.b*g.b;L.updateStyleString()}else L.__styleString=R.color.__styleString;
else if(R instanceof THREE.MeshDepthMaterial){u=1-R.__2near/(R.__farPlusNear-O.z*R.__farMinusNear);L.setRGB(u,u,u)}else R instanceof THREE.MeshNormalMaterial&&L.setRGB(h(O.normalWorld.x),h(O.normalWorld.y),h(O.normalWorld.z));R.wireframe?v.setAttribute("style","fill: none; stroke: "+L.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):v.setAttribute("style","fill: "+L.__styleString+
"; fill-opacity: "+R.opacity);b.appendChild(v)}function f(T){if(n[T]==null){n[T]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&n[T].setAttribute("shape-rendering","crispEdges");return n[T]}return n[T]}function h(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var i=null,p=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,j,C,F,A,E,N,P,Q=new THREE.Rectangle,q=new THREE.Rectangle,aa=false,L=new THREE.Color(16777215),g=new THREE.Color(16777215),
l=new THREE.Color(0),r=new THREE.Color(0),m=new THREE.Color(0),u,I=new THREE.Vector3,n=[],w=[],B=[],v,o,K,H,U=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":U=1;break;case "low":U=0}};this.setSize=function(T,M){k=T;j=M;C=k/2;F=j/2;b.setAttribute("viewBox",-C+" "+-F+" "+k+" "+j);b.setAttribute("width",k);b.setAttribute("height",j);Q.set(-C,-F,C,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
this.render=function(T,M){var ba,V,O,R,Z,W,D,S;this.autoClear&&this.clear();i=p.projectScene(T,M,this.sortElements);H=K=o=0;if(aa=T.lights.length>0){D=T.lights;l.setRGB(0,0,0);r.setRGB(0,0,0);m.setRGB(0,0,0);ba=0;for(V=D.length;ba<V;ba++){O=D[ba];R=O.color;if(O instanceof THREE.AmbientLight){l.r+=R.r;l.g+=R.g;l.b+=R.b}else if(O instanceof THREE.DirectionalLight){r.r+=R.r;r.g+=R.g;r.b+=R.b}else if(O instanceof THREE.PointLight){m.r+=R.r;m.g+=R.g;m.b+=R.b}}}ba=0;for(V=i.length;ba<V;ba++){D=i[ba];q.empty();
if(D instanceof THREE.RenderableParticle){A=D;A.x*=C;A.y*=-F;O=0;for(R=D.materials.length;O<R;O++)if(S=D.materials[O]){Z=A;W=D;S=S;var X=K++;if(w[X]==null){w[X]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&w[X].setAttribute("shape-rendering","crispEdges")}v=w[X];v.setAttribute("cx",Z.x);v.setAttribute("cy",Z.y);v.setAttribute("r",W.scale.x*C);if(S instanceof THREE.ParticleCircleMaterial){if(aa){g.r=l.r+r.r+m.r;g.g=l.g+r.g+m.g;g.b=l.b+r.b+m.b;L.r=S.color.r*g.r;L.g=S.color.g*
g.g;L.b=S.color.b*g.b;L.updateStyleString()}else L=S.color;v.setAttribute("style","fill: "+L.__styleString)}b.appendChild(v)}}else if(D instanceof THREE.RenderableLine){A=D.v1;E=D.v2;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);if(Q.instersects(q)){O=0;for(R=D.materials.length;O<R;)if(S=D.materials[O++]){Z=A;W=E;S=S;X=H++;if(B[X]==null){B[X]=document.createElementNS("http://www.w3.org/2000/svg",
"line");U==0&&B[X].setAttribute("shape-rendering","crispEdges")}v=B[X];v.setAttribute("x1",Z.positionScreen.x);v.setAttribute("y1",Z.positionScreen.y);v.setAttribute("x2",W.positionScreen.x);v.setAttribute("y2",W.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){L.__styleString=S.color.__styleString;v.setAttribute("style","fill: none; stroke: "+L.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);b.appendChild(v)}}}}else if(D instanceof
THREE.RenderableFace3){A=D.v1;E=D.v2;N=D.v3;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;N.positionScreen.x*=C;N.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);q.addPoint(N.positionScreen.x,N.positionScreen.y);if(Q.instersects(q)){O=0;for(R=D.meshMaterials.length;O<R;){S=D.meshMaterials[O++];if(S instanceof THREE.MeshFaceMaterial){Z=0;for(W=D.faceMaterials.length;Z<W;)(S=D.faceMaterials[Z++])&&
d(A,E,N,D,S,T)}else S&&d(A,E,N,D,S,T)}}}else if(D instanceof THREE.RenderableFace4){A=D.v1;E=D.v2;N=D.v3;P=D.v4;A.positionScreen.x*=C;A.positionScreen.y*=-F;E.positionScreen.x*=C;E.positionScreen.y*=-F;N.positionScreen.x*=C;N.positionScreen.y*=-F;P.positionScreen.x*=C;P.positionScreen.y*=-F;q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);q.addPoint(N.positionScreen.x,N.positionScreen.y);q.addPoint(P.positionScreen.x,P.positionScreen.y);if(Q.instersects(q)){O=
0;for(R=D.meshMaterials.length;O<R;){S=D.meshMaterials[O++];if(S instanceof THREE.MeshFaceMaterial){Z=0;for(W=D.faceMaterials.length;Z<W;)(S=D.faceMaterials[Z++])&&e(A,E,N,P,D,S,T)}else S&&e(A,E,N,P,D,S,T)}}}}}};
THREE.WebGLRenderer=function(a){function d(g,l){g.fragment_shader=l.fragment_shader;g.vertex_shader=l.vertex_shader;g.uniforms=Uniforms.clone(l.uniforms)}function e(g,l){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(l){g.uniforms.fogColor.value.setHex(l.color.hex);if(l instanceof THREE.Fog){g.uniforms.fogNear.value=l.near;g.uniforms.fogFar.value=l.far}else if(l instanceof THREE.FogExp2)g.uniforms.fogDensity.value=l.density}}function f(g,l){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(l){g.uniforms.fogColor.value.setHex(l.color.hex);if(l instanceof THREE.Fog){g.uniforms.fogNear.value=
l.near;g.uniforms.fogFar.value=l.far}else if(l instanceof THREE.FogExp2)g.uniforms.fogDensity.value=l.density}}function h(g,l){var r;if(g=="fragment")r=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")r=b.createShader(b.VERTEX_SHADER);b.shaderSource(r,l);b.compileShader(r);if(!b.getShaderParameter(r,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(r));return null}return r}function i(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 p=document.createElement("canvas"),b,k=null,j=null,C=new THREE.Matrix4,F,A=new Float32Array(16),E=new Float32Array(16),N=new Float32Array(16),P=new Float32Array(9),
Q=new Float32Array(16),q=true,aa=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)q=a.antialias;a.clearColor!==undefined&&aa.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=p;this.autoClear=true;(function(g,l,r){try{b=p.getContext("experimental-webgl",{antialias:g})}catch(m){}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(l.r,l.g,l.b,r)})(q,aa,L);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,l){p.width=g;p.height=l;b.viewport(0,0,p.width,p.height)};this.setClearColor=function(g,l){var r=new THREE.Color(g);b.clearColor(r.r,r.g,r.b,l)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=
function(g,l){var r,m,u,I=0,n=0,w=0,B,v,o,K=this.lights,H=K.directional.colors,U=K.directional.positions,T=K.point.colors,M=K.point.positions,ba=0,V=0;r=0;for(m=l.length;r<m;r++){u=l[r];B=u.color;v=u.position;o=u.intensity;if(u instanceof THREE.AmbientLight){I+=B.r;n+=B.g;w+=B.b}else if(u instanceof THREE.DirectionalLight){H[ba*3]=B.r*o;H[ba*3+1]=B.g*o;H[ba*3+2]=B.b*o;U[ba*3]=v.x;U[ba*3+1]=v.y;U[ba*3+2]=v.z;ba+=1}else if(u instanceof THREE.PointLight){T[V*3]=B.r*o;T[V*3+1]=B.g*o;T[V*3+2]=B.b*o;M[V*
3]=v.x;M[V*3+1]=v.y;M[V*3+2]=v.z;V+=1}}K.point.length=V;K.directional.length=ba;K.ambient[0]=I;K.ambient[1]=n;K.ambient[2]=w};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 l=g.vertices.length;g.__vertexArray=new Float32Array(l*3);g.__lineArray=new Uint16Array(l);g.__webGLLineCount=l};this.initMeshBuffers=function(g,l){var r,m,u=0,I=0,n=0,w=l.geometry.faces,B=g.faces;r=0;for(m=B.length;r<m;r++){fi=B[r];face=w[fi];if(face instanceof THREE.Face3){u+=3;I+=1;n+=3}else if(face instanceof THREE.Face4){u+=4;I+=2;n+=4}}g.__vertexArray=
new Float32Array(u*3);g.__normalArray=new Float32Array(u*3);g.__tangentArray=new Float32Array(u*4);g.__uvArray=new Float32Array(u*2);g.__faceArray=new Uint16Array(I*3);g.__lineArray=new Uint16Array(n*2);u=false;r=0;for(m=l.materials.length;r<m;r++){w=l.materials[r];if(w instanceof THREE.MeshFaceMaterial){w=0;for(B=g.materials.length;w<B;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){u=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){u=
true;break}if(u)break}g.__needsSmoothNormals=u;g.__webGLFaceCount=I*3;g.__webGLLineCount=n*2};this.setMeshBuffers=function(g,l,r,m,u,I,n,w){var B,v,o,K,H,U,T,M,ba,V=0,O=0,R=0,Z=0,W=0,D=0,S=0,X=g.__vertexArray,ka=g.__uvArray,ha=g.__normalArray,ea=g.__tangentArray,pa=g.__faceArray,da=g.__lineArray,wa=g.__needsSmoothNormals,qa=l.geometry,la=qa.vertices,na=g.faces,ya=qa.faces,Aa=qa.uvs;l=0;for(B=na.length;l<B;l++){v=na[l];o=ya[v];v=Aa[v];K=o.vertexNormals;H=o.normal;if(o instanceof THREE.Face3){if(m){U=
la[o.a].position;T=la[o.b].position;M=la[o.c].position;X[O]=U.x;X[O+1]=U.y;X[O+2]=U.z;X[O+3]=T.x;X[O+4]=T.y;X[O+5]=T.z;X[O+6]=M.x;X[O+7]=M.y;X[O+8]=M.z;O+=9}if(w&&qa.hasTangents){U=la[o.a].tangent;T=la[o.b].tangent;M=la[o.c].tangent;ea[D]=U.x;ea[D+1]=U.y;ea[D+2]=U.z;ea[D+3]=U.w;ea[D+4]=T.x;ea[D+5]=T.y;ea[D+6]=T.z;ea[D+7]=T.w;ea[D+8]=M.x;ea[D+9]=M.y;ea[D+10]=M.z;ea[D+11]=M.w;D+=12}if(n)if(K.length==3&&wa)for(o=0;o<3;o++){H=K[o];ha[W]=H.x;ha[W+1]=H.y;ha[W+2]=H.z;W+=3}else for(o=0;o<3;o++){ha[W]=H.x;
ha[W+1]=H.y;ha[W+2]=H.z;W+=3}if(I&&v)for(o=0;o<3;o++){K=v[o];ka[R]=K.u;ka[R+1]=K.v;R+=2}if(u){pa[Z]=V;pa[Z+1]=V+1;pa[Z+2]=V+2;Z+=3;da[S]=V;da[S+1]=V+1;da[S+2]=V;da[S+3]=V+2;da[S+4]=V+1;da[S+5]=V+2;S+=6;V+=3}}else if(o instanceof THREE.Face4){if(m){U=la[o.a].position;T=la[o.b].position;M=la[o.c].position;ba=la[o.d].position;X[O]=U.x;X[O+1]=U.y;X[O+2]=U.z;X[O+3]=T.x;X[O+4]=T.y;X[O+5]=T.z;X[O+6]=M.x;X[O+7]=M.y;X[O+8]=M.z;X[O+9]=ba.x;X[O+10]=ba.y;X[O+11]=ba.z;O+=12}if(w&&qa.hasTangents){U=la[o.a].tangent;
T=la[o.b].tangent;M=la[o.c].tangent;o=la[o.d].tangent;ea[D]=U.x;ea[D+1]=U.y;ea[D+2]=U.z;ea[D+3]=U.w;ea[D+4]=T.x;ea[D+5]=T.y;ea[D+6]=T.z;ea[D+7]=T.w;ea[D+8]=M.x;ea[D+9]=M.y;ea[D+10]=M.z;ea[D+11]=M.w;ea[D+12]=o.x;ea[D+13]=o.y;ea[D+14]=o.z;ea[D+15]=o.w;D+=16}if(n)if(K.length==4&&wa)for(o=0;o<4;o++){H=K[o];ha[W]=H.x;ha[W+1]=H.y;ha[W+2]=H.z;W+=3}else for(o=0;o<4;o++){ha[W]=H.x;ha[W+1]=H.y;ha[W+2]=H.z;W+=3}if(I&&v)for(o=0;o<4;o++){K=v[o];ka[R]=K.u;ka[R+1]=K.v;R+=2}if(u){pa[Z]=V;pa[Z+1]=V+1;pa[Z+2]=V+2;
pa[Z+3]=V;pa[Z+4]=V+2;pa[Z+5]=V+3;Z+=6;da[S]=V;da[S+1]=V+1;da[S+2]=V;da[S+3]=V+3;da[S+4]=V+1;da[S+5]=V+2;da[S+6]=V+2;da[S+7]=V+3;S+=8;V+=4}}}if(m){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,X,r)}if(n){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,r)}if(w&&qa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ea,r)}if(I&&R>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,
ka,r)}if(u){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,pa,r);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,da,r)}};this.setLineBuffers=function(g,l,r,m){var u,I,n=g.vertices,w=n.length,B=g.__vertexArray,v=g.__lineArray;if(r)for(r=0;r<w;r++){u=n[r].position;I=r*3;B[I]=u.x;B[I+1]=u.y;B[I+2]=u.z}if(m)for(r=0;r<w;r++)v[r]=r;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,l);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,v,l)};this.setParticleBuffers=function(){};this.renderBuffer=function(g,l,r,m,u,I){var n,w,B,v;if(!m.program){if(m instanceof THREE.MeshDepthMaterial){d(m,THREE.ShaderLib.depth);m.uniforms.mNear.value=g.near;m.uniforms.mFar.value=g.far}else if(m instanceof THREE.MeshNormalMaterial)d(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial){d(m,THREE.ShaderLib.basic);e(m,r)}else if(m instanceof
THREE.MeshLambertMaterial){d(m,THREE.ShaderLib.lambert);e(m,r)}else if(m instanceof THREE.MeshPhongMaterial){d(m,THREE.ShaderLib.phong);e(m,r)}else if(m instanceof THREE.LineBasicMaterial){d(m,THREE.ShaderLib.basic);f(m,r)}var o,K,H;o=v=w=0;for(K=l.length;o<K;o++){H=l[o];H instanceof THREE.DirectionalLight&&v++;H instanceof THREE.PointLight&&w++}if(w+v<=4){o=v;w=w}else{o=Math.ceil(4*v/(w+v));w=4-o}w={directional:o,point:w};v={fog:r,map:m.map,env_map:m.env_map,maxDirLights:w.directional,maxPointLights:w.point};
w=m.fragment_shader;o=m.vertex_shader;K=b.createProgram();H=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+
v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.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(K,h("fragment",H+w));b.attachShader(K,h("vertex",v+o));b.linkProgram(K);b.getProgramParameter(K,b.LINK_STATUS)||
alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(K,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");K.uniforms={};K.attributes={};m.program=K;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(n in m.uniforms)w.push(n);n=m.program;o=0;for(K=w.length;o<K;o++){H=w[o];n.uniforms[H]=b.getUniformLocation(n,H)}n=m.program;w=["position","normal","uv","tangent"];o=0;for(K=w.length;o<K;o++){H=w[o];n.attributes[H]=b.getAttribLocation(n,
H)}}n=m.program;if(n!=k){b.useProgram(n);k=n}this.loadCamera(n,g);this.loadMatrices(n);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){this.setupLights(n,l);g=this.lights;m.uniforms.enableLighting.value=g.directional.length+g.point.length;m.uniforms.ambientLightColor.value=g.ambient;m.uniforms.directionalLightColor.value=g.directional.colors;m.uniforms.directionalLightDirection.value=g.directional.positions;m.uniforms.pointLightColor.value=g.point.colors;m.uniforms.pointLightPosition.value=
g.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)e(m,r);m instanceof THREE.LineBasicMaterial&&f(m,r);if(m instanceof THREE.MeshPhongMaterial){m.uniforms.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);m.uniforms.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);m.uniforms.shininess.value=m.shininess}r=m.uniforms;for(B in r)if(o=n.uniforms[B]){l=r[B];w=l.type;g=l.value;if(w=="i")b.uniform1i(o,
g);else if(w=="f")b.uniform1f(o,g);else if(w=="fv1")b.uniform1fv(o,g);else if(w=="fv")b.uniform3fv(o,g);else if(w=="v2")b.uniform2f(o,g.x,g.y);else if(w=="v3")b.uniform3f(o,g.x,g.y,g.z);else if(w=="c")b.uniform3f(o,g.r,g.g,g.b);else if(w=="t"){b.uniform1i(o,g);if(l=l.texture)if(l.image instanceof Array&&l.image.length==6){l=l;g=g;if(l.image.length==6){if(!l.image.__webGLTextureCube&&!l.image.__cubeMapInitialized&&l.image.loadCount==6){l.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,
l.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(w=0;w<6;++w)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,l.image[w]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);l.image.__cubeMapInitialized=
true}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{l=l;g=g;if(!l.__webGLTexture&&l.image.loaded){l.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,l.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,l.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(l.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(l.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(l.mag_filter));b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_MIN_FILTER,i(l.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+g);b.bindTexture(b.TEXTURE_2D,l.__webGLTexture)}}}B=n.attributes;b.bindBuffer(b.ARRAY_BUFFER,u.__webGLVertexBuffer);b.vertexAttribPointer(B.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.position);if(B.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLNormalBuffer);b.vertexAttribPointer(B.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.normal)}if(B.tangent>=
0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLTangentBuffer);b.vertexAttribPointer(B.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.tangent)}if(B.uv>=0)if(u.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer);b.vertexAttribPointer(B.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(B.uv)}else b.disableVertexAttribArray(B.uv);if(m.wireframe||m instanceof THREE.LineBasicMaterial){B=m.wireframe_linewidth!==undefined?m.wireframe_linewidth:m.linewidth!==undefined?m.linewidth:1;m=m instanceof
THREE.LineBasicMaterial&&I.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(B);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.drawElements(m,u.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,u.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,l,r,m,u,I,n){var w,B,v,o,K;v=0;for(o=m.materials.length;v<o;v++){w=m.materials[v];if(w instanceof THREE.MeshFaceMaterial){w=0;for(B=u.materials.length;w<
B;w++)if((K=u.materials[w])&&K.blending==I&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(g,l,r,K,u,m)}}else if((K=w)&&K.blending==I&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(g,l,r,K,u,m)}}};this.render=function(g,l,r,m){var u,I,n,w=g.lights,B=g.fog;this.initWebGLObjects(g);m=m!==undefined?m:true;if(r&&!r.__webGLFramebuffer){r.__webGLFramebuffer=b.createFramebuffer();r.__webGLRenderbuffer=b.createRenderbuffer();r.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,
r.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,r.width,r.height);b.bindTexture(b.TEXTURE_2D,r.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(r.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(r.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(r.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,i(r.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(r.format),r.width,r.height,0,i(r.format),i(r.type),null);b.bindFramebuffer(b.FRAMEBUFFER,
r.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,r.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,r.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(r){u=r.__webGLFramebuffer;n=r.width;I=r.height}else{u=null;n=p.width;I=p.height}if(u!=j){b.bindFramebuffer(b.FRAMEBUFFER,u);b.viewport(0,0,n,I);m&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);
j=u}this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();A.set(l.matrix.flatten());N.set(l.projectionMatrix.flatten());m=0;for(u=g.__webGLObjects.length;m<u;m++){I=g.__webGLObjects[m];n=I.object;I=I.buffer;if(n.visible){this.setupMatrices(n,l);this.renderPass(l,w,B,n,I,THREE.NormalBlending,false)}}m=0;for(u=g.__webGLObjects.length;m<u;m++){I=g.__webGLObjects[m];n=I.object;I=I.buffer;if(n.visible){this.setupMatrices(n,l);if(n.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
n.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}this.renderPass(l,w,B,n,I,THREE.AdditiveBlending,false);this.renderPass(l,w,B,n,I,THREE.SubtractiveBlending,false);this.renderPass(l,w,B,n,I,THREE.AdditiveBlending,true);this.renderPass(l,w,B,n,I,THREE.SubtractiveBlending,true);this.renderPass(l,w,B,n,I,THREE.NormalBlending,true)}}if(r&&r.min_filter!==THREE.NearestFilter&&r.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,r.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,
null)}};this.initWebGLObjects=function(g){function l(v,o,K,H){if(v[o]==undefined){g.__webGLObjects.push({buffer:K,object:H});v[o]=1}}var r,m,u,I,n,w,B;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}r=0;for(m=g.objects.length;r<m;r++){u=g.objects[r];n=u.geometry;if(g.__webGLObjectsMap[u.id]==undefined)g.__webGLObjectsMap[u.id]={};B=g.__webGLObjectsMap[u.id];if(u instanceof THREE.Mesh){for(I in n.geometryChunks){w=n.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);
this.initMeshBuffers(w,u);n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs)this.setMeshBuffers(w,u,b.DYNAMIC_DRAW,n.__dirtyVertices,n.__dirtyElements,n.__dirtyUvs,n.__dirtyNormals,n.__dirtyTangents);l(B,I,w,u)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false}else if(u instanceof THREE.Line){if(!n.__webGLVertexBuffer){this.createLineBuffers(n);
this.initLineBuffers(n);n.__dirtyVertices=true;n.__dirtyElements=true}n.__dirtyVertices&&this.setLineBuffers(n,b.DYNAMIC_DRAW,n.__dirtyVertices,n.__dirtyElements);l(B,0,n,u);n.__dirtyVertices=false;n.__dirtyElements=false}else if(u instanceof THREE.ParticleSystem){n.__webGLVertexBuffer||this.createParticleBuffers(n);l(B,0,n,u)}}};this.removeObject=function(g,l){var r,m;for(r=g.__webGLObjects.length-1;r>=0;r--){m=g.__webGLObjects[r].object;l==m&&g.__webGLObjects.splice(r,1)}};this.setupMatrices=function(g,
l){g.autoUpdateMatrix&&g.updateMatrix();C.multiply(l.matrix,g.matrix);E.set(C.flatten());F=THREE.Matrix4.makeInvert3x3(C).transpose();P.set(F.m);Q.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,A);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,E);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,N);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,P);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,Q)};this.loadCamera=function(g,l){b.uniform3f(g.uniforms.cameraPosition,
l.position.x,l.position.y,l.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,l){if(g){!l||l=="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}};
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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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};
+252 -252
View File
@@ -1,252 +1,252 @@
// 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,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,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,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(a){function b(N,t,H,k){k=k.clone().subSelf(t);H=H.clone().subSelf(t);var f=N.clone().subSelf(t);N=k.dot(k);t=k.dot(H);k=k.dot(f);var m=H.dot(H);H=H.dot(f);f=1/(N*m-t*t);m=(m*k-t*H)*f;N=(N*H-t*k)*f;return m>0&&N>0&&m+N<1}var d,e,g,h,j,c,i,l,v,D,
r,y=a.geometry,A=y.vertices,C=[];d=0;for(e=y.faces.length;d<e;d++){g=y.faces[d];D=this.origin.clone();r=this.direction.clone();h=a.matrix.multiplyVector3(A[g.a].position.clone());j=a.matrix.multiplyVector3(A[g.b].position.clone());c=a.matrix.multiplyVector3(A[g.c].position.clone());i=g instanceof THREE.Face4?a.matrix.multiplyVector3(A[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());v=r.dot(l);if(v<0){l=l.dot((new THREE.Vector3).sub(h,D))/v;D=D.addSelf(r.multiplyScalar(l));
if(g instanceof THREE.Face3){if(b(D,h,j,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};C.push(g)}}else if(g instanceof THREE.Face4)if(b(D,h,j,i)||b(D,j,c,i)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};C.push(g)}}}return C}};
THREE.Rectangle=function(){function a(){h=e-b;j=g-d}var b,d,e,g,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 g};this.set=function(i,l,v,D){c=false;b=i;d=l;e=v;g=D;a()};this.addPoint=function(i,l){if(c){c=false;b=i;d=l;e=i;g=l}else{b=b<i?b:i;d=d<l?d:l;e=e>i?e:i;g=g>l?
g:l}a()};this.add3Points=function(i,l,v,D,r,y){if(c){c=false;b=i<v?i<r?i:r:v<r?v:r;d=l<D?l<y?l:y:D<y?D:y;e=i>v?i>r?i:r:v>r?v:r;g=l>D?l>y?l:y:D>y?D:y}else{b=i<v?i<r?i<b?i:b:r<b?r:b:v<r?v<b?v:b:r<b?r:b;d=l<D?l<y?l<d?l:d:y<d?y:d:D<y?D<d?D:d:y<d?y:d;e=i>v?i>r?i>e?i:e:r>e?r:e:v>r?v>e?v:e:r>e?r:e;g=l>D?l>y?l>g?l:g:y>g?y:g:D>y?D>g?D:g:y>g?y:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();d=i.getTop();e=i.getRight();g=i.getBottom()}else{b=b<i.getLeft()?b: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){b-=i;d-=i;e+=i;g+=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();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(b,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){c=true;g=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", 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,b,d,e,g,h,j,c,i,l,v,D,r,y,A,C){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=l||0;this.n33=v||1;this.n34=D||0;this.n41=r||0;this.n42=y||0;this.n43=A||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,g,h,j,c,i,l,v,D,r,y,A,C){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=l;this.n33=v;this.n34=D;this.n41=r;this.n42=y;this.n43=A;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).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 b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*
e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,l=a.n24,v=a.n31,
D=a.n32,r=a.n33,y=a.n34,A=a.n41,C=a.n42,N=a.n43,t=a.n44,H=b.n11,k=b.n12,f=b.n13,m=b.n14,u=b.n21,n=b.n22,s=b.n23,I=b.n24,p=b.n31,w=b.n32,z=b.n33,x=b.n34,q=b.n41,K=b.n42,F=b.n43,R=b.n44;this.n11=d*H+e*u+g*p+h*q;this.n12=d*k+e*n+g*w+h*K;this.n13=d*f+e*s+g*z+h*F;this.n14=d*m+e*I+g*x+h*R;this.n21=j*H+c*u+i*p+l*q;this.n22=j*k+c*n+i*w+l*K;this.n23=j*f+c*s+i*z+l*F;this.n24=j*m+c*I+i*x+l*R;this.n31=v*H+D*u+r*p+y*q;this.n32=v*k+D*n+r*w+y*K;this.n33=v*f+D*s+r*z+y*F;this.n34=v*m+D*I+r*x+y*R;this.n41=A*H+C*u+
N*p+t*q;this.n42=A*k+C*n+N*w+t*K;this.n43=A*f+C*s+N*z+t*F;this.n44=A*m+C*I+N*x+t*R;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,l=this.n31,v=this.n32,D=this.n33,r=this.n34,y=this.n41,A=this.n42,C=this.n43,N=this.n44,t=a.n11,H=a.n21,k=a.n31,f=a.n41,m=a.n12,u=a.n22,n=a.n32,s=a.n42,I=a.n13,p=a.n23,w=a.n33,z=a.n43,x=a.n14,q=a.n24,K=a.n34;a=a.n44;this.n11=b*t+d*H+e*k+g*f;this.n12=b*m+d*u+e*n+g*s;this.n13=b*I+d*p+e*w+g*
z;this.n14=b*x+d*q+e*K+g*a;this.n21=h*t+j*H+c*k+i*f;this.n22=h*m+j*u+c*n+i*s;this.n23=h*I+j*p+c*w+i*z;this.n24=h*x+j*q+c*K+i*a;this.n31=l*t+v*H+D*k+r*f;this.n32=l*m+v*u+D*n+r*s;this.n33=l*I+v*p+D*w+r*z;this.n34=l*x+v*q+D*K+r*a;this.n41=y*t+A*H+C*k+N*f;this.n42=y*m+A*u+C*n+N*s;this.n43=y*I+A*p+C*w+N*z;this.n44=y*x+A*q+C*K+N*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*
this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var g=b[d];
b[d]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},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.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};
THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),h=1-e,j=a.x,c=a.y,i=a.z;d.n11=h*j*j+e;d.n12=h*j*c-g*i;d.n13=h*j*i+g*c;d.n21=h*j*c+g*i;d.n22=h*c*c+e;d.n23=h*c*i-g*j;d.n31=h*j*i-g*c;d.n32=h*c*i+g*j;d.n33=h*i*i+e;return d};
THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],h=-b[10]*b[4]+b[6]*b[8],j=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],i=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],v=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*h+b[2]*i;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*h;a.m[4]=b*j;a.m[5]=b*c;a.m[6]=b*i;a.m[7]=b*l;a.m[8]=b*v;return a};
THREE.Matrix4.makeFrustum=function(a,b,d,e,g,h){var j,c,i;j=new THREE.Matrix4;c=2*g/(b-a);i=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(h+g)/(h-g);g=-2*h*g/(h-g);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=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
THREE.Matrix4.makeOrtho=function(a,b,d,e,g,h){var j,c,i,l;j=new THREE.Matrix4;c=b-a;i=d-e;l=h-g;a=(b+a)/c;d=(d+e)/i;g=(h+g)/l;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/l;j.n34=-g;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,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,d,e,g,h){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=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,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,h,j,c=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){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(x,q,K,F,R,T,L){h=x.vertices[q].position;j=x.vertices[K].position;c=x.vertices[F].position;i=g[R];l=g[T];v=g[L];D=j.x-h.x;r=c.x-h.x;y=j.y-h.y;A=c.y-h.y;
C=j.z-h.z;N=c.z-h.z;t=l.u-i.u;H=v.u-i.u;k=l.v-i.v;f=v.v-i.v;m=1/(t*f-H*k);s.set((f*D-k*r)*m,(f*y-k*A)*m,(f*C-k*N)*m);I.set((t*r-H*D)*m,(t*A-H*y)*m,(t*N-H*C)*m);u[q].addSelf(s);u[K].addSelf(s);u[F].addSelf(s);n[q].addSelf(I);n[K].addSelf(I);n[F].addSelf(I)}var b,d,e,g,h,j,c,i,l,v,D,r,y,A,C,N,t,H,k,f,m,u=[],n=[],s=new THREE.Vector3,I=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,z=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){u[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;
for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){z.copy(this.vertices[b].normal);e=u[b];p.copy(e);p.subSelf(z.multiplyScalar(z.dot(e))).normalize();w.cross(this.vertices[b].normal,e);e=w.dot(n[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.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(v){var D=[];b=0;for(d=v.length;b<d;b++)v[b]==undefined?D.push("undefined"):D.push(v[b].toString());return D.join("_")}var b,d,e,g,h,j,c,i,l={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
j=h.materials;c=a(j);if(l[c]==undefined)l[c]={hash:c,counter:0};i=l[c].hash+"_"+l[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){l[c].counter+=1;i=l[c].hash+"_"+l[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,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(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,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.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,b,d,e,g,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=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,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,g={};for(b in a){g[b]={};for(d in a[b]){e=a[b][d];g[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,d,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);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,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(n,s){return s.z-n.z}function b(n,s){var I=0,p=1,w=n.z+n.w,z=s.z+s.w,x=-n.z+n.w,q=-s.z+s.w;if(w>=0&&z>=0&&x>=0&&q>=0)return true;else if(w<0&&z<0||x<0&&q<0)return false;else{if(w<0)I=Math.max(I,w/(w-z));else if(z<0)p=Math.min(p,w/(w-z));if(x<0)I=Math.max(I,x/(x-q));else if(q<0)p=Math.min(p,x/(x-q));if(p<I)return false;else{n.lerpSelf(s,I);s.lerpSelf(n,1-p);return true}}}var d,e,g=[],h,j,c,i=[],l,v,D=[],r,y,A=[],C=new THREE.Vector4,N=new THREE.Vector4,t=new THREE.Matrix4,
H=new THREE.Matrix4,k=[],f=new THREE.Vector4,m=new THREE.Vector4,u;this.projectObjects=function(n,s,I){var p=[],w,z;e=0;t.multiply(s.projectionMatrix,s.matrix);k[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);k[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);k[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);k[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);k[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
t.n33,t.n44-t.n34);k[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);s=0;for(w=k.length;s<w;s++){z=k[s];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}w=n.objects;n=0;for(s=w.length;n<s;n++){z=w[n];var x;if(!(x=!z.visible)){if(x=z instanceof THREE.Mesh){a:{x=void 0;for(var q=z.position,K=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),F=0;F<6;F++){x=k[F].x*q.x+k[F].y*q.y+k[F].z*q.z+k[F].w;if(x<=K){x=false;break a}}x=true}x=!x}x=x}if(!x){d=
g[e]=g[e]||new THREE.RenderableObject;C.copy(z.position);t.multiplyVector3(C);d.object=z;d.z=C.z;p.push(d);e++}}I&&p.sort(a);return p};this.projectScene=function(n,s,I){var p=[],w=s.near,z=s.far,x,q,K,F,R,T,L,aa,U,O,Q,Z,V,B,P,S;c=v=y=0;s.autoUpdateMatrix&&s.updateMatrix();t.multiply(s.projectionMatrix,s.matrix);T=this.projectObjects(n,s,true);n=0;for(x=T.length;n<x;n++){L=T[n].object;if(L.visible){L.autoUpdateMatrix&&L.updateMatrix();aa=L.matrix;U=L.rotationMatrix;O=L.materials;Q=L.overdraw;if(L instanceof
THREE.Mesh){Z=L.geometry;V=Z.vertices;q=0;for(K=V.length;q<K;q++){B=V[q];B.positionWorld.copy(B.position);aa.multiplyVector3(B.positionWorld);F=B.positionScreen;F.copy(B.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;B.__visible=F.z>w&&F.z<z}Z=Z.faces;q=0;for(K=Z.length;q<K;q++){B=Z[q];if(B instanceof THREE.Face3){F=V[B.a];R=V[B.b];P=V[B.c];if(F.__visible&&R.__visible&&P.__visible)if(L.doubleSided||L.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[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(B.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(B.centroid);aa.multiplyVector3(h.centroidWorld);
h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);P=B.vertexNormals;u=h.vertexNormalsWorld;F=0;for(R=P.length;F<R;F++){S=u[F]=u[F]||new THREE.Vector3;S.copy(P[F]);U.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=B.materials;h.overdraw=Q;if(L.geometry.uvs[q]){h.uvs[0]=L.geometry.uvs[q][0];h.uvs[1]=L.geometry.uvs[q][1];h.uvs[2]=L.geometry.uvs[q][2]}p.push(h);c++}}else if(B instanceof THREE.Face4){F=V[B.a];R=V[B.b];P=V[B.c];S=V[B.d];if(F.__visible&&
R.__visible&&P.__visible&&S.__visible)if(L.doubleSided||L.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(B.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(B.centroid);aa.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=B.materials;h.overdraw=Q;if(L.geometry.uvs[q]){h.uvs[0]=L.geometry.uvs[q][0];
h.uvs[1]=L.geometry.uvs[q][1];h.uvs[2]=L.geometry.uvs[q][3]}p.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=B.materials;j.overdraw=Q;if(L.geometry.uvs[q]){j.uvs[0]=L.geometry.uvs[q][1];j.uvs[1]=L.geometry.uvs[q][2];j.uvs[2]=L.geometry.uvs[q][3]}p.push(j);c++}}}}else if(L instanceof THREE.Line){H.multiply(t,aa);V=L.geometry.vertices;B=V[0];B.positionScreen.copy(B.position);H.multiplyVector4(B.positionScreen);q=1;for(K=V.length;q<K;q++){F=V[q];F.positionScreen.copy(F.position);H.multiplyVector4(F.positionScreen);R=V[q-1];f.copy(F.positionScreen);m.copy(R.positionScreen);if(b(f,m)){f.multiplyScalar(1/
f.w);m.multiplyScalar(1/m.w);l=D[v]=D[v]||new THREE.RenderableLine;l.v1.positionScreen.copy(f);l.v2.positionScreen.copy(m);l.z=Math.max(f.z,m.z);l.materials=L.materials;p.push(l);v++}}}else if(L instanceof THREE.Particle){N.set(L.position.x,L.position.y,L.position.z,1);t.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){r=A[y]=A[y]||new THREE.RenderableParticle;r.x=N.x/N.w;r.y=N.y/N.w;r.z=N.z;r.rotation=L.rotation.z;r.scale.x=L.scale.x*Math.abs(r.x-(N.x+s.projectionMatrix.n11)/(N.w+s.projectionMatrix.n14));
r.scale.y=L.scale.y*Math.abs(r.y-(N.y+s.projectionMatrix.n22)/(N.w+s.projectionMatrix.n24));r.materials=L.materials;p.push(r);y++}}}}I&&p.sort(a);return p};this.unprojectVector=function(n,s){var I=new THREE.Matrix4;I.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));I.multiplyVector3(n);return n}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;h=e/2};this.render=function(j,c){var i,l,v,D,r,y,A,C;a=b.projectScene(j,c);i=0;for(l=a.length;i<l;i++){r=a[i];if(r instanceof THREE.RenderableParticle){A=r.x*g+g;C=r.y*h+h;v=0;for(D=r.material.length;v<D;v++){y=r.material[v];if(y instanceof THREE.ParticleDOMMaterial){y=y.domElement;y.style.left=A+"px";y.style.top=C+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(ja){if(r!=ja)l.globalAlpha=r=ja}function b(ja){if(y!=ja){switch(ja){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}y=ja}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),h,j,c,i,l=g.getContext("2d"),v=null,D=null,r=1,y=0,A=null,C=null,N=1,t,H,k,f,m,u,n,s,I,p=new THREE.Color,
w=new THREE.Color,z=new THREE.Color,x=new THREE.Color,q=new THREE.Color,K,F,R,T,L,aa,U,O,Q,Z=new THREE.Rectangle,V=new THREE.Rectangle,B=new THREE.Rectangle,P=false,S=new THREE.Color,fa=new THREE.Color,ea=new THREE.Color,o=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=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;c=h/2;i=j/2;g.width=h;g.height=j;Z.set(-c,-i,c,i);r=1;y=0;C=A=null;N=1};this.setClearColor=function(ja,ta){v=ja!==null?new THREE.Color(ja):null;D=ta;V.set(-c,-i,c,i);l.setTransform(1,0,0,-1,c,i);this.clear()};this.clear=function(){if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(v!==null){b(THREE.NormalBlending);a(1);
l.fillStyle="rgba("+Math.floor(v.r*255)+","+Math.floor(v.g*255)+","+Math.floor(v.b*255)+","+D+")";l.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}else l.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());V.empty()}};this.render=function(ja,ta){function Ma(J){var ba,Y,M,X=J.lights;fa.setRGB(0,0,0);ea.setRGB(0,0,0);o.setRGB(0,0,0);J=0;for(ba=X.length;J<ba;J++){Y=X[J];M=Y.color;if(Y instanceof THREE.AmbientLight){fa.r+=M.r;fa.g+=M.g;fa.b+=M.b}else if(Y instanceof THREE.DirectionalLight){ea.r+=
M.r;ea.g+=M.g;ea.b+=M.b}else if(Y instanceof THREE.PointLight){o.r+=M.r;o.g+=M.g;o.b+=M.b}}}function Aa(J,ba,Y,M){var X,ca,ia,ka,la=J.lights;J=0;for(X=la.length;J<X;J++){ca=la[J];ia=ca.color;ka=ca.intensity;if(ca instanceof THREE.DirectionalLight){ca=Y.dot(ca.position)*ka;if(ca>0){M.r+=ia.r*ca;M.g+=ia.g*ca;M.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){M.r+=ia.r*ca;M.g+=ia.g*ca;M.b+=ia.b*ca}}}}function Na(J,ba,Y){if(Y.opacity!=0){a(Y.opacity);
b(Y.blending);var M,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;M=ca*la;B.set(J.x-Y,J.y-M,J.x+Y,J.y+M);if(Z.instersects(B)){l.save();l.translate(J.x,J.y);l.rotate(-ba.rotation);l.scale(X,-ca);l.translate(-ka,-la);l.drawImage(ia,0,0);l.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+o.r;S.g=fa.g+ea.g+o.g;S.b=fa.b+ea.b+o.b;p.r=Y.color.r*S.r;p.g=Y.color.g*S.g;p.b=
Y.color.b*S.b;p.updateStyleString()}else p.__styleString=Y.color.__styleString;Y=ba.scale.x*c;M=ba.scale.y*i;B.set(J.x-Y,J.y-M,J.x+Y,J.y+M);if(Z.instersects(B)){X=p.__styleString;if(C!=X)l.fillStyle=C=X;l.save();l.translate(J.x,J.y);l.rotate(-ba.rotation);l.scale(Y,M);l.beginPath();l.arc(0,0,1,0,G,true);l.closePath();l.fill();l.restore()}}}}function Oa(J,ba,Y,M){if(M.opacity!=0){a(M.opacity);b(M.blending);l.beginPath();l.moveTo(J.positionScreen.x,J.positionScreen.y);l.lineTo(ba.positionScreen.x,ba.positionScreen.y);
l.closePath();if(M instanceof THREE.LineBasicMaterial){p.__styleString=M.color.__styleString;J=M.linewidth;if(N!=J)l.lineWidth=N=J;J=p.__styleString;if(A!=J)l.strokeStyle=A=J;l.stroke();B.inflate(M.linewidth*2)}}}function Ia(J,ba,Y,M,X,ca){if(X.opacity!=0){a(X.opacity);b(X.blending);f=J.positionScreen.x;m=J.positionScreen.y;u=ba.positionScreen.x;n=ba.positionScreen.y;s=Y.positionScreen.x;I=Y.positionScreen.y;l.beginPath();l.moveTo(f,m);l.lineTo(u,n);l.lineTo(s,I);l.lineTo(f,m);l.closePath();if(X instanceof
THREE.MeshBasicMaterial)if(X.map)X.map.image.loaded&&X.map.mapping instanceof THREE.UVMapping&&xa(f,m,u,n,s,I,X.map.image,M.uvs[0].u,M.uvs[0].v,M.uvs[1].u,M.uvs[1].v,M.uvs[2].u,M.uvs[2].v);else if(X.env_map){if(X.env_map.image.loaded)if(X.env_map.mapping instanceof THREE.SphericalReflectionMapping){J=ta.matrix;E.copy(M.vertexNormalsWorld[0]);T=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;L=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(M.vertexNormalsWorld[1]);aa=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;
U=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(M.vertexNormalsWorld[2]);O=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;Q=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;xa(f,m,u,n,s,I,X.env_map.image,T,L,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(f,m,u,n,s,I,X.map.image,M.uvs[0].u,M.uvs[0].v,M.uvs[1].u,M.uvs[1].v,M.uvs[2].u,M.uvs[2].v);
b(THREE.SubtractiveBlending)}if(P)if(!X.wireframe&&X.shading==THREE.SmoothShading&&M.vertexNormalsWorld.length==3){w.r=z.r=x.r=fa.r;w.g=z.g=x.g=fa.g;w.b=z.b=x.b=fa.b;Aa(ca,M.v1.positionWorld,M.vertexNormalsWorld[0],w);Aa(ca,M.v2.positionWorld,M.vertexNormalsWorld[1],z);Aa(ca,M.v3.positionWorld,M.vertexNormalsWorld[2],x);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,m,u,n,s,I,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,M.centroidWorld,M.normalWorld,S);p.r=X.color.r*
S.r;p.g=X.color.g*S.g;p.b=X.color.b*S.b;p.updateStyleString();X.wireframe?Ba(p.__styleString,X.wireframe_linewidth):Ca(p.__styleString)}else X.wireframe?Ba(X.color.__styleString,X.wireframe_linewidth):Ca(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){K=ta.near;F=ta.far;w.r=w.g=w.b=1-Ea(J.positionScreen.z,K,F);z.r=z.g=z.b=1-Ea(ba.positionScreen.z,K,F);x.r=x.g=x.b=1-Ea(Y.positionScreen.z,K,F);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,m,u,n,s,I,R,
0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){p.r=Fa(M.normalWorld.x);p.g=Fa(M.normalWorld.y);p.b=Fa(M.normalWorld.z);p.updateStyleString();X.wireframe?Ba(p.__styleString,X.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(J,ba){if(A!=J)l.strokeStyle=A=J;if(N!=ba)l.lineWidth=N=ba;l.stroke();B.inflate(ba*2)}function Ca(J){if(C!=J)l.fillStyle=C=J;l.fill()}function xa(J,ba,Y,M,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-=J;M-=ba;X-=J;ca-=ba;qa-=ka;ma-=la;ra-=ka;ya-=la;sa=1/(qa*ya-ra*ma);ua=(ya*Y-ma*X)*sa;ma=(ya*M-ma*ca)*sa;Y=(qa*X-ra*Y)*sa;M=(qa*ca-ra*M)*sa;J=J-ua*ka-Y*la;ba=ba-ma*ka-M*la;l.save();l.transform(ua,ma,Y,M,J,ba);l.clip();l.drawImage(ia,0,0);l.restore()}function Ja(J,ba,Y,M){var X=~~(J.r*255),ca=~~(J.g*255);J=~~(J.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=~~(M.r*255),ra=~~(M.g*255);M=~~(M.b*255);ga[0]=X<0?0:X>255?255:X;ga[1]=
ca<0?0:ca>255?255:ca;ga[2]=J<0?0:J>255?255:J;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]=M<0?0:M>255?255:M;$.putImageData(da,0,0);pa.drawImage(W,0,0);return na}function Ea(J,ba,Y){J=(J-ba)/(Y-ba);return J*J*(3-2*J)}function Fa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function Ga(J,ba){var Y=ba.x-J.x,M=ba.y-J.y,X=1/Math.sqrt(Y*
Y+M*M);Y*=X;M*=X;ba.x+=Y;ba.y+=M;J.x-=Y;J.y-=M}var Da,Ka,ha,oa,wa,Ha,La,za;l.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];B.empty();if(ha instanceof THREE.RenderableParticle){t=ha;t.x*=c;t.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(t,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){t=ha.v1;H=ha.v2;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=
c;H.positionScreen.y*=i;B.addPoint(t.positionScreen.x,t.positionScreen.y);B.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(B)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(t,H,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){t=ha.v1;H=ha.v2;k=ha.v3;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=c;H.positionScreen.y*=i;k.positionScreen.x*=c;k.positionScreen.y*=i;if(ha.overdraw){Ga(t.positionScreen,H.positionScreen);Ga(H.positionScreen,k.positionScreen);
Ga(k.positionScreen,t.positionScreen)}B.add3Points(t.positionScreen.x,t.positionScreen.y,H.positionScreen.x,H.positionScreen.y,k.positionScreen.x,k.positionScreen.y);if(Z.instersects(B)){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(t,H,k,ha,za,ja)}else Ia(t,H,k,ha,za,ja)}}}V.addRectangle(B)}l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(T,L,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=L.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){I.sub(Q.position,L.centroidWorld);I.normalize();Z=L.normalWorld.dot(I)*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,L,aa,U,O,Q){x=e(q++);x.setAttribute("d","M "+
T.positionScreen.x+" "+T.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)k.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(H){f.r=m.r;f.g=m.g;f.b=m.b;a(Q,U,f);k.r=O.color.r*f.r;k.g=O.color.g*f.g;k.b=O.color.b*f.b;k.updateStyleString()}else k.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){s=1-O.__2near/(O.__farPlusNear-
U.z*O.__farMinusNear);k.setRGB(s,s,s)}else O instanceof THREE.MeshNormalMaterial&&k.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));O.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(x)}function d(T,L,aa,U,O,Q,Z){x=
e(q++);x.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)k.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(H){f.r=m.r;f.g=m.g;f.b=m.b;a(Z,O,f);k.r=Q.color.r*f.r;k.g=Q.color.g*f.g;k.b=Q.color.b*f.b;k.updateStyleString()}else k.__styleString=Q.color.__styleString;
else if(Q instanceof THREE.MeshDepthMaterial){s=1-Q.__2near/(Q.__farPlusNear-O.z*Q.__farMinusNear);k.setRGB(s,s,s)}else Q instanceof THREE.MeshNormalMaterial&&k.setRGB(g(O.normalWorld.x),g(O.normalWorld.y),g(O.normalWorld.z));Q.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+
"; fill-opacity: "+Q.opacity);c.appendChild(x)}function e(T){if(p[T]==null){p[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&p[T].setAttribute("shape-rendering","crispEdges");return p[T]}return p[T]}function g(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,l,v,D,r,y,A,C,N=new THREE.Rectangle,t=new THREE.Rectangle,H=false,k=new THREE.Color(16777215),f=new THREE.Color(16777215),
m=new THREE.Color(0),u=new THREE.Color(0),n=new THREE.Color(0),s,I=new THREE.Vector3,p=[],w=[],z=[],x,q,K,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,L){i=T;l=L;v=i/2;D=l/2;c.setAttribute("viewBox",-v+" "+-D+" "+i+" "+l);c.setAttribute("width",i);c.setAttribute("height",l);N.set(-v,-D,v,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
this.render=function(T,L){var aa,U,O,Q,Z,V,B,P;this.autoClear&&this.clear();h=j.projectScene(T,L,this.sortElements);F=K=q=0;if(H=T.lights.length>0){B=T.lights;m.setRGB(0,0,0);u.setRGB(0,0,0);n.setRGB(0,0,0);aa=0;for(U=B.length;aa<U;aa++){O=B[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){u.r+=Q.r;u.g+=Q.g;u.b+=Q.b}else if(O instanceof THREE.PointLight){n.r+=Q.r;n.g+=Q.g;n.b+=Q.b}}}aa=0;for(U=h.length;aa<U;aa++){B=h[aa];t.empty();
if(B instanceof THREE.RenderableParticle){r=B;r.x*=v;r.y*=-D;O=0;for(Q=B.materials.length;O<Q;O++)if(P=B.materials[O]){Z=r;V=B;P=P;var S=K++;if(w[S]==null){w[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&w[S].setAttribute("shape-rendering","crispEdges")}x=w[S];x.setAttribute("cx",Z.x);x.setAttribute("cy",Z.y);x.setAttribute("r",V.scale.x*v);if(P instanceof THREE.ParticleCircleMaterial){if(H){f.r=m.r+u.r+n.r;f.g=m.g+u.g+n.g;f.b=m.b+u.b+n.b;k.r=P.color.r*f.r;k.g=P.color.g*
f.g;k.b=P.color.b*f.b;k.updateStyleString()}else k=P.color;x.setAttribute("style","fill: "+k.__styleString)}c.appendChild(x)}}else if(B instanceof THREE.RenderableLine){r=B.v1;y=B.v2;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);if(N.instersects(t)){O=0;for(Q=B.materials.length;O<Q;)if(P=B.materials[O++]){Z=r;V=y;P=P;S=F++;if(z[S]==null){z[S]=document.createElementNS("http://www.w3.org/2000/svg",
"line");R==0&&z[S].setAttribute("shape-rendering","crispEdges")}x=z[S];x.setAttribute("x1",Z.positionScreen.x);x.setAttribute("y1",Z.positionScreen.y);x.setAttribute("x2",V.positionScreen.x);x.setAttribute("y2",V.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){k.__styleString=P.color.__styleString;x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);c.appendChild(x)}}}}else if(B instanceof
THREE.RenderableFace3){r=B.v1;y=B.v2;A=B.v3;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;A.positionScreen.x*=v;A.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);if(N.instersects(t)){O=0;for(Q=B.meshMaterials.length;O<Q;){P=B.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=B.faceMaterials.length;Z<V;)(P=B.faceMaterials[Z++])&&
b(r,y,A,B,P,T)}else P&&b(r,y,A,B,P,T)}}}else if(B instanceof THREE.RenderableFace4){r=B.v1;y=B.v2;A=B.v3;C=B.v4;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;A.positionScreen.x*=v;A.positionScreen.y*=-D;C.positionScreen.x*=v;C.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);t.addPoint(C.positionScreen.x,C.positionScreen.y);if(N.instersects(t)){O=
0;for(Q=B.meshMaterials.length;O<Q;){P=B.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=B.faceMaterials.length;Z<V;)(P=B.faceMaterials[Z++])&&d(r,y,A,C,B,P,T)}else P&&d(r,y,A,C,B,P,T)}}}}}};
THREE.WebGLRenderer=function(a){function b(f,m){f.fragment_shader=m.fragment_shader;f.vertex_shader=m.vertex_shader;f.uniforms=Uniforms.clone(m.uniforms)}function d(f,m){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(m){f.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){f.uniforms.fogNear.value=m.near;f.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)f.uniforms.fogDensity.value=m.density}}function e(f,m){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(m){f.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){f.uniforms.fogNear.value=
m.near;f.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)f.uniforms.fogDensity.value=m.density}}function g(f,m){var u;if(f=="fragment")u=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")u=c.createShader(c.VERTEX_SHADER);c.shaderSource(u,m);c.compileShader(u);if(!c.getShaderParameter(u,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(u));return null}return u}function h(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),c,i=null,l=null,v=new THREE.Matrix4,D,r=new Float32Array(16),y=new Float32Array(16),A=new Float32Array(16),C=new Float32Array(9),
N=new Float32Array(16),t=true,H=new THREE.Color(0),k=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)k=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(f,m,u){try{c=j.getContext("experimental-webgl",{antialias:f})}catch(n){}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,u)})(t,H,k);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,m){j.width=f;j.height=m;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(f,m){var u=new THREE.Color(f);c.clearColor(u.r,u.g,u.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
function(f,m){var u,n,s,I=0,p=0,w=0,z,x,q,K=this.lights,F=K.directional.colors,R=K.directional.positions,T=K.point.colors,L=K.point.positions,aa=0,U=0;u=0;for(n=m.length;u<n;u++){s=m[u];z=s.color;x=s.position;q=s.intensity;if(s instanceof THREE.AmbientLight){I+=z.r;p+=z.g;w+=z.b}else if(s instanceof THREE.DirectionalLight){F[aa*3]=z.r*q;F[aa*3+1]=z.g*q;F[aa*3+2]=z.b*q;R[aa*3]=x.x;R[aa*3+1]=x.y;R[aa*3+2]=x.z;aa+=1}else if(s instanceof THREE.PointLight){T[U*3]=z.r*q;T[U*3+1]=z.g*q;T[U*3+2]=z.b*q;L[U*
3]=x.x;L[U*3+1]=x.y;L[U*3+2]=x.z;U+=1}}K.point.length=U;K.directional.length=aa;K.ambient[0]=I;K.ambient[1]=p;K.ambient[2]=w};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLNormalBuffer=c.createBuffer();f.__webGLTangentBuffer=c.createBuffer();
f.__webGLUVBuffer=c.createBuffer();f.__webGLFaceBuffer=c.createBuffer();f.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(f){var m=f.vertices.length;f.__vertexArray=new Float32Array(m*3);f.__lineArray=new Uint16Array(m);f.__webGLLineCount=m};this.initMeshBuffers=function(f,m){var u,n,s=0,I=0,p=0,w=m.geometry.faces,z=f.faces;u=0;for(n=z.length;u<n;u++){fi=z[u];face=w[fi];if(face instanceof THREE.Face3){s+=3;I+=1;p+=3}else if(face instanceof THREE.Face4){s+=4;I+=2;p+=4}}f.__vertexArray=
new Float32Array(s*3);f.__normalArray=new Float32Array(s*3);f.__tangentArray=new Float32Array(s*4);f.__uvArray=new Float32Array(s*2);f.__faceArray=new Uint16Array(I*3);f.__lineArray=new Uint16Array(p*2);s=false;u=0;for(n=m.materials.length;u<n;u++){w=m.materials[u];if(w instanceof THREE.MeshFaceMaterial){w=0;for(z=f.materials.length;w<z;w++)if(f.materials[w]&&f.materials[w].shading!=undefined&&f.materials[w].shading==THREE.SmoothShading){s=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){s=
true;break}if(s)break}f.__needsSmoothNormals=s;f.__webGLFaceCount=I*3;f.__webGLLineCount=p*2};this.setMeshBuffers=function(f,m,u,n,s,I,p,w){var z,x,q,K,F,R,T,L,aa,U=0,O=0,Q=0,Z=0,V=0,B=0,P=0,S=f.__vertexArray,fa=f.__uvArray,ea=f.__normalArray,o=f.__tangentArray,G=f.__faceArray,E=f.__lineArray,W=f.__needsSmoothNormals,$=m.geometry,da=$.vertices,ga=f.faces,na=$.faces,pa=$.uvs;m=0;for(z=ga.length;m<z;m++){x=ga[m];q=na[x];x=pa[x];K=q.vertexNormals;F=q.normal;if(q instanceof THREE.Face3){if(n){R=da[q.a].position;
T=da[q.b].position;L=da[q.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]=L.x;S[O+7]=L.y;S[O+8]=L.z;O+=9}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;L=da[q.c].tangent;o[B]=R.x;o[B+1]=R.y;o[B+2]=R.z;o[B+3]=R.w;o[B+4]=T.x;o[B+5]=T.y;o[B+6]=T.z;o[B+7]=T.w;o[B+8]=L.x;o[B+9]=L.y;o[B+10]=L.z;o[B+11]=L.w;B+=12}if(p)if(K.length==3&&W)for(q=0;q<3;q++){F=K[q];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(q=0;q<3;q++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(I&&
x)for(q=0;q<3;q++){K=x[q];fa[Q]=K.u;fa[Q+1]=K.v;Q+=2}if(s){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(q instanceof THREE.Face4){if(n){R=da[q.a].position;T=da[q.b].position;L=da[q.c].position;aa=da[q.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]=L.x;S[O+7]=L.y;S[O+8]=L.z;S[O+9]=aa.x;S[O+10]=aa.y;S[O+11]=aa.z;O+=12}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;L=da[q.c].tangent;q=da[q.d].tangent;
o[B]=R.x;o[B+1]=R.y;o[B+2]=R.z;o[B+3]=R.w;o[B+4]=T.x;o[B+5]=T.y;o[B+6]=T.z;o[B+7]=T.w;o[B+8]=L.x;o[B+9]=L.y;o[B+10]=L.z;o[B+11]=L.w;o[B+12]=q.x;o[B+13]=q.y;o[B+14]=q.z;o[B+15]=q.w;B+=16}if(p)if(K.length==4&&W)for(q=0;q<4;q++){F=K[q];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(q=0;q<4;q++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(I&&x)for(q=0;q<4;q++){K=x[q];fa[Q]=K.u;fa[Q+1]=K.v;Q+=2}if(s){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(n){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,u)}if(p){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ea,u)}if(w&&$.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,o,u)}if(I&&Q>0){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,fa,u)}if(s){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
G,u);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,u)}};this.setLineBuffers=function(f,m,u,n){var s,I,p=f.vertices,w=p.length,z=f.__vertexArray,x=f.__lineArray;if(u)for(u=0;u<w;u++){s=p[u].position;I=u*3;z[I]=s.x;z[I+1]=s.y;z[I+2]=s.z}if(n)for(u=0;u<w;u++)x[u]=u;c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,z,m);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,x,m)};this.setParticleBuffers=
function(){};this.renderBuffer=function(f,m,u,n,s,I){var p,w,z,x;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=f.near;n.uniforms.mFar.value=f.far}else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);d(n,u)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);d(n,u)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);
d(n,u)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,u)}var q,K,F;q=x=w=0;for(K=m.length;q<K;q++){F=m[q];F instanceof THREE.DirectionalLight&&x++;F instanceof THREE.PointLight&&w++}if(w+x<=4){q=x;w=w}else{q=Math.ceil(4*x/(w+x));w=4-q}w={directional:q,point:w};x={fog:u,map:n.map,env_map:n.env_map,maxDirLights:w.directional,maxPointLights:w.point};w=n.fragment_shader;q=n.vertex_shader;K=c.createProgram();F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");x=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.map?"#define USE_MAP":"",x.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(K,g("fragment",F+w));c.attachShader(K,g("vertex",x+q));c.linkProgram(K);c.getProgramParameter(K,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(K,c.VALIDATE_STATUS)+", gl error ["+
c.getError()+"]");K.uniforms={};K.attributes={};n.program=K;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(p in n.uniforms)w.push(p);p=n.program;q=0;for(K=w.length;q<K;q++){F=w[q];p.uniforms[F]=c.getUniformLocation(p,F)}p=n.program;w=["position","normal","uv","tangent"];q=0;for(K=w.length;q<K;q++){F=w[q];p.attributes[F]=c.getAttribLocation(p,F)}}p=n.program;if(p!=i){c.useProgram(p);i=p}this.loadCamera(p,f);this.loadMatrices(p);if(n instanceof
THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){this.setupLights(p,m);f=this.lights;n.uniforms.enableLighting.value=f.directional.length+f.point.length;n.uniforms.ambientLightColor.value=f.ambient;n.uniforms.directionalLightColor.value=f.directional.colors;n.uniforms.directionalLightDirection.value=f.directional.positions;n.uniforms.pointLightColor.value=f.point.colors;n.uniforms.pointLightPosition.value=f.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||
n instanceof THREE.MeshPhongMaterial)d(n,u);n instanceof THREE.LineBasicMaterial&&e(n,u);if(n instanceof THREE.MeshPhongMaterial){n.uniforms.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);n.uniforms.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);n.uniforms.shininess.value=n.shininess}u=n.uniforms;for(z in u)if(q=p.uniforms[z]){m=u[z];w=m.type;f=m.value;if(w=="i")c.uniform1i(q,f);else if(w=="f")c.uniform1f(q,f);else if(w=="fv1")c.uniform1fv(q,f);else if(w=="fv")c.uniform3fv(q,
f);else if(w=="v2")c.uniform2f(q,f.x,f.y);else if(w=="v3")c.uniform3f(q,f.x,f.y,f.z);else if(w=="c")c.uniform3f(q,f.r,f.g,f.b);else if(w=="t"){c.uniform1i(q,f);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;f=f;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(w=0;w<6;++w)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[w]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=
m;f=f;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+f);c.bindTexture(c.TEXTURE_2D,m.__webGLTexture)}}}z=p.attributes;c.bindBuffer(c.ARRAY_BUFFER,s.__webGLVertexBuffer);c.vertexAttribPointer(z.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.position);if(z.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLNormalBuffer);c.vertexAttribPointer(z.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.normal)}if(z.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLTangentBuffer);c.vertexAttribPointer(z.tangent,4,c.FLOAT,
false,0,0);c.enableVertexAttribArray(z.tangent)}if(z.uv>=0)if(s.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLUVBuffer);c.vertexAttribPointer(z.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.uv)}else c.disableVertexAttribArray(z.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){z=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&I.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(z);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
s.__webGLLineBuffer);c.drawElements(n,s.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,s.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,m,u,n,s,I,p){var w,z,x,q,K;x=0;for(q=n.materials.length;x<q;x++){w=n.materials[x];if(w instanceof THREE.MeshFaceMaterial){w=0;for(z=s.materials.length;w<z;w++)if((K=s.materials[w])&&K.blending==I&&K.opacity<1==p){this.setBlending(K.blending);this.renderBuffer(f,m,u,K,
s,n)}}else if((K=w)&&K.blending==I&&K.opacity<1==p){this.setBlending(K.blending);this.renderBuffer(f,m,u,K,s,n)}}};this.render=function(f,m,u,n){var s,I,p,w=f.lights,z=f.fog;this.initWebGLObjects(f);n=n!==undefined?n:true;if(u&&!u.__webGLFramebuffer){u.__webGLFramebuffer=c.createFramebuffer();u.__webGLRenderbuffer=c.createRenderbuffer();u.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,u.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,u.width,u.height);
c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(u.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(u.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(u.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(u.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(u.format),u.width,u.height,0,h(u.format),h(u.type),null);c.bindFramebuffer(c.FRAMEBUFFER,u.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,
u.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,u.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(u){s=u.__webGLFramebuffer;p=u.width;I=u.height}else{s=null;p=j.width;I=j.height}if(s!=l){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(0,0,p,I);n&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);l=s}this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();r.set(m.matrix.flatten());
A.set(m.projectionMatrix.flatten());n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,m);this.renderPass(m,w,z,p,I,THREE.NormalBlending,false)}}n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,m);if(p.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);p.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW)}this.renderPass(m,w,z,p,I,THREE.AdditiveBlending,
false);this.renderPass(m,w,z,p,I,THREE.SubtractiveBlending,false);this.renderPass(m,w,z,p,I,THREE.AdditiveBlending,true);this.renderPass(m,w,z,p,I,THREE.SubtractiveBlending,true);this.renderPass(m,w,z,p,I,THREE.NormalBlending,true)}}if(u&&u.min_filter!==THREE.NearestFilter&&u.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){function m(x,q,K,F){if(x[q]==undefined){f.__webGLObjects.push({buffer:K,
object:F});x[q]=1}}var u,n,s,I,p,w,z;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}u=0;for(n=f.objects.length;u<n;u++){s=f.objects[u];p=s.geometry;if(f.__webGLObjectsMap[s.id]==undefined)f.__webGLObjectsMap[s.id]={};z=f.__webGLObjectsMap[s.id];if(s instanceof THREE.Mesh){for(I in p.geometryChunks){w=p.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);this.initMeshBuffers(w,s);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;
p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(w,s,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);m(z,I,w,s)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(s instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&
this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);m(z,0,p,s);p.__dirtyVertices=false;p.__dirtyElements=false}else if(s instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);m(z,0,p,s)}}};this.removeObject=function(f,m){var u,n;for(u=f.__webGLObjects.length-1;u>=0;u--){n=f.__webGLObjects[u].object;m==n&&f.__webGLObjects.splice(u,1)}};this.setupMatrices=function(f,m){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(m.matrix,f.matrix);y.set(v.flatten());
D=THREE.Matrix4.makeInvert3x3(v).transpose();C.set(D.m);N.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,r);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,N)};this.loadCamera=function(f,m){c.uniform3f(f.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=
function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,h=a.vertices,j=g.vertices,c=a.faces,i=g.faces,l=a.uvs;g=g.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var v=0,D=j.length;v<D;v++){var r=new THREE.Vertex(j[v].position.clone());d&&b.matrix.multiplyVector3(r.position);h.push(r)}v=0;for(D=i.length;v<D;v++){j=i[v];var y,A=j.vertexNormals;if(j instanceof THREE.Face3)y=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)y=new THREE.Face4(j.a+
e,j.b+e,j.c+e,j.d+e);y.centroid.copy(j.centroid);y.normal.copy(j.normal);d=0;for(h=A.length;d<h;d++){r=A[d];y.vertexNormals.push(r.clone())}y.materials=j.materials.slice();c.push(y)}v=0;for(D=g.length;v<D;v++){e=g[v];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));l.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,g,h,j,c,i,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;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 g=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,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,
b,1,0,e,0,g,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-g,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}"},
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:{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}"}}},Cube=function(a,b,d,e,g,h,j,c){function i(C,N,t,H,k,f,m,u){var n,s,I=e||1,p=g||1,w=I+1,z=p+1,x=k/2,q=f/2;k=k/I;var K=f/p,F=l.vertices.length;if(C=="x"&&N=="y"||C=="y"&&N=="x")n="z";else if(C=="x"&&N=="z"||C=="z"&&N=="x")n="y";else if(C=="z"&&N=="y"||C=="y"&&N=="z")n="x";for(s=0;s<z;s++)for(f=0;f<
w;f++){var R=new THREE.Vector3;R[C]=(f*k-x)*t;R[N]=(s*K-q)*H;R[n]=m;l.vertices.push(new THREE.Vertex(R))}for(s=0;s<p;s++)for(f=0;f<I;f++){l.faces.push(new THREE.Face4(f+w*s+F,f+w*(s+1)+F,f+1+w*(s+1)+F,f+1+w*s+F,null,u));l.uvs.push([new THREE.UV(f/I,s/p),new THREE.UV(f/I,(s+1)/p),new THREE.UV((f+1)/I,(s+1)/p),new THREE.UV((f+1)/I,s/p)])}}THREE.Geometry.call(this);var l=this,v=a/2,D=b/2,r=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)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 A in c)if(this.sides[A]!=undefined)this.sides[A]=c[A];this.sides.px&&i("z","y",1*j,-1,d,b,-v,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,b,v,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,D,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-D,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,b,r,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,b,-r,this.materials[5]);(function(){for(var C=
[],N=[],t=0,H=l.vertices.length;t<H;t++){for(var k=l.vertices[t],f=false,m=0,u=C.length;m<u;m++){var n=C[m];if(k.position.x==n.position.x&&k.position.y==n.position.y&&k.position.z==n.position.z){N[t]=m;f=true;break}}if(!f){N[t]=C.length;C.push(new THREE.Vertex(k.position.clone()))}}t=0;for(H=l.faces.length;t<H;t++){k=l.faces[t];k.a=N[k.a];k.b=N[k.b];k.c=N[k.c];k.d=N[k.d]}l.vertices=C})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,d,e,g){function h(l,v,D){j.vertices.push(new THREE.Vertex(new THREE.Vector3(l,v,D)))}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,-g);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+g);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,b,d,e){THREE.Geometry.call(this);var g,h=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,i=e+1;a=a/d;var l=b/e;for(g=0;g<i;g++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(g*l-j),0)));for(g=0;g<e;g++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+c*g,b+c*(g+1),b+1+c*(g+1),b+1+c*g));this.uvs.push([new THREE.UV(b/d,g/e),new THREE.UV(b/d,(g+1)/e),new THREE.UV((b+1)/d,(g+1)/e),new THREE.UV((b+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=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*g),i=a*Math.sin(e*g),l=[],v=0;for(e=0;e<h;e++){var D=2*e/h,r=i*Math.sin(D*g);D=i*Math.cos(D*g);(d==0||d==j)&&e>0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(D,c,r)))-1);l.push(v)}b.push(l)}var y,A,C;g=b.length;for(d=0;d<g;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){l=e==h-1;j=b[d][l?0:e+1];c=b[d][l?h-1:e];i=b[d-1][l?h-1:e];l=b[d-1][l?
0:e+1];r=d/(g-1);y=(d-1)/(g-1);A=(e+1)/h;D=e/h;v=new THREE.UV(1-A,r);r=new THREE.UV(1-D,r);D=new THREE.UV(1-D,y);var N=new THREE.UV(1-A,y);if(d<b.length-1){y=this.vertices[j].position.clone();A=this.vertices[c].position.clone();C=this.vertices[i].position.clone();y.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(j,c,i,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,r,D])}if(d>1){y=this.vertices[j].position.clone();
A=this.vertices[i].position.clone();C=this.vertices[l].position.clone();y.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(j,i,l,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,D,N])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],g=[],h=[],j=[],c=0;c<a.length;c++){this.vertices.push(new THREE.Vertex(a[c]));g[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),l=0;l<=d+0.0010;l+=b){for(c=0;c<e.length;c++)if(l<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(l==0)j=g;for(c=0;c<g.length-1;c++){this.faces.push(new THREE.Face4(h[c],
h[c+1],g[c+1],g[c]));this.uvs.push([new THREE.UV(l/d,c/a.length),new THREE.UV(l/d,(c+1)/a.length),new THREE.UV((l-b)/d,(c+1)/a.length),new THREE.UV((l-b)/d,c/a.length)])}g=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(g){THREE.Loader.prototype.createModel(g.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),g=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,g,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,g,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,g,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 g=function(h){function j(o,G){var E=v(o,G),W=v(o,G+1),$=v(o,G+2),da=v(o,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(o,G){var E=v(o,G),W=v(o,G+1),$=v(o,G+2);return(v(o,G+3)<<24)+($<<16)+(W<<8)+E}function i(o,G){var E=v(o,G);return(v(o,G+1)<<8)+E}function l(o,G){var E=v(o,G);return E>127?E-256:E}function v(o,G){return o.charCodeAt(G)&255}function D(o){var G,E,W;G=
c(a,o);E=c(a,o+u);W=c(a,o+n);o=i(a,o+s);THREE.Loader.prototype.f3(t,G,E,W,o)}function r(o){var G,E,W,$,da,ga;G=c(a,o);E=c(a,o+u);W=c(a,o+n);$=i(a,o+s);da=c(a,o+I);ga=c(a,o+p);o=c(a,o+w);THREE.Loader.prototype.f3n(t,f,G,E,W,$,da,ga,o)}function y(o){var G,E,W,$;G=c(a,o);E=c(a,o+z);W=c(a,o+x);$=c(a,o+q);o=i(a,o+K);THREE.Loader.prototype.f4(t,G,E,W,$,o)}function A(o){var G,E,W,$,da,ga,na,pa;G=c(a,o);E=c(a,o+z);W=c(a,o+x);$=c(a,o+q);da=i(a,o+K);ga=c(a,o+F);na=c(a,o+R);pa=c(a,o+T);o=c(a,o+L);THREE.Loader.prototype.f4n(t,
f,G,E,W,$,da,ga,na,pa,o)}function C(o){var G,E;G=c(a,o);E=c(a,o+aa);o=c(a,o+U);THREE.Loader.prototype.uv3(t,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[o*2],m[o*2+1])}function N(o){var G,E,W;G=c(a,o);E=c(a,o+O);W=c(a,o+Q);o=c(a,o+Z);THREE.Loader.prototype.uv4(t,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[W*2],m[W*2+1],m[o*2],m[o*2+1])}var t=this,H=0,k,f=[],m=[],u,n,s,I,p,w,z,x,q,K,F,R,T,L,aa,U,O,Q,Z,V,B,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,h);k={signature:a.substr(H,8),header_bytes:v(a,
H+8),vertex_coordinate_bytes:v(a,H+9),normal_coordinate_bytes:v(a,H+10),uv_coordinate_bytes:v(a,H+11),vertex_index_bytes:v(a,H+12),normal_index_bytes:v(a,H+13),uv_index_bytes:v(a,H+14),material_index_bytes:v(a,H+15),nvertices:c(a,H+16),nnormals:c(a,H+16+4),nuvs:c(a,H+16+8),ntri_flat:c(a,H+16+12),ntri_smooth:c(a,H+16+16),ntri_flat_uv:c(a,H+16+20),ntri_smooth_uv:c(a,H+16+24),nquad_flat:c(a,H+16+28),nquad_smooth:c(a,H+16+32),nquad_flat_uv:c(a,H+16+36),nquad_smooth_uv:c(a,H+16+40)};H+=k.header_bytes;
u=k.vertex_index_bytes;n=k.vertex_index_bytes*2;s=k.vertex_index_bytes*3;I=k.vertex_index_bytes*3+k.material_index_bytes;p=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes;w=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*2;z=k.vertex_index_bytes;x=k.vertex_index_bytes*2;q=k.vertex_index_bytes*3;K=k.vertex_index_bytes*4;F=k.vertex_index_bytes*4+k.material_index_bytes;R=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes;T=k.vertex_index_bytes*4+
k.material_index_bytes+k.normal_index_bytes*2;L=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*3;aa=k.uv_index_bytes;U=k.uv_index_bytes*2;O=k.uv_index_bytes;Q=k.uv_index_bytes*2;Z=k.uv_index_bytes*3;h=k.vertex_index_bytes*3+k.material_index_bytes;ea=k.vertex_index_bytes*4+k.material_index_bytes;V=k.ntri_flat*h;B=k.ntri_smooth*(h+k.normal_index_bytes*3);P=k.ntri_flat_uv*(h+k.uv_index_bytes*3);S=k.ntri_smooth_uv*(h+k.normal_index_bytes*3+k.uv_index_bytes*3);fa=k.nquad_flat*ea;h=
k.nquad_smooth*(ea+k.normal_index_bytes*4);ea=k.nquad_flat_uv*(ea+k.uv_index_bytes*4);H+=function(o){var G,E,W,$=k.vertex_coordinate_bytes*3,da=o+k.nvertices*$;for(o=o;o<da;o+=$){G=j(a,o);E=j(a,o+k.vertex_coordinate_bytes);W=j(a,o+k.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,G,E,W)}return k.nvertices*$}(H);H+=function(o){var G,E,W,$=k.normal_coordinate_bytes*3,da=o+k.nnormals*$;for(o=o;o<da;o+=$){G=l(a,o);E=l(a,o+k.normal_coordinate_bytes);W=l(a,o+k.normal_coordinate_bytes*2);f.push(G/
127,E/127,W/127)}return k.nnormals*$}(H);H+=function(o){var G,E,W=k.uv_coordinate_bytes*2,$=o+k.nuvs*W;for(o=o;o<$;o+=W){G=j(a,o);E=j(a,o+k.uv_coordinate_bytes);m.push(G,E)}return k.nuvs*W}(H);H=H;V=H+V;B=V+B;P=B+P;S=P+S;fa=S+fa;h=fa+h;ea=h+ea;(function(o){var G,E=k.vertex_index_bytes*3+k.material_index_bytes,W=E+k.uv_index_bytes*3,$=o+k.ntri_flat_uv*W;for(G=o;G<$;G+=W){D(G);C(G+E)}return $-o})(B);(function(o){var G,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,W=E+k.uv_index_bytes*
3,$=o+k.ntri_smooth_uv*W;for(G=o;G<$;G+=W){r(G);C(G+E)}return $-o})(P);(function(o){var G,E=k.vertex_index_bytes*4+k.material_index_bytes,W=E+k.uv_index_bytes*4,$=o+k.nquad_flat_uv*W;for(G=o;G<$;G+=W){y(G);N(G+E)}return $-o})(h);(function(o){var G,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,W=E+k.uv_index_bytes*4,$=o+k.nquad_smooth_uv*W;for(G=o;G<$;G+=W){A(G);N(G+E)}return $-o})(ea);(function(o){var G,E=k.vertex_index_bytes*3+k.material_index_bytes,W=o+k.ntri_flat*E;for(G=
o;G<W;G+=E)D(G);return W-o})(H);(function(o){var G,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,W=o+k.ntri_smooth*E;for(G=o;G<W;G+=E)r(G);return W-o})(V);(function(o){var G,E=k.vertex_index_bytes*4+k.material_index_bytes,W=o+k.nquad_flat*E;for(G=o;G<W;G+=E)y(G);return W-o})(S);(function(o){var G,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,W=o+k.nquad_smooth*E;for(G=o;G<W;G+=E)A(G);return W-o})(fa);this.computeCentroids();this.computeFaceNormals();
this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,g);(function(){var j,c,i,l,v;j=0;for(c=a.vertices.length;j<c;j+=3){i=a.vertices[j];l=a.vertices[j+1];v=a.vertices[j+2];THREE.Loader.prototype.v(h,i,l,v)}})();(function(){function j(A,C){THREE.Loader.prototype.f3(h,A[C],A[C+1],A[C+2],A[C+3])}function c(A,C){THREE.Loader.prototype.f3n(h,
a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6])}function i(A,C){THREE.Loader.prototype.f4(h,A[C],A[C+1],A[C+2],A[C+3],A[C+4])}function l(A,C){THREE.Loader.prototype.f4n(h,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6],A[C+7],A[C+8])}function v(A,C){var N,t,H;N=A[C];t=A[C+1];H=A[C+2];THREE.Loader.prototype.uv3(h,a.uvs[N*2],a.uvs[N*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1])}function D(A,C){var N,t,H,k;N=A[C];t=A[C+1];H=A[C+2];k=A[C+3];THREE.Loader.prototype.uv4(h,a.uvs[N*
2],a.uvs[N*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[k*2],a.uvs[k*2+1])}var r,y;r=0;for(y=a.triangles_uv.length;r<y;r+=7){j(a.triangles_uv,r);v(a.triangles_uv,r+4)}r=0;for(y=a.triangles_n_uv.length;r<y;r+=10){c(a.triangles_n_uv,r);v(a.triangles_n_uv,r+7)}r=0;for(y=a.quads_uv.length;r<y;r+=9){i(a.quads_uv,r);D(a.quads_uv,r+5)}r=0;for(y=a.quads_n_uv.length;r<y;r+=13){l(a.quads_n_uv,r);D(a.quads_n_uv,r+9)}r=0;for(y=a.triangles.length;r<y;r+=4)j(a.triangles,r);r=0;for(y=a.triangles_n.length;r<
y;r+=7)c(a.triangles_n,r);r=0;for(y=a.quads.length;r<y;r+=5)i(a.quads,r);r=0;for(y=a.quads_n.length;r<y;r+=9)l(a.quads_n,r)})();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,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,h){a.faces.push(new THREE.Face4(b,d,e,g,null,
a.materials[h]))},f3n:function(a,b,d,e,g,h,j,c,i){h=a.materials[h];var l=b[c*3],v=b[c*3+1];c=b[c*3+2];var D=b[i*3],r=b[i*3+1];i=b[i*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(l,v,c),new THREE.Vector3(D,r,i)],h))},f4n:function(a,b,d,e,g,h,j,c,i,l,v){j=a.materials[j];var D=b[i*3],r=b[i*3+1];i=b[i*3+2];var y=b[l*3],A=b[l*3+1];l=b[l*3+2];var C=b[v*3],N=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(d,e,g,h,[new THREE.Vector3(b[c*3],b[c*3+1],
b[c*3+2]),new THREE.Vector3(D,r,i),new THREE.Vector3(y,A,l),new THREE.Vector3(C,N,v)],j))},uv3:function(a,b,d,e,g,h,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(h,j));a.uvs.push(c)},uv4:function(a,b,d,e,g,h,j,c,i){var l=[];l.push(new THREE.UV(b,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(h,j));l.push(new THREE.UV(c,i));a.uvs.push(l)},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,g;if(a.map_diffuse&&b){g=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.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};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:g,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("/")}};
// 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,b,e){this.r=a;this.g=b;this.b=e;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,e){this.x=a||0;this.y=b||0;this.z=e||0};
THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+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,b,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1};
THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;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,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,e,f=a.objects,g=[];a=0;for(b=f.length;a<b;a++){e=f[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(i,k){return i.distance-k.distance});return g},intersectObject:function(a){function b(N,r,O,m){m=m.clone().subSelf(r);O=O.clone().subSelf(r);var h=N.clone().subSelf(r);N=m.dot(m);r=m.dot(O);m=m.dot(h);var n=O.dot(O);O=O.dot(h);h=1/(N*n-r*r);n=(n*m-r*O)*h;N=(N*O-r*m)*h;return n>0&&N>0&&n+N<1}var e,f,g,i,k,d,j,l,q,F,
o,A=a.geometry,D=A.vertices,E=[];e=0;for(f=A.faces.length;e<f;e++){g=A.faces[e];F=this.origin.clone();o=this.direction.clone();i=a.matrix.multiplyVector3(D[g.a].position.clone());k=a.matrix.multiplyVector3(D[g.b].position.clone());d=a.matrix.multiplyVector3(D[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(D[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());q=o.dot(l);if(q<0){l=l.dot((new THREE.Vector3).sub(i,F))/q;F=F.addSelf(o.multiplyScalar(l));
if(g instanceof THREE.Face3){if(b(F,i,k,d)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};E.push(g)}}else if(g instanceof THREE.Face4)if(b(F,i,k,j)||b(F,k,d,j)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};E.push(g)}}}return E}};
THREE.Rectangle=function(){function a(){i=f-b;k=g-e}var b,e,f,g,i,k,d=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(j,l,q,F){d=false;b=j;e=l;f=q;g=F;a()};this.addPoint=function(j,l){if(d){d=false;b=j;e=l;f=j;g=l}else{b=b<j?b:j;e=e<l?e:l;f=f>j?f:j;g=g>l?
g:l}a()};this.add3Points=function(j,l,q,F,o,A){if(d){d=false;b=j<q?j<o?j:o:q<o?q:o;e=l<F?l<A?l:A:F<A?F:A;f=j>q?j>o?j:o:q>o?q:o;g=l>F?l>A?l:A:F>A?F:A}else{b=j<q?j<o?j<b?j:b:o<b?o:b:q<o?q<b?q:b:o<b?o:b;e=l<F?l<A?l<e?l:e:A<e?A:e:F<A?F<e?F:e:A<e?A:e;f=j>q?j>o?j>f?j:f:o>f?o:f:q>o?q>f?q:f:o>f?o:f;g=l>F?l>A?l>g?l:g:A>g?A:g:F>A?F>g?F:g:A>g?A:g}a()};this.addRectangle=function(j){if(d){d=false;b=j.getLeft();e=j.getTop();f=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();e=e<j.getTop()?e:j.getTop();
f=f>j.getRight()?f:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;f+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e: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(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){d=true;g=f=e=b=0;a()};this.isEmpty=function(){return d};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+i+", height: "+k+" )"}};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,b,e,f,g,i,k,d,j,l,q,F,o,A,D,E){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=k||0;this.n24=d||0;this.n31=j||0;this.n32=l||0;this.n33=q||1;this.n34=F||0;this.n41=o||0;this.n42=A||0;this.n43=D||0;this.n44=E||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,e,f,g,i,k,d,j,l,q,F,o,A,D,E){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=k;this.n24=d;this.n31=j;this.n32=l;this.n33=q;this.n34=F;this.n41=o;this.n42=A;this.n43=D;this.n44=E;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,e){var f=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();f.cross(e,i).normalize();g.cross(i,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=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*
f+this.n24*g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,f=a.n12,g=a.n13,i=a.n14,k=a.n21,d=a.n22,j=a.n23,l=a.n24,q=a.n31,
F=a.n32,o=a.n33,A=a.n34,D=a.n41,E=a.n42,N=a.n43,r=a.n44,O=b.n11,m=b.n12,h=b.n13,n=b.n14,C=b.n21,p=b.n22,B=b.n23,P=b.n24,v=b.n31,G=b.n32,I=b.n33,H=b.n34,w=b.n41,R=b.n42,L=b.n43,X=b.n44;this.n11=e*O+f*C+g*v+i*w;this.n12=e*m+f*p+g*G+i*R;this.n13=e*h+f*B+g*I+i*L;this.n14=e*n+f*P+g*H+i*X;this.n21=k*O+d*C+j*v+l*w;this.n22=k*m+d*p+j*G+l*R;this.n23=k*h+d*B+j*I+l*L;this.n24=k*n+d*P+j*H+l*X;this.n31=q*O+F*C+o*v+A*w;this.n32=q*m+F*p+o*G+A*R;this.n33=q*h+F*B+o*I+A*L;this.n34=q*n+F*P+o*H+A*X;this.n41=D*O+E*C+
N*v+r*w;this.n42=D*m+E*p+N*G+r*R;this.n43=D*h+E*B+N*I+r*L;this.n44=D*n+E*P+N*H+r*X;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,i=this.n21,k=this.n22,d=this.n23,j=this.n24,l=this.n31,q=this.n32,F=this.n33,o=this.n34,A=this.n41,D=this.n42,E=this.n43,N=this.n44,r=a.n11,O=a.n21,m=a.n31,h=a.n41,n=a.n12,C=a.n22,p=a.n32,B=a.n42,P=a.n13,v=a.n23,G=a.n33,I=a.n43,H=a.n14,w=a.n24,R=a.n34;a=a.n44;this.n11=b*r+e*O+f*m+g*h;this.n12=b*n+e*C+f*p+g*B;this.n13=b*P+e*v+f*G+g*
I;this.n14=b*H+e*w+f*R+g*a;this.n21=i*r+k*O+d*m+j*h;this.n22=i*n+k*C+d*p+j*B;this.n23=i*P+k*v+d*G+j*I;this.n24=i*H+k*w+d*R+j*a;this.n31=l*r+q*O+F*m+o*h;this.n32=l*n+q*C+F*p+o*B;this.n33=l*P+q*v+F*G+o*I;this.n34=l*H+q*w+F*R+o*a;this.n41=A*r+D*O+E*m+N*h;this.n42=A*n+D*C+E*p+N*B;this.n43=A*P+D*v+E*G+N*I;this.n44=A*H+D*w+E*R+N*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,e=this.n13,f=this.n14,g=this.n21,i=this.n22,k=this.n23,d=this.n24,j=this.n31,l=this.n32,q=this.n33,F=this.n34,o=this.n41,A=this.n42,D=this.n43,E=this.n44;return f*k*l*o-e*d*l*o-f*i*q*o+b*d*q*o+e*i*F*o-b*k*F*o-f*k*j*A+e*d*j*A+f*g*q*A-a*d*q*A-e*g*F*A+a*k*F*A+f*i*j*D-b*d*j*D-f*g*l*D+a*d*l*D+b*g*F*D-a*i*F*D-e*i*j*E+b*k*j*E+e*g*l*E-a*k*l*E-b*g*q*E+a*i*q*E},transpose:function(){function a(b,e,
f){var g=b[e];b[e]=b[f];b[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,b,e){this.set(1,0,0,a,0,1,0,b,0,0,1,e,0,0,0,1);return this},setScale:function(a,b,e){this.set(a,0,0,0,0,b,0,0,0,0,e,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){c=Math.cos(b);s=Math.sin(b);t=1-c;x=a.x;y=a.y;z=a.z;tx=t*x;ty=t*y;this.set(tx*x+c,tx*y-s*z,tx*z+s*y,0,tx*y+s*z,ty*y+c,ty*z-s*x,0,tx*z-s*y,ty*z+s*x,t*z*z+
c,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,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f};THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};
THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),i=1-f,k=a.x,d=a.y,j=a.z,l=i*k,q=i*d;e.n11=l*k+f;e.n12=l*d-g*j;e.n13=l*j+g*d;e.n21=l*d+g*j;e.n22=q*d+f;e.n23=q*j-g*k;e.n31=l*j-g*d;e.n32=q*j+g*k;e.n33=i*j*j+f;return e};
THREE.Matrix4.makeInvert=function(a){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,k=a.n22,d=a.n23,j=a.n24,l=a.n31,q=a.n32,F=a.n33,o=a.n34,A=a.n41,D=a.n42,E=a.n43,N=a.n44,r=new THREE.Matrix4;r.n11=d*o*D-j*F*D+j*q*E-k*o*E-d*q*N+k*F*N;r.n12=g*F*D-f*o*D-g*q*E+e*o*E+f*q*N-e*F*N;r.n13=f*j*D-g*d*D+g*k*E-e*j*E-f*k*N+e*d*N;r.n14=g*d*q-f*j*q-g*k*F+e*j*F+f*k*o-e*d*o;r.n21=j*F*A-d*o*A-j*l*E+i*o*E+d*l*N-i*F*N;r.n22=f*o*A-g*F*A+g*l*E-b*o*E-f*l*N+b*F*N;r.n23=g*d*A-f*j*A-g*i*E+b*j*E+f*i*N-b*d*N;r.n24=f*j*l-g*d*l+
g*i*F-b*j*F-f*i*o+b*d*o;r.n31=k*o*A-j*q*A+j*l*D-i*o*D-k*l*N+i*q*N;r.n32=g*q*A-e*o*A-g*l*D+b*o*D+e*l*N-b*q*N;r.n33=f*j*A-g*k*A+g*i*D-b*j*D-e*i*N+b*k*N;r.n34=g*k*l-e*j*l-g*i*q+b*j*q+e*i*o-b*k*o;r.n41=d*q*A-k*F*A-d*l*D+i*F*D+k*l*E-i*q*E;r.n42=e*F*A-f*q*A+f*l*D-b*F*D-e*l*E+b*q*E;r.n43=f*k*A-e*d*A-f*i*D+b*d*D+e*i*E-b*k*E;r.n44=e*d*l-f*k*l+f*i*q-b*d*q-e*i*F+b*k*F;r.multiplyScalar(1/a.determinant());return r};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],d=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],q=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*i+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*i;a.m[4]=b*k;a.m[5]=b*d;a.m[6]=b*j;a.m[7]=b*l;a.m[8]=b*q;return a};
THREE.Matrix4.makeFrustum=function(a,b,e,f,g,i){var k,d,j;k=new THREE.Matrix4;d=2*g/(b-a);j=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(i+g)/(i-g);g=-2*i*g/(i-g);k.n11=d;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=e;k.n24=0;k.n31=0;k.n32=0;k.n33=f;k.n34=g;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)};
THREE.Matrix4.makeOrtho=function(a,b,e,f,g,i){var k,d,j,l;k=new THREE.Matrix4;d=b-a;j=e-f;l=i-g;a=(b+a)/d;e=(e+f)/j;g=(i+g)/l;k.n11=2/d;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-e;k.n31=0;k.n32=0;k.n33=-2/l;k.n34=-g;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};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,e,f,g){this.a=a;this.b=b;this.c=e;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,b,e,f,g,i){this.a=a;this.b=b;this.c=e;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=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,f,g,i,k,d=new THREE.Vector3,j=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){i=this.faces[f];if(a&&i.vertexNormals.length){d.set(0,0,0);b=0;for(e=i.normal.length;b<e;b++)d.addSelf(i.vertexNormals[b]);d.divideScalar(3)}else{b=this.vertices[i.a];e=this.vertices[i.b];k=this.vertices[i.c];d.sub(k.position,
e.position);j.sub(b.position,e.position);d.crossSelf(j)}d.isZero()||d.normalize();i.normal.copy(d)}},computeVertexNormals:function(){var a,b,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)f[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<
b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(H,w,R,L,X,Z,S){i=H.vertices[w].position;k=H.vertices[R].position;d=H.vertices[L].position;j=g[X];l=g[Z];q=g[S];F=k.x-i.x;o=d.x-i.x;A=k.y-i.y;D=d.y-i.y;
E=k.z-i.z;N=d.z-i.z;r=l.u-j.u;O=q.u-j.u;m=l.v-j.v;h=q.v-j.v;n=1/(r*h-O*m);B.set((h*F-m*o)*n,(h*A-m*D)*n,(h*E-m*N)*n);P.set((r*o-O*F)*n,(r*D-O*A)*n,(r*N-O*E)*n);C[w].addSelf(B);C[R].addSelf(B);C[L].addSelf(B);p[w].addSelf(P);p[R].addSelf(P);p[L].addSelf(P)}var b,e,f,g,i,k,d,j,l,q,F,o,A,D,E,N,r,O,m,h,n,C=[],p=[],B=new THREE.Vector3,P=new THREE.Vector3,v=new THREE.Vector3,G=new THREE.Vector3,I=new THREE.Vector3;b=0;for(e=this.vertices.length;b<e;b++){C[b]=new THREE.Vector3;p[b]=new THREE.Vector3}b=0;
for(e=this.faces.length;b<e;b++){f=this.faces[b];g=this.uvs[b];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])}}b=0;for(e=this.vertices.length;b<e;b++){I.copy(this.vertices[b].normal);f=C[b];v.copy(f);v.subSelf(I.multiplyScalar(I.dot(f))).normalize();G.cross(this.vertices[b].normal,f);f=G.dot(p[b]);f=f<0?-1:1;this.vertices[b].tangent.set(v.x,v.y,v.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],
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=this.vertices.length;b<e;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,e=this.vertices.length;b<e;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(q){var F=[];b=0;for(e=q.length;b<e;b++)q[b]==undefined?F.push("undefined"):F.push(q[b].toString());return F.join("_")}var b,e,f,g,i,k,d,j,l={};f=0;for(g=this.faces.length;f<g;f++){i=this.faces[f];
k=i.materials;d=a(k);if(l[d]==undefined)l[d]={hash:d,counter:0};j=l[d].hash+"_"+l[d].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:k,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+i>65535){l[d].counter+=1;j=l[d].hash+"_"+l[d].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:k,vertices:0}}this.geometryChunks[j].faces.push(f);this.geometryChunks[j].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;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)};
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,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.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,b=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);if(b.x!=0){f.setRotX(b.x);this.matrix.multiplySelf(f)}if(b.y!=0){f.setRotY(b.y);this.matrix.multiplySelf(f)}if(b.z!=0){f.setRotZ(b.z);this.matrix.multiplySelf(f)}if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};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,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!=undefined?e: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/>)"}};
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
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,b,e,f,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,b,e){this.width=a;this.height=b;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
var Uniforms={clone:function(a){var b,e,f,g={};for(b in a){g[b]={};for(e in a[b]){f=a[b][e];g[b][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var b,e,f,g={};for(b=0;b<a.length;b++){f=this.clone(a[b]);for(e in f)g[e]=f[e]}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,b,e){this.color=new THREE.Color(a);this.near=b||1;this.far=e||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
THREE.Projector=function(){function a(p,B){return B.z-p.z}function b(p,B){var P=0,v=1,G=p.z+p.w,I=B.z+B.w,H=-p.z+p.w,w=-B.z+B.w;if(G>=0&&I>=0&&H>=0&&w>=0)return true;else if(G<0&&I<0||H<0&&w<0)return false;else{if(G<0)P=Math.max(P,G/(G-I));else if(I<0)v=Math.min(v,G/(G-I));if(H<0)P=Math.max(P,H/(H-w));else if(w<0)v=Math.min(v,H/(H-w));if(v<P)return false;else{p.lerpSelf(B,P);B.lerpSelf(p,1-v);return true}}}var e,f,g=[],i,k,d,j=[],l,q,F=[],o,A,D=[],E=new THREE.Vector4,N=new THREE.Vector4,r=new THREE.Matrix4,
O=new THREE.Matrix4,m=[],h=new THREE.Vector4,n=new THREE.Vector4,C;this.projectObjects=function(p,B,P){var v=[],G,I;f=0;r.multiply(B.projectionMatrix,B.matrix);m[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);m[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);m[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);m[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);m[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
r.n33,r.n44-r.n34);m[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);B=0;for(G=m.length;B<G;B++){I=m[B];I.divideScalar(Math.sqrt(I.x*I.x+I.y*I.y+I.z*I.z))}G=p.objects;p=0;for(B=G.length;p<B;p++){I=G[p];var H;if(!(H=!I.visible)){if(H=I instanceof THREE.Mesh){a:{H=void 0;for(var w=I.position,R=-I.geometry.boundingSphere.radius*Math.max(I.scale.x,Math.max(I.scale.y,I.scale.z)),L=0;L<6;L++){H=m[L].x*w.x+m[L].y*w.y+m[L].z*w.z+m[L].w;if(H<=R){H=false;break a}}H=true}H=!H}H=H}if(!H){e=
g[f]=g[f]||new THREE.RenderableObject;E.copy(I.position);r.multiplyVector3(E);e.object=I;e.z=E.z;v.push(e);f++}}P&&v.sort(a);return v};this.projectScene=function(p,B,P){var v=[],G=B.near,I=B.far,H,w,R,L,X,Z,S,ga,$,U,W,ea,aa,J,V,Y;d=q=A=0;B.autoUpdateMatrix&&B.updateMatrix();r.multiply(B.projectionMatrix,B.matrix);Z=this.projectObjects(p,B,true);p=0;for(H=Z.length;p<H;p++){S=Z[p].object;if(S.visible){S.autoUpdateMatrix&&S.updateMatrix();ga=S.matrix;$=S.rotationMatrix;U=S.materials;W=S.overdraw;if(S instanceof
THREE.Mesh){ea=S.geometry;aa=ea.vertices;w=0;for(R=aa.length;w<R;w++){J=aa[w];J.positionWorld.copy(J.position);ga.multiplyVector3(J.positionWorld);L=J.positionScreen;L.copy(J.positionWorld);r.multiplyVector4(L);L.x/=L.w;L.y/=L.w;J.__visible=L.z>G&&L.z<I}ea=ea.faces;w=0;for(R=ea.length;w<R;w++){J=ea[w];if(J instanceof THREE.Face3){L=aa[J.a];X=aa[J.b];V=aa[J.c];if(L.__visible&&X.__visible&&V.__visible)if(S.doubleSided||S.flipSided!=(V.positionScreen.x-L.positionScreen.x)*(X.positionScreen.y-L.positionScreen.y)-
(V.positionScreen.y-L.positionScreen.y)*(X.positionScreen.x-L.positionScreen.x)<0){i=j[d]=j[d]||new THREE.RenderableFace3;i.v1.positionWorld.copy(L.positionWorld);i.v2.positionWorld.copy(X.positionWorld);i.v3.positionWorld.copy(V.positionWorld);i.v1.positionScreen.copy(L.positionScreen);i.v2.positionScreen.copy(X.positionScreen);i.v3.positionScreen.copy(V.positionScreen);i.normalWorld.copy(J.normal);$.multiplyVector3(i.normalWorld);i.centroidWorld.copy(J.centroid);ga.multiplyVector3(i.centroidWorld);
i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);V=J.vertexNormals;C=i.vertexNormalsWorld;L=0;for(X=V.length;L<X;L++){Y=C[L]=C[L]||new THREE.Vector3;Y.copy(V[L]);$.multiplyVector3(Y)}i.z=i.centroidScreen.z;i.meshMaterials=U;i.faceMaterials=J.materials;i.overdraw=W;if(S.geometry.uvs[w]){i.uvs[0]=S.geometry.uvs[w][0];i.uvs[1]=S.geometry.uvs[w][1];i.uvs[2]=S.geometry.uvs[w][2]}v.push(i);d++}}else if(J instanceof THREE.Face4){L=aa[J.a];X=aa[J.b];V=aa[J.c];Y=aa[J.d];if(L.__visible&&
X.__visible&&V.__visible&&Y.__visible)if(S.doubleSided||S.flipSided!=((Y.positionScreen.x-L.positionScreen.x)*(X.positionScreen.y-L.positionScreen.y)-(Y.positionScreen.y-L.positionScreen.y)*(X.positionScreen.x-L.positionScreen.x)<0||(X.positionScreen.x-V.positionScreen.x)*(Y.positionScreen.y-V.positionScreen.y)-(X.positionScreen.y-V.positionScreen.y)*(Y.positionScreen.x-V.positionScreen.x)<0)){i=j[d]=j[d]||new THREE.RenderableFace3;i.v1.positionWorld.copy(L.positionWorld);i.v2.positionWorld.copy(X.positionWorld);
i.v3.positionWorld.copy(Y.positionWorld);i.v1.positionScreen.copy(L.positionScreen);i.v2.positionScreen.copy(X.positionScreen);i.v3.positionScreen.copy(Y.positionScreen);i.normalWorld.copy(J.normal);$.multiplyVector3(i.normalWorld);i.centroidWorld.copy(J.centroid);ga.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=U;i.faceMaterials=J.materials;i.overdraw=W;if(S.geometry.uvs[w]){i.uvs[0]=S.geometry.uvs[w][0];
i.uvs[1]=S.geometry.uvs[w][1];i.uvs[2]=S.geometry.uvs[w][3]}v.push(i);d++;k=j[d]=j[d]||new THREE.RenderableFace3;k.v1.positionWorld.copy(X.positionWorld);k.v2.positionWorld.copy(V.positionWorld);k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(X.positionScreen);k.v2.positionScreen.copy(V.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(i.normalWorld);k.centroidWorld.copy(i.centroidWorld);k.centroidScreen.copy(i.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=
U;k.faceMaterials=J.materials;k.overdraw=W;if(S.geometry.uvs[w]){k.uvs[0]=S.geometry.uvs[w][1];k.uvs[1]=S.geometry.uvs[w][2];k.uvs[2]=S.geometry.uvs[w][3]}v.push(k);d++}}}}else if(S instanceof THREE.Line){O.multiply(r,ga);aa=S.geometry.vertices;J=aa[0];J.positionScreen.copy(J.position);O.multiplyVector4(J.positionScreen);w=1;for(R=aa.length;w<R;w++){L=aa[w];L.positionScreen.copy(L.position);O.multiplyVector4(L.positionScreen);X=aa[w-1];h.copy(L.positionScreen);n.copy(X.positionScreen);if(b(h,n)){h.multiplyScalar(1/
h.w);n.multiplyScalar(1/n.w);l=F[q]=F[q]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(n);l.z=Math.max(h.z,n.z);l.materials=S.materials;v.push(l);q++}}}else if(S instanceof THREE.Particle){N.set(S.position.x,S.position.y,S.position.z,1);r.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){o=D[A]=D[A]||new THREE.RenderableParticle;o.x=N.x/N.w;o.y=N.y/N.w;o.z=N.z;o.rotation=S.rotation.z;o.scale.x=S.scale.x*Math.abs(o.x-(N.x+B.projectionMatrix.n11)/(N.w+B.projectionMatrix.n14));
o.scale.y=S.scale.y*Math.abs(o.y-(N.y+B.projectionMatrix.n22)/(N.w+B.projectionMatrix.n24));o.materials=S.materials;v.push(o);A++}}}}P&&v.sort(a);return v};this.unprojectVector=function(p,B){var P=new THREE.Matrix4;P.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));P.multiplyVector3(p);return p}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,i;this.domElement=document.createElement("div");this.setSize=function(k,d){e=k;f=d;g=e/2;i=f/2};this.render=function(k,d){var j,l,q,F,o,A,D,E;a=b.projectScene(k,d);j=0;for(l=a.length;j<l;j++){o=a[j];if(o instanceof THREE.RenderableParticle){D=o.x*g+g;E=o.y*i+i;q=0;for(F=o.material.length;q<F;q++){A=o.material[q];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=D+"px";A.style.top=E+"px"}}}}}};
THREE.CanvasRenderer=function(){function a(pa){if(o!=pa)l.globalAlpha=o=pa}function b(pa){if(A!=pa){switch(pa){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}A=pa}}var e=null,f=new THREE.Projector,g=document.createElement("canvas"),i,k,d,j,l=g.getContext("2d"),q=null,F=null,o=1,A=0,D=null,E=null,N=1,r,O,m,h,n,C,p,B,P,v=new THREE.Color,
G=new THREE.Color,I=new THREE.Color,H=new THREE.Color,w=new THREE.Color,R,L,X,Z,S,ga,$,U,W,ea=new THREE.Rectangle,aa=new THREE.Rectangle,J=new THREE.Rectangle,V=false,Y=new THREE.Color,la=new THREE.Color,ka=new THREE.Color,u=new THREE.Color,M=Math.PI*2,K=new THREE.Vector3,ba,fa,ja,ma,ta,va,Ba=16;ba=document.createElement("canvas");ba.width=ba.height=2;fa=ba.getContext("2d");fa.fillStyle="rgba(0,0,0,1)";fa.fillRect(0,0,2,2);ja=fa.getImageData(0,0,2,2);ma=ja.data;ta=document.createElement("canvas");
ta.width=ta.height=Ba;va=ta.getContext("2d");va.translate(-Ba/2,-Ba/2);va.scale(Ba,Ba);Ba--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(pa,za){i=pa;k=za;d=i/2;j=k/2;g.width=i;g.height=k;ea.set(-d,-j,d,j);o=1;A=0;E=D=null;N=1};this.setClearColor=function(pa,za){q=pa!==null?new THREE.Color(pa):null;F=za;aa.set(-d,-j,d,j);l.setTransform(1,0,0,-1,d,j);this.clear()};this.clear=function(){if(!aa.isEmpty()){aa.inflate(1);aa.minSelf(ea);if(q!==null){b(THREE.NormalBlending);
a(1);l.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+F+")";l.fillRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight())}else l.clearRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight());aa.empty()}};this.render=function(pa,za){function Sa(Q){var ha,da,T,ca=Q.lights;la.setRGB(0,0,0);ka.setRGB(0,0,0);u.setRGB(0,0,0);Q=0;for(ha=ca.length;Q<ha;Q++){da=ca[Q];T=da.color;if(da instanceof THREE.AmbientLight){la.r+=T.r;la.g+=T.g;la.b+=T.b}else if(da instanceof THREE.DirectionalLight){ka.r+=
T.r;ka.g+=T.g;ka.b+=T.b}else if(da instanceof THREE.PointLight){u.r+=T.r;u.g+=T.g;u.b+=T.b}}}function Ga(Q,ha,da,T){var ca,ia,oa,qa,ra=Q.lights;Q=0;for(ca=ra.length;Q<ca;Q++){ia=ra[Q];oa=ia.color;qa=ia.intensity;if(ia instanceof THREE.DirectionalLight){ia=da.dot(ia.position)*qa;if(ia>0){T.r+=oa.r*ia;T.g+=oa.g*ia;T.b+=oa.b*ia}}else if(ia instanceof THREE.PointLight){K.sub(ia.position,ha);K.normalize();ia=da.dot(K)*qa;if(ia>0){T.r+=oa.r*ia;T.g+=oa.g*ia;T.b+=oa.b*ia}}}}function Ta(Q,ha,da){if(da.opacity!=
0){a(da.opacity);b(da.blending);var T,ca,ia,oa,qa,ra;if(da instanceof THREE.ParticleBasicMaterial){if(da.map){oa=da.map;qa=oa.width>>1;ra=oa.height>>1;ca=ha.scale.x*d;ia=ha.scale.y*j;da=ca*qa;T=ia*ra;J.set(Q.x-da,Q.y-T,Q.x+da,Q.y+T);if(ea.instersects(J)){l.save();l.translate(Q.x,Q.y);l.rotate(-ha.rotation);l.scale(ca,-ia);l.translate(-qa,-ra);l.drawImage(oa,0,0);l.restore()}}}else if(da instanceof THREE.ParticleCircleMaterial){if(V){Y.r=la.r+ka.r+u.r;Y.g=la.g+ka.g+u.g;Y.b=la.b+ka.b+u.b;v.r=da.color.r*
Y.r;v.g=da.color.g*Y.g;v.b=da.color.b*Y.b;v.updateStyleString()}else v.__styleString=da.color.__styleString;da=ha.scale.x*d;T=ha.scale.y*j;J.set(Q.x-da,Q.y-T,Q.x+da,Q.y+T);if(ea.instersects(J)){ca=v.__styleString;if(E!=ca)l.fillStyle=E=ca;l.save();l.translate(Q.x,Q.y);l.rotate(-ha.rotation);l.scale(da,T);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ua(Q,ha,da,T){if(T.opacity!=0){a(T.opacity);b(T.blending);l.beginPath();l.moveTo(Q.positionScreen.x,Q.positionScreen.y);
l.lineTo(ha.positionScreen.x,ha.positionScreen.y);l.closePath();if(T instanceof THREE.LineBasicMaterial){v.__styleString=T.color.__styleString;Q=T.linewidth;if(N!=Q)l.lineWidth=N=Q;Q=v.__styleString;if(D!=Q)l.strokeStyle=D=Q;l.stroke();J.inflate(T.linewidth*2)}}}function Oa(Q,ha,da,T,ca,ia){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);h=Q.positionScreen.x;n=Q.positionScreen.y;C=ha.positionScreen.x;p=ha.positionScreen.y;B=da.positionScreen.x;P=da.positionScreen.y;l.beginPath();l.moveTo(h,n);l.lineTo(C,
p);l.lineTo(B,P);l.lineTo(h,n);l.closePath();if(ca instanceof THREE.MeshBasicMaterial)if(ca.map)ca.map.image.loaded&&ca.map.mapping instanceof THREE.UVMapping&&Da(h,n,C,p,B,P,ca.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if(ca.env_map){if(ca.env_map.image.loaded)if(ca.env_map.mapping instanceof THREE.SphericalReflectionMapping){Q=za.matrix;K.copy(T.vertexNormalsWorld[0]);Z=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;S=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;K.copy(T.vertexNormalsWorld[1]);
ga=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;$=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;K.copy(T.vertexNormalsWorld[2]);U=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;W=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;Da(h,n,C,p,B,P,ca.env_map.image,Z,S,ga,$,U,W)}}else ca.wireframe?Ha(ca.color.__styleString,ca.wireframe_linewidth):Ia(ca.color.__styleString);else if(ca instanceof THREE.MeshLambertMaterial){if(ca.map&&!ca.wireframe){ca.map.mapping instanceof THREE.UVMapping&&Da(h,n,C,p,B,P,ca.map.image,T.uvs[0].u,
T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(V)if(!ca.wireframe&&ca.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){G.r=I.r=H.r=la.r;G.g=I.g=H.g=la.g;G.b=I.b=H.b=la.b;Ga(ia,T.v1.positionWorld,T.vertexNormalsWorld[0],G);Ga(ia,T.v2.positionWorld,T.vertexNormalsWorld[1],I);Ga(ia,T.v3.positionWorld,T.vertexNormalsWorld[2],H);w.r=(I.r+H.r)*0.5;w.g=(I.g+H.g)*0.5;w.b=(I.b+H.b)*0.5;X=Pa(G,I,H,w);Da(h,n,C,p,B,P,X,0,0,1,0,0,1)}else{Y.r=la.r;Y.g=la.g;
Y.b=la.b;Ga(ia,T.centroidWorld,T.normalWorld,Y);v.r=ca.color.r*Y.r;v.g=ca.color.g*Y.g;v.b=ca.color.b*Y.b;v.updateStyleString();ca.wireframe?Ha(v.__styleString,ca.wireframe_linewidth):Ia(v.__styleString)}else ca.wireframe?Ha(ca.color.__styleString,ca.wireframe_linewidth):Ia(ca.color.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){R=za.near;L=za.far;G.r=G.g=G.b=1-Ka(Q.positionScreen.z,R,L);I.r=I.g=I.b=1-Ka(ha.positionScreen.z,R,L);H.r=H.g=H.b=1-Ka(da.positionScreen.z,R,L);w.r=(I.r+H.r)*
0.5;w.g=(I.g+H.g)*0.5;w.b=(I.b+H.b)*0.5;X=Pa(G,I,H,w);Da(h,n,C,p,B,P,X,0,0,1,0,0,1)}else if(ca instanceof THREE.MeshNormalMaterial){v.r=La(T.normalWorld.x);v.g=La(T.normalWorld.y);v.b=La(T.normalWorld.z);v.updateStyleString();ca.wireframe?Ha(v.__styleString,ca.wireframe_linewidth):Ia(v.__styleString)}}}function Ha(Q,ha){if(D!=Q)l.strokeStyle=D=Q;if(N!=ha)l.lineWidth=N=ha;l.stroke();J.inflate(ha*2)}function Ia(Q){if(E!=Q)l.fillStyle=E=Q;l.fill()}function Da(Q,ha,da,T,ca,ia,oa,qa,ra,wa,sa,xa,Ea){var Aa,
ya;Aa=oa.width-1;ya=oa.height-1;qa*=Aa;ra*=ya;wa*=Aa;sa*=ya;xa*=Aa;Ea*=ya;da-=Q;T-=ha;ca-=Q;ia-=ha;wa-=qa;sa-=ra;xa-=qa;Ea-=ra;ya=1/(wa*Ea-xa*sa);Aa=(Ea*da-sa*ca)*ya;sa=(Ea*T-sa*ia)*ya;da=(wa*ca-xa*da)*ya;T=(wa*ia-xa*T)*ya;Q=Q-Aa*qa-da*ra;ha=ha-sa*qa-T*ra;l.save();l.transform(Aa,sa,da,T,Q,ha);l.clip();l.drawImage(oa,0,0);l.restore()}function Pa(Q,ha,da,T){var ca=~~(Q.r*255),ia=~~(Q.g*255);Q=~~(Q.b*255);var oa=~~(ha.r*255),qa=~~(ha.g*255);ha=~~(ha.b*255);var ra=~~(da.r*255),wa=~~(da.g*255);da=~~(da.b*
255);var sa=~~(T.r*255),xa=~~(T.g*255);T=~~(T.b*255);ma[0]=ca<0?0:ca>255?255:ca;ma[1]=ia<0?0:ia>255?255:ia;ma[2]=Q<0?0:Q>255?255:Q;ma[4]=oa<0?0:oa>255?255:oa;ma[5]=qa<0?0:qa>255?255:qa;ma[6]=ha<0?0:ha>255?255:ha;ma[8]=ra<0?0:ra>255?255:ra;ma[9]=wa<0?0:wa>255?255:wa;ma[10]=da<0?0:da>255?255:da;ma[12]=sa<0?0:sa>255?255:sa;ma[13]=xa<0?0:xa>255?255:xa;ma[14]=T<0?0:T>255?255:T;fa.putImageData(ja,0,0);va.drawImage(ba,0,0);return ta}function Ka(Q,ha,da){Q=(Q-ha)/(da-ha);return Q*Q*(3-2*Q)}function La(Q){Q=
(Q+1)*0.5;return Q<0?0:Q>1?1:Q}function Ma(Q,ha){var da=ha.x-Q.x,T=ha.y-Q.y,ca=1/Math.sqrt(da*da+T*T);da*=ca;T*=ca;ha.x+=da;ha.y+=T;Q.x-=da;Q.y-=T}var Ja,Qa,na,ua,Ca,Na,Ra,Fa;l.setTransform(1,0,0,-1,d,j);this.autoClear&&this.clear();e=f.projectScene(pa,za,this.sortElements);(V=pa.lights.length>0)&&Sa(pa);Ja=0;for(Qa=e.length;Ja<Qa;Ja++){na=e[Ja];J.empty();if(na instanceof THREE.RenderableParticle){r=na;r.x*=d;r.y*=j;ua=0;for(Ca=na.materials.length;ua<Ca;ua++)Ta(r,na,na.materials[ua],pa)}else if(na instanceof
THREE.RenderableLine){r=na.v1;O=na.v2;r.positionScreen.x*=d;r.positionScreen.y*=j;O.positionScreen.x*=d;O.positionScreen.y*=j;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(O.positionScreen.x,O.positionScreen.y);if(ea.instersects(J)){ua=0;for(Ca=na.materials.length;ua<Ca;)Ua(r,O,na,na.materials[ua++],pa)}}else if(na instanceof THREE.RenderableFace3){r=na.v1;O=na.v2;m=na.v3;r.positionScreen.x*=d;r.positionScreen.y*=j;O.positionScreen.x*=d;O.positionScreen.y*=j;m.positionScreen.x*=d;m.positionScreen.y*=
j;if(na.overdraw){Ma(r.positionScreen,O.positionScreen);Ma(O.positionScreen,m.positionScreen);Ma(m.positionScreen,r.positionScreen)}J.add3Points(r.positionScreen.x,r.positionScreen.y,O.positionScreen.x,O.positionScreen.y,m.positionScreen.x,m.positionScreen.y);if(ea.instersects(J)){ua=0;for(Ca=na.meshMaterials.length;ua<Ca;){Fa=na.meshMaterials[ua++];if(Fa instanceof THREE.MeshFaceMaterial){Na=0;for(Ra=na.faceMaterials.length;Na<Ra;)(Fa=na.faceMaterials[Na++])&&Oa(r,O,m,na,Fa,pa)}else Oa(r,O,m,na,
Fa,pa)}}}aa.addRectangle(J)}l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(Z,S,ga){var $,U,W,ea;$=0;for(U=Z.lights.length;$<U;$++){W=Z.lights[$];if(W instanceof THREE.DirectionalLight){ea=S.normalWorld.dot(W.position)*W.intensity;if(ea>0){ga.r+=W.color.r*ea;ga.g+=W.color.g*ea;ga.b+=W.color.b*ea}}else if(W instanceof THREE.PointLight){P.sub(W.position,S.centroidWorld);P.normalize();ea=S.normalWorld.dot(P)*W.intensity;if(ea>0){ga.r+=W.color.r*ea;ga.g+=W.color.g*ea;ga.b+=W.color.b*ea}}}}function b(Z,S,ga,$,U,W){H=f(w++);H.setAttribute("d",
"M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(O){h.r=n.r;h.g=n.g;h.b=n.b;a(W,$,h);m.r=U.color.r*h.r;m.g=U.color.g*h.g;m.b=U.color.b*h.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshDepthMaterial){B=1-U.__2near/(U.__farPlusNear-
$.z*U.__farMinusNear);m.setRGB(B,B,B)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(g($.normalWorld.x),g($.normalWorld.y),g($.normalWorld.z));U.wireframe?H.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):H.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+U.opacity);d.appendChild(H)}function e(Z,S,ga,$,U,W,ea){H=
f(w++);H.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)m.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(O){h.r=n.r;h.g=n.g;h.b=n.b;a(ea,U,h);m.r=W.color.r*h.r;m.g=W.color.g*h.g;m.b=W.color.b*h.b;m.updateStyleString()}else m.__styleString=W.color.__styleString;
else if(W instanceof THREE.MeshDepthMaterial){B=1-W.__2near/(W.__farPlusNear-U.z*W.__farMinusNear);m.setRGB(B,B,B)}else W instanceof THREE.MeshNormalMaterial&&m.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));W.wireframe?H.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):H.setAttribute("style","fill: "+m.__styleString+
"; fill-opacity: "+W.opacity);d.appendChild(H)}function f(Z){if(v[Z]==null){v[Z]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&v[Z].setAttribute("shape-rendering","crispEdges");return v[Z]}return v[Z]}function g(Z){return Z<0?Math.min((1+Z)*0.5,0.5):0.5+Math.min(Z*0.5,0.5)}var i=null,k=new THREE.Projector,d=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,q,F,o,A,D,E,N=new THREE.Rectangle,r=new THREE.Rectangle,O=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),
n=new THREE.Color(0),C=new THREE.Color(0),p=new THREE.Color(0),B,P=new THREE.Vector3,v=[],G=[],I=[],H,w,R,L,X=1;this.domElement=d;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Z){switch(Z){case "high":X=1;break;case "low":X=0}};this.setSize=function(Z,S){j=Z;l=S;q=j/2;F=l/2;d.setAttribute("viewBox",-q+" "+-F+" "+j+" "+l);d.setAttribute("width",j);d.setAttribute("height",l);N.set(-q,-F,q,F)};this.clear=function(){for(;d.childNodes.length>0;)d.removeChild(d.childNodes[0])};
this.render=function(Z,S){var ga,$,U,W,ea,aa,J,V;this.autoClear&&this.clear();i=k.projectScene(Z,S,this.sortElements);L=R=w=0;if(O=Z.lights.length>0){J=Z.lights;n.setRGB(0,0,0);C.setRGB(0,0,0);p.setRGB(0,0,0);ga=0;for($=J.length;ga<$;ga++){U=J[ga];W=U.color;if(U instanceof THREE.AmbientLight){n.r+=W.r;n.g+=W.g;n.b+=W.b}else if(U instanceof THREE.DirectionalLight){C.r+=W.r;C.g+=W.g;C.b+=W.b}else if(U instanceof THREE.PointLight){p.r+=W.r;p.g+=W.g;p.b+=W.b}}}ga=0;for($=i.length;ga<$;ga++){J=i[ga];r.empty();
if(J instanceof THREE.RenderableParticle){o=J;o.x*=q;o.y*=-F;U=0;for(W=J.materials.length;U<W;U++)if(V=J.materials[U]){ea=o;aa=J;V=V;var Y=R++;if(G[Y]==null){G[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&G[Y].setAttribute("shape-rendering","crispEdges")}H=G[Y];H.setAttribute("cx",ea.x);H.setAttribute("cy",ea.y);H.setAttribute("r",aa.scale.x*q);if(V instanceof THREE.ParticleCircleMaterial){if(O){h.r=n.r+C.r+p.r;h.g=n.g+C.g+p.g;h.b=n.b+C.b+p.b;m.r=V.color.r*h.r;m.g=V.color.g*
h.g;m.b=V.color.b*h.b;m.updateStyleString()}else m=V.color;H.setAttribute("style","fill: "+m.__styleString)}d.appendChild(H)}}else if(J instanceof THREE.RenderableLine){o=J.v1;A=J.v2;o.positionScreen.x*=q;o.positionScreen.y*=-F;A.positionScreen.x*=q;A.positionScreen.y*=-F;r.addPoint(o.positionScreen.x,o.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);if(N.instersects(r)){U=0;for(W=J.materials.length;U<W;)if(V=J.materials[U++]){ea=o;aa=A;V=V;Y=L++;if(I[Y]==null){I[Y]=document.createElementNS("http://www.w3.org/2000/svg",
"line");X==0&&I[Y].setAttribute("shape-rendering","crispEdges")}H=I[Y];H.setAttribute("x1",ea.positionScreen.x);H.setAttribute("y1",ea.positionScreen.y);H.setAttribute("x2",aa.positionScreen.x);H.setAttribute("y2",aa.positionScreen.y);if(V instanceof THREE.LineBasicMaterial){m.__styleString=V.color.__styleString;H.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+V.linewidth+"; stroke-opacity: "+V.opacity+"; stroke-linecap: "+V.linecap+"; stroke-linejoin: "+V.linejoin);
d.appendChild(H)}}}}else if(J instanceof THREE.RenderableFace3){o=J.v1;A=J.v2;D=J.v3;o.positionScreen.x*=q;o.positionScreen.y*=-F;A.positionScreen.x*=q;A.positionScreen.y*=-F;D.positionScreen.x*=q;D.positionScreen.y*=-F;r.addPoint(o.positionScreen.x,o.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);if(N.instersects(r)){U=0;for(W=J.meshMaterials.length;U<W;){V=J.meshMaterials[U++];if(V instanceof THREE.MeshFaceMaterial){ea=0;for(aa=
J.faceMaterials.length;ea<aa;)(V=J.faceMaterials[ea++])&&b(o,A,D,J,V,Z)}else V&&b(o,A,D,J,V,Z)}}}else if(J instanceof THREE.RenderableFace4){o=J.v1;A=J.v2;D=J.v3;E=J.v4;o.positionScreen.x*=q;o.positionScreen.y*=-F;A.positionScreen.x*=q;A.positionScreen.y*=-F;D.positionScreen.x*=q;D.positionScreen.y*=-F;E.positionScreen.x*=q;E.positionScreen.y*=-F;r.addPoint(o.positionScreen.x,o.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);r.addPoint(E.positionScreen.x,
E.positionScreen.y);if(N.instersects(r)){U=0;for(W=J.meshMaterials.length;U<W;){V=J.meshMaterials[U++];if(V instanceof THREE.MeshFaceMaterial){ea=0;for(aa=J.faceMaterials.length;ea<aa;)(V=J.faceMaterials[ea++])&&e(o,A,D,E,J,V,Z)}else V&&e(o,A,D,E,J,V,Z)}}}}}};
THREE.WebGLRenderer=function(a){function b(h,n){h.fragment_shader=n.fragment_shader;h.vertex_shader=n.vertex_shader;h.uniforms=Uniforms.clone(n.uniforms)}function e(h,n){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;h.uniforms.map.texture=h.map;h.uniforms.env_map.texture=h.env_map;h.uniforms.reflectivity.value=h.reflectivity;h.uniforms.refraction_ratio.value=h.refraction_ratio;h.uniforms.combine.value=h.combine;h.uniforms.useRefract.value=
h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;if(n){h.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){h.uniforms.fogNear.value=n.near;h.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)h.uniforms.fogDensity.value=n.density}}function f(h,n){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;if(n){h.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){h.uniforms.fogNear.value=
n.near;h.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)h.uniforms.fogDensity.value=n.density}}function g(h,n){var C;if(h=="fragment")C=d.createShader(d.FRAGMENT_SHADER);else if(h=="vertex")C=d.createShader(d.VERTEX_SHADER);d.shaderSource(C,n);d.compileShader(C);if(!d.getShaderParameter(C,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(C));return null}return C}function i(h){switch(h){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;
case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;
case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var k=document.createElement("canvas"),d,j=null,l=null,q=new THREE.Matrix4,F,o=new Float32Array(16),A=new Float32Array(16),D=new Float32Array(16),E=new Float32Array(9),
N=new Float32Array(16),r=true,O=new THREE.Color(0),m=0;if(a){if(a.antialias!==undefined)r=a.antialias;a.clearColor!==undefined&&O.setHex(a.clearColor);if(a.clearAlpha!==undefined)m=a.clearAlpha}this.domElement=k;this.autoClear=true;(function(h,n,C){try{d=k.getContext("experimental-webgl",{antialias:h})}catch(p){}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);
d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(n.r,n.g,n.b,C)})(r,O,m);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(h,n){k.width=h;k.height=n;d.viewport(0,0,k.width,k.height)};this.setClearColor=function(h,n){var C=new THREE.Color(h);d.clearColor(C.r,C.g,C.b,n)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=
function(h,n){var C,p,B,P=0,v=0,G=0,I,H,w,R=this.lights,L=R.directional.colors,X=R.directional.positions,Z=R.point.colors,S=R.point.positions,ga=0,$=0;C=0;for(p=n.length;C<p;C++){B=n[C];I=B.color;H=B.position;w=B.intensity;if(B instanceof THREE.AmbientLight){P+=I.r;v+=I.g;G+=I.b}else if(B instanceof THREE.DirectionalLight){L[ga*3]=I.r*w;L[ga*3+1]=I.g*w;L[ga*3+2]=I.b*w;X[ga*3]=H.x;X[ga*3+1]=H.y;X[ga*3+2]=H.z;ga+=1}else if(B instanceof THREE.PointLight){Z[$*3]=I.r*w;Z[$*3+1]=I.g*w;Z[$*3+2]=I.b*w;S[$*
3]=H.x;S[$*3+1]=H.y;S[$*3+2]=H.z;$+=1}}R.point.length=$;R.directional.length=ga;R.ambient[0]=P;R.ambient[1]=v;R.ambient[2]=G};this.createParticleBuffers=function(h){h.__webGLVertexBuffer=d.createBuffer();h.__webGLFaceBuffer=d.createBuffer()};this.createLineBuffers=function(h){h.__webGLVertexBuffer=d.createBuffer();h.__webGLLineBuffer=d.createBuffer()};this.createMeshBuffers=function(h){h.__webGLVertexBuffer=d.createBuffer();h.__webGLNormalBuffer=d.createBuffer();h.__webGLTangentBuffer=d.createBuffer();
h.__webGLUVBuffer=d.createBuffer();h.__webGLFaceBuffer=d.createBuffer();h.__webGLLineBuffer=d.createBuffer()};this.initLineBuffers=function(h){var n=h.vertices.length;h.__vertexArray=new Float32Array(n*3);h.__lineArray=new Uint16Array(n);h.__webGLLineCount=n};this.initMeshBuffers=function(h,n){var C,p,B=0,P=0,v=0,G=n.geometry.faces,I=h.faces;C=0;for(p=I.length;C<p;C++){fi=I[C];face=G[fi];if(face instanceof THREE.Face3){B+=3;P+=1;v+=3}else if(face instanceof THREE.Face4){B+=4;P+=2;v+=4}}h.__vertexArray=
new Float32Array(B*3);h.__normalArray=new Float32Array(B*3);h.__tangentArray=new Float32Array(B*4);h.__uvArray=new Float32Array(B*2);h.__faceArray=new Uint16Array(P*3);h.__lineArray=new Uint16Array(v*2);B=false;C=0;for(p=n.materials.length;C<p;C++){G=n.materials[C];if(G instanceof THREE.MeshFaceMaterial){G=0;for(I=h.materials.length;G<I;G++)if(h.materials[G]&&h.materials[G].shading!=undefined&&h.materials[G].shading==THREE.SmoothShading){B=true;break}}else if(G&&G.shading!=undefined&&G.shading==THREE.SmoothShading){B=
true;break}if(B)break}h.__needsSmoothNormals=B;h.__webGLFaceCount=P*3;h.__webGLLineCount=v*2};this.setMeshBuffers=function(h,n,C,p,B,P,v,G){var I,H,w,R,L,X,Z,S,ga,$=0,U=0,W=0,ea=0,aa=0,J=0,V=0,Y=h.__vertexArray,la=h.__uvArray,ka=h.__normalArray,u=h.__tangentArray,M=h.__faceArray,K=h.__lineArray,ba=h.__needsSmoothNormals,fa=n.geometry,ja=fa.vertices,ma=h.faces,ta=fa.faces,va=fa.uvs;n=0;for(I=ma.length;n<I;n++){H=ma[n];w=ta[H];H=va[H];R=w.vertexNormals;L=w.normal;if(w instanceof THREE.Face3){if(p){X=
ja[w.a].position;Z=ja[w.b].position;S=ja[w.c].position;Y[U]=X.x;Y[U+1]=X.y;Y[U+2]=X.z;Y[U+3]=Z.x;Y[U+4]=Z.y;Y[U+5]=Z.z;Y[U+6]=S.x;Y[U+7]=S.y;Y[U+8]=S.z;U+=9}if(G&&fa.hasTangents){X=ja[w.a].tangent;Z=ja[w.b].tangent;S=ja[w.c].tangent;u[J]=X.x;u[J+1]=X.y;u[J+2]=X.z;u[J+3]=X.w;u[J+4]=Z.x;u[J+5]=Z.y;u[J+6]=Z.z;u[J+7]=Z.w;u[J+8]=S.x;u[J+9]=S.y;u[J+10]=S.z;u[J+11]=S.w;J+=12}if(v)if(R.length==3&&ba)for(w=0;w<3;w++){L=R[w];ka[aa]=L.x;ka[aa+1]=L.y;ka[aa+2]=L.z;aa+=3}else for(w=0;w<3;w++){ka[aa]=L.x;ka[aa+
1]=L.y;ka[aa+2]=L.z;aa+=3}if(P&&H)for(w=0;w<3;w++){R=H[w];la[W]=R.u;la[W+1]=R.v;W+=2}if(B){M[ea]=$;M[ea+1]=$+1;M[ea+2]=$+2;ea+=3;K[V]=$;K[V+1]=$+1;K[V+2]=$;K[V+3]=$+2;K[V+4]=$+1;K[V+5]=$+2;V+=6;$+=3}}else if(w instanceof THREE.Face4){if(p){X=ja[w.a].position;Z=ja[w.b].position;S=ja[w.c].position;ga=ja[w.d].position;Y[U]=X.x;Y[U+1]=X.y;Y[U+2]=X.z;Y[U+3]=Z.x;Y[U+4]=Z.y;Y[U+5]=Z.z;Y[U+6]=S.x;Y[U+7]=S.y;Y[U+8]=S.z;Y[U+9]=ga.x;Y[U+10]=ga.y;Y[U+11]=ga.z;U+=12}if(G&&fa.hasTangents){X=ja[w.a].tangent;Z=ja[w.b].tangent;
S=ja[w.c].tangent;w=ja[w.d].tangent;u[J]=X.x;u[J+1]=X.y;u[J+2]=X.z;u[J+3]=X.w;u[J+4]=Z.x;u[J+5]=Z.y;u[J+6]=Z.z;u[J+7]=Z.w;u[J+8]=S.x;u[J+9]=S.y;u[J+10]=S.z;u[J+11]=S.w;u[J+12]=w.x;u[J+13]=w.y;u[J+14]=w.z;u[J+15]=w.w;J+=16}if(v)if(R.length==4&&ba)for(w=0;w<4;w++){L=R[w];ka[aa]=L.x;ka[aa+1]=L.y;ka[aa+2]=L.z;aa+=3}else for(w=0;w<4;w++){ka[aa]=L.x;ka[aa+1]=L.y;ka[aa+2]=L.z;aa+=3}if(P&&H)for(w=0;w<4;w++){R=H[w];la[W]=R.u;la[W+1]=R.v;W+=2}if(B){M[ea]=$;M[ea+1]=$+1;M[ea+2]=$+2;M[ea+3]=$;M[ea+4]=$+2;M[ea+
5]=$+3;ea+=6;K[V]=$;K[V+1]=$+1;K[V+2]=$;K[V+3]=$+3;K[V+4]=$+1;K[V+5]=$+2;K[V+6]=$+2;K[V+7]=$+3;V+=8;$+=4}}}if(p){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Y,C)}if(v){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,ka,C)}if(G&&fa.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,u,C)}if(P&&W>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,la,C)}if(B){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,
h.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,M,C);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,K,C)}};this.setLineBuffers=function(h,n,C,p){var B,P,v=h.vertices,G=v.length,I=h.__vertexArray,H=h.__lineArray;if(C)for(C=0;C<G;C++){B=v[C].position;P=C*3;I[P]=B.x;I[P+1]=B.y;I[P+2]=B.z}if(p)for(C=0;C<G;C++)H[C]=C;d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,I,n);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);
d.bufferData(d.ELEMENT_ARRAY_BUFFER,H,n)};this.setParticleBuffers=function(){};this.renderBuffer=function(h,n,C,p,B,P){var v,G,I,H;if(!p.program){if(p instanceof THREE.MeshDepthMaterial){b(p,THREE.ShaderLib.depth);p.uniforms.mNear.value=h.near;p.uniforms.mFar.value=h.far}else if(p instanceof THREE.MeshNormalMaterial)b(p,THREE.ShaderLib.normal);else if(p instanceof THREE.MeshBasicMaterial){b(p,THREE.ShaderLib.basic);e(p,C)}else if(p instanceof THREE.MeshLambertMaterial){b(p,THREE.ShaderLib.lambert);
e(p,C)}else if(p instanceof THREE.MeshPhongMaterial){b(p,THREE.ShaderLib.phong);e(p,C)}else if(p instanceof THREE.LineBasicMaterial){b(p,THREE.ShaderLib.basic);f(p,C)}var w,R,L;w=H=G=0;for(R=n.length;w<R;w++){L=n[w];L instanceof THREE.DirectionalLight&&H++;L instanceof THREE.PointLight&&G++}if(G+H<=4){w=H;G=G}else{w=Math.ceil(4*H/(G+H));G=4-w}G={directional:w,point:G};H={fog:C,map:p.map,env_map:p.env_map,maxDirLights:G.directional,maxPointLights:G.point};G=p.fragment_shader;w=p.vertex_shader;R=d.createProgram();
L=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+H.maxDirLights,"#define MAX_POINT_LIGHTS "+H.maxPointLights,H.fog?"#define USE_FOG":"",H.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",H.map?"#define USE_MAP":"",H.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");H=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+H.maxDirLights,"#define MAX_POINT_LIGHTS "+H.maxPointLights,
H.map?"#define USE_MAP":"",H.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");d.attachShader(R,g("fragment",L+G));d.attachShader(R,g("vertex",H+w));d.linkProgram(R);d.getProgramParameter(R,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
d.getProgramParameter(R,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");R.uniforms={};R.attributes={};p.program=R;G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in p.uniforms)G.push(v);v=p.program;w=0;for(R=G.length;w<R;w++){L=G[w];v.uniforms[L]=d.getUniformLocation(v,L)}v=p.program;G=["position","normal","uv","tangent"];w=0;for(R=G.length;w<R;w++){L=G[w];v.attributes[L]=d.getAttribLocation(v,L)}}v=p.program;if(v!=j){d.useProgram(v);
j=v}this.loadCamera(v,h);this.loadMatrices(v);if(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial){this.setupLights(v,n);h=this.lights;p.uniforms.enableLighting.value=h.directional.length+h.point.length;p.uniforms.ambientLightColor.value=h.ambient;p.uniforms.directionalLightColor.value=h.directional.colors;p.uniforms.directionalLightDirection.value=h.directional.positions;p.uniforms.pointLightColor.value=h.point.colors;p.uniforms.pointLightPosition.value=h.point.positions}if(p instanceof
THREE.MeshBasicMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshPhongMaterial)e(p,C);p instanceof THREE.LineBasicMaterial&&f(p,C);if(p instanceof THREE.MeshPhongMaterial){p.uniforms.ambient.value.setRGB(p.ambient.r,p.ambient.g,p.ambient.b);p.uniforms.specular.value.setRGB(p.specular.r,p.specular.g,p.specular.b);p.uniforms.shininess.value=p.shininess}C=p.uniforms;for(I in C)if(w=v.uniforms[I]){n=C[I];G=n.type;h=n.value;if(G=="i")d.uniform1i(w,h);else if(G=="f")d.uniform1f(w,
h);else if(G=="fv1")d.uniform1fv(w,h);else if(G=="fv")d.uniform3fv(w,h);else if(G=="v2")d.uniform2f(w,h.x,h.y);else if(G=="v3")d.uniform3f(w,h.x,h.y,h.z);else if(G=="c")d.uniform3f(w,h.r,h.g,h.b);else if(G=="t"){d.uniform1i(w,h);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;h=h;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);
d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(G=0;G<6;++G)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+G,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image[G]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+
h);d.bindTexture(d.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;h=h;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,i(n.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,i(n.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,i(n.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,i(n.min_filter));
d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+h);d.bindTexture(d.TEXTURE_2D,n.__webGLTexture)}}}I=v.attributes;d.bindBuffer(d.ARRAY_BUFFER,B.__webGLVertexBuffer);d.vertexAttribPointer(I.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.position);if(I.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLNormalBuffer);d.vertexAttribPointer(I.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.normal)}if(I.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLTangentBuffer);
d.vertexAttribPointer(I.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.tangent)}if(I.uv>=0)if(B.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLUVBuffer);d.vertexAttribPointer(I.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.uv)}else d.disableVertexAttribArray(I.uv);if(p.wireframe||p instanceof THREE.LineBasicMaterial){I=p.wireframe_linewidth!==undefined?p.wireframe_linewidth:p.linewidth!==undefined?p.linewidth:1;p=p instanceof THREE.LineBasicMaterial&&P.type==THREE.LineStrip?
d.LINE_STRIP:d.LINES;d.lineWidth(I);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);d.drawElements(p,B.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,B.__webGLFaceCount,d.UNSIGNED_SHORT,0)}};this.renderPass=function(h,n,C,p,B,P,v){var G,I,H,w,R;H=0;for(w=p.materials.length;H<w;H++){G=p.materials[H];if(G instanceof THREE.MeshFaceMaterial){G=0;for(I=B.materials.length;G<I;G++)if((R=B.materials[G])&&R.blending==P&&
R.opacity<1==v){this.setBlending(R.blending);this.renderBuffer(h,n,C,R,B,p)}}else if((R=G)&&R.blending==P&&R.opacity<1==v){this.setBlending(R.blending);this.renderBuffer(h,n,C,R,B,p)}}};this.render=function(h,n,C,p){var B,P,v,G=h.lights,I=h.fog;this.initWebGLObjects(h);p=p!==undefined?p:true;if(C&&!C.__webGLFramebuffer){C.__webGLFramebuffer=d.createFramebuffer();C.__webGLRenderbuffer=d.createRenderbuffer();C.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,C.__webGLRenderbuffer);
d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,C.width,C.height);d.bindTexture(d.TEXTURE_2D,C.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,i(C.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,i(C.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,i(C.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,i(C.min_filter));d.texImage2D(d.TEXTURE_2D,0,i(C.format),C.width,C.height,0,i(C.format),i(C.type),null);d.bindFramebuffer(d.FRAMEBUFFER,C.__webGLFramebuffer);
d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,C.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,C.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}if(C){B=C.__webGLFramebuffer;v=C.width;P=C.height}else{B=null;v=k.width;P=k.height}if(B!=l){d.bindFramebuffer(d.FRAMEBUFFER,B);d.viewport(0,0,v,P);p&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);l=B}this.autoClear&&
this.clear();n.autoUpdateMatrix&&n.updateMatrix();o.set(n.matrix.flatten());D.set(n.projectionMatrix.flatten());p=0;for(B=h.__webGLObjects.length;p<B;p++){P=h.__webGLObjects[p];v=P.object;P=P.buffer;if(v.visible){this.setupMatrices(v,n);this.renderPass(n,G,I,v,P,THREE.NormalBlending,false)}}p=0;for(B=h.__webGLObjects.length;p<B;p++){P=h.__webGLObjects[p];v=P.object;P=P.buffer;if(v.visible){this.setupMatrices(v,n);if(v.doubleSided)d.disable(d.CULL_FACE);else{d.enable(d.CULL_FACE);v.flipSided?d.frontFace(d.CW):
d.frontFace(d.CCW)}this.renderPass(n,G,I,v,P,THREE.AdditiveBlending,false);this.renderPass(n,G,I,v,P,THREE.SubtractiveBlending,false);this.renderPass(n,G,I,v,P,THREE.AdditiveBlending,true);this.renderPass(n,G,I,v,P,THREE.SubtractiveBlending,true);this.renderPass(n,G,I,v,P,THREE.NormalBlending,true)}}if(C&&C.min_filter!==THREE.NearestFilter&&C.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,C.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=
function(h){function n(H,w,R,L){if(H[w]==undefined){h.__webGLObjects.push({buffer:R,object:L});H[w]=1}}var C,p,B,P,v,G,I;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}C=0;for(p=h.objects.length;C<p;C++){B=h.objects[C];v=B.geometry;if(h.__webGLObjectsMap[B.id]==undefined)h.__webGLObjectsMap[B.id]={};I=h.__webGLObjectsMap[B.id];if(B instanceof THREE.Mesh){for(P in v.geometryChunks){G=v.geometryChunks[P];if(!G.__webGLVertexBuffer){this.createMeshBuffers(G);this.initMeshBuffers(G,B);
v.__dirtyVertices=true;v.__dirtyElements=true;v.__dirtyUvs=true;v.__dirtyNormals=true;v.__dirtyTangents=true}if(v.__dirtyVertices||v.__dirtyElements||v.__dirtyUvs)this.setMeshBuffers(G,B,d.DYNAMIC_DRAW,v.__dirtyVertices,v.__dirtyElements,v.__dirtyUvs,v.__dirtyNormals,v.__dirtyTangents);n(I,P,G,B)}v.__dirtyVertices=false;v.__dirtyElements=false;v.__dirtyUvs=false;v.__dirtyNormals=false;v.__dirtyTangents=false}else if(B instanceof THREE.Line){if(!v.__webGLVertexBuffer){this.createLineBuffers(v);this.initLineBuffers(v);
v.__dirtyVertices=true;v.__dirtyElements=true}v.__dirtyVertices&&this.setLineBuffers(v,d.DYNAMIC_DRAW,v.__dirtyVertices,v.__dirtyElements);n(I,0,v,B);v.__dirtyVertices=false;v.__dirtyElements=false}else if(B instanceof THREE.ParticleSystem){v.__webGLVertexBuffer||this.createParticleBuffers(v);n(I,0,v,B)}}};this.removeObject=function(h,n){var C,p;for(C=h.__webGLObjects.length-1;C>=0;C--){p=h.__webGLObjects[C].object;n==p&&h.__webGLObjects.splice(C,1)}};this.setupMatrices=function(h,n){h.autoUpdateMatrix&&
h.updateMatrix();q.multiply(n.matrix,h.matrix);A.set(q.flatten());F=THREE.Matrix4.makeInvert3x3(q).transpose();E.set(F.m);N.set(h.matrix.flatten())};this.loadMatrices=function(h){d.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);d.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,A);d.uniformMatrix4fv(h.uniforms.projectionMatrix,false,D);d.uniformMatrix3fv(h.uniforms.normalMatrix,false,E);d.uniformMatrix4fv(h.uniforms.objectMatrix,false,N)};this.loadCamera=function(h,n){d.uniform3f(h.uniforms.cameraPosition,
n.position.x,n.position.y,n.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,n){if(h){!n||n=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(h=="back")d.cullFace(d.BACK);else h=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);
d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.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",
lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"};
THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",
value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}}};
THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",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,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
"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,b){var e=b instanceof THREE.Mesh,f=a.vertices.length,g=e?b.geometry:b,i=a.vertices,k=g.vertices,d=a.faces,j=g.faces,l=a.uvs;g=g.uvs;e&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,F=k.length;q<F;q++){var o=new THREE.Vertex(k[q].position.clone());e&&b.matrix.multiplyVector3(o.position);i.push(o)}q=0;for(F=j.length;q<F;q++){k=j[q];var A,D=k.vertexNormals;if(k instanceof THREE.Face3)A=new THREE.Face3(k.a+f,k.b+f,k.c+f);else if(k instanceof THREE.Face4)A=new THREE.Face4(k.a+
f,k.b+f,k.c+f,k.d+f);A.centroid.copy(k.centroid);A.normal.copy(k.normal);e=0;for(i=D.length;e<i;e++){o=D[e];A.vertexNormals.push(o.clone())}A.materials=k.materials.slice();d.push(A)}q=0;for(F=g.length;q<F;q++){f=g[q];d=[];e=0;for(i=f.length;e<i;e++)d.push(new THREE.UV(f[e].u,f[e].v));l.push(d)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,f=[];b=f.loadCount=0;for(e=a.length;b<e;++b){f[b]=
new Image;f[b].loaded=0;f[b].onload=function(){f.loadCount+=1;this.loaded=true};f[b].src=a[b]}return f}},SceneUtils={addMesh:function(a,b,e,f,g,i,k,d,j,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=f;b.position.y=g;b.position.z=i;b.rotation.x=k;b.rotation.y=d;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=e;e=new THREE.MeshShaderMaterial({fragment_shader:f.fragment_shader,vertex_shader:f.vertex_shader,
uniforms:f.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),e);a.addObject(b);return b},addPanoramaCube:function(a,b,e){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));
b=new THREE.Mesh(new Cube(b,b,b,1,1,f,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,e){var f=b/2;b=new Plane(b,b);var g=Math.PI/2,i=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-f,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,f,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,
b,1,0,f,0,g,0,i,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));SceneUtils.addMesh(a,b,1,0,-f,0,-g,0,i,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[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,b,e,f,g,i,k,d){function j(E,N,r,O,m,h,n,C){var p,B,P=f||1,v=g||1,G=P+1,I=v+1,H=m/2,w=h/2;m=m/P;var R=h/v,L=l.vertices.length;if(E=="x"&&N=="y"||E=="y"&&N=="x")p="z";else if(E=="x"&&N=="z"||E=="z"&&N=="x")p="y";else if(E=="z"&&N=="y"||E=="y"&&N=="z")p="x";for(B=0;B<I;B++)for(h=0;h<G;h++){var X=new THREE.Vector3;
X[E]=(h*m-H)*r;X[N]=(B*R-w)*O;X[p]=n;l.vertices.push(new THREE.Vertex(X))}for(B=0;B<v;B++)for(h=0;h<P;h++){l.faces.push(new THREE.Face4(h+G*B+L,h+G*(B+1)+L,h+1+G*(B+1)+L,h+1+G*B+L,null,C));l.uvs.push([new THREE.UV(h/P,B/v),new THREE.UV(h/P,(B+1)/v),new THREE.UV((h+1)/P,(B+1)/v),new THREE.UV((h+1)/P,B/v)])}}THREE.Geometry.call(this);var l=this,q=a/2,F=b/2,o=e/2;k=k?-1:1;if(i!==undefined)if(i instanceof Array)this.materials=i;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([i])}else this.materials=
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(d!=undefined)for(var D in d)if(this.sides[D]!=undefined)this.sides[D]=d[D];this.sides.px&&j("z","y",1*k,-1,e,b,-q,this.materials[0]);this.sides.nx&&j("z","y",-1*k,-1,e,b,q,this.materials[1]);this.sides.py&&j("x","z",1*k,1,a,e,F,this.materials[2]);this.sides.ny&&j("x","z",1*k,-1,a,e,-F,this.materials[3]);this.sides.pz&&j("x","y",1*k,-1,a,b,o,this.materials[4]);this.sides.nz&&j("x","y",-1*k,-1,a,b,-o,this.materials[5]);(function(){for(var E=
[],N=[],r=0,O=l.vertices.length;r<O;r++){for(var m=l.vertices[r],h=false,n=0,C=E.length;n<C;n++){var p=E[n];if(m.position.x==p.position.x&&m.position.y==p.position.y&&m.position.z==p.position.z){N[r]=n;h=true;break}}if(!h){N[r]=E.length;E.push(new THREE.Vertex(m.position.clone()))}}r=0;for(O=l.faces.length;r<O;r++){m=l.faces[r];m.a=N[m.a];m.b=N[m.b];m.c=N[m.c];m.d=N[m.d]}l.vertices=E})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,e,f,g){function i(l,q,F){k.vertices.push(new THREE.Vertex(new THREE.Vector3(l,q,F)))}THREE.Geometry.call(this);var k=this,d=Math.PI,j;for(j=0;j<a;j++)i(Math.sin(2*d*j/a)*b,Math.cos(2*d*j/a)*b,0);for(j=0;j<a;j++)i(Math.sin(2*d*j/a)*e,Math.cos(2*d*j/a)*e,f);for(j=0;j<a;j++)k.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(e!=0){i(0,0,-g);for(j=a;j<a+a/2;j++)k.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){i(0,0,f+g);for(j=a+a/2;j<
2*a;j++)k.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-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,b,e,f){THREE.Geometry.call(this);var g,i=a/2,k=b/2;e=e||1;f=f||1;var d=e+1,j=f+1;a=a/e;var l=b/f;for(g=0;g<j;g++)for(b=0;b<d;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-i,-(g*l-k),0)));for(g=0;g<f;g++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+d*g,b+d*(g+1),b+1+d*(g+1),b+1+d*g));this.uvs.push([new THREE.UV(b/e,g/f),new THREE.UV(b/e,(g+1)/f),new THREE.UV((b+1)/e,(g+1)/f),new THREE.UV((b+1)/e,g/f)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
var Sphere=function(a,b,e){THREE.Geometry.call(this);var f,g=Math.PI,i=Math.max(3,b||8),k=Math.max(2,e||6);b=[];for(e=0;e<k+1;e++){f=e/k;var d=a*Math.cos(f*g),j=a*Math.sin(f*g),l=[],q=0;for(f=0;f<i;f++){var F=2*f/i,o=j*Math.sin(F*g);F=j*Math.cos(F*g);(e==0||e==k)&&f>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(F,d,o)))-1);l.push(q)}b.push(l)}var A,D,E;g=b.length;for(e=0;e<g;e++){i=b[e].length;if(e>0)for(f=0;f<i;f++){l=f==i-1;k=b[e][l?0:f+1];d=b[e][l?i-1:f];j=b[e-1][l?i-1:f];l=b[e-1][l?
0:f+1];o=e/(g-1);A=(e-1)/(g-1);D=(f+1)/i;F=f/i;q=new THREE.UV(1-D,o);o=new THREE.UV(1-F,o);F=new THREE.UV(1-F,A);var N=new THREE.UV(1-D,A);if(e<b.length-1){A=this.vertices[k].position.clone();D=this.vertices[d].position.clone();E=this.vertices[j].position.clone();A.normalize();D.normalize();E.normalize();this.faces.push(new THREE.Face3(k,d,j,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([q,o,F])}if(e>1){A=this.vertices[k].position.clone();
D=this.vertices[j].position.clone();E=this.vertices[l].position.clone();A.normalize();D.normalize();E.normalize();this.faces.push(new THREE.Face3(k,j,l,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([q,F,N])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
function LathedObject(a,b,e){THREE.Geometry.call(this);b=b||12;e=e||2*Math.PI;b=e/b;for(var f=[],g=[],i=[],k=[],d=0;d<a.length;d++){this.vertices.push(new THREE.Vertex(a[d]));g[d]=this.vertices.length-1;f[d]=new THREE.Vector3(a[d].x,a[d].y,a[d].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),l=0;l<=e+0.001;l+=b){for(d=0;d<f.length;d++)if(l<e){f[d]=j.multiplyVector3(f[d].clone());this.vertices.push(new THREE.Vertex(f[d]));i[d]=this.vertices.length-1}else i=k;if(l==0)k=g;for(d=0;d<g.length-1;d++){this.faces.push(new THREE.Face4(i[d],
i[d+1],g[d+1],g[d]));this.uvs.push([new THREE.UV(l/e,d/a.length),new THREE.UV(l/e,(d+1)/a.length),new THREE.UV((l-b)/e,(d+1)/a.length),new THREE.UV((l-b)/e,d/a.length)])}g=i;i=[]}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 e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a){var b=a.model,e=a.callback,f=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,e,f)};b.postMessage(a)},loadBinary:function(a){var b=a.model,e=a.callback,f=a.texture_path?a.texture_path:
THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var i=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(k){THREE.Loader.prototype.loadAjaxBuffers(k.data.buffers,k.data.materials,e,g,f,i)};b.onerror=function(k){alert("worker.onerror: "+k.message+"\n"+k.data);k.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,e,f,g,i){var k=new XMLHttpRequest,d=f+"/"+a,j=0;
k.onreadystatechange=function(){if(k.readyState==4)k.status==200||k.status==0?THREE.Loader.prototype.createBinModel(k.responseText,e,g,b):alert("Couldn't load ["+d+"] ["+k.status+"]");else if(k.readyState==3){if(i){if(j==0)j=k.getResponseHeader("Content-Length");i({total:j,loaded:k.responseText.length})}}else if(k.readyState==2)j=k.getResponseHeader("Content-Length")};k.open("GET",d,true);k.overrideMimeType("text/plain; charset=x-user-defined");k.setRequestHeader("Content-Type","text/plain");k.send(null)},
createBinModel:function(a,b,e,f){var g=function(i){function k(u,M){var K=q(u,M),ba=q(u,M+1),fa=q(u,M+2),ja=q(u,M+3),ma=(ja<<1&255|fa>>7)-127;K=(fa&127)<<16|ba<<8|K;if(K==0&&ma==-127)return 0;return(1-2*(ja>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,ma)}function d(u,M){var K=q(u,M),ba=q(u,M+1),fa=q(u,M+2);return(q(u,M+3)<<24)+(fa<<16)+(ba<<8)+K}function j(u,M){var K=q(u,M);return(q(u,M+1)<<8)+K}function l(u,M){var K=q(u,M);return K>127?K-256:K}function q(u,M){return u.charCodeAt(M)&255}function F(u){var M,
K,ba;M=d(a,u);K=d(a,u+C);ba=d(a,u+p);u=j(a,u+B);THREE.Loader.prototype.f3(r,M,K,ba,u)}function o(u){var M,K,ba,fa,ja,ma;M=d(a,u);K=d(a,u+C);ba=d(a,u+p);fa=j(a,u+B);ja=d(a,u+P);ma=d(a,u+v);u=d(a,u+G);THREE.Loader.prototype.f3n(r,h,M,K,ba,fa,ja,ma,u)}function A(u){var M,K,ba,fa;M=d(a,u);K=d(a,u+I);ba=d(a,u+H);fa=d(a,u+w);u=j(a,u+R);THREE.Loader.prototype.f4(r,M,K,ba,fa,u)}function D(u){var M,K,ba,fa,ja,ma,ta,va;M=d(a,u);K=d(a,u+I);ba=d(a,u+H);fa=d(a,u+w);ja=j(a,u+R);ma=d(a,u+L);ta=d(a,u+X);va=d(a,u+
Z);u=d(a,u+S);THREE.Loader.prototype.f4n(r,h,M,K,ba,fa,ja,ma,ta,va,u)}function E(u){var M,K;M=d(a,u);K=d(a,u+ga);u=d(a,u+$);THREE.Loader.prototype.uv3(r,n[M*2],n[M*2+1],n[K*2],n[K*2+1],n[u*2],n[u*2+1])}function N(u){var M,K,ba;M=d(a,u);K=d(a,u+U);ba=d(a,u+W);u=d(a,u+ea);THREE.Loader.prototype.uv4(r,n[M*2],n[M*2+1],n[K*2],n[K*2+1],n[ba*2],n[ba*2+1],n[u*2],n[u*2+1])}var r=this,O=0,m,h=[],n=[],C,p,B,P,v,G,I,H,w,R,L,X,Z,S,ga,$,U,W,ea,aa,J,V,Y,la,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(r,
f,i);m={signature:a.substr(O,8),header_bytes:q(a,O+8),vertex_coordinate_bytes:q(a,O+9),normal_coordinate_bytes:q(a,O+10),uv_coordinate_bytes:q(a,O+11),vertex_index_bytes:q(a,O+12),normal_index_bytes:q(a,O+13),uv_index_bytes:q(a,O+14),material_index_bytes:q(a,O+15),nvertices:d(a,O+16),nnormals:d(a,O+16+4),nuvs:d(a,O+16+8),ntri_flat:d(a,O+16+12),ntri_smooth:d(a,O+16+16),ntri_flat_uv:d(a,O+16+20),ntri_smooth_uv:d(a,O+16+24),nquad_flat:d(a,O+16+28),nquad_smooth:d(a,O+16+32),nquad_flat_uv:d(a,O+16+36),
nquad_smooth_uv:d(a,O+16+40)};O+=m.header_bytes;C=m.vertex_index_bytes;p=m.vertex_index_bytes*2;B=m.vertex_index_bytes*3;P=m.vertex_index_bytes*3+m.material_index_bytes;v=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;G=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;I=m.vertex_index_bytes;H=m.vertex_index_bytes*2;w=m.vertex_index_bytes*3;R=m.vertex_index_bytes*4;L=m.vertex_index_bytes*4+m.material_index_bytes;X=m.vertex_index_bytes*4+m.material_index_bytes+
m.normal_index_bytes;Z=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;S=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;ga=m.uv_index_bytes;$=m.uv_index_bytes*2;U=m.uv_index_bytes;W=m.uv_index_bytes*2;ea=m.uv_index_bytes*3;i=m.vertex_index_bytes*3+m.material_index_bytes;ka=m.vertex_index_bytes*4+m.material_index_bytes;aa=m.ntri_flat*i;J=m.ntri_smooth*(i+m.normal_index_bytes*3);V=m.ntri_flat_uv*(i+m.uv_index_bytes*3);Y=m.ntri_smooth_uv*(i+m.normal_index_bytes*
3+m.uv_index_bytes*3);la=m.nquad_flat*ka;i=m.nquad_smooth*(ka+m.normal_index_bytes*4);ka=m.nquad_flat_uv*(ka+m.uv_index_bytes*4);O+=function(u){var M,K,ba,fa=m.vertex_coordinate_bytes*3,ja=u+m.nvertices*fa;for(u=u;u<ja;u+=fa){M=k(a,u);K=k(a,u+m.vertex_coordinate_bytes);ba=k(a,u+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(r,M,K,ba)}return m.nvertices*fa}(O);O+=function(u){var M,K,ba,fa=m.normal_coordinate_bytes*3,ja=u+m.nnormals*fa;for(u=u;u<ja;u+=fa){M=l(a,u);K=l(a,u+m.normal_coordinate_bytes);
ba=l(a,u+m.normal_coordinate_bytes*2);h.push(M/127,K/127,ba/127)}return m.nnormals*fa}(O);O+=function(u){var M,K,ba=m.uv_coordinate_bytes*2,fa=u+m.nuvs*ba;for(u=u;u<fa;u+=ba){M=k(a,u);K=k(a,u+m.uv_coordinate_bytes);n.push(M,K)}return m.nuvs*ba}(O);O=O;aa=O+aa;J=aa+J;V=J+V;Y=V+Y;la=Y+la;i=la+i;ka=i+ka;(function(u){var M,K=m.vertex_index_bytes*3+m.material_index_bytes,ba=K+m.uv_index_bytes*3,fa=u+m.ntri_flat_uv*ba;for(M=u;M<fa;M+=ba){F(M);E(M+K)}return fa-u})(J);(function(u){var M,K=m.vertex_index_bytes*
3+m.material_index_bytes+m.normal_index_bytes*3,ba=K+m.uv_index_bytes*3,fa=u+m.ntri_smooth_uv*ba;for(M=u;M<fa;M+=ba){o(M);E(M+K)}return fa-u})(V);(function(u){var M,K=m.vertex_index_bytes*4+m.material_index_bytes,ba=K+m.uv_index_bytes*4,fa=u+m.nquad_flat_uv*ba;for(M=u;M<fa;M+=ba){A(M);N(M+K)}return fa-u})(i);(function(u){var M,K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,ba=K+m.uv_index_bytes*4,fa=u+m.nquad_smooth_uv*ba;for(M=u;M<fa;M+=ba){D(M);N(M+K)}return fa-u})(ka);(function(u){var M,
K=m.vertex_index_bytes*3+m.material_index_bytes,ba=u+m.ntri_flat*K;for(M=u;M<ba;M+=K)F(M);return ba-u})(O);(function(u){var M,K=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,ba=u+m.ntri_smooth*K;for(M=u;M<ba;M+=K)o(M);return ba-u})(aa);(function(u){var M,K=m.vertex_index_bytes*4+m.material_index_bytes,ba=u+m.nquad_flat*K;for(M=u;M<ba;M+=K)A(M);return ba-u})(Y);(function(u){var M,K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,ba=u+m.nquad_smooth*K;for(M=
u;M<ba;M+=K)D(M);return ba-u})(la);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(e))},createModel:function(a,b,e){var f=function(g){var i=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(i,a.materials,g);(function(){var k,d,j,l,q;k=0;for(d=a.vertices.length;k<d;k+=3){j=a.vertices[k];l=a.vertices[k+1];q=a.vertices[k+2];THREE.Loader.prototype.v(i,j,l,q)}})();(function(){function k(D,
E){THREE.Loader.prototype.f3(i,D[E],D[E+1],D[E+2],D[E+3])}function d(D,E){THREE.Loader.prototype.f3n(i,a.normals,D[E],D[E+1],D[E+2],D[E+3],D[E+4],D[E+5],D[E+6])}function j(D,E){THREE.Loader.prototype.f4(i,D[E],D[E+1],D[E+2],D[E+3],D[E+4])}function l(D,E){THREE.Loader.prototype.f4n(i,a.normals,D[E],D[E+1],D[E+2],D[E+3],D[E+4],D[E+5],D[E+6],D[E+7],D[E+8])}function q(D,E){var N,r,O;N=D[E];r=D[E+1];O=D[E+2];THREE.Loader.prototype.uv3(i,a.uvs[N*2],a.uvs[N*2+1],a.uvs[r*2],a.uvs[r*2+1],a.uvs[O*2],a.uvs[O*
2+1])}function F(D,E){var N,r,O,m;N=D[E];r=D[E+1];O=D[E+2];m=D[E+3];THREE.Loader.prototype.uv4(i,a.uvs[N*2],a.uvs[N*2+1],a.uvs[r*2],a.uvs[r*2+1],a.uvs[O*2],a.uvs[O*2+1],a.uvs[m*2],a.uvs[m*2+1])}var o,A;o=0;for(A=a.triangles_uv.length;o<A;o+=7){k(a.triangles_uv,o);q(a.triangles_uv,o+4)}o=0;for(A=a.triangles_n_uv.length;o<A;o+=10){d(a.triangles_n_uv,o);q(a.triangles_n_uv,o+7)}o=0;for(A=a.quads_uv.length;o<A;o+=9){j(a.quads_uv,o);F(a.quads_uv,o+5)}o=0;for(A=a.quads_n_uv.length;o<A;o+=13){l(a.quads_n_uv,
o);F(a.quads_n_uv,o+9)}o=0;for(A=a.triangles.length;o<A;o+=4)k(a.triangles,o);o=0;for(A=a.triangles_n.length;o<A;o+=7)d(a.triangles_n,o);o=0;for(A=a.quads.length;o<A;o+=5)j(a.quads,o);o=0;for(A=a.quads_n.length;o<A;o+=9)l(a.quads_n,o)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(e))},v:function(a,b,e,f){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,f)))},f3:function(a,b,e,f,g){a.faces.push(new THREE.Face3(b,
e,f,null,a.materials[g]))},f4:function(a,b,e,f,g,i){a.faces.push(new THREE.Face4(b,e,f,g,null,a.materials[i]))},f3n:function(a,b,e,f,g,i,k,d,j){i=a.materials[i];var l=b[d*3],q=b[d*3+1];d=b[d*3+2];var F=b[j*3],o=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(e,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(l,q,d),new THREE.Vector3(F,o,j)],i))},f4n:function(a,b,e,f,g,i,k,d,j,l,q){k=a.materials[k];var F=b[j*3],o=b[j*3+1];j=b[j*3+2];var A=b[l*3],D=b[l*3+1];l=b[l*3+2];var E=b[q*3],
N=b[q*3+1];q=b[q*3+2];a.faces.push(new THREE.Face4(e,f,g,i,[new THREE.Vector3(b[d*3],b[d*3+1],b[d*3+2]),new THREE.Vector3(F,o,j),new THREE.Vector3(A,D,l),new THREE.Vector3(E,N,q)],k))},uv3:function(a,b,e,f,g,i,k){var d=[];d.push(new THREE.UV(b,e));d.push(new THREE.UV(f,g));d.push(new THREE.UV(i,k));a.uvs.push(d)},uv4:function(a,b,e,f,g,i,k,d,j){var l=[];l.push(new THREE.UV(b,e));l.push(new THREE.UV(f,g));l.push(new THREE.UV(i,k));l.push(new THREE.UV(d,j));a.uvs.push(l)},init_materials:function(a,
b,e){a.materials=[];for(var f=0;f<b.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(b[f],e)]},createMaterial:function(a,b){function e(i){i=Math.log(i)/Math.LN2;return Math.floor(i)==i}var f,g;if(a.map_diffuse&&b){g=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!e(this.width)||!e(this.height)){var i=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
f.map.image.width=i;f.map.image.height=k;f.map.image.getContext("2d").drawImage(this,0,0,i,k)}else f.map.image=this;f.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return f},extractUrlbase:function(a){a=a.split("/");
a.pop();return a.join("/")}};