Cleaned up CanvasRenderer/MeshDepthMaterial code.

Moved near/far values from MeshDepthMaterial to Camera (CanvasRenderer/WebGLRenderer/WebGLRenderer2).
This commit is contained in:
Mr.doob
2010-12-25 18:14:10 +00:00
parent 0c3e69ccda
commit e46346c9ba
14 changed files with 440 additions and 426 deletions
+124 -124
View File
@@ -12,52 +12,53 @@ THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1}
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;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,f,d=a.objects,j=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)j=j.concat(this.intersectObject(f))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function b(N,s,T,B){B=B.clone().subSelf(s);T=T.clone().subSelf(s);var L=N.clone().subSelf(s);N=B.dot(B);s=B.dot(T);B=B.dot(L);var O=T.dot(T);T=T.dot(L);L=1/(N*O-s*s);O=(O*B-s*T)*L;N=(N*T-s*B)*L;return O>0&&N>0&&O+N<1}var f,d,j,k,q,l,p,y,c,C,
u,t=a.geometry,J=t.vertices,R=[];f=0;for(d=t.faces.length;f<d;f++){j=t.faces[f];C=this.origin.clone();u=this.direction.clone();k=a.matrix.multiplyVector3(J[j.a].position.clone());q=a.matrix.multiplyVector3(J[j.b].position.clone());l=a.matrix.multiplyVector3(J[j.c].position.clone());p=j instanceof THREE.Face4?a.matrix.multiplyVector3(J[j.d].position.clone()):null;y=a.rotationMatrix.multiplyVector3(j.normal.clone());c=u.dot(y);if(c<0){y=y.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(u.multiplyScalar(y));
if(j instanceof THREE.Face3){if(b(C,k,q,l)){j={distance:this.origin.distanceTo(C),point:C,face:j,object:a};R.push(j)}}else if(j instanceof THREE.Face4)if(b(C,k,q,p)||b(C,q,l,p)){j={distance:this.origin.distanceTo(C),point:C,face:j,object:a};R.push(j)}}}return R}};
THREE.Rectangle=function(){function a(){k=d-b;q=j-f}var b,f,d,j,k,q,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return j};this.set=function(p,y,c,C){l=false;b=p;f=y;d=c;j=C;a()};this.addPoint=function(p,y){if(l){l=false;b=p;f=y;d=p;j=y}else{b=b<p?b:p;f=f<y?f:y;d=d>p?d:p;j=j>y?
j:y}a()};this.add3Points=function(p,y,c,C,u,t){if(l){l=false;b=p<c?p<u?p:u:c<u?c:u;f=y<C?y<t?y:t:C<t?C:t;d=p>c?p>u?p:u:c>u?c:u;j=y>C?y>t?y:t:C>t?C:t}else{b=p<c?p<u?p<b?p:b:u<b?u:b:c<u?c<b?c:b:u<b?u:b;f=y<C?y<t?y<f?y:f:t<f?t:f:C<t?C<f?C:f:t<f?t:f;d=p>c?p>u?p>d?p:d:u>d?u:d:c>u?c>d?c:d:u>d?u:d;j=y>C?y>t?y>j?y:j:t>j?t:j:C>t?C>j?C:j:t>j?t:j}a()};this.addRectangle=function(p){if(l){l=false;b=p.getLeft();f=p.getTop();d=p.getRight();j=p.getBottom()}else{b=b<p.getLeft()?b:p.getLeft();f=f<p.getTop()?f:p.getTop();
d=d>p.getRight()?d:p.getRight();j=j>p.getBottom()?j:p.getBottom()}a()};this.inflate=function(p){b-=p;f-=p;d+=p;j+=p;a()};this.minSelf=function(p){b=b>p.getLeft()?b:p.getLeft();f=f>p.getTop()?f:p.getTop();d=d<p.getRight()?d:p.getRight();j=j<p.getBottom()?j:p.getBottom();a()};this.instersects=function(p){return Math.min(d,p.getRight())-Math.max(b,p.getLeft())>=0&&Math.min(j,p.getBottom())-Math.max(f,p.getTop())>=0};this.empty=function(){l=true;j=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+k+", 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,b,f,d,j,k,q,l,p,y,c,C,u,t,J,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=l||0;this.n31=p||0;this.n32=y||0;this.n33=c||1;this.n34=C||0;this.n41=u||0;this.n42=t||0;this.n43=J||0;this.n44=R||1};
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,f,d,j,k,q,l,p,y,c,C,u,t,J,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=k;this.n23=q;this.n24=l;this.n31=p;this.n32=y;this.n33=c;this.n34=C;this.n41=u;this.n42=t;this.n43=J;this.n44=R;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,f){var d=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();j.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=k.x;
this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*j;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 f=a.n11,d=a.n12,j=a.n13,k=a.n14,q=a.n21,l=a.n22,p=a.n23,y=a.n24,c=a.n31,C=a.n32,
u=a.n33,t=a.n34,J=a.n41,R=a.n42,N=a.n43,s=a.n44,T=b.n11,B=b.n12,L=b.n13,O=b.n14,Q=b.n21,e=b.n22,h=b.n23,m=b.n24,i=b.n31,n=b.n32,g=b.n33,o=b.n34,r=b.n41,D=b.n42,M=b.n43,H=b.n44;this.n11=f*T+d*Q+j*i+k*r;this.n12=f*B+d*e+j*n+k*D;this.n13=f*L+d*h+j*g+k*M;this.n14=f*O+d*m+j*o+k*H;this.n21=q*T+l*Q+p*i+y*r;this.n22=q*B+l*e+p*n+y*D;this.n23=q*L+l*h+p*g+y*M;this.n24=q*O+l*m+p*o+y*H;this.n31=c*T+C*Q+u*i+t*r;this.n32=c*B+C*e+u*n+t*D;this.n33=c*L+C*h+u*g+t*M;this.n34=c*O+C*m+u*o+t*H;this.n41=J*T+R*Q+N*i+s*r;
this.n42=J*B+R*e+N*n+s*D;this.n43=J*L+R*h+N*g+s*M;this.n44=J*O+R*m+N*o+s*H;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,k=this.n21,q=this.n22,l=this.n23,p=this.n24,y=this.n31,c=this.n32,C=this.n33,u=this.n34,t=this.n41,J=this.n42,R=this.n43,N=this.n44,s=a.n11,T=a.n21,B=a.n31,L=a.n41,O=a.n12,Q=a.n22,e=a.n32,h=a.n42,m=a.n13,i=a.n23,n=a.n33,g=a.n43,o=a.n14,r=a.n24,D=a.n34;a=a.n44;this.n11=b*s+f*T+d*B+j*L;this.n12=b*O+f*Q+d*e+j*h;this.n13=b*m+f*i+d*n+j*g;this.n14=
b*o+f*r+d*D+j*a;this.n21=k*s+q*T+l*B+p*L;this.n22=k*O+q*Q+l*e+p*h;this.n23=k*m+q*i+l*n+p*g;this.n24=k*o+q*r+l*D+p*a;this.n31=y*s+c*T+C*B+u*L;this.n32=y*O+c*Q+C*e+u*h;this.n33=y*m+c*i+C*n+u*g;this.n34=y*o+c*r+C*D+u*a;this.n41=t*s+J*T+R*B+N*L;this.n42=t*O+J*Q+R*e+N*h;this.n43=t*m+J*i+R*n+N*g;this.n44=t*o+J*r+R*D+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*=
THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)i=i.concat(this.intersectObject(f))}i.sort(function(j,p){return j.distance-p.distance});return i},intersectObject:function(a){function b(P,r,V,C){C=C.clone().subSelf(r);V=V.clone().subSelf(r);var J=P.clone().subSelf(r);P=C.dot(C);r=C.dot(V);C=C.dot(J);var Q=V.dot(V);V=V.dot(J);J=1/(P*Q-r*r);Q=(Q*C-r*V)*J;P=(P*V-r*C)*J;return Q>0&&P>0&&Q+P<1}var f,d,i,j,p,l,o,x,c,E,
v,u=a.geometry,I=u.vertices,S=[];f=0;for(d=u.faces.length;f<d;f++){i=u.faces[f];E=this.origin.clone();v=this.direction.clone();j=a.matrix.multiplyVector3(I[i.a].position.clone());p=a.matrix.multiplyVector3(I[i.b].position.clone());l=a.matrix.multiplyVector3(I[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(I[i.d].position.clone()):null;x=a.rotationMatrix.multiplyVector3(i.normal.clone());c=v.dot(x);if(c<0){x=x.dot((new THREE.Vector3).sub(j,E))/c;E=E.addSelf(v.multiplyScalar(x));
if(i instanceof THREE.Face3){if(b(E,j,p,l)){i={distance:this.origin.distanceTo(E),point:E,face:i,object:a};S.push(i)}}else if(i instanceof THREE.Face4)if(b(E,j,p,o)||b(E,p,l,o)){i={distance:this.origin.distanceTo(E),point:E,face:i,object:a};S.push(i)}}}return S}};
THREE.Rectangle=function(){function a(){j=d-b;p=i-f}var b,f,d,i,j,p,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return i};this.set=function(o,x,c,E){l=false;b=o;f=x;d=c;i=E;a()};this.addPoint=function(o,x){if(l){l=false;b=o;f=x;d=o;i=x}else{b=b<o?b:o;f=f<x?f:x;d=d>o?d:o;i=i>x?
i:x}a()};this.add3Points=function(o,x,c,E,v,u){if(l){l=false;b=o<c?o<v?o:v:c<v?c:v;f=x<E?x<u?x:u:E<u?E:u;d=o>c?o>v?o:v:c>v?c:v;i=x>E?x>u?x:u:E>u?E:u}else{b=o<c?o<v?o<b?o:b:v<b?v:b:c<v?c<b?c:b:v<b?v:b;f=x<E?x<u?x<f?x:f:u<f?u:f:E<u?E<f?E:f:u<f?u:f;d=o>c?o>v?o>d?o:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;i=x>E?x>u?x>i?x:i:u>i?u:i:E>u?E>i?E:i:u>i?u:i}a()};this.addRectangle=function(o){if(l){l=false;b=o.getLeft();f=o.getTop();d=o.getRight();i=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();f=f<o.getTop()?f:o.getTop();
d=d>o.getRight()?d:o.getRight();i=i>o.getBottom()?i:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;i+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d<o.getRight()?d:o.getRight();i=i<o.getBottom()?i:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(i,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){l=true;i=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+j+", 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,b,f,d,i,j,p,l,o,x,c,E,v,u,I,S){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=j||1;this.n23=p||0;this.n24=l||0;this.n31=o||0;this.n32=x||0;this.n33=c||1;this.n34=E||0;this.n41=v||0;this.n42=u||0;this.n43=I||0;this.n44=S||1};
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,f,d,i,j,p,l,o,x,c,E,v,u,I,S){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=j;this.n23=p;this.n24=l;this.n31=o;this.n32=x;this.n33=c;this.n34=E;this.n41=v;this.n42=u;this.n43=I;this.n44=S;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,f){var d=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(f,j).normalize();i.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=j.x;
this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;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 f=a.n11,d=a.n12,i=a.n13,j=a.n14,p=a.n21,l=a.n22,o=a.n23,x=a.n24,c=a.n31,E=a.n32,
v=a.n33,u=a.n34,I=a.n41,S=a.n42,P=a.n43,r=a.n44,V=b.n11,C=b.n12,J=b.n13,Q=b.n14,R=b.n21,e=b.n22,g=b.n23,m=b.n24,h=b.n31,n=b.n32,k=b.n33,q=b.n34,s=b.n41,K=b.n42,w=b.n43,T=b.n44;this.n11=f*V+d*R+i*h+j*s;this.n12=f*C+d*e+i*n+j*K;this.n13=f*J+d*g+i*k+j*w;this.n14=f*Q+d*m+i*q+j*T;this.n21=p*V+l*R+o*h+x*s;this.n22=p*C+l*e+o*n+x*K;this.n23=p*J+l*g+o*k+x*w;this.n24=p*Q+l*m+o*q+x*T;this.n31=c*V+E*R+v*h+u*s;this.n32=c*C+E*e+v*n+u*K;this.n33=c*J+E*g+v*k+u*w;this.n34=c*Q+E*m+v*q+u*T;this.n41=I*V+S*R+P*h+r*s;
this.n42=I*C+S*e+P*n+r*K;this.n43=I*J+S*g+P*k+r*w;this.n44=I*Q+S*m+P*q+r*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,j=this.n21,p=this.n22,l=this.n23,o=this.n24,x=this.n31,c=this.n32,E=this.n33,v=this.n34,u=this.n41,I=this.n42,S=this.n43,P=this.n44,r=a.n11,V=a.n21,C=a.n31,J=a.n41,Q=a.n12,R=a.n22,e=a.n32,g=a.n42,m=a.n13,h=a.n23,n=a.n33,k=a.n43,q=a.n14,s=a.n24,K=a.n34;a=a.n44;this.n11=b*r+f*V+d*C+i*J;this.n12=b*Q+f*R+d*e+i*g;this.n13=b*m+f*h+d*n+i*k;this.n14=
b*q+f*s+d*K+i*a;this.n21=j*r+p*V+l*C+o*J;this.n22=j*Q+p*R+l*e+o*g;this.n23=j*m+p*h+l*n+o*k;this.n24=j*q+p*s+l*K+o*a;this.n31=x*r+c*V+E*C+v*J;this.n32=x*Q+c*R+E*e+v*g;this.n33=x*m+c*h+E*n+v*k;this.n34=x*q+c*s+E*K+v*a;this.n41=u*r+I*V+S*C+P*J;this.n42=u*Q+I*R+S*e+P*g;this.n43=u*m+I*h+S*n+P*k;this.n44=u*q+I*s+S*K+P*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,f,d){var j=b[f];b[f]=b[d];
b[d]=j}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
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,f,d){var i=b[f];b[f]=b[d];
b[d]=i}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},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,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};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 f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),k=1-d,q=a.x,l=a.y,p=a.z;f.n11=k*q*q+d;f.n12=k*q*l-j*p;f.n13=k*q*p+j*l;f.n21=k*q*l+j*p;f.n22=k*l*l+d;f.n23=k*l*p-j*q;f.n31=k*q*p-j*l;f.n32=k*l*p+j*q;f.n33=k*p*p+d;return f};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),j=1-d,p=a.x,l=a.y,o=a.z;f.n11=j*p*p+d;f.n12=j*p*l-i*o;f.n13=j*p*o+i*l;f.n21=j*p*l+i*o;f.n22=j*l*l+d;f.n23=j*l*o-i*p;f.n31=j*p*o-i*l;f.n32=j*l*o+i*p;f.n33=j*o*o+d;return f};
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=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],y=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*k+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*k;a.m[4]=b*q;a.m[5]=b*l;a.m[6]=b*p;a.m[7]=b*y;a.m[8]=b*c;return a};
THREE.Matrix4.makeFrustum=function(a,b,f,d,j,k){var q,l,p;q=new THREE.Matrix4;l=2*j/(b-a);p=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=l;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=p;q.n23=f;q.n24=0;q.n31=0;q.n32=0;q.n33=d;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)};
THREE.Matrix4.makeOrtho=function(a,b,f,d,j,k){var q,l,p,y;q=new THREE.Matrix4;l=b-a;p=f-d;y=k-j;a=(b+a)/l;f=(f+d)/p;j=(k+j)/y;q.n11=2/l;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/p;q.n23=0;q.n24=-f;q.n31=0;q.n32=0;q.n33=-2/y;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],x=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*x;a.m[8]=b*c;return a};
THREE.Matrix4.makeFrustum=function(a,b,f,d,i,j){var p,l,o;p=new THREE.Matrix4;l=2*i/(b-a);o=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(j+i)/(j-i);i=-2*j*i/(j-i);p.n11=l;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=i;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)};
THREE.Matrix4.makeOrtho=function(a,b,f,d,i,j){var p,l,o,x;p=new THREE.Matrix4;l=b-a;o=f-d;x=j-i;a=(b+a)/l;f=(f+d)/o;i=(j+i)/x;p.n11=2/l;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/x;p.n34=-i;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
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,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,f,d,j,k){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};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.Face3=function(a,b,f,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,f,d,i,j){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=j instanceof Array?j:[j]};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,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,j,k,q,l=new THREE.Vector3,p=new THREE.Vector3;d=0;for(j=this.vertices.length;d<j;d++){k=this.vertices[d];k.normal.set(0,0,0)}d=0;for(j=this.faces.length;d<j;d++){k=this.faces[d];if(a&&k.vertexNormals.length){l.set(0,0,0);b=0;for(f=k.normal.length;b<f;b++)l.addSelf(k.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[k.a];f=this.vertices[k.b];q=this.vertices[k.c];l.sub(q.position,
f.position);p.sub(b.position,f.position);l.crossSelf(p)}l.isZero()||l.normalize();k.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(o,r,D,M){k=o.vertices[r].position;q=o.vertices[D].position;
l=o.vertices[M].position;p=j[0];y=j[1];c=j[2];C=q.x-k.x;u=l.x-k.x;t=q.y-k.y;J=l.y-k.y;R=q.z-k.z;N=l.z-k.z;s=y.u-p.u;T=c.u-p.u;B=y.v-p.v;L=c.v-p.v;O=1/(s*L-T*B);m.set((L*C-B*u)*O,(L*t-B*J)*O,(L*R-B*N)*O);i.set((s*u-T*C)*O,(s*J-T*t)*O,(s*N-T*R)*O);e[r].addSelf(m);e[D].addSelf(m);e[M].addSelf(m);h[r].addSelf(i);h[D].addSelf(i);h[M].addSelf(i)}var b,f,d,j,k,q,l,p,y,c,C,u,t,J,R,N,s,T,B,L,O,Q,e=[],h=[],m=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,g=new THREE.Vector3;Q=new THREE.Vector3;b=
0;for(f=this.vertices.length;b<f;b++){e[b]=new THREE.Vector3;h[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];j=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){Q.copy(this.vertices[b].normal);d=e[b];n.copy(d);n.subSelf(Q.multiplyScalar(Q.dot(d))).normalize();g.cross(this.vertices[b].normal,d);test=g.dot(h[b]);d=test<0?-1:1;this.vertices[b].tangent.set(n.x,n.y,n.z,d)}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],
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,i,j,p,l=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){j=this.vertices[d];j.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){j=this.faces[d];if(a&&j.vertexNormals.length){l.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)l.addSelf(j.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];l.sub(p.position,
f.position);o.sub(b.position,f.position);l.crossSelf(o)}l.isZero()||l.normalize();j.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(q,s,K,w){j=q.vertices[s].position;p=q.vertices[K].position;
l=q.vertices[w].position;o=i[0];x=i[1];c=i[2];E=p.x-j.x;v=l.x-j.x;u=p.y-j.y;I=l.y-j.y;S=p.z-j.z;P=l.z-j.z;r=x.u-o.u;V=c.u-o.u;C=x.v-o.v;J=c.v-o.v;Q=1/(r*J-V*C);m.set((J*E-C*v)*Q,(J*u-C*I)*Q,(J*S-C*P)*Q);h.set((r*v-V*E)*Q,(r*I-V*u)*Q,(r*P-V*S)*Q);e[s].addSelf(m);e[K].addSelf(m);e[w].addSelf(m);g[s].addSelf(h);g[K].addSelf(h);g[w].addSelf(h)}var b,f,d,i,j,p,l,o,x,c,E,v,u,I,S,P,r,V,C,J,Q,R,e=[],g=[],m=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,k=new THREE.Vector3;R=new THREE.Vector3;b=
0;for(f=this.vertices.length;b<f;b++){e[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];i=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){R.copy(this.vertices[b].normal);d=e[b];n.copy(d);n.subSelf(R.multiplyScalar(R.dot(d))).normalize();k.cross(this.vertices[b].normal,d);test=k.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(n.x,n.y,n.z,d)}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,f=this.vertices.length;b<f;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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var c=[];b=0;for(f=y.length;b<f;b++)y[b]==undefined?c.push("undefined"):c.push(y[b].toString());return c.join("_")}
var b,f,d,j,k,q,l,p={};d=0;for(j=this.faces.length;d<j;d++){k=this.faces[d];materials=k.materials;q=a(materials);if(p[q]==undefined)p[q]={hash:q,counter:0};l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){p[q].counter+=1;l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d);
this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);
this.position.subSelf(j);this.target.position.subSelf(j)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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;
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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(x){var c=[];b=0;for(f=x.length;b<f;b++)x[b]==undefined?c.push("undefined"):c.push(x[b].toString());return c.join("_")}
var b,f,d,i,j,p,l,o={};d=0;for(i=this.faces.length;d<i;d++){j=this.faces[d];materials=j.materials;p=a(materials);if(o[p]==undefined)o[p]={hash:p,counter:0};l=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+j>65535){o[p].counter+=1;l=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d);
this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);
this.position.subSelf(i);this.target.position.subSelf(i)};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();this.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.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;
@@ -80,107 +81,106 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract
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.near=1;this.far=1E3;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.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
this.far-this.near};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.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,f,d,j,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
THREE.Texture=function(a,b,f,d,i,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter};
THREE.Texture.prototype={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.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,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};
THREE.Projector=function(){function a(e,h){return h.z-e.z}function b(e,h){var m=0,i=1,n=e.z+e.w,g=h.z+h.w,o=-e.z+e.w,r=-h.z+h.w;if(n>=0&&g>=0&&o>=0&&r>=0)return true;else if(n<0&&g<0||o<0&&r<0)return false;else{if(n<0)m=Math.max(m,n/(n-g));else if(g<0)i=Math.min(i,n/(n-g));if(o<0)m=Math.max(m,o/(o-r));else if(r<0)i=Math.min(i,o/(o-r));if(i<m)return false;else{e.lerpSelf(h,m);h.lerpSelf(e,1-i);return true}}}var f,d,j=[],k,q,l,p=[],y,c,C=[],u,t,J=[],R=new THREE.Vector4,N=new THREE.Vector4,s=new THREE.Matrix4,
T=new THREE.Matrix4,B=[],L=new THREE.Vector4,O=new THREE.Vector4,Q;this.projectObjects=function(e,h,m){var i=[],n,g;d=0;s.multiply(h.projectionMatrix,h.matrix);B[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);B[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);B[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);B[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);B[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);B[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);h=0;for(n=B.length;h<n;h++){g=B[h];g.divideScalar(Math.sqrt(g.x*g.x+g.y*g.y+g.z*g.z))}n=e.objects;e=0;for(h=n.length;e<h;e++){g=n[e];var o;if(!(o=!g.visible)){if(o=g instanceof THREE.Mesh){a:{o=void 0;for(var r=g.position,D=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,Math.max(g.scale.y,g.scale.z)),M=0;M<6;M++){o=B[M].x*r.x+B[M].y*r.y+B[M].z*r.z+B[M].w;if(o<=D){o=false;break a}}o=true}o=!o}o=o}if(!o){f=
j[d]=j[d]||new THREE.RenderableObject;R.copy(g.position);s.multiplyVector3(R);f.object=g;f.z=R.z;i.push(f);d++}}m&&i.sort(a);return i};this.projectScene=function(e,h,m){var i=[],n,g,o,r,D,M,H,z,S,E,U,F,w,x,K,G;l=c=t=0;h.autoUpdateMatrix&&h.updateMatrix();s.multiply(h.projectionMatrix,h.matrix);M=this.projectObjects(e,h,true);e=0;for(n=M.length;e<n;e++){H=M[e].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();z=H.matrix;S=H.rotationMatrix;E=H.materials;U=H.overdraw;if(H instanceof THREE.Mesh){F=
H.geometry;w=F.vertices;g=0;for(o=w.length;g<o;g++){x=w[g];x.positionWorld.copy(x.position);z.multiplyVector3(x.positionWorld);r=x.positionScreen;r.copy(x.positionWorld);s.multiplyVector4(r);r.multiplyScalar(1/r.w);x.__visible=r.z>0&&r.z<1}F=F.faces;g=0;for(o=F.length;g<o;g++){x=F[g];if(x instanceof THREE.Face3){r=w[x.a];D=w[x.b];K=w[x.c];if(r.__visible&&D.__visible&&K.__visible)if(H.doubleSided||H.flipSided!=(K.positionScreen.x-r.positionScreen.x)*(D.positionScreen.y-r.positionScreen.y)-(K.positionScreen.y-
r.positionScreen.y)*(D.positionScreen.x-r.positionScreen.x)<0){k=p[l]=p[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(r.positionWorld);k.v2.positionWorld.copy(D.positionWorld);k.v3.positionWorld.copy(K.positionWorld);k.v1.positionScreen.copy(r.positionScreen);k.v2.positionScreen.copy(D.positionScreen);k.v3.positionScreen.copy(K.positionScreen);k.normalWorld.copy(x.normal);S.multiplyVector3(k.normalWorld);k.centroidWorld.copy(x.centroid);z.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);
s.multiplyVector3(k.centroidScreen);K=x.vertexNormals;Q=k.vertexNormalsWorld;r=0;for(D=K.length;r<D;r++){G=Q[r]=Q[r]||new THREE.Vector3;G.copy(K[r]);S.multiplyVector3(G)}k.z=k.centroidScreen.z;k.meshMaterials=E;k.faceMaterials=x.materials;k.overdraw=U;if(H.geometry.uvs[g]){k.uvs[0]=H.geometry.uvs[g][0];k.uvs[1]=H.geometry.uvs[g][1];k.uvs[2]=H.geometry.uvs[g][2]}i.push(k);l++}}else if(x instanceof THREE.Face4){r=w[x.a];D=w[x.b];K=w[x.c];G=w[x.d];if(r.__visible&&D.__visible&&K.__visible&&G.__visible)if(H.doubleSided||
H.flipSided!=((G.positionScreen.x-r.positionScreen.x)*(D.positionScreen.y-r.positionScreen.y)-(G.positionScreen.y-r.positionScreen.y)*(D.positionScreen.x-r.positionScreen.x)<0||(D.positionScreen.x-K.positionScreen.x)*(G.positionScreen.y-K.positionScreen.y)-(D.positionScreen.y-K.positionScreen.y)*(G.positionScreen.x-K.positionScreen.x)<0)){k=p[l]=p[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(r.positionWorld);k.v2.positionWorld.copy(D.positionWorld);k.v3.positionWorld.copy(G.positionWorld);
k.v1.positionScreen.copy(r.positionScreen);k.v2.positionScreen.copy(D.positionScreen);k.v3.positionScreen.copy(G.positionScreen);k.normalWorld.copy(x.normal);S.multiplyVector3(k.normalWorld);k.centroidWorld.copy(x.centroid);z.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=E;k.faceMaterials=x.materials;k.overdraw=U;if(H.geometry.uvs[g]){k.uvs[0]=H.geometry.uvs[g][0];k.uvs[1]=H.geometry.uvs[g][1];k.uvs[2]=
H.geometry.uvs[g][3]}i.push(k);l++;q=p[l]=p[l]||new THREE.RenderableFace3;q.v1.positionWorld.copy(D.positionWorld);q.v2.positionWorld.copy(K.positionWorld);q.v3.positionWorld.copy(G.positionWorld);q.v1.positionScreen.copy(D.positionScreen);q.v2.positionScreen.copy(K.positionScreen);q.v3.positionScreen.copy(G.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=E;q.faceMaterials=x.materials;
q.overdraw=U;if(H.geometry.uvs[g]){q.uvs[0]=H.geometry.uvs[g][1];q.uvs[1]=H.geometry.uvs[g][2];q.uvs[2]=H.geometry.uvs[g][3]}i.push(q);l++}}}}else if(H instanceof THREE.Line){T.multiply(s,z);w=H.geometry.vertices;x=w[0];x.positionScreen.copy(x.position);T.multiplyVector4(x.positionScreen);g=1;for(o=w.length;g<o;g++){r=w[g];r.positionScreen.copy(r.position);T.multiplyVector4(r.positionScreen);D=w[g-1];L.copy(r.positionScreen);O.copy(D.positionScreen);if(b(L,O)){L.multiplyScalar(1/L.w);O.multiplyScalar(1/
O.w);y=C[c]=C[c]||new THREE.RenderableLine;y.v1.positionScreen.copy(L);y.v2.positionScreen.copy(O);y.z=Math.max(L.z,O.z);y.materials=H.materials;i.push(y);c++}}}else if(H instanceof THREE.Particle){N.set(H.position.x,H.position.y,H.position.z,1);s.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){u=J[t]=J[t]||new THREE.RenderableParticle;u.x=N.x/N.w;u.y=N.y/N.w;u.z=N.z;u.rotation=H.rotation.z;u.scale.x=H.scale.x*Math.abs(u.x-(N.x+h.projectionMatrix.n11)/(N.w+h.projectionMatrix.n14));u.scale.y=H.scale.y*
Math.abs(u.y-(N.y+h.projectionMatrix.n22)/(N.w+h.projectionMatrix.n24));u.materials=H.materials;i.push(u);t++}}}}m&&i.sort(a);return i};this.unprojectVector=function(e,h){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(h.matrix),THREE.Matrix4.makeInvert(h.projectionMatrix));m.multiplyVector3(e);return e}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,k;this.domElement=document.createElement("div");this.setSize=function(q,l){f=q;d=l;j=f/2;k=d/2};this.render=function(q,l){var p,y,c,C,u,t,J,R;a=b.projectScene(q,l);p=0;for(y=a.length;p<y;p++){u=a[p];if(u instanceof THREE.RenderableParticle){J=u.x*j+j;R=u.y*k+k;c=0;for(C=u.material.length;c<C;c++){t=u.material[c];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=J+"px";t.style.top=R+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,j,k,q,l=f.getContext("2d"),p=1,y=0,c=null,C=null,u=1,t,J,R,N,s,T,B,L,O,Q=new THREE.Color,e=new THREE.Color,h=new THREE.Color,m=new THREE.Color,i=new THREE.Color,n,g,o,r,D,M,H,z,S,E,U=new THREE.Rectangle,F=new THREE.Rectangle,w=new THREE.Rectangle,x=false,K=new THREE.Color,G=new THREE.Color,W=new THREE.Color,ba=new THREE.Color,Ka=Math.PI*2,Y=new THREE.Vector3,oa,pa,Ba,ea,qa,ua,ma=16;oa=document.createElement("canvas");
oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Ba=pa.getImageData(0,0,2,2);ea=Ba.data;qa=document.createElement("canvas");qa.width=qa.height=ma;ua=qa.getContext("2d");ua.translate(-ma/2,-ma/2);ua.scale(ma,ma);ma--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ha,va){d=ha;j=va;k=d/2;q=j/2;f.width=d;f.height=j;U.set(-k,-q,k,q)};this.clear=function(){if(!F.isEmpty()){F.inflate(1);F.minSelf(U);l.clearRect(F.getX(),
F.getY(),F.getWidth(),F.getHeight());F.empty()}};this.render=function(ha,va){function La(v){var V,P,A,I=v.lights;G.setRGB(0,0,0);W.setRGB(0,0,0);ba.setRGB(0,0,0);v=0;for(V=I.length;v<V;v++){P=I[v];A=P.color;if(P instanceof THREE.AmbientLight){G.r+=A.r;G.g+=A.g;G.b+=A.b}else if(P instanceof THREE.DirectionalLight){W.r+=A.r;W.g+=A.g;W.b+=A.b}else if(P instanceof THREE.PointLight){ba.r+=A.r;ba.g+=A.g;ba.b+=A.b}}}function wa(v,V,P,A){var I,X,$,ca,da=v.lights;v=0;for(I=da.length;v<I;v++){X=da[v];$=X.color;
ca=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,V);Y.normalize();X=P.dot(Y)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}}}function Ma(v,V,P){if(P.opacity!=0){Ca(P.opacity);xa(P.blending);var A,I,X,$,ca,da;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){$=P.map;ca=$.width>>1;da=$.height>>1;I=V.scale.x*k;X=V.scale.y*q;P=I*ca;A=X*da;w.set(v.x-P,v.y-A,v.x+P,v.y+A);if(U.instersects(w)){l.save();
l.translate(v.x,v.y);l.rotate(-V.rotation);l.scale(I,-X);l.translate(-ca,-da);l.drawImage($,0,0);l.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(x){K.r=G.r+W.r+ba.r;K.g=G.g+W.g+ba.g;K.b=G.b+W.b+ba.b;Q.r=P.color.r*K.r;Q.g=P.color.g*K.g;Q.b=P.color.b*K.b;Q.updateStyleString()}else Q.__styleString=P.color.__styleString;P=V.scale.x*k;A=V.scale.y*q;w.set(v.x-P,v.y-A,v.x+P,v.y+A);if(U.instersects(w)){I=Q.__styleString;if(C!=I)l.fillStyle=C=I;l.save();l.translate(v.x,v.y);l.rotate(-V.rotation);
l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Ka,true);l.closePath();l.fill();l.restore()}}}}function Na(v,V,P,A){if(A.opacity!=0){Ca(A.opacity);xa(A.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(V.positionScreen.x,V.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){Q.__styleString=A.color.__styleString;v=A.linewidth;if(u!=v)l.lineWidth=u=v;v=Q.__styleString;if(c!=v)l.strokeStyle=c=v;l.stroke();w.inflate(A.linewidth*2)}}}function Ga(v,V,P,A,I,X){if(I.opacity!=
0){Ca(I.opacity);xa(I.blending);N=v.positionScreen.x;s=v.positionScreen.y;T=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;O=P.positionScreen.y;l.beginPath();l.moveTo(N,s);l.lineTo(T,B);l.lineTo(L,O);l.lineTo(N,s);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ra(N,s,T,B,L,O,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof
THREE.SphericalReflectionMapping){v=va.matrix;Y.copy(A.vertexNormalsWorld[0]);D=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;M=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);H=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;z=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);S=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;E=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;ra(N,s,T,B,L,O,I.env_map.image,D,M,H,z,S,E)}}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):
za(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ra(N,s,T,B,L,O,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);xa(THREE.SubtractiveBlending)}if(x)if(!I.wireframe&&I.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){e.r=h.r=m.r=G.r;e.g=h.g=m.g=G.g;e.b=h.b=m.b=G.b;wa(X,A.v1.positionWorld,A.vertexNormalsWorld[0],e);wa(X,A.v2.positionWorld,A.vertexNormalsWorld[1],h);wa(X,
A.v3.positionWorld,A.vertexNormalsWorld[2],m);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,T,B,L,O,r,0,0,1,0,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;wa(X,A.centroidWorld,A.normalWorld,K);Q.r=I.color.r*K.r;Q.g=I.color.g*K.g;Q.b=I.color.b*K.b;Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){n=I.__2near;
g=I.__farPlusNear;o=I.__farMinusNear;e.r=e.g=e.b=1-n/(g-v.positionScreen.z*o);h.r=h.g=h.b=1-n/(g-V.positionScreen.z*o);m.r=m.g=m.b=1-n/(g-P.positionScreen.z*o);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,T,B,L,O,r,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){Q.r=Da(A.normalWorld.x);Q.g=Da(A.normalWorld.y);Q.b=Da(A.normalWorld.z);Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}}}function ya(v,V){if(c!=v)l.strokeStyle=
c=v;if(u!=V)l.lineWidth=u=V;l.stroke();w.inflate(V*2)}function za(v){if(C!=v)l.fillStyle=C=v;l.fill()}function ra(v,V,P,A,I,X,$,ca,da,ia,fa,ja,sa){var la,ka;la=$.width-1;ka=$.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;sa*=ka;P-=v;A-=V;I-=v;X-=V;ia-=ca;fa-=da;ja-=ca;sa-=da;ka=1/(ia*sa-ja*fa);la=(sa*P-fa*I)*ka;fa=(sa*A-fa*X)*ka;P=(ia*I-ja*P)*ka;A=(ia*X-ja*A)*ka;v=v-la*ca-P*da;V=V-fa*ca-A*da;l.save();l.transform(la,fa,P,A,v,V);l.clip();l.drawImage($,0,0);l.restore()}function Ca(v){if(p!=v)l.globalAlpha=
p=v}function xa(v){if(y!=v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}y=v}}function Ha(v,V,P,A){var I=~~(v.r*255),X=~~(v.g*255);v=~~(v.b*255);var $=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(P.r*255),ia=~~(P.g*255);P=~~(P.b*255);var fa=~~(A.r*255),ja=~~(A.g*255);A=~~(A.b*255);ea[0]=I<0?0:I>255?255:I;ea[1]=X<0?0:X>
255?255:X;ea[2]=v<0?0:v>255?255:v;ea[4]=$<0?0:$>255?255:$;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=V<0?0:V>255?255:V;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=P<0?0:P>255?255:P;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=A<0?0:A>255?255:A;pa.putImageData(Ba,0,0);ua.drawImage(oa,0,0);return qa}function Da(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Ea(v,V){var P=V.x-v.x,A=V.y-v.y,I=1/Math.sqrt(P*P+A*A);P*=I;A*=I;V.x+=P;V.y+=A;v.x-=P;v.y-=A}var Aa,Ia,Z,ga,na,Fa,Ja,ta;
l.setTransform(1,0,0,-1,k,q);this.autoClear&&this.clear();a=b.projectScene(ha,va,this.sortElements);(x=ha.lights.length>0)&&La(ha);Aa=0;for(Ia=a.length;Aa<Ia;Aa++){Z=a[Aa];w.empty();if(Z instanceof THREE.RenderableParticle){t=Z;t.x*=k;t.y*=q;ga=0;for(na=Z.materials.length;ga<na;ga++)Ma(t,Z,Z.materials[ga],ha)}else if(Z instanceof THREE.RenderableLine){t=Z.v1;J=Z.v2;t.positionScreen.x*=k;t.positionScreen.y*=q;J.positionScreen.x*=k;J.positionScreen.y*=q;w.addPoint(t.positionScreen.x,t.positionScreen.y);
w.addPoint(J.positionScreen.x,J.positionScreen.y);if(U.instersects(w)){ga=0;for(na=Z.materials.length;ga<na;)Na(t,J,Z,Z.materials[ga++],ha)}}else if(Z instanceof THREE.RenderableFace3){t=Z.v1;J=Z.v2;R=Z.v3;t.positionScreen.x*=k;t.positionScreen.y*=q;J.positionScreen.x*=k;J.positionScreen.y*=q;R.positionScreen.x*=k;R.positionScreen.y*=q;if(Z.overdraw){Ea(t.positionScreen,J.positionScreen);Ea(J.positionScreen,R.positionScreen);Ea(R.positionScreen,t.positionScreen)}w.add3Points(t.positionScreen.x,t.positionScreen.y,
J.positionScreen.x,J.positionScreen.y,R.positionScreen.x,R.positionScreen.y);if(U.instersects(w)){ga=0;for(na=Z.meshMaterials.length;ga<na;){ta=Z.meshMaterials[ga++];if(ta instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=Z.faceMaterials.length;Fa<Ja;)(ta=Z.faceMaterials[Fa++])&&Ga(t,J,R,Z,ta,ha)}else Ga(t,J,R,Z,ta,ha)}}}F.addRectangle(w)}l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(z,S,E){var U,F,w,x;U=0;for(F=z.lights.length;U<F;U++){w=z.lights[U];if(w instanceof THREE.DirectionalLight){x=S.normalWorld.dot(w.position)*w.intensity;if(x>0){E.r+=w.color.r*x;E.g+=w.color.g*x;E.b+=w.color.b*x}}else if(w instanceof THREE.PointLight){m.sub(w.position,S.centroidWorld);m.normalize();x=S.normalWorld.dot(m)*w.intensity;if(x>0){E.r+=w.color.r*x;E.g+=w.color.g*x;E.b+=w.color.b*x}}}}function b(z,S,E,U,F,w){o=d(r++);o.setAttribute("d","M "+z.positionScreen.x+
" "+z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(T){L.r=O.r;L.g=O.g;L.b=O.b;a(w,U,L);B.r=F.color.r*L.r;B.g=F.color.g*L.g;B.b=F.color.b*L.b;B.updateStyleString()}else B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){h=1-F.__2near/(F.__farPlusNear-U.z*F.__farMinusNear);
B.setRGB(h,h,h)}else F instanceof THREE.MeshNormalMaterial&&B.setRGB(j(U.normalWorld.x),j(U.normalWorld.y),j(U.normalWorld.z));F.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+F.opacity);l.appendChild(o)}function f(z,S,E,U,F,w,x){o=d(r++);o.setAttribute("d",
"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(T){L.r=O.r;L.g=O.g;L.b=O.b;a(x,F,L);B.r=w.color.r*L.r;B.g=w.color.g*L.g;B.b=w.color.b*L.b;B.updateStyleString()}else B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){h=
1-w.__2near/(w.__farPlusNear-F.z*w.__farMinusNear);B.setRGB(h,h,h)}else w instanceof THREE.MeshNormalMaterial&&B.setRGB(j(F.normalWorld.x),j(F.normalWorld.y),j(F.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)}
function d(z){if(i[z]==null){i[z]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&i[z].setAttribute("shape-rendering","crispEdges");return i[z]}return i[z]}function j(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var k=null,q=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,y,c,C,u,t,J,R,N=new THREE.Rectangle,s=new THREE.Rectangle,T=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),Q=new THREE.Color(0),
e=new THREE.Color(0),h,m=new THREE.Vector3,i=[],n=[],g=[],o,r,D,M,H=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":H=1;break;case "low":H=0}};this.setSize=function(z,S){p=z;y=S;c=p/2;C=y/2;l.setAttribute("viewBox",-c+" "+-C+" "+p+" "+y);l.setAttribute("width",p);l.setAttribute("height",y);N.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,S){var E,U,
F,w,x,K,G,W;this.autoClear&&this.clear();k=q.projectScene(z,S,this.sortElements);M=D=r=0;if(T=z.lights.length>0){G=z.lights;O.setRGB(0,0,0);Q.setRGB(0,0,0);e.setRGB(0,0,0);E=0;for(U=G.length;E<U;E++){F=G[E];w=F.color;if(F instanceof THREE.AmbientLight){O.r+=w.r;O.g+=w.g;O.b+=w.b}else if(F instanceof THREE.DirectionalLight){Q.r+=w.r;Q.g+=w.g;Q.b+=w.b}else if(F instanceof THREE.PointLight){e.r+=w.r;e.g+=w.g;e.b+=w.b}}}E=0;for(U=k.length;E<U;E++){G=k[E];s.empty();if(G instanceof THREE.RenderableParticle){u=
G;u.x*=c;u.y*=-C;F=0;for(w=G.materials.length;F<w;F++)if(W=G.materials[F]){x=u;K=G;W=W;var ba=D++;if(n[ba]==null){n[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&n[ba].setAttribute("shape-rendering","crispEdges")}o=n[ba];o.setAttribute("cx",x.x);o.setAttribute("cy",x.y);o.setAttribute("r",K.scale.x*c);if(W instanceof THREE.ParticleCircleMaterial){if(T){L.r=O.r+Q.r+e.r;L.g=O.g+Q.g+e.g;L.b=O.b+Q.b+e.b;B.r=W.color.r*L.r;B.g=W.color.g*L.g;B.b=W.color.b*L.b;B.updateStyleString()}else B=
W.color;o.setAttribute("style","fill: "+B.__styleString)}l.appendChild(o)}}else if(G instanceof THREE.RenderableLine){u=G.v1;t=G.v2;u.positionScreen.x*=c;u.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(t.positionScreen.x,t.positionScreen.y);if(N.instersects(s)){F=0;for(w=G.materials.length;F<w;)if(W=G.materials[F++]){x=u;K=t;W=W;ba=M++;if(g[ba]==null){g[ba]=document.createElementNS("http://www.w3.org/2000/svg","line");
H==0&&g[ba].setAttribute("shape-rendering","crispEdges")}o=g[ba];o.setAttribute("x1",x.positionScreen.x);o.setAttribute("y1",x.positionScreen.y);o.setAttribute("x2",K.positionScreen.x);o.setAttribute("y2",K.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){B.__styleString=W.color.__styleString;o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);l.appendChild(o)}}}}else if(G instanceof
THREE.RenderableFace3){u=G.v1;t=G.v2;J=G.v3;u.positionScreen.x*=c;u.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(t.positionScreen.x,t.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);if(N.instersects(s)){F=0;for(w=G.meshMaterials.length;F<w;){W=G.meshMaterials[F++];if(W instanceof THREE.MeshFaceMaterial){x=0;for(K=G.faceMaterials.length;x<K;)(W=G.faceMaterials[x++])&&
b(u,t,J,G,W,z)}else W&&b(u,t,J,G,W,z)}}}else if(G instanceof THREE.RenderableFace4){u=G.v1;t=G.v2;J=G.v3;R=G.v4;u.positionScreen.x*=c;u.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;R.positionScreen.x*=c;R.positionScreen.y*=-C;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(t.positionScreen.x,t.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);s.addPoint(R.positionScreen.x,R.positionScreen.y);if(N.instersects(s)){F=
0;for(w=G.meshMaterials.length;F<w;){W=G.meshMaterials[F++];if(W instanceof THREE.MeshFaceMaterial){x=0;for(K=G.faceMaterials.length;x<K;)(W=G.faceMaterials[x++])&&f(u,t,J,R,G,W,z)}else W&&f(u,t,J,R,G,W,z)}}}}}};
THREE.WebGLRenderer=function(a,b){function f(e,h,m){var i=c.createProgram();m=["#ifdef GL_ES\nprecision highp float;\n#endif",m?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(i,l("fragment",m+e));c.attachShader(i,l("vertex",n+h));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(e,h){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
THREE.Projector=function(){function a(e,g){return g.z-e.z}function b(e,g){var m=0,h=1,n=e.z+e.w,k=g.z+g.w,q=-e.z+e.w,s=-g.z+g.w;if(n>=0&&k>=0&&q>=0&&s>=0)return true;else if(n<0&&k<0||q<0&&s<0)return false;else{if(n<0)m=Math.max(m,n/(n-k));else if(k<0)h=Math.min(h,n/(n-k));if(q<0)m=Math.max(m,q/(q-s));else if(s<0)h=Math.min(h,q/(q-s));if(h<m)return false;else{e.lerpSelf(g,m);g.lerpSelf(e,1-h);return true}}}var f,d,i=[],j,p,l,o=[],x,c,E=[],v,u,I=[],S=new THREE.Vector4,P=new THREE.Vector4,r=new THREE.Matrix4,
V=new THREE.Matrix4,C=[],J=new THREE.Vector4,Q=new THREE.Vector4,R;this.projectObjects=function(e,g,m){var h=[],n,k;d=0;r.multiply(g.projectionMatrix,g.matrix);C[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);C[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);C[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);C[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);C[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
r.n33,r.n44-r.n34);C[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);g=0;for(n=C.length;g<n;g++){k=C[g];k.divideScalar(Math.sqrt(k.x*k.x+k.y*k.y+k.z*k.z))}n=e.objects;e=0;for(g=n.length;e<g;e++){k=n[e];var q;if(!(q=!k.visible)){if(q=k instanceof THREE.Mesh){a:{q=void 0;for(var s=k.position,K=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),w=0;w<6;w++){q=C[w].x*s.x+C[w].y*s.y+C[w].z*s.z+C[w].w;if(q<=K){q=false;break a}}q=true}q=!q}q=q}if(!q){f=
i[d]=i[d]||new THREE.RenderableObject;S.copy(k.position);r.multiplyVector3(S);f.object=k;f.z=S.z;h.push(f);d++}}m&&h.sort(a);return h};this.projectScene=function(e,g,m){var h=[],n=g.near,k=g.far,q,s,K,w,T,z,A,D,U,F,H,G,L,B,N,Y;l=c=u=0;g.autoUpdateMatrix&&g.updateMatrix();r.multiply(g.projectionMatrix,g.matrix);z=this.projectObjects(e,g,true);e=0;for(q=z.length;e<q;e++){A=z[e].object;if(A.visible){A.autoUpdateMatrix&&A.updateMatrix();D=A.matrix;U=A.rotationMatrix;F=A.materials;H=A.overdraw;if(A instanceof
THREE.Mesh){G=A.geometry;L=G.vertices;s=0;for(K=L.length;s<K;s++){B=L[s];B.positionWorld.copy(B.position);D.multiplyVector3(B.positionWorld);w=B.positionScreen;w.copy(B.positionWorld);r.multiplyVector4(w);w.x/=w.w;w.y/=w.w;B.__visible=w.z>n&&w.z<k}G=G.faces;s=0;for(K=G.length;s<K;s++){B=G[s];if(B instanceof THREE.Face3){w=L[B.a];T=L[B.b];N=L[B.c];if(w.__visible&&T.__visible&&N.__visible)if(A.doubleSided||A.flipSided!=(N.positionScreen.x-w.positionScreen.x)*(T.positionScreen.y-w.positionScreen.y)-
(N.positionScreen.y-w.positionScreen.y)*(T.positionScreen.x-w.positionScreen.x)<0){j=o[l]=o[l]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(T.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(B.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(B.centroid);D.multiplyVector3(j.centroidWorld);
j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);N=B.vertexNormals;R=j.vertexNormalsWorld;w=0;for(T=N.length;w<T;w++){Y=R[w]=R[w]||new THREE.Vector3;Y.copy(N[w]);U.multiplyVector3(Y)}j.z=j.centroidScreen.z;j.meshMaterials=F;j.faceMaterials=B.materials;j.overdraw=H;if(A.geometry.uvs[s]){j.uvs[0]=A.geometry.uvs[s][0];j.uvs[1]=A.geometry.uvs[s][1];j.uvs[2]=A.geometry.uvs[s][2]}h.push(j);l++}}else if(B instanceof THREE.Face4){w=L[B.a];T=L[B.b];N=L[B.c];Y=L[B.d];if(w.__visible&&
T.__visible&&N.__visible&&Y.__visible)if(A.doubleSided||A.flipSided!=((Y.positionScreen.x-w.positionScreen.x)*(T.positionScreen.y-w.positionScreen.y)-(Y.positionScreen.y-w.positionScreen.y)*(T.positionScreen.x-w.positionScreen.x)<0||(T.positionScreen.x-N.positionScreen.x)*(Y.positionScreen.y-N.positionScreen.y)-(T.positionScreen.y-N.positionScreen.y)*(Y.positionScreen.x-N.positionScreen.x)<0)){j=o[l]=o[l]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(T.positionWorld);
j.v3.positionWorld.copy(Y.positionWorld);j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(Y.positionScreen);j.normalWorld.copy(B.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(B.centroid);D.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=F;j.faceMaterials=B.materials;j.overdraw=H;if(A.geometry.uvs[s]){j.uvs[0]=A.geometry.uvs[s][0];
j.uvs[1]=A.geometry.uvs[s][1];j.uvs[2]=A.geometry.uvs[s][3]}h.push(j);l++;p=o[l]=o[l]||new THREE.RenderableFace3;p.v1.positionWorld.copy(T.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(T.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
F;p.faceMaterials=B.materials;p.overdraw=H;if(A.geometry.uvs[s]){p.uvs[0]=A.geometry.uvs[s][1];p.uvs[1]=A.geometry.uvs[s][2];p.uvs[2]=A.geometry.uvs[s][3]}h.push(p);l++}}}}else if(A instanceof THREE.Line){V.multiply(r,D);L=A.geometry.vertices;B=L[0];B.positionScreen.copy(B.position);V.multiplyVector4(B.positionScreen);s=1;for(K=L.length;s<K;s++){w=L[s];w.positionScreen.copy(w.position);V.multiplyVector4(w.positionScreen);T=L[s-1];J.copy(w.positionScreen);Q.copy(T.positionScreen);if(b(J,Q)){J.multiplyScalar(1/
J.w);Q.multiplyScalar(1/Q.w);x=E[c]=E[c]||new THREE.RenderableLine;x.v1.positionScreen.copy(J);x.v2.positionScreen.copy(Q);x.z=Math.max(J.z,Q.z);x.materials=A.materials;h.push(x);c++}}}else if(A instanceof THREE.Particle){P.set(A.position.x,A.position.y,A.position.z,1);r.multiplyVector4(P);P.z/=P.w;if(P.z>0&&P.z<1){v=I[u]=I[u]||new THREE.RenderableParticle;v.x=P.x/P.w;v.y=P.y/P.w;v.z=P.z;v.rotation=A.rotation.z;v.scale.x=A.scale.x*Math.abs(v.x-(P.x+g.projectionMatrix.n11)/(P.w+g.projectionMatrix.n14));
v.scale.y=A.scale.y*Math.abs(v.y-(P.y+g.projectionMatrix.n22)/(P.w+g.projectionMatrix.n24));v.materials=A.materials;h.push(v);u++}}}}m&&h.sort(a);return h};this.unprojectVector=function(e,g){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));m.multiplyVector3(e);return e}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,j;this.domElement=document.createElement("div");this.setSize=function(p,l){f=p;d=l;i=f/2;j=d/2};this.render=function(p,l){var o,x,c,E,v,u,I,S;a=b.projectScene(p,l);o=0;for(x=a.length;o<x;o++){v=a[o];if(v instanceof THREE.RenderableParticle){I=v.x*i+i;S=v.y*j+j;c=0;for(E=v.material.length;c<E;c++){u=v.material[c];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=I+"px";u.style.top=S+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,j,p,l=f.getContext("2d"),o=1,x=0,c=null,E=null,v=1,u,I,S,P,r,V,C,J,Q,R=new THREE.Color,e=new THREE.Color,g=new THREE.Color,m=new THREE.Color,h=new THREE.Color,n,k,q,s,K,w,T,z,A,D=new THREE.Rectangle,U=new THREE.Rectangle,F=new THREE.Rectangle,H=false,G=new THREE.Color,L=new THREE.Color,B=new THREE.Color,N=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,pa,qa,Ba,ea,ra,va,ma=16;pa=document.createElement("canvas");
pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);Ba=qa.getImageData(0,0,2,2);ea=Ba.data;ra=document.createElement("canvas");ra.width=ra.height=ma;va=ra.getContext("2d");va.translate(-ma/2,-ma/2);va.scale(ma,ma);ma--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ha,na){d=ha;i=na;j=d/2;p=i/2;f.width=d;f.height=i;D.set(-j,-p,j,p)};this.clear=function(){if(!U.isEmpty()){U.inflate(1);U.minSelf(D);l.clearRect(U.getX(),
U.getY(),U.getWidth(),U.getHeight());U.empty()}};this.render=function(ha,na){function La(t){var W,O,y,M=t.lights;L.setRGB(0,0,0);B.setRGB(0,0,0);N.setRGB(0,0,0);t=0;for(W=M.length;t<W;t++){O=M[t];y=O.color;if(O instanceof THREE.AmbientLight){L.r+=y.r;L.g+=y.g;L.b+=y.b}else if(O instanceof THREE.DirectionalLight){B.r+=y.r;B.g+=y.g;B.b+=y.b}else if(O instanceof THREE.PointLight){N.r+=y.r;N.g+=y.g;N.b+=y.b}}}function wa(t,W,O,y){var M,X,ba,ca,da=t.lights;t=0;for(M=da.length;t<M;t++){X=da[t];ba=X.color;
ca=X.intensity;if(X instanceof THREE.DirectionalLight){X=O.dot(X.position)*ca;if(X>0){y.r+=ba.r*X;y.g+=ba.g*X;y.b+=ba.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=O.dot(Z)*ca;if(X>0){y.r+=ba.r*X;y.g+=ba.g*X;y.b+=ba.b*X}}}}function Ma(t,W,O){if(O.opacity!=0){Ca(O.opacity);xa(O.blending);var y,M,X,ba,ca,da;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){ba=O.map;ca=ba.width>>1;da=ba.height>>1;M=W.scale.x*j;X=W.scale.y*p;O=M*ca;y=X*da;F.set(t.x-O,t.y-y,t.x+O,
t.y+y);if(D.instersects(F)){l.save();l.translate(t.x,t.y);l.rotate(-W.rotation);l.scale(M,-X);l.translate(-ca,-da);l.drawImage(ba,0,0);l.restore()}}}else if(O instanceof THREE.ParticleCircleMaterial){if(H){G.r=L.r+B.r+N.r;G.g=L.g+B.g+N.g;G.b=L.b+B.b+N.b;R.r=O.color.r*G.r;R.g=O.color.g*G.g;R.b=O.color.b*G.b;R.updateStyleString()}else R.__styleString=O.color.__styleString;O=W.scale.x*j;y=W.scale.y*p;F.set(t.x-O,t.y-y,t.x+O,t.y+y);if(D.instersects(F)){M=R.__styleString;if(E!=M)l.fillStyle=E=M;l.save();
l.translate(t.x,t.y);l.rotate(-W.rotation);l.scale(O,y);l.beginPath();l.arc(0,0,1,0,Y,true);l.closePath();l.fill();l.restore()}}}}function Na(t,W,O,y){if(y.opacity!=0){Ca(y.opacity);xa(y.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(y instanceof THREE.LineBasicMaterial){R.__styleString=y.color.__styleString;t=y.linewidth;if(v!=t)l.lineWidth=v=t;t=R.__styleString;if(c!=t)l.strokeStyle=c=t;l.stroke();F.inflate(y.linewidth*
2)}}}function Ha(t,W,O,y,M,X){if(M.opacity!=0){Ca(M.opacity);xa(M.blending);P=t.positionScreen.x;r=t.positionScreen.y;V=W.positionScreen.x;C=W.positionScreen.y;J=O.positionScreen.x;Q=O.positionScreen.y;l.beginPath();l.moveTo(P,r);l.lineTo(V,C);l.lineTo(J,Q);l.lineTo(P,r);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof THREE.UVMapping&&sa(P,r,V,C,J,Q,M.map.image,y.uvs[0].u,y.uvs[0].v,y.uvs[1].u,y.uvs[1].v,y.uvs[2].u,y.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof
THREE.SphericalReflectionMapping){t=na.matrix;Z.copy(y.vertexNormalsWorld[0]);s=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;K=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[1]);w=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;T=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[2]);z=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;A=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;sa(P,r,V,C,J,Q,M.env_map.image,s,K,w,T,z,A)}}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):
za(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&sa(P,r,V,C,J,Q,M.map.image,y.uvs[0].u,y.uvs[0].v,y.uvs[1].u,y.uvs[1].v,y.uvs[2].u,y.uvs[2].v);xa(THREE.SubtractiveBlending)}if(H)if(!M.wireframe&&M.shading==THREE.SmoothShading&&y.vertexNormalsWorld.length==3){e.r=g.r=m.r=L.r;e.g=g.g=m.g=L.g;e.b=g.b=m.b=L.b;wa(X,y.v1.positionWorld,y.vertexNormalsWorld[0],e);wa(X,y.v2.positionWorld,y.vertexNormalsWorld[1],g);wa(X,
y.v3.positionWorld,y.vertexNormalsWorld[2],m);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,r,V,C,J,Q,q,0,0,1,0,0,1)}else{G.r=L.r;G.g=L.g;G.b=L.b;wa(X,y.centroidWorld,y.normalWorld,G);R.r=M.color.r*G.r;R.g=M.color.g*G.g;R.b=M.color.b*G.b;R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){n=na.near;
k=na.far;e.r=e.g=e.b=1-Da(t.positionScreen.z,n,k);g.r=g.g=g.b=1-Da(W.positionScreen.z,n,k);m.r=m.g=m.b=1-Da(O.positionScreen.z,n,k);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,r,V,C,J,Q,q,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){R.r=Ea(y.normalWorld.x);R.g=Ea(y.normalWorld.y);R.b=Ea(y.normalWorld.z);R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}}}function ya(t,W){if(c!=t)l.strokeStyle=c=t;if(v!=W)l.lineWidth=
v=W;l.stroke();F.inflate(W*2)}function za(t){if(E!=t)l.fillStyle=E=t;l.fill()}function sa(t,W,O,y,M,X,ba,ca,da,ia,fa,ja,ta){var la,ka;la=ba.width-1;ka=ba.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;ta*=ka;O-=t;y-=W;M-=t;X-=W;ia-=ca;fa-=da;ja-=ca;ta-=da;ka=1/(ia*ta-ja*fa);la=(ta*O-fa*M)*ka;fa=(ta*y-fa*X)*ka;O=(ia*M-ja*O)*ka;y=(ia*X-ja*y)*ka;t=t-la*ca-O*da;W=W-fa*ca-y*da;l.save();l.transform(la,fa,O,y,t,W);l.clip();l.drawImage(ba,0,0);l.restore()}function Ca(t){if(o!=t)l.globalAlpha=o=t}function xa(t){if(x!=
t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}x=t}}function Ia(t,W,O,y){var M=~~(t.r*255),X=~~(t.g*255);t=~~(t.b*255);var ba=~~(W.r*255),ca=~~(W.g*255);W=~~(W.b*255);var da=~~(O.r*255),ia=~~(O.g*255);O=~~(O.b*255);var fa=~~(y.r*255),ja=~~(y.g*255);y=~~(y.b*255);ea[0]=M<0?0:M>255?255:M;ea[1]=X<0?0:X>255?255:X;ea[2]=t<0?0:t>
255?255:t;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=W<0?0:W>255?255:W;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=O<0?0:O>255?255:O;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=y<0?0:y>255?255:y;qa.putImageData(Ba,0,0);va.drawImage(pa,0,0);return ra}function Da(t,W,O){t=(t-W)/(O-W);return t*t*(3-2*t)}function Ea(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Fa(t,W){var O=W.x-t.x,y=W.y-t.y,M=1/Math.sqrt(O*O+y*y);O*=M;y*=M;W.x+=O;W.y+=y;t.x-=O;t.y-=
y}var Aa,Ja,$,ga,oa,Ga,Ka,ua;l.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ha,na,this.sortElements);(H=ha.lights.length>0)&&La(ha);Aa=0;for(Ja=a.length;Aa<Ja;Aa++){$=a[Aa];F.empty();if($ instanceof THREE.RenderableParticle){u=$;u.x*=j;u.y*=p;ga=0;for(oa=$.materials.length;ga<oa;ga++)Ma(u,$,$.materials[ga],ha)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;F.addPoint(u.positionScreen.x,
u.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(D.instersects(F)){ga=0;for(oa=$.materials.length;ga<oa;)Na(u,I,$,$.materials[ga++],ha)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=$.v2;S=$.v3;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;S.positionScreen.x*=j;S.positionScreen.y*=p;if($.overdraw){Fa(u.positionScreen,I.positionScreen);Fa(I.positionScreen,S.positionScreen);Fa(S.positionScreen,u.positionScreen)}F.add3Points(u.positionScreen.x,
u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,S.positionScreen.x,S.positionScreen.y);if(D.instersects(F)){ga=0;for(oa=$.meshMaterials.length;ga<oa;){ua=$.meshMaterials[ga++];if(ua instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(ua=$.faceMaterials[Ga++])&&Ha(u,I,S,$,ua,ha)}else Ha(u,I,S,$,ua,ha)}}}U.addRectangle(F)}l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(z,A,D){var U,F,H,G;U=0;for(F=z.lights.length;U<F;U++){H=z.lights[U];if(H instanceof THREE.DirectionalLight){G=A.normalWorld.dot(H.position)*H.intensity;if(G>0){D.r+=H.color.r*G;D.g+=H.color.g*G;D.b+=H.color.b*G}}else if(H instanceof THREE.PointLight){m.sub(H.position,A.centroidWorld);m.normalize();G=A.normalWorld.dot(m)*H.intensity;if(G>0){D.r+=H.color.r*G;D.g+=H.color.g*G;D.b+=H.color.b*G}}}}function b(z,A,D,U,F,H){q=d(s++);q.setAttribute("d","M "+z.positionScreen.x+
" "+z.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)C.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(H,U,J);C.r=F.color.r*J.r;C.g=F.color.g*J.g;C.b=F.color.b*J.b;C.updateStyleString()}else C.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){g=1-F.__2near/(F.__farPlusNear-U.z*F.__farMinusNear);
C.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&C.setRGB(i(U.normalWorld.x),i(U.normalWorld.y),i(U.normalWorld.z));F.wireframe?q.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):q.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+F.opacity);l.appendChild(q)}function f(z,A,D,U,F,H,G){q=d(s++);q.setAttribute("d",
"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)C.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(G,F,J);C.r=H.color.r*J.r;C.g=H.color.g*J.g;C.b=H.color.b*J.b;C.updateStyleString()}else C.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){g=
1-H.__2near/(H.__farPlusNear-F.z*H.__farMinusNear);C.setRGB(g,g,g)}else H instanceof THREE.MeshNormalMaterial&&C.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));H.wireframe?q.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):q.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+H.opacity);l.appendChild(q)}
function d(z){if(h[z]==null){h[z]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&h[z].setAttribute("shape-rendering","crispEdges");return h[z]}return h[z]}function i(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var j=null,p=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,x,c,E,v,u,I,S,P=new THREE.Rectangle,r=new THREE.Rectangle,V=false,C=new THREE.Color(16777215),J=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0),
e=new THREE.Color(0),g,m=new THREE.Vector3,h=[],n=[],k=[],q,s,K,w,T=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":T=1;break;case "low":T=0}};this.setSize=function(z,A){o=z;x=A;c=o/2;E=x/2;l.setAttribute("viewBox",-c+" "+-E+" "+o+" "+x);l.setAttribute("width",o);l.setAttribute("height",x);P.set(-c,-E,c,E)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,A){var D,U,
F,H,G,L,B,N;this.autoClear&&this.clear();j=p.projectScene(z,A,this.sortElements);w=K=s=0;if(V=z.lights.length>0){B=z.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);e.setRGB(0,0,0);D=0;for(U=B.length;D<U;D++){F=B[D];H=F.color;if(F instanceof THREE.AmbientLight){Q.r+=H.r;Q.g+=H.g;Q.b+=H.b}else if(F instanceof THREE.DirectionalLight){R.r+=H.r;R.g+=H.g;R.b+=H.b}else if(F instanceof THREE.PointLight){e.r+=H.r;e.g+=H.g;e.b+=H.b}}}D=0;for(U=j.length;D<U;D++){B=j[D];r.empty();if(B instanceof THREE.RenderableParticle){v=
B;v.x*=c;v.y*=-E;F=0;for(H=B.materials.length;F<H;F++)if(N=B.materials[F]){G=v;L=B;N=N;var Y=K++;if(n[Y]==null){n[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&n[Y].setAttribute("shape-rendering","crispEdges")}q=n[Y];q.setAttribute("cx",G.x);q.setAttribute("cy",G.y);q.setAttribute("r",L.scale.x*c);if(N instanceof THREE.ParticleCircleMaterial){if(V){J.r=Q.r+R.r+e.r;J.g=Q.g+R.g+e.g;J.b=Q.b+R.b+e.b;C.r=N.color.r*J.r;C.g=N.color.g*J.g;C.b=N.color.b*J.b;C.updateStyleString()}else C=
N.color;q.setAttribute("style","fill: "+C.__styleString)}l.appendChild(q)}}else if(B instanceof THREE.RenderableLine){v=B.v1;u=B.v2;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);if(P.instersects(r)){F=0;for(H=B.materials.length;F<H;)if(N=B.materials[F++]){G=v;L=u;N=N;Y=w++;if(k[Y]==null){k[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");T==
0&&k[Y].setAttribute("shape-rendering","crispEdges")}q=k[Y];q.setAttribute("x1",G.positionScreen.x);q.setAttribute("y1",G.positionScreen.y);q.setAttribute("x2",L.positionScreen.x);q.setAttribute("y2",L.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){C.__styleString=N.color.__styleString;q.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);l.appendChild(q)}}}}else if(B instanceof
THREE.RenderableFace3){v=B.v1;u=B.v2;I=B.v3;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;I.positionScreen.x*=c;I.positionScreen.y*=-E;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);if(P.instersects(r)){F=0;for(H=B.meshMaterials.length;F<H;){N=B.meshMaterials[F++];if(N instanceof THREE.MeshFaceMaterial){G=0;for(L=B.faceMaterials.length;G<L;)(N=B.faceMaterials[G++])&&
b(v,u,I,B,N,z)}else N&&b(v,u,I,B,N,z)}}}else if(B instanceof THREE.RenderableFace4){v=B.v1;u=B.v2;I=B.v3;S=B.v4;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;I.positionScreen.x*=c;I.positionScreen.y*=-E;S.positionScreen.x*=c;S.positionScreen.y*=-E;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);r.addPoint(S.positionScreen.x,S.positionScreen.y);if(P.instersects(r)){F=
0;for(H=B.meshMaterials.length;F<H;){N=B.meshMaterials[F++];if(N instanceof THREE.MeshFaceMaterial){G=0;for(L=B.faceMaterials.length;G<L;)(N=B.faceMaterials[G++])&&f(v,u,I,S,B,N,z)}else N&&f(v,u,I,S,B,N,z)}}}}}};
THREE.WebGLRenderer=function(a,b){function f(e,g,m){var h=c.createProgram();m=["#ifdef GL_ES\nprecision highp float;\n#endif",m?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(h,l("fragment",m+e));c.attachShader(h,l("vertex",n+g));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(e,g){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.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(var m=0;m<6;++m)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[m]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
h);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function j(e,h){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,p(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,p(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,p(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
p(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,h){var m,i,n;m=0;for(i=h.length;m<i;m++){n=h[m];e.uniforms[n]=c.getUniformLocation(e,n)}}function q(e,h){var m,i,n;m=0;for(i=h.length;m<i;m++){n=h[m];e.attributes[n]=c.getAttribLocation(e,n)}}function l(e,h){var m;if(e=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")m=c.createShader(c.VERTEX_SHADER);c.shaderSource(m,
h);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function p(e){switch(e){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}return 0}var y=document.createElement("canvas"),c,C,u,t=new THREE.Matrix4,J,R=new Float32Array(16),N=new Float32Array(16),s=new Float32Array(16),T=new Float32Array(9),B=new Float32Array(16),L=function(e,h){if(e){var m,i,n,g=pointLights=maxDirLights=maxPointLights=0;m=0;for(i=e.lights.length;m<i;m++){n=e.lights[m];n instanceof THREE.DirectionalLight&&g++;n instanceof
THREE.PointLight&&pointLights++}if(pointLights+g<=h){maxDirLights=g;maxPointLights=pointLights}else{maxDirLights=Math.ceil(h*g/(pointLights+g));maxPointLights=h-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:h-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=y;this.autoClear=true;try{c=y.getContext("experimental-webgl",{antialias:aa})}catch(O){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,
1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);C=u=function(e,h,m){var i=[e?"#define MAX_DIR_LIGHTS "+e:"",h?"#define MAX_POINT_LIGHTS "+h:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",h?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",h?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",h?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",h?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",h?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",h?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",h?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",h?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
n=[e?"#define MAX_DIR_LIGHTS "+e:"",h?"#define MAX_POINT_LIGHTS "+h:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",h?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
h?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",h?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",h?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",h?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",h?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",h?"float pointSpecularWeight = 0.0;":"",h?"if ( pointDotNormalHalf >= 0.0 )":
"",h?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",h?"pointDiffuse += mColor * pointDiffuseWeight;":"",h?"pointSpecular += mSpecular * pointSpecularWeight;":"",h?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",h?"totalLight += pointDiffuse + pointSpecular;":
g);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,g){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,o(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,o(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,o(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
o(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,g){var m,h,n;m=0;for(h=g.length;m<h;m++){n=g[m];e.uniforms[n]=c.getUniformLocation(e,n)}}function p(e,g){var m,h,n;m=0;for(h=g.length;m<h;m++){n=g[m];e.attributes[n]=c.getAttribLocation(e,n)}}function l(e,g){var m;if(e=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")m=c.createShader(c.VERTEX_SHADER);c.shaderSource(m,
g);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function o(e){switch(e){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}return 0}var x=document.createElement("canvas"),c,E,v,u=new THREE.Matrix4,I,S=new Float32Array(16),P=new Float32Array(16),r=new Float32Array(16),V=new Float32Array(9),C=new Float32Array(16),J=function(e,g){if(e){var m,h,n,k=pointLights=maxDirLights=maxPointLights=0;m=0;for(h=e.lights.length;m<h;m++){n=e.lights[m];n instanceof THREE.DirectionalLight&&k++;n instanceof
THREE.PointLight&&pointLights++}if(pointLights+k<=g){maxDirLights=k;maxPointLights=pointLights}else{maxDirLights=Math.ceil(g*k/(pointLights+k));maxPointLights=g-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:g-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=x;this.autoClear=true;try{c=x.getContext("experimental-webgl",{antialias:aa})}catch(Q){}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(0,0,0,0);E=v=function(e,g,m){var h=[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",g?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",g?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",g?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",g?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",g?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",g?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",g?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
n=[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
g?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",g?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",g?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",g?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",g?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",g?"float pointSpecularWeight = 0.0;":"",g?"if ( pointDotNormalHalf >= 0.0 )":
"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"totalLight += pointDiffuse + pointSpecular;":
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
i=f(n,i,m);c.useProgram(i);k(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&k(i,["fogColor","fogNear","fogFar"]);e&&k(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);h&&k(i,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);q(i,["position","normal","uv"]);return i}(L.directional,L.point,fog);this.setSize=function(e,h){y.width=e;y.height=h;c.viewport(0,0,y.width,y.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var m,i,n,g,o,
r=[],D=[],M=[];g=[];o=[];c.uniform1i(e.uniforms.enableLighting,h.length);m=0;for(i=h.length;m<i;m++){n=h[m];if(n instanceof THREE.AmbientLight)r.push(n);else if(n instanceof THREE.DirectionalLight)M.push(n);else n instanceof THREE.PointLight&&D.push(n)}m=n=g=o=0;for(i=r.length;m<i;m++){n+=r[m].color.r;g+=r[m].color.g;o+=r[m].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,g,o);g=[];o=[];m=0;for(i=M.length;m<i;m++){n=M[m];g.push(n.color.r*n.intensity);g.push(n.color.g*n.intensity);g.push(n.color.b*
n.intensity);o.push(n.position.x);o.push(n.position.y);o.push(n.position.z)}if(M.length){c.uniform1i(e.uniforms.directionalLightNumber,M.length);c.uniform3fv(e.uniforms.directionalLightDirection,o);c.uniform3fv(e.uniforms.directionalLightColor,g)}g=[];o=[];m=0;for(i=D.length;m<i;m++){n=D[m];g.push(n.color.r*n.intensity);g.push(n.color.g*n.intensity);g.push(n.color.b*n.intensity);o.push(n.position.x);o.push(n.position.y);o.push(n.position.z)}if(D.length){c.uniform1i(e.uniforms.pointLightNumber,D.length);
c.uniform3fv(e.uniforms.pointLightPosition,o);c.uniform3fv(e.uniforms.pointLightColor,g)}};this.createBuffers=function(e,h){var m,i,n,g,o,r,D,M,H,z=[],S=[],E=[],U=[],F=[],w=[],x=0,K=e.geometry.geometryChunks[h],G;n=false;m=0;for(i=e.materials.length;m<i;m++){meshMaterial=e.materials[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(G=K.materials.length;o<G;o++)if(K.materials[o]&&K.materials[o].shading!=undefined&&K.materials[o].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}G=n;m=0;for(i=K.faces.length;m<i;m++){n=K.faces[m];g=e.geometry.faces[n];o=g.vertexNormals;faceNormal=g.normal;n=e.geometry.uvs[n];if(g instanceof THREE.Face3){r=e.geometry.vertices[g.a].position;D=e.geometry.vertices[g.b].position;M=e.geometry.vertices[g.c].position;E.push(r.x,r.y,r.z);E.push(D.x,D.y,D.z);E.push(M.x,M.y,M.z);if(e.geometry.hasTangents){r=e.geometry.vertices[g.a].tangent;D=e.geometry.vertices[g.b].tangent;
M=e.geometry.vertices[g.c].tangent;F.push(r.x,r.y,r.z,r.w);F.push(D.x,D.y,D.z,D.w);F.push(M.x,M.y,M.z,M.w)}if(o.length==3&&G)for(g=0;g<3;g++)U.push(o[g].x,o[g].y,o[g].z);else for(g=0;g<3;g++)U.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(g=0;g<3;g++)w.push(n[g].u,n[g].v);z.push(x,x+1,x+2);S.push(x,x+1);S.push(x,x+2);S.push(x+1,x+2);x+=3}else if(g instanceof THREE.Face4){r=e.geometry.vertices[g.a].position;D=e.geometry.vertices[g.b].position;M=e.geometry.vertices[g.c].position;H=e.geometry.vertices[g.d].position;
E.push(r.x,r.y,r.z);E.push(D.x,D.y,D.z);E.push(M.x,M.y,M.z);E.push(H.x,H.y,H.z);if(e.geometry.hasTangents){r=e.geometry.vertices[g.a].tangent;D=e.geometry.vertices[g.b].tangent;M=e.geometry.vertices[g.c].tangent;g=e.geometry.vertices[g.d].tangent;F.push(r.x,r.y,r.z,r.w);F.push(D.x,D.y,D.z,D.w);F.push(M.x,M.y,M.z,M.w);F.push(g.x,g.y,g.z,g.w)}if(o.length==4&&G)for(g=0;g<4;g++)U.push(o[g].x,o[g].y,o[g].z);else for(g=0;g<4;g++)U.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(g=0;g<4;g++)w.push(n[g].u,
n[g].v);z.push(x,x+1,x+2);z.push(x,x+2,x+3);S.push(x,x+1);S.push(x,x+2);S.push(x,x+3);S.push(x+1,x+2);S.push(x+2,x+3);x+=4}}if(E.length){K.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);K.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW);if(e.geometry.hasTangents){K.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,K.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}if(w.length>0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(w),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);K.__webGLFaceCount=z.length;K.__webGLLineCount=S.length}};this.renderBuffer=function(e,h,m,i,n){var g,o,r,D,M,H,z,S,E;if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){if(!i.program){if(i instanceof THREE.MeshDepthMaterial){z=Q.depth;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms;i.uniforms.mNear.value=
i.near;i.uniforms.mFar.value=i.far}else if(i instanceof THREE.MeshNormalMaterial){z=Q.normal;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms}i.program=f(i.fragment_shader,i.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)z.push(E);k(i.program,z);q(i.program,["position","normal","uv","tangent"])}E=i.program}else E=u;if(E!=C){c.useProgram(E);C=E}E==u&&this.setupLights(E,
h);this.loadCamera(E,e);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){r=i.wireframe;D=i.wireframe_linewidth;e=E;h=i.uniforms;var U;for(g in h){S=h[g].type;z=h[g].value;U=e.uniforms[g];if(S=="i")c.uniform1i(U,z);else if(S=="f")c.uniform1f(U,z);else if(S=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(S=="c")c.uniform3f(U,z.r,z.g,z.b);else if(S=="t"){c.uniform1i(U,z);if(S=h[g].texture)S.image instanceof Array&&S.image.length==
6?d(S,z):j(S,z)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){g=i.color;o=i.opacity;r=i.wireframe;D=i.wireframe_linewidth;M=i.map;H=i.env_map;h=i.combine==THREE.MixOperation;e=i.reflectivity;S=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;z=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,g.r*o,g.g*o,g.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,h);c.uniform1f(E.uniforms.mReflectivity,e);c.uniform1i(E.uniforms.useRefract,
S);c.uniform1f(E.uniforms.mRefractionRatio,z);if(m){c.uniform1f(E.uniforms.fogNear,m.near);c.uniform1f(E.uniforms.fogFar,m.far);c.uniform3f(E.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(i instanceof THREE.MeshPhongMaterial){m=i.ambient;g=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,m.r,m.g,m.b,o);c.uniform4f(E.uniforms.mSpecular,g.r,g.g,g.b,o);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,
1);else i instanceof THREE.MeshBasicMaterial&&c.uniform1i(E.uniforms.material,0);if(M){j(M,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(H){d(H,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);o=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(r){c.lineWidth(D);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,h,m,i,n,g,o){var r,D,M,H,z;M=0;for(H=i.materials.length;M<H;M++){r=i.materials[M];if(r instanceof THREE.MeshFaceMaterial){r=0;for(D=n.materials.length;r<D;r++)if((z=n.materials[r])&&z.blending==g&&z.opacity<1==o){this.setBlending(z.blending);
this.renderBuffer(e,h,m,z,n)}}else if((z=r)&&z.blending==g&&z.opacity<1==o){this.setBlending(z.blending);this.renderBuffer(e,h,m,z,n)}}};this.render=function(e,h){var m,i,n,g,o=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();R.set(h.matrix.flatten());s.set(h.projectionMatrix.flatten());m=0;for(i=e.__webGLObjects.length;m<i;m++){n=e.__webGLObjects[m];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,h);this.renderPass(h,o,r,g,n,THREE.NormalBlending,
false)}}m=0;for(i=e.__webGLObjects.length;m<i;m++){n=e.__webGLObjects[m];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,h);this.renderPass(h,o,r,g,n,THREE.AdditiveBlending,false);this.renderPass(h,o,r,g,n,THREE.SubtractiveBlending,false);this.renderPass(h,o,r,g,n,THREE.AdditiveBlending,true);this.renderPass(h,o,r,g,n,THREE.SubtractiveBlending,true);this.renderPass(h,o,r,g,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var h,m,i,n,g,o;if(!e.__webGLObjects){e.__webGLObjects=
[];e.__webGLObjectsMap={}}h=0;for(m=e.objects.length;h<m;h++){i=e.objects[h];if(e.__webGLObjectsMap[i.id]==undefined)e.__webGLObjectsMap[i.id]={};o=e.__webGLObjectsMap[i.id];if(i instanceof THREE.Mesh)for(g in i.geometry.geometryChunks){n=i.geometry.geometryChunks[g];n.__webGLVertexBuffer||this.createBuffers(i,g);if(o[g]==undefined){n={buffer:n,object:i};e.__webGLObjects.push(n);o[g]=1}}}};this.removeObject=function(e,h){var m,i;for(m=e.__webGLObjects.length-1;m>=0;m--){i=e.__webGLObjects[m].object;
h==i&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,h){e.autoUpdateMatrix&&e.updateMatrix();t.multiply(h.matrix,e.matrix);N.set(t.flatten());J=THREE.Matrix4.makeInvert3x3(t).transpose();T.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,T);c.uniformMatrix4fv(e.uniforms.objectMatrix,
false,B)};this.loadCamera=function(e,h){c.uniform3f(e.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){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(e,h){if(e){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
else e=="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};var Q={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}",
h=f(n,h,m);c.useProgram(h);j(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&j(h,["fogColor","fogNear","fogFar"]);e&&j(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);g&&j(h,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);p(h,["position","normal","uv"]);return h}(J.directional,J.point,fog);this.setSize=function(e,g){x.width=e;x.height=g;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,g){var m,h,n,k,q,
s=[],K=[],w=[];k=[];q=[];c.uniform1i(e.uniforms.enableLighting,g.length);m=0;for(h=g.length;m<h;m++){n=g[m];if(n instanceof THREE.AmbientLight)s.push(n);else if(n instanceof THREE.DirectionalLight)w.push(n);else n instanceof THREE.PointLight&&K.push(n)}m=n=k=q=0;for(h=s.length;m<h;m++){n+=s[m].color.r;k+=s[m].color.g;q+=s[m].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,k,q);k=[];q=[];m=0;for(h=w.length;m<h;m++){n=w[m];k.push(n.color.r*n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*
n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(w.length){c.uniform1i(e.uniforms.directionalLightNumber,w.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,k)}k=[];q=[];m=0;for(h=K.length;m<h;m++){n=K[m];k.push(n.color.r*n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(K.length){c.uniform1i(e.uniforms.pointLightNumber,K.length);
c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,k)}};this.createBuffers=function(e,g){var m,h,n,k,q,s,K,w,T,z=[],A=[],D=[],U=[],F=[],H=[],G=0,L=e.geometry.geometryChunks[g],B;n=false;m=0;for(h=e.materials.length;m<h;m++){meshMaterial=e.materials[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(B=L.materials.length;q<B;q++)if(L.materials[q]&&L.materials[q].shading!=undefined&&L.materials[q].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}B=n;m=0;for(h=L.faces.length;m<h;m++){n=L.faces[m];k=e.geometry.faces[n];q=k.vertexNormals;faceNormal=k.normal;n=e.geometry.uvs[n];if(k instanceof THREE.Face3){s=e.geometry.vertices[k.a].position;K=e.geometry.vertices[k.b].position;w=e.geometry.vertices[k.c].position;D.push(s.x,s.y,s.z);D.push(K.x,K.y,K.z);D.push(w.x,w.y,w.z);if(e.geometry.hasTangents){s=e.geometry.vertices[k.a].tangent;K=e.geometry.vertices[k.b].tangent;
w=e.geometry.vertices[k.c].tangent;F.push(s.x,s.y,s.z,s.w);F.push(K.x,K.y,K.z,K.w);F.push(w.x,w.y,w.z,w.w)}if(q.length==3&&B)for(k=0;k<3;k++)U.push(q[k].x,q[k].y,q[k].z);else for(k=0;k<3;k++)U.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<3;k++)H.push(n[k].u,n[k].v);z.push(G,G+1,G+2);A.push(G,G+1);A.push(G,G+2);A.push(G+1,G+2);G+=3}else if(k instanceof THREE.Face4){s=e.geometry.vertices[k.a].position;K=e.geometry.vertices[k.b].position;w=e.geometry.vertices[k.c].position;T=e.geometry.vertices[k.d].position;
D.push(s.x,s.y,s.z);D.push(K.x,K.y,K.z);D.push(w.x,w.y,w.z);D.push(T.x,T.y,T.z);if(e.geometry.hasTangents){s=e.geometry.vertices[k.a].tangent;K=e.geometry.vertices[k.b].tangent;w=e.geometry.vertices[k.c].tangent;k=e.geometry.vertices[k.d].tangent;F.push(s.x,s.y,s.z,s.w);F.push(K.x,K.y,K.z,K.w);F.push(w.x,w.y,w.z,w.w);F.push(k.x,k.y,k.z,k.w)}if(q.length==4&&B)for(k=0;k<4;k++)U.push(q[k].x,q[k].y,q[k].z);else for(k=0;k<4;k++)U.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<4;k++)H.push(n[k].u,
n[k].v);z.push(G,G+1,G+2);z.push(G,G+2,G+3);A.push(G,G+1);A.push(G,G+2);A.push(G,G+3);A.push(G+1,G+2);A.push(G+2,G+3);G+=4}}if(D.length){L.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);L.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW);if(e.geometry.hasTangents){L.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,L.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}if(H.length>0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),c.STATIC_DRAW);L.__webGLFaceCount=z.length;L.__webGLLineCount=A.length}};this.renderBuffer=function(e,g,m,h,n){var k,q,s,K,w,T,z,A,D;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){z=R.depth;h.fragment_shader=z.fragment_shader;h.vertex_shader=z.vertex_shader;h.uniforms=z.uniforms;h.uniforms.mNear.value=
e.near;h.uniforms.mFar.value=e.far}else if(h instanceof THREE.MeshNormalMaterial){z=R.normal;h.fragment_shader=z.fragment_shader;h.vertex_shader=z.vertex_shader;h.uniforms=z.uniforms}h.program=f(h.fragment_shader,h.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in h.uniforms)z.push(D);j(h.program,z);p(h.program,["position","normal","uv","tangent"])}D=h.program}else D=v;if(D!=E){c.useProgram(D);E=D}D==v&&this.setupLights(D,
g);this.loadCamera(D,e);this.loadMatrices(D);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){s=h.wireframe;K=h.wireframe_linewidth;e=D;g=h.uniforms;var U;for(k in g){A=g[k].type;z=g[k].value;U=e.uniforms[k];if(A=="i")c.uniform1i(U,z);else if(A=="f")c.uniform1f(U,z);else if(A=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(A=="c")c.uniform3f(U,z.r,z.g,z.b);else if(A=="t"){c.uniform1i(U,z);if(A=g[k].texture)A.image instanceof Array&&A.image.length==
6?d(A,z):i(A,z)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){k=h.color;q=h.opacity;s=h.wireframe;K=h.wireframe_linewidth;w=h.map;T=h.env_map;g=h.combine==THREE.MixOperation;e=h.reflectivity;A=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;z=h.refraction_ratio;c.uniform4f(D.uniforms.mColor,k.r*q,k.g*q,k.b*q,q);c.uniform1i(D.uniforms.mixEnvMap,g);c.uniform1f(D.uniforms.mReflectivity,e);c.uniform1i(D.uniforms.useRefract,
A);c.uniform1f(D.uniforms.mRefractionRatio,z);if(m){c.uniform1f(D.uniforms.fogNear,m.near);c.uniform1f(D.uniforms.fogFar,m.far);c.uniform3f(D.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(h instanceof THREE.MeshPhongMaterial){m=h.ambient;k=h.specular;h=h.shininess;c.uniform4f(D.uniforms.mAmbient,m.r,m.g,m.b,q);c.uniform4f(D.uniforms.mSpecular,k.r,k.g,k.b,q);c.uniform1f(D.uniforms.mShininess,h);c.uniform1i(D.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,
1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(D.uniforms.material,0);if(w){i(w,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(T){d(T,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);q=D.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(s){c.lineWidth(K);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m,h,n,k,q){var s,K,w,T,z;w=0;for(T=h.materials.length;w<T;w++){s=h.materials[w];if(s instanceof THREE.MeshFaceMaterial){s=0;for(K=n.materials.length;s<K;s++)if((z=n.materials[s])&&z.blending==k&&z.opacity<1==q){this.setBlending(z.blending);
this.renderBuffer(e,g,m,z,n)}}else if((z=s)&&z.blending==k&&z.opacity<1==q){this.setBlending(z.blending);this.renderBuffer(e,g,m,z,n)}}};this.render=function(e,g){var m,h,n,k,q=e.lights,s=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();S.set(g.matrix.flatten());r.set(g.projectionMatrix.flatten());m=0;for(h=e.__webGLObjects.length;m<h;m++){n=e.__webGLObjects[m];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,g);this.renderPass(g,q,s,k,n,THREE.NormalBlending,
false)}}m=0;for(h=e.__webGLObjects.length;m<h;m++){n=e.__webGLObjects[m];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,g);this.renderPass(g,q,s,k,n,THREE.AdditiveBlending,false);this.renderPass(g,q,s,k,n,THREE.SubtractiveBlending,false);this.renderPass(g,q,s,k,n,THREE.AdditiveBlending,true);this.renderPass(g,q,s,k,n,THREE.SubtractiveBlending,true);this.renderPass(g,q,s,k,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var g,m,h,n,k,q;if(!e.__webGLObjects){e.__webGLObjects=
[];e.__webGLObjectsMap={}}g=0;for(m=e.objects.length;g<m;g++){h=e.objects[g];if(e.__webGLObjectsMap[h.id]==undefined)e.__webGLObjectsMap[h.id]={};q=e.__webGLObjectsMap[h.id];if(h instanceof THREE.Mesh)for(k in h.geometry.geometryChunks){n=h.geometry.geometryChunks[k];n.__webGLVertexBuffer||this.createBuffers(h,k);if(q[k]==undefined){n={buffer:n,object:h};e.__webGLObjects.push(n);q[k]=1}}}};this.removeObject=function(e,g){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;
g==h&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(g.matrix,e.matrix);P.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();V.set(I.m);C.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,S);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,r);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);c.uniformMatrix4fv(e.uniforms.objectMatrix,
false,C)};this.loadCamera=function(e,g){c.uniform3f(e.uniforms.cameraPosition,g.position.x,g.position.y,g.position.z)};this.setBlending=function(e){switch(e){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(e,g){if(e){!g||g=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
else e=="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};var R={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}"}}};
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};
+125 -125
View File
@@ -12,52 +12,53 @@ THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1}
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;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,f,d=a.objects,j=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)j=j.concat(this.intersectObject(f))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function b(N,s,U,B){B=B.clone().subSelf(s);U=U.clone().subSelf(s);var L=N.clone().subSelf(s);N=B.dot(B);s=B.dot(U);B=B.dot(L);var O=U.dot(U);U=U.dot(L);L=1/(N*O-s*s);O=(O*B-s*U)*L;N=(N*U-s*B)*L;return O>0&&N>0&&O+N<1}var f,d,j,k,q,l,p,y,c,C,
v,u=a.geometry,J=u.vertices,R=[];f=0;for(d=u.faces.length;f<d;f++){j=u.faces[f];C=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(J[j.a].position.clone());q=a.matrix.multiplyVector3(J[j.b].position.clone());l=a.matrix.multiplyVector3(J[j.c].position.clone());p=j instanceof THREE.Face4?a.matrix.multiplyVector3(J[j.d].position.clone()):null;y=a.rotationMatrix.multiplyVector3(j.normal.clone());c=v.dot(y);if(c<0){y=y.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(v.multiplyScalar(y));
if(j instanceof THREE.Face3){if(b(C,k,q,l)){j={distance:this.origin.distanceTo(C),point:C,face:j,object:a};R.push(j)}}else if(j instanceof THREE.Face4)if(b(C,k,q,p)||b(C,q,l,p)){j={distance:this.origin.distanceTo(C),point:C,face:j,object:a};R.push(j)}}}return R}};
THREE.Rectangle=function(){function a(){k=d-b;q=j-f}var b,f,d,j,k,q,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return j};this.set=function(p,y,c,C){l=false;b=p;f=y;d=c;j=C;a()};this.addPoint=function(p,y){if(l){l=false;b=p;f=y;d=p;j=y}else{b=b<p?b:p;f=f<y?f:y;d=d>p?d:p;j=j>y?
j:y}a()};this.add3Points=function(p,y,c,C,v,u){if(l){l=false;b=p<c?p<v?p:v:c<v?c:v;f=y<C?y<u?y:u:C<u?C:u;d=p>c?p>v?p:v:c>v?c:v;j=y>C?y>u?y:u:C>u?C:u}else{b=p<c?p<v?p<b?p:b:v<b?v:b:c<v?c<b?c:b:v<b?v:b;f=y<C?y<u?y<f?y:f:u<f?u:f:C<u?C<f?C:f:u<f?u:f;d=p>c?p>v?p>d?p:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;j=y>C?y>u?y>j?y:j:u>j?u:j:C>u?C>j?C:j:u>j?u:j}a()};this.addRectangle=function(p){if(l){l=false;b=p.getLeft();f=p.getTop();d=p.getRight();j=p.getBottom()}else{b=b<p.getLeft()?b:p.getLeft();f=f<p.getTop()?f:p.getTop();
d=d>p.getRight()?d:p.getRight();j=j>p.getBottom()?j:p.getBottom()}a()};this.inflate=function(p){b-=p;f-=p;d+=p;j+=p;a()};this.minSelf=function(p){b=b>p.getLeft()?b:p.getLeft();f=f>p.getTop()?f:p.getTop();d=d<p.getRight()?d:p.getRight();j=j<p.getBottom()?j:p.getBottom();a()};this.instersects=function(p){return Math.min(d,p.getRight())-Math.max(b,p.getLeft())>=0&&Math.min(j,p.getBottom())-Math.max(f,p.getTop())>=0};this.empty=function(){l=true;j=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+k+", 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,b,f,d,j,k,q,l,p,y,c,C,v,u,J,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=l||0;this.n31=p||0;this.n32=y||0;this.n33=c||1;this.n34=C||0;this.n41=v||0;this.n42=u||0;this.n43=J||0;this.n44=R||1};
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,f,d,j,k,q,l,p,y,c,C,v,u,J,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=k;this.n23=q;this.n24=l;this.n31=p;this.n32=y;this.n33=c;this.n34=C;this.n41=v;this.n42=u;this.n43=J;this.n44=R;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,f){var d=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();j.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=k.x;
this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*j;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 f=a.n11,d=a.n12,j=a.n13,k=a.n14,q=a.n21,l=a.n22,p=a.n23,y=a.n24,c=a.n31,C=a.n32,
v=a.n33,u=a.n34,J=a.n41,R=a.n42,N=a.n43,s=a.n44,U=b.n11,B=b.n12,L=b.n13,O=b.n14,Q=b.n21,e=b.n22,h=b.n23,m=b.n24,i=b.n31,n=b.n32,g=b.n33,o=b.n34,r=b.n41,E=b.n42,M=b.n43,H=b.n44;this.n11=f*U+d*Q+j*i+k*r;this.n12=f*B+d*e+j*n+k*E;this.n13=f*L+d*h+j*g+k*M;this.n14=f*O+d*m+j*o+k*H;this.n21=q*U+l*Q+p*i+y*r;this.n22=q*B+l*e+p*n+y*E;this.n23=q*L+l*h+p*g+y*M;this.n24=q*O+l*m+p*o+y*H;this.n31=c*U+C*Q+v*i+u*r;this.n32=c*B+C*e+v*n+u*E;this.n33=c*L+C*h+v*g+u*M;this.n34=c*O+C*m+v*o+u*H;this.n41=J*U+R*Q+N*i+s*r;
this.n42=J*B+R*e+N*n+s*E;this.n43=J*L+R*h+N*g+s*M;this.n44=J*O+R*m+N*o+s*H;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,k=this.n21,q=this.n22,l=this.n23,p=this.n24,y=this.n31,c=this.n32,C=this.n33,v=this.n34,u=this.n41,J=this.n42,R=this.n43,N=this.n44,s=a.n11,U=a.n21,B=a.n31,L=a.n41,O=a.n12,Q=a.n22,e=a.n32,h=a.n42,m=a.n13,i=a.n23,n=a.n33,g=a.n43,o=a.n14,r=a.n24,E=a.n34;a=a.n44;this.n11=b*s+f*U+d*B+j*L;this.n12=b*O+f*Q+d*e+j*h;this.n13=b*m+f*i+d*n+j*g;this.n14=
b*o+f*r+d*E+j*a;this.n21=k*s+q*U+l*B+p*L;this.n22=k*O+q*Q+l*e+p*h;this.n23=k*m+q*i+l*n+p*g;this.n24=k*o+q*r+l*E+p*a;this.n31=y*s+c*U+C*B+v*L;this.n32=y*O+c*Q+C*e+v*h;this.n33=y*m+c*i+C*n+v*g;this.n34=y*o+c*r+C*E+v*a;this.n41=u*s+J*U+R*B+N*L;this.n42=u*O+J*Q+R*e+N*h;this.n43=u*m+J*i+R*n+N*g;this.n44=u*o+J*r+R*E+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*=
THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)i=i.concat(this.intersectObject(f))}i.sort(function(j,p){return j.distance-p.distance});return i},intersectObject:function(a){function b(P,s,V,D){D=D.clone().subSelf(s);V=V.clone().subSelf(s);var J=P.clone().subSelf(s);P=D.dot(D);s=D.dot(V);D=D.dot(J);var Q=V.dot(V);V=V.dot(J);J=1/(P*Q-s*s);Q=(Q*D-s*V)*J;P=(P*V-s*D)*J;return Q>0&&P>0&&Q+P<1}var f,d,i,j,p,k,o,x,c,E,
v,u=a.geometry,I=u.vertices,T=[];f=0;for(d=u.faces.length;f<d;f++){i=u.faces[f];E=this.origin.clone();v=this.direction.clone();j=a.matrix.multiplyVector3(I[i.a].position.clone());p=a.matrix.multiplyVector3(I[i.b].position.clone());k=a.matrix.multiplyVector3(I[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(I[i.d].position.clone()):null;x=a.rotationMatrix.multiplyVector3(i.normal.clone());c=v.dot(x);if(c<0){x=x.dot((new THREE.Vector3).sub(j,E))/c;E=E.addSelf(v.multiplyScalar(x));
if(i instanceof THREE.Face3){if(b(E,j,p,k)){i={distance:this.origin.distanceTo(E),point:E,face:i,object:a};T.push(i)}}else if(i instanceof THREE.Face4)if(b(E,j,p,o)||b(E,p,k,o)){i={distance:this.origin.distanceTo(E),point:E,face:i,object:a};T.push(i)}}}return T}};
THREE.Rectangle=function(){function a(){j=d-b;p=i-f}var b,f,d,i,j,p,k=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return i};this.set=function(o,x,c,E){k=false;b=o;f=x;d=c;i=E;a()};this.addPoint=function(o,x){if(k){k=false;b=o;f=x;d=o;i=x}else{b=b<o?b:o;f=f<x?f:x;d=d>o?d:o;i=i>x?
i:x}a()};this.add3Points=function(o,x,c,E,v,u){if(k){k=false;b=o<c?o<v?o:v:c<v?c:v;f=x<E?x<u?x:u:E<u?E:u;d=o>c?o>v?o:v:c>v?c:v;i=x>E?x>u?x:u:E>u?E:u}else{b=o<c?o<v?o<b?o:b:v<b?v:b:c<v?c<b?c:b:v<b?v:b;f=x<E?x<u?x<f?x:f:u<f?u:f:E<u?E<f?E:f:u<f?u:f;d=o>c?o>v?o>d?o:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;i=x>E?x>u?x>i?x:i:u>i?u:i:E>u?E>i?E:i:u>i?u:i}a()};this.addRectangle=function(o){if(k){k=false;b=o.getLeft();f=o.getTop();d=o.getRight();i=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();f=f<o.getTop()?f:o.getTop();
d=d>o.getRight()?d:o.getRight();i=i>o.getBottom()?i:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;i+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d<o.getRight()?d:o.getRight();i=i<o.getBottom()?i:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(i,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){k=true;i=d=f=b=0;a()};this.isEmpty=function(){return k};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+j+", 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,b,f,d,i,j,p,k,o,x,c,E,v,u,I,T){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=j||1;this.n23=p||0;this.n24=k||0;this.n31=o||0;this.n32=x||0;this.n33=c||1;this.n34=E||0;this.n41=v||0;this.n42=u||0;this.n43=I||0;this.n44=T||1};
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,f,d,i,j,p,k,o,x,c,E,v,u,I,T){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=j;this.n23=p;this.n24=k;this.n31=o;this.n32=x;this.n33=c;this.n34=E;this.n41=v;this.n42=u;this.n43=I;this.n44=T;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,f){var d=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(f,j).normalize();i.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=j.x;
this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;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 f=a.n11,d=a.n12,i=a.n13,j=a.n14,p=a.n21,k=a.n22,o=a.n23,x=a.n24,c=a.n31,E=a.n32,
v=a.n33,u=a.n34,I=a.n41,T=a.n42,P=a.n43,s=a.n44,V=b.n11,D=b.n12,J=b.n13,Q=b.n14,R=b.n21,e=b.n22,g=b.n23,m=b.n24,h=b.n31,n=b.n32,l=b.n33,q=b.n34,t=b.n41,K=b.n42,w=b.n43,U=b.n44;this.n11=f*V+d*R+i*h+j*t;this.n12=f*D+d*e+i*n+j*K;this.n13=f*J+d*g+i*l+j*w;this.n14=f*Q+d*m+i*q+j*U;this.n21=p*V+k*R+o*h+x*t;this.n22=p*D+k*e+o*n+x*K;this.n23=p*J+k*g+o*l+x*w;this.n24=p*Q+k*m+o*q+x*U;this.n31=c*V+E*R+v*h+u*t;this.n32=c*D+E*e+v*n+u*K;this.n33=c*J+E*g+v*l+u*w;this.n34=c*Q+E*m+v*q+u*U;this.n41=I*V+T*R+P*h+s*t;
this.n42=I*D+T*e+P*n+s*K;this.n43=I*J+T*g+P*l+s*w;this.n44=I*Q+T*m+P*q+s*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,j=this.n21,p=this.n22,k=this.n23,o=this.n24,x=this.n31,c=this.n32,E=this.n33,v=this.n34,u=this.n41,I=this.n42,T=this.n43,P=this.n44,s=a.n11,V=a.n21,D=a.n31,J=a.n41,Q=a.n12,R=a.n22,e=a.n32,g=a.n42,m=a.n13,h=a.n23,n=a.n33,l=a.n43,q=a.n14,t=a.n24,K=a.n34;a=a.n44;this.n11=b*s+f*V+d*D+i*J;this.n12=b*Q+f*R+d*e+i*g;this.n13=b*m+f*h+d*n+i*l;this.n14=
b*q+f*t+d*K+i*a;this.n21=j*s+p*V+k*D+o*J;this.n22=j*Q+p*R+k*e+o*g;this.n23=j*m+p*h+k*n+o*l;this.n24=j*q+p*t+k*K+o*a;this.n31=x*s+c*V+E*D+v*J;this.n32=x*Q+c*R+E*e+v*g;this.n33=x*m+c*h+E*n+v*l;this.n34=x*q+c*t+E*K+v*a;this.n41=u*s+I*V+T*D+P*J;this.n42=u*Q+I*R+T*e+P*g;this.n43=u*m+I*h+T*n+P*l;this.n44=u*q+I*t+T*K+P*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,f,d){var j=b[f];b[f]=b[d];
b[d]=j}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
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,f,d){var i=b[f];b[f]=b[d];
b[d]=i}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},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,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};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 f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),k=1-d,q=a.x,l=a.y,p=a.z;f.n11=k*q*q+d;f.n12=k*q*l-j*p;f.n13=k*q*p+j*l;f.n21=k*q*l+j*p;f.n22=k*l*l+d;f.n23=k*l*p-j*q;f.n31=k*q*p-j*l;f.n32=k*l*p+j*q;f.n33=k*p*p+d;return f};
THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),j=1-d,p=a.x,k=a.y,o=a.z;f.n11=j*p*p+d;f.n12=j*p*k-i*o;f.n13=j*p*o+i*k;f.n21=j*p*k+i*o;f.n22=j*k*k+d;f.n23=j*k*o-i*p;f.n31=j*p*o-i*k;f.n32=j*k*o+i*p;f.n33=j*o*o+d;return f};
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=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],y=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*k+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*k;a.m[4]=b*q;a.m[5]=b*l;a.m[6]=b*p;a.m[7]=b*y;a.m[8]=b*c;return a};
THREE.Matrix4.makeFrustum=function(a,b,f,d,j,k){var q,l,p;q=new THREE.Matrix4;l=2*j/(b-a);p=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=l;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=p;q.n23=f;q.n24=0;q.n31=0;q.n32=0;q.n33=d;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)};
THREE.Matrix4.makeOrtho=function(a,b,f,d,j,k){var q,l,p,y;q=new THREE.Matrix4;l=b-a;p=f-d;y=k-j;a=(b+a)/l;f=(f+d)/p;j=(k+j)/y;q.n11=2/l;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/p;q.n23=0;q.n24=-f;q.n31=0;q.n32=0;q.n33=-2/y;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],x=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*x;a.m[8]=b*c;return a};
THREE.Matrix4.makeFrustum=function(a,b,f,d,i,j){var p,k,o;p=new THREE.Matrix4;k=2*i/(b-a);o=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(j+i)/(j-i);i=-2*j*i/(j-i);p.n11=k;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=i;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)};
THREE.Matrix4.makeOrtho=function(a,b,f,d,i,j){var p,k,o,x;p=new THREE.Matrix4;k=b-a;o=f-d;x=j-i;a=(b+a)/k;f=(f+d)/o;i=(j+i)/x;p.n11=2/k;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/x;p.n34=-i;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
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,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,f,d,j,k){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};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.Face3=function(a,b,f,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
THREE.Face4=function(a,b,f,d,i,j){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=j instanceof Array?j:[j]};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,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,j,k,q,l=new THREE.Vector3,p=new THREE.Vector3;d=0;for(j=this.vertices.length;d<j;d++){k=this.vertices[d];k.normal.set(0,0,0)}d=0;for(j=this.faces.length;d<j;d++){k=this.faces[d];if(a&&k.vertexNormals.length){l.set(0,0,0);b=0;for(f=k.normal.length;b<f;b++)l.addSelf(k.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[k.a];f=this.vertices[k.b];q=this.vertices[k.c];l.sub(q.position,
f.position);p.sub(b.position,f.position);l.crossSelf(p)}l.isZero()||l.normalize();k.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(o,r,E,M){k=o.vertices[r].position;q=o.vertices[E].position;
l=o.vertices[M].position;p=j[0];y=j[1];c=j[2];C=q.x-k.x;v=l.x-k.x;u=q.y-k.y;J=l.y-k.y;R=q.z-k.z;N=l.z-k.z;s=y.u-p.u;U=c.u-p.u;B=y.v-p.v;L=c.v-p.v;O=1/(s*L-U*B);m.set((L*C-B*v)*O,(L*u-B*J)*O,(L*R-B*N)*O);i.set((s*v-U*C)*O,(s*J-U*u)*O,(s*N-U*R)*O);e[r].addSelf(m);e[E].addSelf(m);e[M].addSelf(m);h[r].addSelf(i);h[E].addSelf(i);h[M].addSelf(i)}var b,f,d,j,k,q,l,p,y,c,C,v,u,J,R,N,s,U,B,L,O,Q,e=[],h=[],m=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,g=new THREE.Vector3;Q=new THREE.Vector3;b=
0;for(f=this.vertices.length;b<f;b++){e[b]=new THREE.Vector3;h[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];j=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){Q.copy(this.vertices[b].normal);d=e[b];n.copy(d);n.subSelf(Q.multiplyScalar(Q.dot(d))).normalize();g.cross(this.vertices[b].normal,d);test=g.dot(h[b]);d=test<0?-1:1;this.vertices[b].tangent.set(n.x,n.y,n.z,d)}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],
f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,i,j,p,k=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){j=this.vertices[d];j.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){j=this.faces[d];if(a&&j.vertexNormals.length){k.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)k.addSelf(j.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];k.sub(p.position,
f.position);o.sub(b.position,f.position);k.crossSelf(o)}k.isZero()||k.normalize();j.normal.copy(k)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(q,t,K,w){j=q.vertices[t].position;p=q.vertices[K].position;
k=q.vertices[w].position;o=i[0];x=i[1];c=i[2];E=p.x-j.x;v=k.x-j.x;u=p.y-j.y;I=k.y-j.y;T=p.z-j.z;P=k.z-j.z;s=x.u-o.u;V=c.u-o.u;D=x.v-o.v;J=c.v-o.v;Q=1/(s*J-V*D);m.set((J*E-D*v)*Q,(J*u-D*I)*Q,(J*T-D*P)*Q);h.set((s*v-V*E)*Q,(s*I-V*u)*Q,(s*P-V*T)*Q);e[t].addSelf(m);e[K].addSelf(m);e[w].addSelf(m);g[t].addSelf(h);g[K].addSelf(h);g[w].addSelf(h)}var b,f,d,i,j,p,k,o,x,c,E,v,u,I,T,P,s,V,D,J,Q,R,e=[],g=[],m=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,l=new THREE.Vector3;R=new THREE.Vector3;b=
0;for(f=this.vertices.length;b<f;b++){e[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];i=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){R.copy(this.vertices[b].normal);d=e[b];n.copy(d);n.subSelf(R.multiplyScalar(R.dot(d))).normalize();l.cross(this.vertices[b].normal,d);test=l.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(n.x,n.y,n.z,d)}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,f=this.vertices.length;b<f;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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var c=[];b=0;for(f=y.length;b<f;b++)y[b]==undefined?c.push("undefined"):c.push(y[b].toString());return c.join("_")}
var b,f,d,j,k,q,l,p={};d=0;for(j=this.faces.length;d<j;d++){k=this.faces[d];materials=k.materials;q=a(materials);if(p[q]==undefined)p[q]={hash:q,counter:0};l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){p[q].counter+=1;l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d);
this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);
this.position.subSelf(j);this.target.position.subSelf(j)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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;
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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(x){var c=[];b=0;for(f=x.length;b<f;b++)x[b]==undefined?c.push("undefined"):c.push(x[b].toString());return c.join("_")}
var b,f,d,i,j,p,k,o={};d=0;for(i=this.faces.length;d<i;d++){j=this.faces[d];materials=j.materials;p=a(materials);if(o[p]==undefined)o[p]={hash:p,counter:0};k=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:materials,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){o[p].counter+=1;k=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:materials,vertices:0}}this.geometryChunks[k].faces.push(d);
this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);
this.position.subSelf(i);this.target.position.subSelf(i)};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();this.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.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;
@@ -80,108 +81,107 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract
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.near=1;this.far=1E3;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.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
this.far-this.near};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.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,f,d,j,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
THREE.Texture=function(a,b,f,d,i,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter};
THREE.Texture.prototype={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.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,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};
THREE.Projector=function(){function a(e,h){return h.z-e.z}function b(e,h){var m=0,i=1,n=e.z+e.w,g=h.z+h.w,o=-e.z+e.w,r=-h.z+h.w;if(n>=0&&g>=0&&o>=0&&r>=0)return true;else if(n<0&&g<0||o<0&&r<0)return false;else{if(n<0)m=Math.max(m,n/(n-g));else if(g<0)i=Math.min(i,n/(n-g));if(o<0)m=Math.max(m,o/(o-r));else if(r<0)i=Math.min(i,o/(o-r));if(i<m)return false;else{e.lerpSelf(h,m);h.lerpSelf(e,1-i);return true}}}var f,d,j=[],k,q,l,p=[],y,c,C=[],v,u,J=[],R=new THREE.Vector4,N=new THREE.Vector4,s=new THREE.Matrix4,
U=new THREE.Matrix4,B=[],L=new THREE.Vector4,O=new THREE.Vector4,Q;this.projectObjects=function(e,h,m){var i=[],n,g;d=0;s.multiply(h.projectionMatrix,h.matrix);B[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);B[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);B[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);B[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);B[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);B[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);h=0;for(n=B.length;h<n;h++){g=B[h];g.divideScalar(Math.sqrt(g.x*g.x+g.y*g.y+g.z*g.z))}n=e.objects;e=0;for(h=n.length;e<h;e++){g=n[e];var o;if(!(o=!g.visible)){if(o=g instanceof THREE.Mesh){a:{o=void 0;for(var r=g.position,E=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,Math.max(g.scale.y,g.scale.z)),M=0;M<6;M++){o=B[M].x*r.x+B[M].y*r.y+B[M].z*r.z+B[M].w;if(o<=E){o=false;break a}}o=true}o=!o}o=o}if(!o){f=
j[d]=j[d]||new THREE.RenderableObject;R.copy(g.position);s.multiplyVector3(R);f.object=g;f.z=R.z;i.push(f);d++}}m&&i.sort(a);return i};this.projectScene=function(e,h,m){var i=[],n,g,o,r,E,M,H,z,T,F,S,D,w,x,K,G;l=c=u=0;h.autoUpdateMatrix&&h.updateMatrix();s.multiply(h.projectionMatrix,h.matrix);M=this.projectObjects(e,h,true);e=0;for(n=M.length;e<n;e++){H=M[e].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();z=H.matrix;T=H.rotationMatrix;F=H.materials;S=H.overdraw;if(H instanceof THREE.Mesh){D=
H.geometry;w=D.vertices;g=0;for(o=w.length;g<o;g++){x=w[g];x.positionWorld.copy(x.position);z.multiplyVector3(x.positionWorld);r=x.positionScreen;r.copy(x.positionWorld);s.multiplyVector4(r);r.multiplyScalar(1/r.w);x.__visible=r.z>0&&r.z<1}D=D.faces;g=0;for(o=D.length;g<o;g++){x=D[g];if(x instanceof THREE.Face3){r=w[x.a];E=w[x.b];K=w[x.c];if(r.__visible&&E.__visible&&K.__visible)if(H.doubleSided||H.flipSided!=(K.positionScreen.x-r.positionScreen.x)*(E.positionScreen.y-r.positionScreen.y)-(K.positionScreen.y-
r.positionScreen.y)*(E.positionScreen.x-r.positionScreen.x)<0){k=p[l]=p[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(r.positionWorld);k.v2.positionWorld.copy(E.positionWorld);k.v3.positionWorld.copy(K.positionWorld);k.v1.positionScreen.copy(r.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(K.positionScreen);k.normalWorld.copy(x.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(x.centroid);z.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);
s.multiplyVector3(k.centroidScreen);K=x.vertexNormals;Q=k.vertexNormalsWorld;r=0;for(E=K.length;r<E;r++){G=Q[r]=Q[r]||new THREE.Vector3;G.copy(K[r]);T.multiplyVector3(G)}k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=x.materials;k.overdraw=S;if(H.geometry.uvs[g]){k.uvs[0]=H.geometry.uvs[g][0];k.uvs[1]=H.geometry.uvs[g][1];k.uvs[2]=H.geometry.uvs[g][2]}i.push(k);l++}}else if(x instanceof THREE.Face4){r=w[x.a];E=w[x.b];K=w[x.c];G=w[x.d];if(r.__visible&&E.__visible&&K.__visible&&G.__visible)if(H.doubleSided||
H.flipSided!=((G.positionScreen.x-r.positionScreen.x)*(E.positionScreen.y-r.positionScreen.y)-(G.positionScreen.y-r.positionScreen.y)*(E.positionScreen.x-r.positionScreen.x)<0||(E.positionScreen.x-K.positionScreen.x)*(G.positionScreen.y-K.positionScreen.y)-(E.positionScreen.y-K.positionScreen.y)*(G.positionScreen.x-K.positionScreen.x)<0)){k=p[l]=p[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(r.positionWorld);k.v2.positionWorld.copy(E.positionWorld);k.v3.positionWorld.copy(G.positionWorld);
k.v1.positionScreen.copy(r.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(G.positionScreen);k.normalWorld.copy(x.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(x.centroid);z.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=x.materials;k.overdraw=S;if(H.geometry.uvs[g]){k.uvs[0]=H.geometry.uvs[g][0];k.uvs[1]=H.geometry.uvs[g][1];k.uvs[2]=
H.geometry.uvs[g][3]}i.push(k);l++;q=p[l]=p[l]||new THREE.RenderableFace3;q.v1.positionWorld.copy(E.positionWorld);q.v2.positionWorld.copy(K.positionWorld);q.v3.positionWorld.copy(G.positionWorld);q.v1.positionScreen.copy(E.positionScreen);q.v2.positionScreen.copy(K.positionScreen);q.v3.positionScreen.copy(G.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=F;q.faceMaterials=x.materials;
q.overdraw=S;if(H.geometry.uvs[g]){q.uvs[0]=H.geometry.uvs[g][1];q.uvs[1]=H.geometry.uvs[g][2];q.uvs[2]=H.geometry.uvs[g][3]}i.push(q);l++}}}}else if(H instanceof THREE.Line){U.multiply(s,z);w=H.geometry.vertices;x=w[0];x.positionScreen.copy(x.position);U.multiplyVector4(x.positionScreen);g=1;for(o=w.length;g<o;g++){r=w[g];r.positionScreen.copy(r.position);U.multiplyVector4(r.positionScreen);E=w[g-1];L.copy(r.positionScreen);O.copy(E.positionScreen);if(b(L,O)){L.multiplyScalar(1/L.w);O.multiplyScalar(1/
O.w);y=C[c]=C[c]||new THREE.RenderableLine;y.v1.positionScreen.copy(L);y.v2.positionScreen.copy(O);y.z=Math.max(L.z,O.z);y.materials=H.materials;i.push(y);c++}}}else if(H instanceof THREE.Particle){N.set(H.position.x,H.position.y,H.position.z,1);s.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){v=J[u]=J[u]||new THREE.RenderableParticle;v.x=N.x/N.w;v.y=N.y/N.w;v.z=N.z;v.rotation=H.rotation.z;v.scale.x=H.scale.x*Math.abs(v.x-(N.x+h.projectionMatrix.n11)/(N.w+h.projectionMatrix.n14));v.scale.y=H.scale.y*
Math.abs(v.y-(N.y+h.projectionMatrix.n22)/(N.w+h.projectionMatrix.n24));v.materials=H.materials;i.push(v);u++}}}}m&&i.sort(a);return i};this.unprojectVector=function(e,h){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(h.matrix),THREE.Matrix4.makeInvert(h.projectionMatrix));m.multiplyVector3(e);return e}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,k;this.domElement=document.createElement("div");this.setSize=function(q,l){f=q;d=l;j=f/2;k=d/2};this.render=function(q,l){var p,y,c,C,v,u,J,R;a=b.projectScene(q,l);p=0;for(y=a.length;p<y;p++){v=a[p];if(v instanceof THREE.RenderableParticle){J=v.x*j+j;R=v.y*k+k;c=0;for(C=v.material.length;c<C;c++){u=v.material[c];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=J+"px";u.style.top=R+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,j,k,q,l=f.getContext("2d"),p=1,y=0,c=null,C=null,v=1,u,J,R,N,s,U,B,L,O,Q=new THREE.Color,e=new THREE.Color,h=new THREE.Color,m=new THREE.Color,i=new THREE.Color,n,g,o,r,E,M,H,z,T,F,S=new THREE.Rectangle,D=new THREE.Rectangle,w=new THREE.Rectangle,x=false,K=new THREE.Color,G=new THREE.Color,W=new THREE.Color,ba=new THREE.Color,Ka=Math.PI*2,Y=new THREE.Vector3,oa,pa,Ba,ea,qa,ua,ma=16;oa=document.createElement("canvas");
oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Ba=pa.getImageData(0,0,2,2);ea=Ba.data;qa=document.createElement("canvas");qa.width=qa.height=ma;ua=qa.getContext("2d");ua.translate(-ma/2,-ma/2);ua.scale(ma,ma);ma--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ha,va){d=ha;j=va;k=d/2;q=j/2;f.width=d;f.height=j;S.set(-k,-q,k,q)};this.clear=function(){if(!D.isEmpty()){D.inflate(1);D.minSelf(S);l.clearRect(D.getX(),
D.getY(),D.getWidth(),D.getHeight());D.empty()}};this.render=function(ha,va){function La(t){var V,P,A,I=t.lights;G.setRGB(0,0,0);W.setRGB(0,0,0);ba.setRGB(0,0,0);t=0;for(V=I.length;t<V;t++){P=I[t];A=P.color;if(P instanceof THREE.AmbientLight){G.r+=A.r;G.g+=A.g;G.b+=A.b}else if(P instanceof THREE.DirectionalLight){W.r+=A.r;W.g+=A.g;W.b+=A.b}else if(P instanceof THREE.PointLight){ba.r+=A.r;ba.g+=A.g;ba.b+=A.b}}}function wa(t,V,P,A){var I,X,$,ca,da=t.lights;t=0;for(I=da.length;t<I;t++){X=da[t];$=X.color;
ca=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,V);Y.normalize();X=P.dot(Y)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}}}function Ma(t,V,P){if(P.opacity!=0){Ca(P.opacity);xa(P.blending);var A,I,X,$,ca,da;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){$=P.map;ca=$.width>>1;da=$.height>>1;I=V.scale.x*k;X=V.scale.y*q;P=I*ca;A=X*da;w.set(t.x-P,t.y-A,t.x+P,t.y+A);if(!S.instersects(w))return;
l.save();l.translate(t.x,t.y);l.rotate(-V.rotation);l.scale(I,-X);l.translate(-ca,-da);l.drawImage($,0,0);l.restore()}l.beginPath();l.moveTo(t.x-10,t.y);l.lineTo(t.x+10,t.y);l.moveTo(t.x,t.y-10);l.lineTo(t.x,t.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof THREE.ParticleCircleMaterial){if(x){K.r=G.r+W.r+ba.r;K.g=G.g+W.g+ba.g;K.b=G.b+W.b+ba.b;Q.r=P.color.r*K.r;Q.g=P.color.g*K.g;Q.b=P.color.b*K.b;Q.updateStyleString()}else Q.__styleString=P.color.__styleString;P=
V.scale.x*k;A=V.scale.y*q;w.set(t.x-P,t.y-A,t.x+P,t.y+A);if(S.instersects(w)){I=Q.__styleString;if(C!=I)l.fillStyle=C=I;l.save();l.translate(t.x,t.y);l.rotate(-V.rotation);l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Ka,true);l.closePath();l.fill();l.restore()}}}}function Na(t,V,P,A){if(A.opacity!=0){Ca(A.opacity);xa(A.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(V.positionScreen.x,V.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){Q.__styleString=
A.color.__styleString;t=A.linewidth;if(v!=t)l.lineWidth=v=t;t=Q.__styleString;if(c!=t)l.strokeStyle=c=t;l.stroke();w.inflate(A.linewidth*2)}}}function Ga(t,V,P,A,I,X){if(I.opacity!=0){Ca(I.opacity);xa(I.blending);N=t.positionScreen.x;s=t.positionScreen.y;U=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;O=P.positionScreen.y;l.beginPath();l.moveTo(N,s);l.lineTo(U,B);l.lineTo(L,O);l.lineTo(N,s);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof
THREE.UVMapping&&ra(N,s,U,B,L,O,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){t=va.matrix;Y.copy(A.vertexNormalsWorld[0]);E=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;M=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);H=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;z=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);T=
(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;F=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;ra(N,s,U,B,L,O,I.env_map.image,E,M,H,z,T,F)}}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ra(N,s,U,B,L,O,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);xa(THREE.SubtractiveBlending)}if(x)if(!I.wireframe&&I.shading==THREE.SmoothShading&&
A.vertexNormalsWorld.length==3){e.r=h.r=m.r=G.r;e.g=h.g=m.g=G.g;e.b=h.b=m.b=G.b;wa(X,A.v1.positionWorld,A.vertexNormalsWorld[0],e);wa(X,A.v2.positionWorld,A.vertexNormalsWorld[1],h);wa(X,A.v3.positionWorld,A.vertexNormalsWorld[2],m);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,U,B,L,O,r,0,0,1,0,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;wa(X,A.centroidWorld,A.normalWorld,K);Q.r=I.color.r*K.r;Q.g=I.color.g*K.g;Q.b=I.color.b*K.b;Q.updateStyleString();I.wireframe?ya(Q.__styleString,
I.wireframe_linewidth):za(Q.__styleString)}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){n=I.__2near;g=I.__farPlusNear;o=I.__farMinusNear;e.r=e.g=e.b=1-n/(g-t.positionScreen.z*o);h.r=h.g=h.b=1-n/(g-V.positionScreen.z*o);m.r=m.g=m.b=1-n/(g-P.positionScreen.z*o);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,U,B,L,O,r,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){Q.r=
Da(A.normalWorld.x);Q.g=Da(A.normalWorld.y);Q.b=Da(A.normalWorld.z);Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}}}function ya(t,V){if(c!=t)l.strokeStyle=c=t;if(v!=V)l.lineWidth=v=V;l.stroke();w.inflate(V*2)}function za(t){if(C!=t)l.fillStyle=C=t;l.fill()}function ra(t,V,P,A,I,X,$,ca,da,ia,fa,ja,sa){var la,ka;la=$.width-1;ka=$.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;sa*=ka;P-=t;A-=V;I-=t;X-=V;ia-=ca;fa-=da;ja-=ca;sa-=da;ka=1/(ia*sa-ja*fa);la=
(sa*P-fa*I)*ka;fa=(sa*A-fa*X)*ka;P=(ia*I-ja*P)*ka;A=(ia*X-ja*A)*ka;t=t-la*ca-P*da;V=V-fa*ca-A*da;l.save();l.transform(la,fa,P,A,t,V);l.clip();l.drawImage($,0,0);l.restore()}function Ca(t){if(p!=t)l.globalAlpha=p=t}function xa(t){if(y!=t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}y=t}}function Ha(t,V,P,A){var I=~~(t.r*255),
X=~~(t.g*255);t=~~(t.b*255);var $=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(P.r*255),ia=~~(P.g*255);P=~~(P.b*255);var fa=~~(A.r*255),ja=~~(A.g*255);A=~~(A.b*255);ea[0]=I<0?0:I>255?255:I;ea[1]=X<0?0:X>255?255:X;ea[2]=t<0?0:t>255?255:t;ea[4]=$<0?0:$>255?255:$;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=V<0?0:V>255?255:V;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=P<0?0:P>255?255:P;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=A<0?0:A>255?255:A;pa.putImageData(Ba,0,0);
ua.drawImage(oa,0,0);return qa}function Da(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Ea(t,V){var P=V.x-t.x,A=V.y-t.y,I=1/Math.sqrt(P*P+A*A);P*=I;A*=I;V.x+=P;V.y+=A;t.x-=P;t.y-=A}var Aa,Ia,Z,ga,na,Fa,Ja,ta;l.setTransform(1,0,0,-1,k,q);this.autoClear&&this.clear();a=b.projectScene(ha,va,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());(x=ha.lights.length>0)&&La(ha);Aa=0;for(Ia=a.length;Aa<Ia;Aa++){Z=a[Aa];w.empty();if(Z instanceof
THREE.RenderableParticle){u=Z;u.x*=k;u.y*=q;ga=0;for(na=Z.materials.length;ga<na;ga++)Ma(u,Z,Z.materials[ga],ha)}else if(Z instanceof THREE.RenderableLine){u=Z.v1;J=Z.v2;u.positionScreen.x*=k;u.positionScreen.y*=q;J.positionScreen.x*=k;J.positionScreen.y*=q;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(J.positionScreen.x,J.positionScreen.y);if(S.instersects(w)){ga=0;for(na=Z.materials.length;ga<na;)Na(u,J,Z,Z.materials[ga++],ha)}}else if(Z instanceof THREE.RenderableFace3){u=Z.v1;J=
Z.v2;R=Z.v3;u.positionScreen.x*=k;u.positionScreen.y*=q;J.positionScreen.x*=k;J.positionScreen.y*=q;R.positionScreen.x*=k;R.positionScreen.y*=q;if(Z.overdraw){Ea(u.positionScreen,J.positionScreen);Ea(J.positionScreen,R.positionScreen);Ea(R.positionScreen,u.positionScreen)}w.add3Points(u.positionScreen.x,u.positionScreen.y,J.positionScreen.x,J.positionScreen.y,R.positionScreen.x,R.positionScreen.y);if(S.instersects(w)){ga=0;for(na=Z.meshMaterials.length;ga<na;){ta=Z.meshMaterials[ga++];if(ta instanceof
THREE.MeshFaceMaterial){Fa=0;for(Ja=Z.faceMaterials.length;Fa<Ja;)(ta=Z.faceMaterials[Fa++])&&Ga(u,J,R,Z,ta,ha)}else Ga(u,J,R,Z,ta,ha)}}}D.addRectangle(w)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(D.getX(),D.getY(),D.getWidth(),D.getHeight());l.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(z,T,F){var S,D,w,x;S=0;for(D=z.lights.length;S<D;S++){w=z.lights[S];if(w instanceof THREE.DirectionalLight){x=T.normalWorld.dot(w.position)*w.intensity;if(x>0){F.r+=w.color.r*x;F.g+=w.color.g*x;F.b+=w.color.b*x}}else if(w instanceof THREE.PointLight){m.sub(w.position,T.centroidWorld);m.normalize();x=T.normalWorld.dot(m)*w.intensity;if(x>0){F.r+=w.color.r*x;F.g+=w.color.g*x;F.b+=w.color.b*x}}}}function b(z,T,F,S,D,w){o=d(r++);o.setAttribute("d","M "+z.positionScreen.x+
" "+z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(U){L.r=O.r;L.g=O.g;L.b=O.b;a(w,S,L);B.r=D.color.r*L.r;B.g=D.color.g*L.g;B.b=D.color.b*L.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){h=1-D.__2near/(D.__farPlusNear-S.z*D.__farMinusNear);
B.setRGB(h,h,h)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(j(S.normalWorld.x),j(S.normalWorld.y),j(S.normalWorld.z));D.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);l.appendChild(o)}function f(z,T,F,S,D,w,x){o=d(r++);o.setAttribute("d",
"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(U){L.r=O.r;L.g=O.g;L.b=O.b;a(x,D,L);B.r=w.color.r*L.r;B.g=w.color.g*L.g;B.b=w.color.b*L.b;B.updateStyleString()}else B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){h=
1-w.__2near/(w.__farPlusNear-D.z*w.__farMinusNear);B.setRGB(h,h,h)}else w instanceof THREE.MeshNormalMaterial&&B.setRGB(j(D.normalWorld.x),j(D.normalWorld.y),j(D.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)}
function d(z){if(i[z]==null){i[z]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&i[z].setAttribute("shape-rendering","crispEdges");return i[z]}return i[z]}function j(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var k=null,q=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,y,c,C,v,u,J,R,N=new THREE.Rectangle,s=new THREE.Rectangle,U=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),Q=new THREE.Color(0),
e=new THREE.Color(0),h,m=new THREE.Vector3,i=[],n=[],g=[],o,r,E,M,H=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":H=1;break;case "low":H=0}};this.setSize=function(z,T){p=z;y=T;c=p/2;C=y/2;l.setAttribute("viewBox",-c+" "+-C+" "+p+" "+y);l.setAttribute("width",p);l.setAttribute("height",y);N.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,T){var F,S,
D,w,x,K,G,W;this.autoClear&&this.clear();k=q.projectScene(z,T,this.sortElements);M=E=r=0;if(U=z.lights.length>0){G=z.lights;O.setRGB(0,0,0);Q.setRGB(0,0,0);e.setRGB(0,0,0);F=0;for(S=G.length;F<S;F++){D=G[F];w=D.color;if(D instanceof THREE.AmbientLight){O.r+=w.r;O.g+=w.g;O.b+=w.b}else if(D instanceof THREE.DirectionalLight){Q.r+=w.r;Q.g+=w.g;Q.b+=w.b}else if(D instanceof THREE.PointLight){e.r+=w.r;e.g+=w.g;e.b+=w.b}}}F=0;for(S=k.length;F<S;F++){G=k[F];s.empty();if(G instanceof THREE.RenderableParticle){v=
G;v.x*=c;v.y*=-C;D=0;for(w=G.materials.length;D<w;D++)if(W=G.materials[D]){x=v;K=G;W=W;var ba=E++;if(n[ba]==null){n[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&n[ba].setAttribute("shape-rendering","crispEdges")}o=n[ba];o.setAttribute("cx",x.x);o.setAttribute("cy",x.y);o.setAttribute("r",K.scale.x*c);if(W instanceof THREE.ParticleCircleMaterial){if(U){L.r=O.r+Q.r+e.r;L.g=O.g+Q.g+e.g;L.b=O.b+Q.b+e.b;B.r=W.color.r*L.r;B.g=W.color.g*L.g;B.b=W.color.b*L.b;B.updateStyleString()}else B=
W.color;o.setAttribute("style","fill: "+B.__styleString)}l.appendChild(o)}}else if(G instanceof THREE.RenderableLine){v=G.v1;u=G.v2;v.positionScreen.x*=c;v.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);if(N.instersects(s)){D=0;for(w=G.materials.length;D<w;)if(W=G.materials[D++]){x=v;K=u;W=W;ba=M++;if(g[ba]==null){g[ba]=document.createElementNS("http://www.w3.org/2000/svg","line");
H==0&&g[ba].setAttribute("shape-rendering","crispEdges")}o=g[ba];o.setAttribute("x1",x.positionScreen.x);o.setAttribute("y1",x.positionScreen.y);o.setAttribute("x2",K.positionScreen.x);o.setAttribute("y2",K.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){B.__styleString=W.color.__styleString;o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);l.appendChild(o)}}}}else if(G instanceof
THREE.RenderableFace3){v=G.v1;u=G.v2;J=G.v3;v.positionScreen.x*=c;v.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);if(N.instersects(s)){D=0;for(w=G.meshMaterials.length;D<w;){W=G.meshMaterials[D++];if(W instanceof THREE.MeshFaceMaterial){x=0;for(K=G.faceMaterials.length;x<K;)(W=G.faceMaterials[x++])&&
b(v,u,J,G,W,z)}else W&&b(v,u,J,G,W,z)}}}else if(G instanceof THREE.RenderableFace4){v=G.v1;u=G.v2;J=G.v3;R=G.v4;v.positionScreen.x*=c;v.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;R.positionScreen.x*=c;R.positionScreen.y*=-C;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);s.addPoint(R.positionScreen.x,R.positionScreen.y);if(N.instersects(s)){D=
0;for(w=G.meshMaterials.length;D<w;){W=G.meshMaterials[D++];if(W instanceof THREE.MeshFaceMaterial){x=0;for(K=G.faceMaterials.length;x<K;)(W=G.faceMaterials[x++])&&f(v,u,J,R,G,W,z)}else W&&f(v,u,J,R,G,W,z)}}}}}};
THREE.WebGLRenderer=function(a,b){function f(e,h,m){var i=c.createProgram();m=["#ifdef GL_ES\nprecision highp float;\n#endif",m?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(i,l("fragment",m+e));c.attachShader(i,l("vertex",n+h));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(e,h){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
THREE.Projector=function(){function a(e,g){return g.z-e.z}function b(e,g){var m=0,h=1,n=e.z+e.w,l=g.z+g.w,q=-e.z+e.w,t=-g.z+g.w;if(n>=0&&l>=0&&q>=0&&t>=0)return true;else if(n<0&&l<0||q<0&&t<0)return false;else{if(n<0)m=Math.max(m,n/(n-l));else if(l<0)h=Math.min(h,n/(n-l));if(q<0)m=Math.max(m,q/(q-t));else if(t<0)h=Math.min(h,q/(q-t));if(h<m)return false;else{e.lerpSelf(g,m);g.lerpSelf(e,1-h);return true}}}var f,d,i=[],j,p,k,o=[],x,c,E=[],v,u,I=[],T=new THREE.Vector4,P=new THREE.Vector4,s=new THREE.Matrix4,
V=new THREE.Matrix4,D=[],J=new THREE.Vector4,Q=new THREE.Vector4,R;this.projectObjects=function(e,g,m){var h=[],n,l;d=0;s.multiply(g.projectionMatrix,g.matrix);D[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);D[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);D[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);D[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);D[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
s.n33,s.n44-s.n34);D[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);g=0;for(n=D.length;g<n;g++){l=D[g];l.divideScalar(Math.sqrt(l.x*l.x+l.y*l.y+l.z*l.z))}n=e.objects;e=0;for(g=n.length;e<g;e++){l=n[e];var q;if(!(q=!l.visible)){if(q=l instanceof THREE.Mesh){a:{q=void 0;for(var t=l.position,K=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),w=0;w<6;w++){q=D[w].x*t.x+D[w].y*t.y+D[w].z*t.z+D[w].w;if(q<=K){q=false;break a}}q=true}q=!q}q=q}if(!q){f=
i[d]=i[d]||new THREE.RenderableObject;T.copy(l.position);s.multiplyVector3(T);f.object=l;f.z=T.z;h.push(f);d++}}m&&h.sort(a);return h};this.projectScene=function(e,g,m){var h=[],n=g.near,l=g.far,q,t,K,w,U,A,B,y,S,F,H,G,L,C,N,Y;k=c=u=0;g.autoUpdateMatrix&&g.updateMatrix();s.multiply(g.projectionMatrix,g.matrix);A=this.projectObjects(e,g,true);e=0;for(q=A.length;e<q;e++){B=A[e].object;if(B.visible){B.autoUpdateMatrix&&B.updateMatrix();y=B.matrix;S=B.rotationMatrix;F=B.materials;H=B.overdraw;if(B instanceof
THREE.Mesh){G=B.geometry;L=G.vertices;t=0;for(K=L.length;t<K;t++){C=L[t];C.positionWorld.copy(C.position);y.multiplyVector3(C.positionWorld);w=C.positionScreen;w.copy(C.positionWorld);s.multiplyVector4(w);w.x/=w.w;w.y/=w.w;C.__visible=w.z>n&&w.z<l}G=G.faces;t=0;for(K=G.length;t<K;t++){C=G[t];if(C instanceof THREE.Face3){w=L[C.a];U=L[C.b];N=L[C.c];if(w.__visible&&U.__visible&&N.__visible)if(B.doubleSided||B.flipSided!=(N.positionScreen.x-w.positionScreen.x)*(U.positionScreen.y-w.positionScreen.y)-
(N.positionScreen.y-w.positionScreen.y)*(U.positionScreen.x-w.positionScreen.x)<0){j=o[k]=o[k]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(U.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(U.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);S.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);y.multiplyVector3(j.centroidWorld);
j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);N=C.vertexNormals;R=j.vertexNormalsWorld;w=0;for(U=N.length;w<U;w++){Y=R[w]=R[w]||new THREE.Vector3;Y.copy(N[w]);S.multiplyVector3(Y)}j.z=j.centroidScreen.z;j.meshMaterials=F;j.faceMaterials=C.materials;j.overdraw=H;if(B.geometry.uvs[t]){j.uvs[0]=B.geometry.uvs[t][0];j.uvs[1]=B.geometry.uvs[t][1];j.uvs[2]=B.geometry.uvs[t][2]}h.push(j);k++}}else if(C instanceof THREE.Face4){w=L[C.a];U=L[C.b];N=L[C.c];Y=L[C.d];if(w.__visible&&
U.__visible&&N.__visible&&Y.__visible)if(B.doubleSided||B.flipSided!=((Y.positionScreen.x-w.positionScreen.x)*(U.positionScreen.y-w.positionScreen.y)-(Y.positionScreen.y-w.positionScreen.y)*(U.positionScreen.x-w.positionScreen.x)<0||(U.positionScreen.x-N.positionScreen.x)*(Y.positionScreen.y-N.positionScreen.y)-(U.positionScreen.y-N.positionScreen.y)*(Y.positionScreen.x-N.positionScreen.x)<0)){j=o[k]=o[k]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(U.positionWorld);
j.v3.positionWorld.copy(Y.positionWorld);j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(U.positionScreen);j.v3.positionScreen.copy(Y.positionScreen);j.normalWorld.copy(C.normal);S.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);y.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=F;j.faceMaterials=C.materials;j.overdraw=H;if(B.geometry.uvs[t]){j.uvs[0]=B.geometry.uvs[t][0];
j.uvs[1]=B.geometry.uvs[t][1];j.uvs[2]=B.geometry.uvs[t][3]}h.push(j);k++;p=o[k]=o[k]||new THREE.RenderableFace3;p.v1.positionWorld.copy(U.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(U.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
F;p.faceMaterials=C.materials;p.overdraw=H;if(B.geometry.uvs[t]){p.uvs[0]=B.geometry.uvs[t][1];p.uvs[1]=B.geometry.uvs[t][2];p.uvs[2]=B.geometry.uvs[t][3]}h.push(p);k++}}}}else if(B instanceof THREE.Line){V.multiply(s,y);L=B.geometry.vertices;C=L[0];C.positionScreen.copy(C.position);V.multiplyVector4(C.positionScreen);t=1;for(K=L.length;t<K;t++){w=L[t];w.positionScreen.copy(w.position);V.multiplyVector4(w.positionScreen);U=L[t-1];J.copy(w.positionScreen);Q.copy(U.positionScreen);if(b(J,Q)){J.multiplyScalar(1/
J.w);Q.multiplyScalar(1/Q.w);x=E[c]=E[c]||new THREE.RenderableLine;x.v1.positionScreen.copy(J);x.v2.positionScreen.copy(Q);x.z=Math.max(J.z,Q.z);x.materials=B.materials;h.push(x);c++}}}else if(B instanceof THREE.Particle){P.set(B.position.x,B.position.y,B.position.z,1);s.multiplyVector4(P);P.z/=P.w;if(P.z>0&&P.z<1){v=I[u]=I[u]||new THREE.RenderableParticle;v.x=P.x/P.w;v.y=P.y/P.w;v.z=P.z;v.rotation=B.rotation.z;v.scale.x=B.scale.x*Math.abs(v.x-(P.x+g.projectionMatrix.n11)/(P.w+g.projectionMatrix.n14));
v.scale.y=B.scale.y*Math.abs(v.y-(P.y+g.projectionMatrix.n22)/(P.w+g.projectionMatrix.n24));v.materials=B.materials;h.push(v);u++}}}}m&&h.sort(a);return h};this.unprojectVector=function(e,g){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));m.multiplyVector3(e);return e}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,j;this.domElement=document.createElement("div");this.setSize=function(p,k){f=p;d=k;i=f/2;j=d/2};this.render=function(p,k){var o,x,c,E,v,u,I,T;a=b.projectScene(p,k);o=0;for(x=a.length;o<x;o++){v=a[o];if(v instanceof THREE.RenderableParticle){I=v.x*i+i;T=v.y*j+j;c=0;for(E=v.material.length;c<E;c++){u=v.material[c];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=I+"px";u.style.top=T+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,j,p,k=f.getContext("2d"),o=1,x=0,c=null,E=null,v=1,u,I,T,P,s,V,D,J,Q,R=new THREE.Color,e=new THREE.Color,g=new THREE.Color,m=new THREE.Color,h=new THREE.Color,n,l,q,t,K,w,U,A,B,y=new THREE.Rectangle,S=new THREE.Rectangle,F=new THREE.Rectangle,H=false,G=new THREE.Color,L=new THREE.Color,C=new THREE.Color,N=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,pa,qa,Ba,ea,ra,va,ma=16;pa=document.createElement("canvas");
pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);Ba=qa.getImageData(0,0,2,2);ea=Ba.data;ra=document.createElement("canvas");ra.width=ra.height=ma;va=ra.getContext("2d");va.translate(-ma/2,-ma/2);va.scale(ma,ma);ma--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ha,na){d=ha;i=na;j=d/2;p=i/2;f.width=d;f.height=i;y.set(-j,-p,j,p)};this.clear=function(){if(!S.isEmpty()){S.inflate(1);S.minSelf(y);k.clearRect(S.getX(),
S.getY(),S.getWidth(),S.getHeight());S.empty()}};this.render=function(ha,na){function La(r){var W,O,z,M=r.lights;L.setRGB(0,0,0);C.setRGB(0,0,0);N.setRGB(0,0,0);r=0;for(W=M.length;r<W;r++){O=M[r];z=O.color;if(O instanceof THREE.AmbientLight){L.r+=z.r;L.g+=z.g;L.b+=z.b}else if(O instanceof THREE.DirectionalLight){C.r+=z.r;C.g+=z.g;C.b+=z.b}else if(O instanceof THREE.PointLight){N.r+=z.r;N.g+=z.g;N.b+=z.b}}}function wa(r,W,O,z){var M,X,ba,ca,da=r.lights;r=0;for(M=da.length;r<M;r++){X=da[r];ba=X.color;
ca=X.intensity;if(X instanceof THREE.DirectionalLight){X=O.dot(X.position)*ca;if(X>0){z.r+=ba.r*X;z.g+=ba.g*X;z.b+=ba.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=O.dot(Z)*ca;if(X>0){z.r+=ba.r*X;z.g+=ba.g*X;z.b+=ba.b*X}}}}function Ma(r,W,O){if(O.opacity!=0){Ca(O.opacity);xa(O.blending);var z,M,X,ba,ca,da;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){ba=O.map;ca=ba.width>>1;da=ba.height>>1;M=W.scale.x*j;X=W.scale.y*p;O=M*ca;z=X*da;F.set(r.x-O,r.y-z,r.x+O,
r.y+z);if(!y.instersects(F))return;k.save();k.translate(r.x,r.y);k.rotate(-W.rotation);k.scale(M,-X);k.translate(-ca,-da);k.drawImage(ba,0,0);k.restore()}k.beginPath();k.moveTo(r.x-10,r.y);k.lineTo(r.x+10,r.y);k.moveTo(r.x,r.y-10);k.lineTo(r.x,r.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(O instanceof THREE.ParticleCircleMaterial){if(H){G.r=L.r+C.r+N.r;G.g=L.g+C.g+N.g;G.b=L.b+C.b+N.b;R.r=O.color.r*G.r;R.g=O.color.g*G.g;R.b=O.color.b*G.b;R.updateStyleString()}else R.__styleString=
O.color.__styleString;O=W.scale.x*j;z=W.scale.y*p;F.set(r.x-O,r.y-z,r.x+O,r.y+z);if(y.instersects(F)){M=R.__styleString;if(E!=M)k.fillStyle=E=M;k.save();k.translate(r.x,r.y);k.rotate(-W.rotation);k.scale(O,z);k.beginPath();k.arc(0,0,1,0,Y,true);k.closePath();k.fill();k.restore()}}}}function Na(r,W,O,z){if(z.opacity!=0){Ca(z.opacity);xa(z.blending);k.beginPath();k.moveTo(r.positionScreen.x,r.positionScreen.y);k.lineTo(W.positionScreen.x,W.positionScreen.y);k.closePath();if(z instanceof THREE.LineBasicMaterial){R.__styleString=
z.color.__styleString;r=z.linewidth;if(v!=r)k.lineWidth=v=r;r=R.__styleString;if(c!=r)k.strokeStyle=c=r;k.stroke();F.inflate(z.linewidth*2)}}}function Ha(r,W,O,z,M,X){if(M.opacity!=0){Ca(M.opacity);xa(M.blending);P=r.positionScreen.x;s=r.positionScreen.y;V=W.positionScreen.x;D=W.positionScreen.y;J=O.positionScreen.x;Q=O.positionScreen.y;k.beginPath();k.moveTo(P,s);k.lineTo(V,D);k.lineTo(J,Q);k.lineTo(P,s);k.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof
THREE.UVMapping&&sa(P,s,V,D,J,Q,M.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){r=na.matrix;Z.copy(z.vertexNormalsWorld[0]);t=(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;K=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);w=(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;U=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);A=
(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;B=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;sa(P,s,V,D,J,Q,M.env_map.image,t,K,w,U,A,B)}}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&sa(P,s,V,D,J,Q,M.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);xa(THREE.SubtractiveBlending)}if(H)if(!M.wireframe&&M.shading==THREE.SmoothShading&&
z.vertexNormalsWorld.length==3){e.r=g.r=m.r=L.r;e.g=g.g=m.g=L.g;e.b=g.b=m.b=L.b;wa(X,z.v1.positionWorld,z.vertexNormalsWorld[0],e);wa(X,z.v2.positionWorld,z.vertexNormalsWorld[1],g);wa(X,z.v3.positionWorld,z.vertexNormalsWorld[2],m);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,s,V,D,J,Q,q,0,0,1,0,0,1)}else{G.r=L.r;G.g=L.g;G.b=L.b;wa(X,z.centroidWorld,z.normalWorld,G);R.r=M.color.r*G.r;R.g=M.color.g*G.g;R.b=M.color.b*G.b;R.updateStyleString();M.wireframe?ya(R.__styleString,
M.wireframe_linewidth):za(R.__styleString)}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){n=na.near;l=na.far;e.r=e.g=e.b=1-Da(r.positionScreen.z,n,l);g.r=g.g=g.b=1-Da(W.positionScreen.z,n,l);m.r=m.g=m.b=1-Da(O.positionScreen.z,n,l);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,s,V,D,J,Q,q,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){R.r=Ea(z.normalWorld.x);R.g=Ea(z.normalWorld.y);
R.b=Ea(z.normalWorld.z);R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}}}function ya(r,W){if(c!=r)k.strokeStyle=c=r;if(v!=W)k.lineWidth=v=W;k.stroke();F.inflate(W*2)}function za(r){if(E!=r)k.fillStyle=E=r;k.fill()}function sa(r,W,O,z,M,X,ba,ca,da,ia,fa,ja,ta){var la,ka;la=ba.width-1;ka=ba.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;ta*=ka;O-=r;z-=W;M-=r;X-=W;ia-=ca;fa-=da;ja-=ca;ta-=da;ka=1/(ia*ta-ja*fa);la=(ta*O-fa*M)*ka;fa=(ta*z-fa*X)*ka;O=(ia*M-
ja*O)*ka;z=(ia*X-ja*z)*ka;r=r-la*ca-O*da;W=W-fa*ca-z*da;k.save();k.transform(la,fa,O,z,r,W);k.clip();k.drawImage(ba,0,0);k.restore()}function Ca(r){if(o!=r)k.globalAlpha=o=r}function xa(r){if(x!=r){switch(r){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=r}}function Ia(r,W,O,z){var M=~~(r.r*255),X=~~(r.g*255);r=~~(r.b*255);var ba=~~(W.r*
255),ca=~~(W.g*255);W=~~(W.b*255);var da=~~(O.r*255),ia=~~(O.g*255);O=~~(O.b*255);var fa=~~(z.r*255),ja=~~(z.g*255);z=~~(z.b*255);ea[0]=M<0?0:M>255?255:M;ea[1]=X<0?0:X>255?255:X;ea[2]=r<0?0:r>255?255:r;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=W<0?0:W>255?255:W;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=O<0?0:O>255?255:O;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=z<0?0:z>255?255:z;qa.putImageData(Ba,0,0);va.drawImage(pa,0,0);return ra}function Da(r,
W,O){r=(r-W)/(O-W);return r*r*(3-2*r)}function Ea(r){r=(r+1)*0.5;return r<0?0:r>1?1:r}function Fa(r,W){var O=W.x-r.x,z=W.y-r.y,M=1/Math.sqrt(O*O+z*z);O*=M;z*=M;W.x+=O;W.y+=z;r.x-=O;r.y-=z}var Aa,Ja,$,ga,oa,Ga,Ka,ua;k.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ha,na,this.sortElements);k.fillStyle="rgba( 0, 255, 255, 0.5 )";k.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight());(H=ha.lights.length>0)&&La(ha);Aa=0;for(Ja=a.length;Aa<Ja;Aa++){$=a[Aa];F.empty();if($ instanceof
THREE.RenderableParticle){u=$;u.x*=j;u.y*=p;ga=0;for(oa=$.materials.length;ga<oa;ga++)Ma(u,$,$.materials[ga],ha)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;F.addPoint(u.positionScreen.x,u.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(y.instersects(F)){ga=0;for(oa=$.materials.length;ga<oa;)Na(u,I,$,$.materials[ga++],ha)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=
$.v2;T=$.v3;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;T.positionScreen.x*=j;T.positionScreen.y*=p;if($.overdraw){Fa(u.positionScreen,I.positionScreen);Fa(I.positionScreen,T.positionScreen);Fa(T.positionScreen,u.positionScreen)}F.add3Points(u.positionScreen.x,u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,T.positionScreen.x,T.positionScreen.y);if(y.instersects(F)){ga=0;for(oa=$.meshMaterials.length;ga<oa;){ua=$.meshMaterials[ga++];if(ua instanceof
THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(ua=$.faceMaterials[Ga++])&&Ha(u,I,T,$,ua,ha)}else Ha(u,I,T,$,ua,ha)}}}S.addRectangle(F)}k.lineWidth=1;k.strokeStyle="rgba( 255, 0, 0, 0.5 )";k.strokeRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());k.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(A,B,y){var S,F,H,G;S=0;for(F=A.lights.length;S<F;S++){H=A.lights[S];if(H instanceof THREE.DirectionalLight){G=B.normalWorld.dot(H.position)*H.intensity;if(G>0){y.r+=H.color.r*G;y.g+=H.color.g*G;y.b+=H.color.b*G}}else if(H instanceof THREE.PointLight){m.sub(H.position,B.centroidWorld);m.normalize();G=B.normalWorld.dot(m)*H.intensity;if(G>0){y.r+=H.color.r*G;y.g+=H.color.g*G;y.b+=H.color.b*G}}}}function b(A,B,y,S,F,H){q=d(t++);q.setAttribute("d","M "+A.positionScreen.x+
" "+A.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)D.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(H,S,J);D.r=F.color.r*J.r;D.g=F.color.g*J.g;D.b=F.color.b*J.b;D.updateStyleString()}else D.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){g=1-F.__2near/(F.__farPlusNear-S.z*F.__farMinusNear);
D.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&D.setRGB(i(S.normalWorld.x),i(S.normalWorld.y),i(S.normalWorld.z));F.wireframe?q.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):q.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(q)}function f(A,B,y,S,F,H,G){q=d(t++);q.setAttribute("d",
"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)D.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(G,F,J);D.r=H.color.r*J.r;D.g=H.color.g*J.g;D.b=H.color.b*J.b;D.updateStyleString()}else D.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){g=
1-H.__2near/(H.__farPlusNear-F.z*H.__farMinusNear);D.setRGB(g,g,g)}else H instanceof THREE.MeshNormalMaterial&&D.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));H.wireframe?q.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):q.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+H.opacity);k.appendChild(q)}
function d(A){if(h[A]==null){h[A]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&h[A].setAttribute("shape-rendering","crispEdges");return h[A]}return h[A]}function i(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var j=null,p=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,x,c,E,v,u,I,T,P=new THREE.Rectangle,s=new THREE.Rectangle,V=false,D=new THREE.Color(16777215),J=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0),
e=new THREE.Color(0),g,m=new THREE.Vector3,h=[],n=[],l=[],q,t,K,w,U=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(A){switch(A){case "high":U=1;break;case "low":U=0}};this.setSize=function(A,B){o=A;x=B;c=o/2;E=x/2;k.setAttribute("viewBox",-c+" "+-E+" "+o+" "+x);k.setAttribute("width",o);k.setAttribute("height",x);P.set(-c,-E,c,E)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(A,B){var y,S,
F,H,G,L,C,N;this.autoClear&&this.clear();j=p.projectScene(A,B,this.sortElements);w=K=t=0;if(V=A.lights.length>0){C=A.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);e.setRGB(0,0,0);y=0;for(S=C.length;y<S;y++){F=C[y];H=F.color;if(F instanceof THREE.AmbientLight){Q.r+=H.r;Q.g+=H.g;Q.b+=H.b}else if(F instanceof THREE.DirectionalLight){R.r+=H.r;R.g+=H.g;R.b+=H.b}else if(F instanceof THREE.PointLight){e.r+=H.r;e.g+=H.g;e.b+=H.b}}}y=0;for(S=j.length;y<S;y++){C=j[y];s.empty();if(C instanceof THREE.RenderableParticle){v=
C;v.x*=c;v.y*=-E;F=0;for(H=C.materials.length;F<H;F++)if(N=C.materials[F]){G=v;L=C;N=N;var Y=K++;if(n[Y]==null){n[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&n[Y].setAttribute("shape-rendering","crispEdges")}q=n[Y];q.setAttribute("cx",G.x);q.setAttribute("cy",G.y);q.setAttribute("r",L.scale.x*c);if(N instanceof THREE.ParticleCircleMaterial){if(V){J.r=Q.r+R.r+e.r;J.g=Q.g+R.g+e.g;J.b=Q.b+R.b+e.b;D.r=N.color.r*J.r;D.g=N.color.g*J.g;D.b=N.color.b*J.b;D.updateStyleString()}else D=
N.color;q.setAttribute("style","fill: "+D.__styleString)}k.appendChild(q)}}else if(C instanceof THREE.RenderableLine){v=C.v1;u=C.v2;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);if(P.instersects(s)){F=0;for(H=C.materials.length;F<H;)if(N=C.materials[F++]){G=v;L=u;N=N;Y=w++;if(l[Y]==null){l[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");U==
0&&l[Y].setAttribute("shape-rendering","crispEdges")}q=l[Y];q.setAttribute("x1",G.positionScreen.x);q.setAttribute("y1",G.positionScreen.y);q.setAttribute("x2",L.positionScreen.x);q.setAttribute("y2",L.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){D.__styleString=N.color.__styleString;q.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);k.appendChild(q)}}}}else if(C instanceof
THREE.RenderableFace3){v=C.v1;u=C.v2;I=C.v3;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;I.positionScreen.x*=c;I.positionScreen.y*=-E;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(I.positionScreen.x,I.positionScreen.y);if(P.instersects(s)){F=0;for(H=C.meshMaterials.length;F<H;){N=C.meshMaterials[F++];if(N instanceof THREE.MeshFaceMaterial){G=0;for(L=C.faceMaterials.length;G<L;)(N=C.faceMaterials[G++])&&
b(v,u,I,C,N,A)}else N&&b(v,u,I,C,N,A)}}}else if(C instanceof THREE.RenderableFace4){v=C.v1;u=C.v2;I=C.v3;T=C.v4;v.positionScreen.x*=c;v.positionScreen.y*=-E;u.positionScreen.x*=c;u.positionScreen.y*=-E;I.positionScreen.x*=c;I.positionScreen.y*=-E;T.positionScreen.x*=c;T.positionScreen.y*=-E;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(I.positionScreen.x,I.positionScreen.y);s.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(s)){F=
0;for(H=C.meshMaterials.length;F<H;){N=C.meshMaterials[F++];if(N instanceof THREE.MeshFaceMaterial){G=0;for(L=C.faceMaterials.length;G<L;)(N=C.faceMaterials[G++])&&f(v,u,I,T,C,N,A)}else N&&f(v,u,I,T,C,N,A)}}}}}};
THREE.WebGLRenderer=function(a,b){function f(e,g,m){var h=c.createProgram();m=["#ifdef GL_ES\nprecision highp float;\n#endif",m?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(h,k("fragment",m+e));c.attachShader(h,k("vertex",n+g));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(e,g){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.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(var m=0;m<6;++m)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[m]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
h);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function j(e,h){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,p(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,p(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,p(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
p(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,h){var m,i,n;m=0;for(i=h.length;m<i;m++){n=h[m];e.uniforms[n]=c.getUniformLocation(e,n)}}function q(e,h){var m,i,n;m=0;for(i=h.length;m<i;m++){n=h[m];e.attributes[n]=c.getAttribLocation(e,n)}}function l(e,h){var m;if(e=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")m=c.createShader(c.VERTEX_SHADER);c.shaderSource(m,
h);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function p(e){switch(e){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}return 0}var y=document.createElement("canvas"),c,C,v,u=new THREE.Matrix4,J,R=new Float32Array(16),N=new Float32Array(16),s=new Float32Array(16),U=new Float32Array(9),B=new Float32Array(16),L=function(e,h){if(e){var m,i,n,g=pointLights=maxDirLights=maxPointLights=0;m=0;for(i=e.lights.length;m<i;m++){n=e.lights[m];n instanceof THREE.DirectionalLight&&g++;n instanceof
THREE.PointLight&&pointLights++}if(pointLights+g<=h){maxDirLights=g;maxPointLights=pointLights}else{maxDirLights=Math.ceil(h*g/(pointLights+g));maxPointLights=h-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:h-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=y;this.autoClear=true;try{c=y.getContext("experimental-webgl",{antialias:aa})}catch(O){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,
1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);C=v=function(e,h,m){var i=[e?"#define MAX_DIR_LIGHTS "+e:"",h?"#define MAX_POINT_LIGHTS "+h:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",h?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",h?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",h?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",h?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",h?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",h?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",h?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",h?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
n=[e?"#define MAX_DIR_LIGHTS "+e:"",h?"#define MAX_POINT_LIGHTS "+h:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",h?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
h?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",h?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",h?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",h?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",h?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",h?"float pointSpecularWeight = 0.0;":"",h?"if ( pointDotNormalHalf >= 0.0 )":
"",h?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",h?"pointDiffuse += mColor * pointDiffuseWeight;":"",h?"pointSpecular += mSpecular * pointSpecularWeight;":"",h?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",h?"totalLight += pointDiffuse + pointSpecular;":
g);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,g){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,o(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,o(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,o(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
o(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,g){var m,h,n;m=0;for(h=g.length;m<h;m++){n=g[m];e.uniforms[n]=c.getUniformLocation(e,n)}}function p(e,g){var m,h,n;m=0;for(h=g.length;m<h;m++){n=g[m];e.attributes[n]=c.getAttribLocation(e,n)}}function k(e,g){var m;if(e=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")m=c.createShader(c.VERTEX_SHADER);c.shaderSource(m,
g);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function o(e){switch(e){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}return 0}var x=document.createElement("canvas"),c,E,v,u=new THREE.Matrix4,I,T=new Float32Array(16),P=new Float32Array(16),s=new Float32Array(16),V=new Float32Array(9),D=new Float32Array(16),J=function(e,g){if(e){var m,h,n,l=pointLights=maxDirLights=maxPointLights=0;m=0;for(h=e.lights.length;m<h;m++){n=e.lights[m];n instanceof THREE.DirectionalLight&&l++;n instanceof
THREE.PointLight&&pointLights++}if(pointLights+l<=g){maxDirLights=l;maxPointLights=pointLights}else{maxDirLights=Math.ceil(g*l/(pointLights+l));maxPointLights=g-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:g-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=x;this.autoClear=true;try{c=x.getContext("experimental-webgl",{antialias:aa})}catch(Q){}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(0,0,0,0);E=v=function(e,g,m){var h=[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",g?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",g?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",g?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",g?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",g?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",g?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",g?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
n=[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
g?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",g?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",g?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",g?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",g?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",g?"float pointSpecularWeight = 0.0;":"",g?"if ( pointDotNormalHalf >= 0.0 )":
"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"totalLight += pointDiffuse + pointSpecular;":
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
i=f(n,i,m);c.useProgram(i);k(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&k(i,["fogColor","fogNear","fogFar"]);e&&k(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);h&&k(i,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);q(i,["position","normal","uv"]);return i}(L.directional,L.point,fog);this.setSize=function(e,h){y.width=e;y.height=h;c.viewport(0,0,y.width,y.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var m,i,n,g,o,
r=[],E=[],M=[];g=[];o=[];c.uniform1i(e.uniforms.enableLighting,h.length);m=0;for(i=h.length;m<i;m++){n=h[m];if(n instanceof THREE.AmbientLight)r.push(n);else if(n instanceof THREE.DirectionalLight)M.push(n);else n instanceof THREE.PointLight&&E.push(n)}m=n=g=o=0;for(i=r.length;m<i;m++){n+=r[m].color.r;g+=r[m].color.g;o+=r[m].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,g,o);g=[];o=[];m=0;for(i=M.length;m<i;m++){n=M[m];g.push(n.color.r*n.intensity);g.push(n.color.g*n.intensity);g.push(n.color.b*
n.intensity);o.push(n.position.x);o.push(n.position.y);o.push(n.position.z)}if(M.length){c.uniform1i(e.uniforms.directionalLightNumber,M.length);c.uniform3fv(e.uniforms.directionalLightDirection,o);c.uniform3fv(e.uniforms.directionalLightColor,g)}g=[];o=[];m=0;for(i=E.length;m<i;m++){n=E[m];g.push(n.color.r*n.intensity);g.push(n.color.g*n.intensity);g.push(n.color.b*n.intensity);o.push(n.position.x);o.push(n.position.y);o.push(n.position.z)}if(E.length){c.uniform1i(e.uniforms.pointLightNumber,E.length);
c.uniform3fv(e.uniforms.pointLightPosition,o);c.uniform3fv(e.uniforms.pointLightColor,g)}};this.createBuffers=function(e,h){var m,i,n,g,o,r,E,M,H,z=[],T=[],F=[],S=[],D=[],w=[],x=0,K=e.geometry.geometryChunks[h],G;n=false;m=0;for(i=e.materials.length;m<i;m++){meshMaterial=e.materials[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(G=K.materials.length;o<G;o++)if(K.materials[o]&&K.materials[o].shading!=undefined&&K.materials[o].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}G=n;m=0;for(i=K.faces.length;m<i;m++){n=K.faces[m];g=e.geometry.faces[n];o=g.vertexNormals;faceNormal=g.normal;n=e.geometry.uvs[n];if(g instanceof THREE.Face3){r=e.geometry.vertices[g.a].position;E=e.geometry.vertices[g.b].position;M=e.geometry.vertices[g.c].position;F.push(r.x,r.y,r.z);F.push(E.x,E.y,E.z);F.push(M.x,M.y,M.z);if(e.geometry.hasTangents){r=e.geometry.vertices[g.a].tangent;E=e.geometry.vertices[g.b].tangent;
M=e.geometry.vertices[g.c].tangent;D.push(r.x,r.y,r.z,r.w);D.push(E.x,E.y,E.z,E.w);D.push(M.x,M.y,M.z,M.w)}if(o.length==3&&G)for(g=0;g<3;g++)S.push(o[g].x,o[g].y,o[g].z);else for(g=0;g<3;g++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(g=0;g<3;g++)w.push(n[g].u,n[g].v);z.push(x,x+1,x+2);T.push(x,x+1);T.push(x,x+2);T.push(x+1,x+2);x+=3}else if(g instanceof THREE.Face4){r=e.geometry.vertices[g.a].position;E=e.geometry.vertices[g.b].position;M=e.geometry.vertices[g.c].position;H=e.geometry.vertices[g.d].position;
F.push(r.x,r.y,r.z);F.push(E.x,E.y,E.z);F.push(M.x,M.y,M.z);F.push(H.x,H.y,H.z);if(e.geometry.hasTangents){r=e.geometry.vertices[g.a].tangent;E=e.geometry.vertices[g.b].tangent;M=e.geometry.vertices[g.c].tangent;g=e.geometry.vertices[g.d].tangent;D.push(r.x,r.y,r.z,r.w);D.push(E.x,E.y,E.z,E.w);D.push(M.x,M.y,M.z,M.w);D.push(g.x,g.y,g.z,g.w)}if(o.length==4&&G)for(g=0;g<4;g++)S.push(o[g].x,o[g].y,o[g].z);else for(g=0;g<4;g++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(g=0;g<4;g++)w.push(n[g].u,
n[g].v);z.push(x,x+1,x+2);z.push(x,x+2,x+3);T.push(x,x+1);T.push(x,x+2);T.push(x,x+3);T.push(x+1,x+2);T.push(x+2,x+3);x+=4}}if(F.length){K.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW);K.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);if(e.geometry.hasTangents){K.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,K.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW)}if(w.length>0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(w),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);K.__webGLFaceCount=z.length;K.__webGLLineCount=T.length}};this.renderBuffer=function(e,h,m,i,n){var g,o,r,E,M,H,z,T,F;if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){if(!i.program){if(i instanceof THREE.MeshDepthMaterial){z=Q.depth;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms;i.uniforms.mNear.value=
i.near;i.uniforms.mFar.value=i.far}else if(i instanceof THREE.MeshNormalMaterial){z=Q.normal;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms}i.program=f(i.fragment_shader,i.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in i.uniforms)z.push(F);k(i.program,z);q(i.program,["position","normal","uv","tangent"])}F=i.program}else F=v;if(F!=C){c.useProgram(F);C=F}F==v&&this.setupLights(F,
h);this.loadCamera(F,e);this.loadMatrices(F);if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){r=i.wireframe;E=i.wireframe_linewidth;e=F;h=i.uniforms;var S;for(g in h){T=h[g].type;z=h[g].value;S=e.uniforms[g];if(T=="i")c.uniform1i(S,z);else if(T=="f")c.uniform1f(S,z);else if(T=="v3")c.uniform3f(S,z.x,z.y,z.z);else if(T=="c")c.uniform3f(S,z.r,z.g,z.b);else if(T=="t"){c.uniform1i(S,z);if(T=h[g].texture)T.image instanceof Array&&T.image.length==
6?d(T,z):j(T,z)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){g=i.color;o=i.opacity;r=i.wireframe;E=i.wireframe_linewidth;M=i.map;H=i.env_map;h=i.combine==THREE.MixOperation;e=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;z=i.refraction_ratio;c.uniform4f(F.uniforms.mColor,g.r*o,g.g*o,g.b*o,o);c.uniform1i(F.uniforms.mixEnvMap,h);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract,
T);c.uniform1f(F.uniforms.mRefractionRatio,z);if(m){c.uniform1f(F.uniforms.fogNear,m.near);c.uniform1f(F.uniforms.fogFar,m.far);c.uniform3f(F.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(i instanceof THREE.MeshPhongMaterial){m=i.ambient;g=i.specular;i=i.shininess;c.uniform4f(F.uniforms.mAmbient,m.r,m.g,m.b,o);c.uniform4f(F.uniforms.mSpecular,g.r,g.g,g.b,o);c.uniform1f(F.uniforms.mShininess,i);c.uniform1i(F.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,
1);else i instanceof THREE.MeshBasicMaterial&&c.uniform1i(F.uniforms.material,0);if(M){j(M,0);c.uniform1i(F.uniforms.tMap,0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(H){d(H,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);o=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(r){c.lineWidth(E);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,h,m,i,n,g,o){var r,E,M,H,z;M=0;for(H=i.materials.length;M<H;M++){r=i.materials[M];if(r instanceof THREE.MeshFaceMaterial){r=0;for(E=n.materials.length;r<E;r++)if((z=n.materials[r])&&z.blending==g&&z.opacity<1==o){this.setBlending(z.blending);
this.renderBuffer(e,h,m,z,n)}}else if((z=r)&&z.blending==g&&z.opacity<1==o){this.setBlending(z.blending);this.renderBuffer(e,h,m,z,n)}}};this.render=function(e,h){var m,i,n,g,o=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();R.set(h.matrix.flatten());s.set(h.projectionMatrix.flatten());m=0;for(i=e.__webGLObjects.length;m<i;m++){n=e.__webGLObjects[m];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,h);this.renderPass(h,o,r,g,n,THREE.NormalBlending,
false)}}m=0;for(i=e.__webGLObjects.length;m<i;m++){n=e.__webGLObjects[m];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,h);this.renderPass(h,o,r,g,n,THREE.AdditiveBlending,false);this.renderPass(h,o,r,g,n,THREE.SubtractiveBlending,false);this.renderPass(h,o,r,g,n,THREE.AdditiveBlending,true);this.renderPass(h,o,r,g,n,THREE.SubtractiveBlending,true);this.renderPass(h,o,r,g,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var h,m,i,n,g,o;if(!e.__webGLObjects){e.__webGLObjects=
[];e.__webGLObjectsMap={}}h=0;for(m=e.objects.length;h<m;h++){i=e.objects[h];if(e.__webGLObjectsMap[i.id]==undefined)e.__webGLObjectsMap[i.id]={};o=e.__webGLObjectsMap[i.id];if(i instanceof THREE.Mesh)for(g in i.geometry.geometryChunks){n=i.geometry.geometryChunks[g];n.__webGLVertexBuffer||this.createBuffers(i,g);if(o[g]==undefined){n={buffer:n,object:i};e.__webGLObjects.push(n);o[g]=1}}}};this.removeObject=function(e,h){var m,i;for(m=e.__webGLObjects.length-1;m>=0;m--){i=e.__webGLObjects[m].object;
h==i&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,h){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(h.matrix,e.matrix);N.set(u.flatten());J=THREE.Matrix4.makeInvert3x3(u).transpose();U.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,U);c.uniformMatrix4fv(e.uniforms.objectMatrix,
false,B)};this.loadCamera=function(e,h){c.uniform3f(e.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){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(e,h){if(e){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
else e=="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};var Q={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}",
h=f(n,h,m);c.useProgram(h);j(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&j(h,["fogColor","fogNear","fogFar"]);e&&j(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);g&&j(h,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);p(h,["position","normal","uv"]);return h}(J.directional,J.point,fog);this.setSize=function(e,g){x.width=e;x.height=g;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,g){var m,h,n,l,q,
t=[],K=[],w=[];l=[];q=[];c.uniform1i(e.uniforms.enableLighting,g.length);m=0;for(h=g.length;m<h;m++){n=g[m];if(n instanceof THREE.AmbientLight)t.push(n);else if(n instanceof THREE.DirectionalLight)w.push(n);else n instanceof THREE.PointLight&&K.push(n)}m=n=l=q=0;for(h=t.length;m<h;m++){n+=t[m].color.r;l+=t[m].color.g;q+=t[m].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,l,q);l=[];q=[];m=0;for(h=w.length;m<h;m++){n=w[m];l.push(n.color.r*n.intensity);l.push(n.color.g*n.intensity);l.push(n.color.b*
n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(w.length){c.uniform1i(e.uniforms.directionalLightNumber,w.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,l)}l=[];q=[];m=0;for(h=K.length;m<h;m++){n=K[m];l.push(n.color.r*n.intensity);l.push(n.color.g*n.intensity);l.push(n.color.b*n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(K.length){c.uniform1i(e.uniforms.pointLightNumber,K.length);
c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,l)}};this.createBuffers=function(e,g){var m,h,n,l,q,t,K,w,U,A=[],B=[],y=[],S=[],F=[],H=[],G=0,L=e.geometry.geometryChunks[g],C;n=false;m=0;for(h=e.materials.length;m<h;m++){meshMaterial=e.materials[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(C=L.materials.length;q<C;q++)if(L.materials[q]&&L.materials[q].shading!=undefined&&L.materials[q].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}C=n;m=0;for(h=L.faces.length;m<h;m++){n=L.faces[m];l=e.geometry.faces[n];q=l.vertexNormals;faceNormal=l.normal;n=e.geometry.uvs[n];if(l instanceof THREE.Face3){t=e.geometry.vertices[l.a].position;K=e.geometry.vertices[l.b].position;w=e.geometry.vertices[l.c].position;y.push(t.x,t.y,t.z);y.push(K.x,K.y,K.z);y.push(w.x,w.y,w.z);if(e.geometry.hasTangents){t=e.geometry.vertices[l.a].tangent;K=e.geometry.vertices[l.b].tangent;
w=e.geometry.vertices[l.c].tangent;F.push(t.x,t.y,t.z,t.w);F.push(K.x,K.y,K.z,K.w);F.push(w.x,w.y,w.z,w.w)}if(q.length==3&&C)for(l=0;l<3;l++)S.push(q[l].x,q[l].y,q[l].z);else for(l=0;l<3;l++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(l=0;l<3;l++)H.push(n[l].u,n[l].v);A.push(G,G+1,G+2);B.push(G,G+1);B.push(G,G+2);B.push(G+1,G+2);G+=3}else if(l instanceof THREE.Face4){t=e.geometry.vertices[l.a].position;K=e.geometry.vertices[l.b].position;w=e.geometry.vertices[l.c].position;U=e.geometry.vertices[l.d].position;
y.push(t.x,t.y,t.z);y.push(K.x,K.y,K.z);y.push(w.x,w.y,w.z);y.push(U.x,U.y,U.z);if(e.geometry.hasTangents){t=e.geometry.vertices[l.a].tangent;K=e.geometry.vertices[l.b].tangent;w=e.geometry.vertices[l.c].tangent;l=e.geometry.vertices[l.d].tangent;F.push(t.x,t.y,t.z,t.w);F.push(K.x,K.y,K.z,K.w);F.push(w.x,w.y,w.z,w.w);F.push(l.x,l.y,l.z,l.w)}if(q.length==4&&C)for(l=0;l<4;l++)S.push(q[l].x,q[l].y,q[l].z);else for(l=0;l<4;l++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(l=0;l<4;l++)H.push(n[l].u,
n[l].v);A.push(G,G+1,G+2);A.push(G,G+2,G+3);B.push(G,G+1);B.push(G,G+2);B.push(G,G+3);B.push(G+1,G+2);B.push(G+2,G+3);G+=4}}if(y.length){L.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(y),c.STATIC_DRAW);L.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);if(e.geometry.hasTangents){L.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,L.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}if(H.length>0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(B),c.STATIC_DRAW);L.__webGLFaceCount=A.length;L.__webGLLineCount=B.length}};this.renderBuffer=function(e,g,m,h,n){var l,q,t,K,w,U,A,B,y;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){A=R.depth;h.fragment_shader=A.fragment_shader;h.vertex_shader=A.vertex_shader;h.uniforms=A.uniforms;h.uniforms.mNear.value=
e.near;h.uniforms.mFar.value=e.far}else if(h instanceof THREE.MeshNormalMaterial){A=R.normal;h.fragment_shader=A.fragment_shader;h.vertex_shader=A.vertex_shader;h.uniforms=A.uniforms}h.program=f(h.fragment_shader,h.vertex_shader,null);A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(y in h.uniforms)A.push(y);j(h.program,A);p(h.program,["position","normal","uv","tangent"])}y=h.program}else y=v;if(y!=E){c.useProgram(y);E=y}y==v&&this.setupLights(y,
g);this.loadCamera(y,e);this.loadMatrices(y);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){t=h.wireframe;K=h.wireframe_linewidth;e=y;g=h.uniforms;var S;for(l in g){B=g[l].type;A=g[l].value;S=e.uniforms[l];if(B=="i")c.uniform1i(S,A);else if(B=="f")c.uniform1f(S,A);else if(B=="v3")c.uniform3f(S,A.x,A.y,A.z);else if(B=="c")c.uniform3f(S,A.r,A.g,A.b);else if(B=="t"){c.uniform1i(S,A);if(B=g[l].texture)B.image instanceof Array&&B.image.length==
6?d(B,A):i(B,A)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){l=h.color;q=h.opacity;t=h.wireframe;K=h.wireframe_linewidth;w=h.map;U=h.env_map;g=h.combine==THREE.MixOperation;e=h.reflectivity;B=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;A=h.refraction_ratio;c.uniform4f(y.uniforms.mColor,l.r*q,l.g*q,l.b*q,q);c.uniform1i(y.uniforms.mixEnvMap,g);c.uniform1f(y.uniforms.mReflectivity,e);c.uniform1i(y.uniforms.useRefract,
B);c.uniform1f(y.uniforms.mRefractionRatio,A);if(m){c.uniform1f(y.uniforms.fogNear,m.near);c.uniform1f(y.uniforms.fogFar,m.far);c.uniform3f(y.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(h instanceof THREE.MeshPhongMaterial){m=h.ambient;l=h.specular;h=h.shininess;c.uniform4f(y.uniforms.mAmbient,m.r,m.g,m.b,q);c.uniform4f(y.uniforms.mSpecular,l.r,l.g,l.b,q);c.uniform1f(y.uniforms.mShininess,h);c.uniform1i(y.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(y.uniforms.material,
1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(y.uniforms.material,0);if(w){i(w,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableMap,1)}else c.uniform1i(y.uniforms.enableMap,0);if(U){d(U,1);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.enableCubeMap,1)}else c.uniform1i(y.uniforms.enableCubeMap,0);q=y.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(t){c.lineWidth(K);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m,h,n,l,q){var t,K,w,U,A;w=0;for(U=h.materials.length;w<U;w++){t=h.materials[w];if(t instanceof THREE.MeshFaceMaterial){t=0;for(K=n.materials.length;t<K;t++)if((A=n.materials[t])&&A.blending==l&&A.opacity<1==q){this.setBlending(A.blending);
this.renderBuffer(e,g,m,A,n)}}else if((A=t)&&A.blending==l&&A.opacity<1==q){this.setBlending(A.blending);this.renderBuffer(e,g,m,A,n)}}};this.render=function(e,g){var m,h,n,l,q=e.lights,t=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();T.set(g.matrix.flatten());s.set(g.projectionMatrix.flatten());m=0;for(h=e.__webGLObjects.length;m<h;m++){n=e.__webGLObjects[m];l=n.object;n=n.buffer;if(l.visible){this.setupMatrices(l,g);this.renderPass(g,q,t,l,n,THREE.NormalBlending,
false)}}m=0;for(h=e.__webGLObjects.length;m<h;m++){n=e.__webGLObjects[m];l=n.object;n=n.buffer;if(l.visible){this.setupMatrices(l,g);this.renderPass(g,q,t,l,n,THREE.AdditiveBlending,false);this.renderPass(g,q,t,l,n,THREE.SubtractiveBlending,false);this.renderPass(g,q,t,l,n,THREE.AdditiveBlending,true);this.renderPass(g,q,t,l,n,THREE.SubtractiveBlending,true);this.renderPass(g,q,t,l,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var g,m,h,n,l,q;if(!e.__webGLObjects){e.__webGLObjects=
[];e.__webGLObjectsMap={}}g=0;for(m=e.objects.length;g<m;g++){h=e.objects[g];if(e.__webGLObjectsMap[h.id]==undefined)e.__webGLObjectsMap[h.id]={};q=e.__webGLObjectsMap[h.id];if(h instanceof THREE.Mesh)for(l in h.geometry.geometryChunks){n=h.geometry.geometryChunks[l];n.__webGLVertexBuffer||this.createBuffers(h,l);if(q[l]==undefined){n={buffer:n,object:h};e.__webGLObjects.push(n);q[l]=1}}}};this.removeObject=function(e,g){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;
g==h&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(g.matrix,e.matrix);P.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();V.set(I.m);D.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,T);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);c.uniformMatrix4fv(e.uniforms.objectMatrix,
false,D)};this.loadCamera=function(e,g){c.uniform3f(e.uniforms.cameraPosition,g.position.x,g.position.y,g.position.z)};this.setBlending=function(e){switch(e){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(e,g){if(e){!g||g=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
else e=="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};var R={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}"}}};
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};
+130 -130
View File
@@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1}
THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;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,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(f,j){return f.distance-j.distance});return g},intersectObject:function(a){function b(I,w,C,n){n=n.clone().subSelf(w);C=C.clone().subSelf(w);var O=I.clone().subSelf(w);I=n.dot(n);w=n.dot(C);n=n.dot(O);var L=C.dot(C);C=C.dot(O);O=1/(I*L-w*w);L=(L*n-w*C)*O;I=(I*C-w*n)*O;return L>0&&I>0&&L+I<1}var e,d,g,f,j,h,k,x,c,B,
r,t=a.geometry,y=t.vertices,A=[];e=0;for(d=t.faces.length;e<d;e++){g=t.faces[e];B=this.origin.clone();r=this.direction.clone();f=a.matrix.multiplyVector3(y[g.a].position.clone());j=a.matrix.multiplyVector3(y[g.b].position.clone());h=a.matrix.multiplyVector3(y[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(y[g.d].position.clone()):null;x=a.rotationMatrix.multiplyVector3(g.normal.clone());c=r.dot(x);if(c<0){x=x.dot((new THREE.Vector3).sub(f,B))/c;B=B.addSelf(r.multiplyScalar(x));
if(g instanceof THREE.Face3){if(b(B,f,j,h)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};A.push(g)}}else if(g instanceof THREE.Face4)if(b(B,f,j,k)||b(B,j,h,k)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};A.push(g)}}}return A}};
THREE.Rectangle=function(){function a(){f=d-b;j=g-e}var b,e,d,g,f,j,h=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(k,x,c,B){h=false;b=k;e=x;d=c;g=B;a()};this.addPoint=function(k,x){if(h){h=false;b=k;e=x;d=k;g=x}else{b=b<k?b:k;e=e<x?e:x;d=d>k?d:k;g=g>x?
g:x}a()};this.add3Points=function(k,x,c,B,r,t){if(h){h=false;b=k<c?k<r?k:r:c<r?c:r;e=x<B?x<t?x:t:B<t?B:t;d=k>c?k>r?k:r:c>r?c:r;g=x>B?x>t?x:t:B>t?B:t}else{b=k<c?k<r?k<b?k:b:r<b?r:b:c<r?c<b?c:b:r<b?r:b;e=x<B?x<t?x<e?x:e:t<e?t:e:B<t?B<e?B:e:t<e?t:e;d=k>c?k>r?k>d?k:d:r>d?r:d:c>r?c>d?c:d:r>d?r:d;g=x>B?x>t?x>g?x:g:t>g?t:g:B>t?B>g?B:g:t>g?t:g}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();e=e<k.getTop()?e:k.getTop();
THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(f,j){return f.distance-j.distance});return g},intersectObject:function(a){function b(G,w,D,n){n=n.clone().subSelf(w);D=D.clone().subSelf(w);var P=G.clone().subSelf(w);G=n.dot(n);w=n.dot(D);n=n.dot(P);var O=D.dot(D);D=D.dot(P);P=1/(G*O-w*w);O=(O*n-w*D)*P;G=(G*D-w*n)*P;return O>0&&G>0&&O+G<1}var e,d,g,f,j,h,k,x,c,C,
r,t=a.geometry,y=t.vertices,A=[];e=0;for(d=t.faces.length;e<d;e++){g=t.faces[e];C=this.origin.clone();r=this.direction.clone();f=a.matrix.multiplyVector3(y[g.a].position.clone());j=a.matrix.multiplyVector3(y[g.b].position.clone());h=a.matrix.multiplyVector3(y[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(y[g.d].position.clone()):null;x=a.rotationMatrix.multiplyVector3(g.normal.clone());c=r.dot(x);if(c<0){x=x.dot((new THREE.Vector3).sub(f,C))/c;C=C.addSelf(r.multiplyScalar(x));
if(g instanceof THREE.Face3){if(b(C,f,j,h)){g={distance:this.origin.distanceTo(C),point:C,face:g,object:a};A.push(g)}}else if(g instanceof THREE.Face4)if(b(C,f,j,k)||b(C,j,h,k)){g={distance:this.origin.distanceTo(C),point:C,face:g,object:a};A.push(g)}}}return A}};
THREE.Rectangle=function(){function a(){f=d-b;j=g-e}var b,e,d,g,f,j,h=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(k,x,c,C){h=false;b=k;e=x;d=c;g=C;a()};this.addPoint=function(k,x){if(h){h=false;b=k;e=x;d=k;g=x}else{b=b<k?b:k;e=e<x?e:x;d=d>k?d:k;g=g>x?
g:x}a()};this.add3Points=function(k,x,c,C,r,t){if(h){h=false;b=k<c?k<r?k:r:c<r?c:r;e=x<C?x<t?x:t:C<t?C:t;d=k>c?k>r?k:r:c>r?c:r;g=x>C?x>t?x:t:C>t?C:t}else{b=k<c?k<r?k<b?k:b:r<b?r:b:c<r?c<b?c:b:r<b?r:b;e=x<C?x<t?x<e?x:e:t<e?t:e:C<t?C<e?C:e:t<e?t:e;d=k>c?k>r?k>d?k:d:r>d?r:d:c>r?c>d?c:d:r>d?r:d;g=x>C?x>t?x>g?x:g:t>g?t:g:C>t?C>g?C:g:t>g?t:g}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();e=e<k.getTop()?e:k.getTop();
d=d>k.getRight()?d:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;d+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();d=d<k.getRight()?d:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(d,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){h=true;g=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString=
function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+f+", 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,e,d,g,f,j,h,k,x,c,B,r,t,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=h||0;this.n31=k||0;this.n32=x||0;this.n33=c||1;this.n34=B||0;this.n41=r||0;this.n42=t||0;this.n43=y||0;this.n44=A||1};
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,d,g,f,j,h,k,x,c,B,r,t,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=f;this.n23=j;this.n24=h;this.n31=k;this.n32=x;this.n33=c;this.n34=B;this.n41=r;this.n42=t;this.n43=y;this.n44=A;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
THREE.Matrix4=function(a,b,e,d,g,f,j,h,k,x,c,C,r,t,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=h||0;this.n31=k||0;this.n32=x||0;this.n33=c||1;this.n34=C||0;this.n41=r||0;this.n42=t||0;this.n43=y||0;this.n44=A||1};
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,d,g,f,j,h,k,x,c,C,r,t,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=f;this.n23=j;this.n24=h;this.n31=k;this.n32=x;this.n33=c;this.n34=C;this.n41=r;this.n42=t;this.n43=y;this.n44=A;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 d=new THREE.Vector3,g=new THREE.Vector3,f=new THREE.Vector3;f.sub(a,b).normalize();d.cross(e,f).normalize();g.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=f.x;
this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24*
g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+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,d=a.n12,g=a.n13,f=a.n14,j=a.n21,h=a.n22,k=a.n23,x=a.n24,c=a.n31,B=a.n32,
r=a.n33,t=a.n34,y=a.n41,A=a.n42,I=a.n43,w=a.n44,C=b.n11,n=b.n12,O=b.n13,L=b.n14,T=b.n21,i=b.n22,o=b.n23,s=b.n24,p=b.n31,u=b.n32,l=b.n33,v=b.n34,z=b.n41,J=b.n42,S=b.n43,Q=b.n44;this.n11=e*C+d*T+g*p+f*z;this.n12=e*n+d*i+g*u+f*J;this.n13=e*O+d*o+g*l+f*S;this.n14=e*L+d*s+g*v+f*Q;this.n21=j*C+h*T+k*p+x*z;this.n22=j*n+h*i+k*u+x*J;this.n23=j*O+h*o+k*l+x*S;this.n24=j*L+h*s+k*v+x*Q;this.n31=c*C+B*T+r*p+t*z;this.n32=c*n+B*i+r*u+t*J;this.n33=c*O+B*o+r*l+t*S;this.n34=c*L+B*s+r*v+t*Q;this.n41=y*C+A*T+I*p+w*z;
this.n42=y*n+A*i+I*u+w*J;this.n43=y*O+A*o+I*l+w*S;this.n44=y*L+A*s+I*v+w*Q;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,f=this.n21,j=this.n22,h=this.n23,k=this.n24,x=this.n31,c=this.n32,B=this.n33,r=this.n34,t=this.n41,y=this.n42,A=this.n43,I=this.n44,w=a.n11,C=a.n21,n=a.n31,O=a.n41,L=a.n12,T=a.n22,i=a.n32,o=a.n42,s=a.n13,p=a.n23,u=a.n33,l=a.n43,v=a.n14,z=a.n24,J=a.n34;a=a.n44;this.n11=b*w+e*C+d*n+g*O;this.n12=b*L+e*T+d*i+g*o;this.n13=b*s+e*p+d*u+g*l;this.n14=
b*v+e*z+d*J+g*a;this.n21=f*w+j*C+h*n+k*O;this.n22=f*L+j*T+h*i+k*o;this.n23=f*s+j*p+h*u+k*l;this.n24=f*v+j*z+h*J+k*a;this.n31=x*w+c*C+B*n+r*O;this.n32=x*L+c*T+B*i+r*o;this.n33=x*s+c*p+B*u+r*l;this.n34=x*v+c*z+B*J+r*a;this.n41=t*w+y*C+A*n+I*O;this.n42=t*L+y*T+A*i+I*o;this.n43=t*s+y*p+A*u+I*l;this.n44=t*v+y*z+A*J+I*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*=
g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+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,d=a.n12,g=a.n13,f=a.n14,j=a.n21,h=a.n22,k=a.n23,x=a.n24,c=a.n31,C=a.n32,
r=a.n33,t=a.n34,y=a.n41,A=a.n42,G=a.n43,w=a.n44,D=b.n11,n=b.n12,P=b.n13,O=b.n14,U=b.n21,i=b.n22,m=b.n23,s=b.n24,o=b.n31,u=b.n32,q=b.n33,v=b.n34,B=b.n41,R=b.n42,F=b.n43,W=b.n44;this.n11=e*D+d*U+g*o+f*B;this.n12=e*n+d*i+g*u+f*R;this.n13=e*P+d*m+g*q+f*F;this.n14=e*O+d*s+g*v+f*W;this.n21=j*D+h*U+k*o+x*B;this.n22=j*n+h*i+k*u+x*R;this.n23=j*P+h*m+k*q+x*F;this.n24=j*O+h*s+k*v+x*W;this.n31=c*D+C*U+r*o+t*B;this.n32=c*n+C*i+r*u+t*R;this.n33=c*P+C*m+r*q+t*F;this.n34=c*O+C*s+r*v+t*W;this.n41=y*D+A*U+G*o+w*B;
this.n42=y*n+A*i+G*u+w*R;this.n43=y*P+A*m+G*q+w*F;this.n44=y*O+A*s+G*v+w*W;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,f=this.n21,j=this.n22,h=this.n23,k=this.n24,x=this.n31,c=this.n32,C=this.n33,r=this.n34,t=this.n41,y=this.n42,A=this.n43,G=this.n44,w=a.n11,D=a.n21,n=a.n31,P=a.n41,O=a.n12,U=a.n22,i=a.n32,m=a.n42,s=a.n13,o=a.n23,u=a.n33,q=a.n43,v=a.n14,B=a.n24,R=a.n34;a=a.n44;this.n11=b*w+e*D+d*n+g*P;this.n12=b*O+e*U+d*i+g*m;this.n13=b*s+e*o+d*u+g*q;this.n14=
b*v+e*B+d*R+g*a;this.n21=f*w+j*D+h*n+k*P;this.n22=f*O+j*U+h*i+k*m;this.n23=f*s+j*o+h*u+k*q;this.n24=f*v+j*B+h*R+k*a;this.n31=x*w+c*D+C*n+r*P;this.n32=x*O+c*U+C*i+r*m;this.n33=x*s+c*o+C*u+r*q;this.n34=x*v+c*B+C*R+r*a;this.n41=t*w+y*D+A*n+G*P;this.n42=t*O+y*U+A*i+G*m;this.n43=t*s+y*o+A*u+G*q;this.n44=t*v+y*B+A*R+G*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,e,d){var g=b[e];b[e]=b[d];
b[d]=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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
@@ -47,17 +47,18 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){
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,d,g,f,j,h=new THREE.Vector3,k=new THREE.Vector3;d=0;for(g=this.vertices.length;d<g;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(g=this.faces.length;d<g;d++){f=this.faces[d];if(a&&f.vertexNormals.length){h.set(0,0,0);b=0;for(e=f.normal.length;b<e;b++)h.addSelf(f.vertexNormals[b]);h.divideScalar(3)}else{b=this.vertices[f.a];e=this.vertices[f.b];j=this.vertices[f.c];h.sub(j.position,
e.position);k.sub(b.position,e.position);h.crossSelf(k)}h.isZero()||h.normalize();f.normal.copy(h)}},computeVertexNormals:function(){var a,b=[],e,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(v,z,J,S){f=v.vertices[z].position;j=v.vertices[J].position;
h=v.vertices[S].position;k=g[0];x=g[1];c=g[2];B=j.x-f.x;r=h.x-f.x;t=j.y-f.y;y=h.y-f.y;A=j.z-f.z;I=h.z-f.z;w=x.u-k.u;C=c.u-k.u;n=x.v-k.v;O=c.v-k.v;L=1/(w*O-C*n);s.set((O*B-n*r)*L,(O*t-n*y)*L,(O*A-n*I)*L);p.set((w*r-C*B)*L,(w*y-C*t)*L,(w*I-C*A)*L);i[z].addSelf(s);i[J].addSelf(s);i[S].addSelf(s);o[z].addSelf(p);o[J].addSelf(p);o[S].addSelf(p)}var b,e,d,g,f,j,h,k,x,c,B,r,t,y,A,I,w,C,n,O,L,T,i=[],o=[],s=new THREE.Vector3,p=new THREE.Vector3,u=new THREE.Vector3,l=new THREE.Vector3;T=new THREE.Vector3;b=
0;for(e=this.vertices.length;b<e;b++){i[b]=new THREE.Vector3;o[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(e=this.vertices.length;b<e;b++){T.copy(this.vertices[b].normal);d=i[b];u.copy(d);u.subSelf(T.multiplyScalar(T.dot(d))).normalize();l.cross(this.vertices[b].normal,d);test=l.dot(o[b]);d=test<0?-1:1;this.vertices[b].tangent.set(u.x,u.y,u.z,d)}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],
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(v,B,R,F){f=v.vertices[B].position;j=v.vertices[R].position;
h=v.vertices[F].position;k=g[0];x=g[1];c=g[2];C=j.x-f.x;r=h.x-f.x;t=j.y-f.y;y=h.y-f.y;A=j.z-f.z;G=h.z-f.z;w=x.u-k.u;D=c.u-k.u;n=x.v-k.v;P=c.v-k.v;O=1/(w*P-D*n);s.set((P*C-n*r)*O,(P*t-n*y)*O,(P*A-n*G)*O);o.set((w*r-D*C)*O,(w*y-D*t)*O,(w*G-D*A)*O);i[B].addSelf(s);i[R].addSelf(s);i[F].addSelf(s);m[B].addSelf(o);m[R].addSelf(o);m[F].addSelf(o)}var b,e,d,g,f,j,h,k,x,c,C,r,t,y,A,G,w,D,n,P,O,U,i=[],m=[],s=new THREE.Vector3,o=new THREE.Vector3,u=new THREE.Vector3,q=new THREE.Vector3;U=new THREE.Vector3;b=
0;for(e=this.vertices.length;b<e;b++){i[b]=new THREE.Vector3;m[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(e=this.vertices.length;b<e;b++){U.copy(this.vertices[b].normal);d=i[b];u.copy(d);u.subSelf(U.multiplyScalar(U.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(m[b]);d=test<0?-1:1;this.vertices[b].tangent.set(u.x,u.y,u.z,d)}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(x){var c=[];b=0;for(e=x.length;b<e;b++)x[b]==undefined?c.push("undefined"):c.push(x[b].toString());return c.join("_")}
var b,e,d,g,f,j,h,k={};d=0;for(g=this.faces.length;d<g;d++){f=this.faces[d];materials=f.materials;j=a(materials);if(k[j]==undefined)k[j]={hash:j,counter:0};h=k[j].hash+"_"+k[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:materials,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+f>65535){k[j].counter+=1;h=k[j].hash+"_"+k[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:materials,vertices:0}}this.geometryChunks[h].faces.push(d);
this.geometryChunks[h].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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.Camera=function(a,b,e,d){this.fov=a;this.aspect=b;this.near=e;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
this.position.subSelf(g);this.target.position.subSelf(g)};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();this.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.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;
@@ -80,9 +81,8 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract
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.near=1;this.far=1E3;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.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
this.far-this.near};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.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};
@@ -94,98 +94,98 @@ THREE.Texture.prototype={toString:function(){return"THREE.Texture (<br/>image: "
THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;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.Projector=function(){function a(i,o){return o.z-i.z}function b(i,o){var s=0,p=1,u=i.z+i.w,l=o.z+o.w,v=-i.z+i.w,z=-o.z+o.w;if(u>=0&&l>=0&&v>=0&&z>=0)return true;else if(u<0&&l<0||v<0&&z<0)return false;else{if(u<0)s=Math.max(s,u/(u-l));else if(l<0)p=Math.min(p,u/(u-l));if(v<0)s=Math.max(s,v/(v-z));else if(z<0)p=Math.min(p,v/(v-z));if(p<s)return false;else{i.lerpSelf(o,s);o.lerpSelf(i,1-p);return true}}}var e,d,g=[],f,j,h,k=[],x,c,B=[],r,t,y=[],A=new THREE.Vector4,I=new THREE.Vector4,w=new THREE.Matrix4,
C=new THREE.Matrix4,n=[],O=new THREE.Vector4,L=new THREE.Vector4,T;this.projectObjects=function(i,o,s){var p=[],u,l;d=0;w.multiply(o.projectionMatrix,o.matrix);n[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);n[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);n[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);n[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);n[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
w.n33,w.n44-w.n34);n[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);o=0;for(u=n.length;o<u;o++){l=n[o];l.divideScalar(Math.sqrt(l.x*l.x+l.y*l.y+l.z*l.z))}u=i.objects;i=0;for(o=u.length;i<o;i++){l=u[i];var v;if(!(v=!l.visible)){if(v=l instanceof THREE.Mesh){a:{v=void 0;for(var z=l.position,J=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),S=0;S<6;S++){v=n[S].x*z.x+n[S].y*z.y+n[S].z*z.z+n[S].w;if(v<=J){v=false;break a}}v=true}v=!v}v=v}if(!v){e=
g[d]=g[d]||new THREE.RenderableObject;A.copy(l.position);w.multiplyVector3(A);e.object=l;e.z=A.z;p.push(e);d++}}s&&p.sort(a);return p};this.projectScene=function(i,o,s){var p=[],u,l,v,z,J,S,Q,H,V,M,W,N,F,G,m,q;h=c=t=0;o.autoUpdateMatrix&&o.updateMatrix();w.multiply(o.projectionMatrix,o.matrix);S=this.projectObjects(i,o,true);i=0;for(u=S.length;i<u;i++){Q=S[i].object;if(Q.visible){Q.autoUpdateMatrix&&Q.updateMatrix();H=Q.matrix;V=Q.rotationMatrix;M=Q.materials;W=Q.overdraw;if(Q instanceof THREE.Mesh){N=
Q.geometry;F=N.vertices;l=0;for(v=F.length;l<v;l++){G=F[l];G.positionWorld.copy(G.position);H.multiplyVector3(G.positionWorld);z=G.positionScreen;z.copy(G.positionWorld);w.multiplyVector4(z);z.multiplyScalar(1/z.w);G.__visible=z.z>0&&z.z<1}N=N.faces;l=0;for(v=N.length;l<v;l++){G=N[l];if(G instanceof THREE.Face3){z=F[G.a];J=F[G.b];m=F[G.c];if(z.__visible&&J.__visible&&m.__visible)if(Q.doubleSided||Q.flipSided!=(m.positionScreen.x-z.positionScreen.x)*(J.positionScreen.y-z.positionScreen.y)-(m.positionScreen.y-
z.positionScreen.y)*(J.positionScreen.x-z.positionScreen.x)<0){f=k[h]=k[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(z.positionWorld);f.v2.positionWorld.copy(J.positionWorld);f.v3.positionWorld.copy(m.positionWorld);f.v1.positionScreen.copy(z.positionScreen);f.v2.positionScreen.copy(J.positionScreen);f.v3.positionScreen.copy(m.positionScreen);f.normalWorld.copy(G.normal);V.multiplyVector3(f.normalWorld);f.centroidWorld.copy(G.centroid);H.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
w.multiplyVector3(f.centroidScreen);m=G.vertexNormals;T=f.vertexNormalsWorld;z=0;for(J=m.length;z<J;z++){q=T[z]=T[z]||new THREE.Vector3;q.copy(m[z]);V.multiplyVector3(q)}f.z=f.centroidScreen.z;f.meshMaterials=M;f.faceMaterials=G.materials;f.overdraw=W;if(Q.geometry.uvs[l]){f.uvs[0]=Q.geometry.uvs[l][0];f.uvs[1]=Q.geometry.uvs[l][1];f.uvs[2]=Q.geometry.uvs[l][2]}p.push(f);h++}}else if(G instanceof THREE.Face4){z=F[G.a];J=F[G.b];m=F[G.c];q=F[G.d];if(z.__visible&&J.__visible&&m.__visible&&q.__visible)if(Q.doubleSided||
Q.flipSided!=((q.positionScreen.x-z.positionScreen.x)*(J.positionScreen.y-z.positionScreen.y)-(q.positionScreen.y-z.positionScreen.y)*(J.positionScreen.x-z.positionScreen.x)<0||(J.positionScreen.x-m.positionScreen.x)*(q.positionScreen.y-m.positionScreen.y)-(J.positionScreen.y-m.positionScreen.y)*(q.positionScreen.x-m.positionScreen.x)<0)){f=k[h]=k[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(z.positionWorld);f.v2.positionWorld.copy(J.positionWorld);f.v3.positionWorld.copy(q.positionWorld);
f.v1.positionScreen.copy(z.positionScreen);f.v2.positionScreen.copy(J.positionScreen);f.v3.positionScreen.copy(q.positionScreen);f.normalWorld.copy(G.normal);V.multiplyVector3(f.normalWorld);f.centroidWorld.copy(G.centroid);H.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=M;f.faceMaterials=G.materials;f.overdraw=W;if(Q.geometry.uvs[l]){f.uvs[0]=Q.geometry.uvs[l][0];f.uvs[1]=Q.geometry.uvs[l][1];f.uvs[2]=
Q.geometry.uvs[l][3]}p.push(f);h++;j=k[h]=k[h]||new THREE.RenderableFace3;j.v1.positionWorld.copy(J.positionWorld);j.v2.positionWorld.copy(m.positionWorld);j.v3.positionWorld.copy(q.positionWorld);j.v1.positionScreen.copy(J.positionScreen);j.v2.positionScreen.copy(m.positionScreen);j.v3.positionScreen.copy(q.positionScreen);j.normalWorld.copy(f.normalWorld);j.centroidWorld.copy(f.centroidWorld);j.centroidScreen.copy(f.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=M;j.faceMaterials=G.materials;
j.overdraw=W;if(Q.geometry.uvs[l]){j.uvs[0]=Q.geometry.uvs[l][1];j.uvs[1]=Q.geometry.uvs[l][2];j.uvs[2]=Q.geometry.uvs[l][3]}p.push(j);h++}}}}else if(Q instanceof THREE.Line){C.multiply(w,H);F=Q.geometry.vertices;G=F[0];G.positionScreen.copy(G.position);C.multiplyVector4(G.positionScreen);l=1;for(v=F.length;l<v;l++){z=F[l];z.positionScreen.copy(z.position);C.multiplyVector4(z.positionScreen);J=F[l-1];O.copy(z.positionScreen);L.copy(J.positionScreen);if(b(O,L)){O.multiplyScalar(1/O.w);L.multiplyScalar(1/
L.w);x=B[c]=B[c]||new THREE.RenderableLine;x.v1.positionScreen.copy(O);x.v2.positionScreen.copy(L);x.z=Math.max(O.z,L.z);x.materials=Q.materials;p.push(x);c++}}}else if(Q instanceof THREE.Particle){I.set(Q.position.x,Q.position.y,Q.position.z,1);w.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){r=y[t]=y[t]||new THREE.RenderableParticle;r.x=I.x/I.w;r.y=I.y/I.w;r.z=I.z;r.rotation=Q.rotation.z;r.scale.x=Q.scale.x*Math.abs(r.x-(I.x+o.projectionMatrix.n11)/(I.w+o.projectionMatrix.n14));r.scale.y=Q.scale.y*
Math.abs(r.y-(I.y+o.projectionMatrix.n22)/(I.w+o.projectionMatrix.n24));r.materials=Q.materials;p.push(r);t++}}}}s&&p.sort(a);return p};this.unprojectVector=function(i,o){var s=new THREE.Matrix4;s.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));s.multiplyVector3(i);return i}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,f;this.domElement=document.createElement("div");this.setSize=function(j,h){e=j;d=h;g=e/2;f=d/2};this.render=function(j,h){var k,x,c,B,r,t,y,A;a=b.projectScene(j,h);k=0;for(x=a.length;k<x;k++){r=a[k];if(r instanceof THREE.RenderableParticle){y=r.x*g+g;A=r.y*f+f;c=0;for(B=r.material.length;c<B;c++){t=r.material[c];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=y+"px";t.style.top=A+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,f,j,h=e.getContext("2d"),k=1,x=0,c=null,B=null,r=1,t,y,A,I,w,C,n,O,L,T=new THREE.Color,i=new THREE.Color,o=new THREE.Color,s=new THREE.Color,p=new THREE.Color,u,l,v,z,J,S,Q,H,V,M,W=new THREE.Rectangle,N=new THREE.Rectangle,F=new THREE.Rectangle,G=false,m=new THREE.Color,q=new THREE.Color,D=new THREE.Color,P=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,fa,na,pa,ga,sa,wa,qa=16;fa=document.createElement("canvas");
fa.width=fa.height=2;na=fa.getContext("2d");na.fillStyle="rgba(0,0,0,1)";na.fillRect(0,0,2,2);pa=na.getImageData(0,0,2,2);ga=pa.data;sa=document.createElement("canvas");sa.width=sa.height=qa;wa=sa.getContext("2d");wa.translate(-qa/2,-qa/2);wa.scale(qa,qa);qa--;this.domElement=e;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,xa){d=ja;g=xa;f=d/2;j=g/2;e.width=d;e.height=g;W.set(-f,-j,f,j)};this.clear=function(){if(!N.isEmpty()){N.inflate(1);N.minSelf(W);h.clearRect(N.getX(),
N.getY(),N.getWidth(),N.getHeight());N.empty()}};this.render=function(ja,xa){function La(E){var X,U,K,R=E.lights;q.setRGB(0,0,0);D.setRGB(0,0,0);P.setRGB(0,0,0);E=0;for(X=R.length;E<X;E++){U=R[E];K=U.color;if(U instanceof THREE.AmbientLight){q.r+=K.r;q.g+=K.g;q.b+=K.b}else if(U instanceof THREE.DirectionalLight){D.r+=K.r;D.g+=K.g;D.b+=K.b}else if(U instanceof THREE.PointLight){P.r+=K.r;P.g+=K.g;P.b+=K.b}}}function ya(E,X,U,K){var R,$,ca,da,ea=E.lights;E=0;for(R=ea.length;E<R;E++){$=ea[E];ca=$.color;
da=$.intensity;if($ instanceof THREE.DirectionalLight){$=U.dot($.position)*da;if($>0){K.r+=ca.r*$;K.g+=ca.g*$;K.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=U.dot(Z)*da;if($>0){K.r+=ca.r*$;K.g+=ca.g*$;K.b+=ca.b*$}}}}function Ma(E,X,U){if(U.opacity!=0){Da(U.opacity);za(U.blending);var K,R,$,ca,da,ea;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){ca=U.map;da=ca.width>>1;ea=ca.height>>1;R=X.scale.x*f;$=X.scale.y*j;U=R*da;K=$*ea;F.set(E.x-U,E.y-K,E.x+U,
E.y+K);if(W.instersects(F)){h.save();h.translate(E.x,E.y);h.rotate(-X.rotation);h.scale(R,-$);h.translate(-da,-ea);h.drawImage(ca,0,0);h.restore()}}}else if(U instanceof THREE.ParticleCircleMaterial){if(G){m.r=q.r+D.r+P.r;m.g=q.g+D.g+P.g;m.b=q.b+D.b+P.b;T.r=U.color.r*m.r;T.g=U.color.g*m.g;T.b=U.color.b*m.b;T.updateStyleString()}else T.__styleString=U.color.__styleString;U=X.scale.x*f;K=X.scale.y*j;F.set(E.x-U,E.y-K,E.x+U,E.y+K);if(W.instersects(F)){R=T.__styleString;if(B!=R)h.fillStyle=B=R;h.save();
h.translate(E.x,E.y);h.rotate(-X.rotation);h.scale(U,K);h.beginPath();h.arc(0,0,1,0,Y,true);h.closePath();h.fill();h.restore()}}}}function Na(E,X,U,K){if(K.opacity!=0){Da(K.opacity);za(K.blending);h.beginPath();h.moveTo(E.positionScreen.x,E.positionScreen.y);h.lineTo(X.positionScreen.x,X.positionScreen.y);h.closePath();if(K instanceof THREE.LineBasicMaterial){T.__styleString=K.color.__styleString;E=K.linewidth;if(r!=E)h.lineWidth=r=E;E=T.__styleString;if(c!=E)h.strokeStyle=c=E;h.stroke();F.inflate(K.linewidth*
2)}}}function Ha(E,X,U,K,R,$){if(R.opacity!=0){Da(R.opacity);za(R.blending);I=E.positionScreen.x;w=E.positionScreen.y;C=X.positionScreen.x;n=X.positionScreen.y;O=U.positionScreen.x;L=U.positionScreen.y;h.beginPath();h.moveTo(I,w);h.lineTo(C,n);h.lineTo(O,L);h.lineTo(I,w);h.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof THREE.UVMapping&&ta(I,w,C,n,O,L,R.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof
THREE.SphericalReflectionMapping){E=xa.matrix;Z.copy(K.vertexNormalsWorld[0]);J=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;S=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;Z.copy(K.vertexNormalsWorld[1]);Q=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;H=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;Z.copy(K.vertexNormalsWorld[2]);V=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;M=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;ta(I,w,C,n,O,L,R.env_map.image,J,S,Q,H,V,M)}}else R.wireframe?Aa(R.color.__styleString,R.wireframe_linewidth):
Ba(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&ta(I,w,C,n,O,L,R.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);za(THREE.SubtractiveBlending)}if(G)if(!R.wireframe&&R.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){i.r=o.r=s.r=q.r;i.g=o.g=s.g=q.g;i.b=o.b=s.b=q.b;ya($,K.v1.positionWorld,K.vertexNormalsWorld[0],i);ya($,K.v2.positionWorld,K.vertexNormalsWorld[1],o);ya($,
K.v3.positionWorld,K.vertexNormalsWorld[2],s);p.r=(o.r+s.r)*0.5;p.g=(o.g+s.g)*0.5;p.b=(o.b+s.b)*0.5;z=Ia(i,o,s,p);ta(I,w,C,n,O,L,z,0,0,1,0,0,1)}else{m.r=q.r;m.g=q.g;m.b=q.b;ya($,K.centroidWorld,K.normalWorld,m);T.r=R.color.r*m.r;T.g=R.color.g*m.g;T.b=R.color.b*m.b;T.updateStyleString();R.wireframe?Aa(T.__styleString,R.wireframe_linewidth):Ba(T.__styleString)}else R.wireframe?Aa(R.color.__styleString,R.wireframe_linewidth):Ba(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){u=R.__2near;
l=R.__farPlusNear;v=R.__farMinusNear;i.r=i.g=i.b=1-u/(l-E.positionScreen.z*v);o.r=o.g=o.b=1-u/(l-X.positionScreen.z*v);s.r=s.g=s.b=1-u/(l-U.positionScreen.z*v);p.r=(o.r+s.r)*0.5;p.g=(o.g+s.g)*0.5;p.b=(o.b+s.b)*0.5;z=Ia(i,o,s,p);ta(I,w,C,n,O,L,z,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){T.r=Ea(K.normalWorld.x);T.g=Ea(K.normalWorld.y);T.b=Ea(K.normalWorld.z);T.updateStyleString();R.wireframe?Aa(T.__styleString,R.wireframe_linewidth):Ba(T.__styleString)}}}function Aa(E,X){if(c!=E)h.strokeStyle=
c=E;if(r!=X)h.lineWidth=r=X;h.stroke();F.inflate(X*2)}function Ba(E){if(B!=E)h.fillStyle=B=E;h.fill()}function ta(E,X,U,K,R,$,ca,da,ea,ka,ha,la,ua){var oa,ma;oa=ca.width-1;ma=ca.height-1;da*=oa;ea*=ma;ka*=oa;ha*=ma;la*=oa;ua*=ma;U-=E;K-=X;R-=E;$-=X;ka-=da;ha-=ea;la-=da;ua-=ea;ma=1/(ka*ua-la*ha);oa=(ua*U-ha*R)*ma;ha=(ua*K-ha*$)*ma;U=(ka*R-la*U)*ma;K=(ka*$-la*K)*ma;E=E-oa*da-U*ea;X=X-ha*da-K*ea;h.save();h.transform(oa,ha,U,K,E,X);h.clip();h.drawImage(ca,0,0);h.restore()}function Da(E){if(k!=E)h.globalAlpha=
k=E}function za(E){if(x!=E){switch(E){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}x=E}}function Ia(E,X,U,K){var R=~~(E.r*255),$=~~(E.g*255);E=~~(E.b*255);var ca=~~(X.r*255),da=~~(X.g*255);X=~~(X.b*255);var ea=~~(U.r*255),ka=~~(U.g*255);U=~~(U.b*255);var ha=~~(K.r*255),la=~~(K.g*255);K=~~(K.b*255);ga[0]=R<0?0:R>255?255:R;ga[1]=$<0?0:
$>255?255:$;ga[2]=E<0?0:E>255?255:E;ga[4]=ca<0?0:ca>255?255:ca;ga[5]=da<0?0:da>255?255:da;ga[6]=X<0?0:X>255?255:X;ga[8]=ea<0?0:ea>255?255:ea;ga[9]=ka<0?0:ka>255?255:ka;ga[10]=U<0?0:U>255?255:U;ga[12]=ha<0?0:ha>255?255:ha;ga[13]=la<0?0:la>255?255:la;ga[14]=K<0?0:K>255?255:K;na.putImageData(pa,0,0);wa.drawImage(fa,0,0);return sa}function Ea(E){E=(E+1)*0.5;return E<0?0:E>1?1:E}function Fa(E,X){var U=X.x-E.x,K=X.y-E.y,R=1/Math.sqrt(U*U+K*K);U*=R;K*=R;X.x+=U;X.y+=K;E.x-=U;E.y-=K}var Ca,Ja,ba,ia,ra,Ga,
Ka,va;h.setTransform(1,0,0,-1,f,j);this.autoClear&&this.clear();a=b.projectScene(ja,xa,this.sortElements);(G=ja.lights.length>0)&&La(ja);Ca=0;for(Ja=a.length;Ca<Ja;Ca++){ba=a[Ca];F.empty();if(ba instanceof THREE.RenderableParticle){t=ba;t.x*=f;t.y*=j;ia=0;for(ra=ba.materials.length;ia<ra;ia++)Ma(t,ba,ba.materials[ia],ja)}else if(ba instanceof THREE.RenderableLine){t=ba.v1;y=ba.v2;t.positionScreen.x*=f;t.positionScreen.y*=j;y.positionScreen.x*=f;y.positionScreen.y*=j;F.addPoint(t.positionScreen.x,
t.positionScreen.y);F.addPoint(y.positionScreen.x,y.positionScreen.y);if(W.instersects(F)){ia=0;for(ra=ba.materials.length;ia<ra;)Na(t,y,ba,ba.materials[ia++],ja)}}else if(ba instanceof THREE.RenderableFace3){t=ba.v1;y=ba.v2;A=ba.v3;t.positionScreen.x*=f;t.positionScreen.y*=j;y.positionScreen.x*=f;y.positionScreen.y*=j;A.positionScreen.x*=f;A.positionScreen.y*=j;if(ba.overdraw){Fa(t.positionScreen,y.positionScreen);Fa(y.positionScreen,A.positionScreen);Fa(A.positionScreen,t.positionScreen)}F.add3Points(t.positionScreen.x,
t.positionScreen.y,y.positionScreen.x,y.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(W.instersects(F)){ia=0;for(ra=ba.meshMaterials.length;ia<ra;){va=ba.meshMaterials[ia++];if(va instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=ba.faceMaterials.length;Ga<Ka;)(va=ba.faceMaterials[Ga++])&&Ha(t,y,A,ba,va,ja)}else Ha(t,y,A,ba,va,ja)}}}N.addRectangle(F)}h.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(H,V,M){var W,N,F,G;W=0;for(N=H.lights.length;W<N;W++){F=H.lights[W];if(F instanceof THREE.DirectionalLight){G=V.normalWorld.dot(F.position)*F.intensity;if(G>0){M.r+=F.color.r*G;M.g+=F.color.g*G;M.b+=F.color.b*G}}else if(F instanceof THREE.PointLight){s.sub(F.position,V.centroidWorld);s.normalize();G=V.normalWorld.dot(s)*F.intensity;if(G>0){M.r+=F.color.r*G;M.g+=F.color.g*G;M.b+=F.color.b*G}}}}function b(H,V,M,W,N,F){v=d(z++);v.setAttribute("d","M "+H.positionScreen.x+
" "+H.positionScreen.y+" L "+V.positionScreen.x+" "+V.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(C){O.r=L.r;O.g=L.g;O.b=L.b;a(F,W,O);n.r=N.color.r*O.r;n.g=N.color.g*O.g;n.b=N.color.b*O.b;n.updateStyleString()}else n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){o=1-N.__2near/(N.__farPlusNear-W.z*N.__farMinusNear);
n.setRGB(o,o,o)}else N instanceof THREE.MeshNormalMaterial&&n.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));N.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+N.opacity);h.appendChild(v)}function e(H,V,M,W,N,F,G){v=d(z++);v.setAttribute("d",
"M "+H.positionScreen.x+" "+H.positionScreen.y+" L "+V.positionScreen.x+" "+V.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(C){O.r=L.r;O.g=L.g;O.b=L.b;a(G,N,O);n.r=F.color.r*O.r;n.g=F.color.g*O.g;n.b=F.color.b*O.b;n.updateStyleString()}else n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){o=
1-F.__2near/(F.__farPlusNear-N.z*F.__farMinusNear);n.setRGB(o,o,o)}else F instanceof THREE.MeshNormalMaterial&&n.setRGB(g(N.normalWorld.x),g(N.normalWorld.y),g(N.normalWorld.z));F.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+F.opacity);h.appendChild(v)}
function d(H){if(p[H]==null){p[H]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&p[H].setAttribute("shape-rendering","crispEdges");return p[H]}return p[H]}function g(H){return H<0?Math.min((1+H)*0.5,0.5):0.5+Math.min(H*0.5,0.5)}var f=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,x,c,B,r,t,y,A,I=new THREE.Rectangle,w=new THREE.Rectangle,C=false,n=new THREE.Color(16777215),O=new THREE.Color(16777215),L=new THREE.Color(0),T=new THREE.Color(0),
i=new THREE.Color(0),o,s=new THREE.Vector3,p=[],u=[],l=[],v,z,J,S,Q=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(H){switch(H){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(H,V){k=H;x=V;c=k/2;B=x/2;h.setAttribute("viewBox",-c+" "+-B+" "+k+" "+x);h.setAttribute("width",k);h.setAttribute("height",x);I.set(-c,-B,c,B)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(H,V){var M,W,
N,F,G,m,q,D;this.autoClear&&this.clear();f=j.projectScene(H,V,this.sortElements);S=J=z=0;if(C=H.lights.length>0){q=H.lights;L.setRGB(0,0,0);T.setRGB(0,0,0);i.setRGB(0,0,0);M=0;for(W=q.length;M<W;M++){N=q[M];F=N.color;if(N instanceof THREE.AmbientLight){L.r+=F.r;L.g+=F.g;L.b+=F.b}else if(N instanceof THREE.DirectionalLight){T.r+=F.r;T.g+=F.g;T.b+=F.b}else if(N instanceof THREE.PointLight){i.r+=F.r;i.g+=F.g;i.b+=F.b}}}M=0;for(W=f.length;M<W;M++){q=f[M];w.empty();if(q instanceof THREE.RenderableParticle){r=
q;r.x*=c;r.y*=-B;N=0;for(F=q.materials.length;N<F;N++)if(D=q.materials[N]){G=r;m=q;D=D;var P=J++;if(u[P]==null){u[P]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&u[P].setAttribute("shape-rendering","crispEdges")}v=u[P];v.setAttribute("cx",G.x);v.setAttribute("cy",G.y);v.setAttribute("r",m.scale.x*c);if(D instanceof THREE.ParticleCircleMaterial){if(C){O.r=L.r+T.r+i.r;O.g=L.g+T.g+i.g;O.b=L.b+T.b+i.b;n.r=D.color.r*O.r;n.g=D.color.g*O.g;n.b=D.color.b*O.b;n.updateStyleString()}else n=
D.color;v.setAttribute("style","fill: "+n.__styleString)}h.appendChild(v)}}else if(q instanceof THREE.RenderableLine){r=q.v1;t=q.v2;r.positionScreen.x*=c;r.positionScreen.y*=-B;t.positionScreen.x*=c;t.positionScreen.y*=-B;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);if(I.instersects(w)){N=0;for(F=q.materials.length;N<F;)if(D=q.materials[N++]){G=r;m=t;D=D;P=S++;if(l[P]==null){l[P]=document.createElementNS("http://www.w3.org/2000/svg","line");Q==
0&&l[P].setAttribute("shape-rendering","crispEdges")}v=l[P];v.setAttribute("x1",G.positionScreen.x);v.setAttribute("y1",G.positionScreen.y);v.setAttribute("x2",m.positionScreen.x);v.setAttribute("y2",m.positionScreen.y);if(D instanceof THREE.LineBasicMaterial){n.__styleString=D.color.__styleString;v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+D.linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.linecap+"; stroke-linejoin: "+D.linejoin);h.appendChild(v)}}}}else if(q instanceof
THREE.RenderableFace3){r=q.v1;t=q.v2;y=q.v3;r.positionScreen.x*=c;r.positionScreen.y*=-B;t.positionScreen.x*=c;t.positionScreen.y*=-B;y.positionScreen.x*=c;y.positionScreen.y*=-B;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);if(I.instersects(w)){N=0;for(F=q.meshMaterials.length;N<F;){D=q.meshMaterials[N++];if(D instanceof THREE.MeshFaceMaterial){G=0;for(m=q.faceMaterials.length;G<m;)(D=q.faceMaterials[G++])&&
b(r,t,y,q,D,H)}else D&&b(r,t,y,q,D,H)}}}else if(q instanceof THREE.RenderableFace4){r=q.v1;t=q.v2;y=q.v3;A=q.v4;r.positionScreen.x*=c;r.positionScreen.y*=-B;t.positionScreen.x*=c;t.positionScreen.y*=-B;y.positionScreen.x*=c;y.positionScreen.y*=-B;A.positionScreen.x*=c;A.positionScreen.y*=-B;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(I.instersects(w)){N=
0;for(F=q.meshMaterials.length;N<F;){D=q.meshMaterials[N++];if(D instanceof THREE.MeshFaceMaterial){G=0;for(m=q.faceMaterials.length;G<m;)(D=q.faceMaterials[G++])&&e(r,t,y,A,q,D,H)}else D&&e(r,t,y,A,q,D,H)}}}}}};
THREE.WebGLRenderer=function(a,b){function e(i,o,s){var p=c.createProgram();s=["#ifdef GL_ES\nprecision highp float;\n#endif",s?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var u=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(p,h("fragment",s+i));c.attachShader(p,h("vertex",u+o));c.linkProgram(p);c.getProgramParameter(p,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(p,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");p.uniforms={};p.attributes={};return p}function d(i,o){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);
THREE.Projector=function(){function a(i,m){return m.z-i.z}function b(i,m){var s=0,o=1,u=i.z+i.w,q=m.z+m.w,v=-i.z+i.w,B=-m.z+m.w;if(u>=0&&q>=0&&v>=0&&B>=0)return true;else if(u<0&&q<0||v<0&&B<0)return false;else{if(u<0)s=Math.max(s,u/(u-q));else if(q<0)o=Math.min(o,u/(u-q));if(v<0)s=Math.max(s,v/(v-B));else if(B<0)o=Math.min(o,v/(v-B));if(o<s)return false;else{i.lerpSelf(m,s);m.lerpSelf(i,1-o);return true}}}var e,d,g=[],f,j,h,k=[],x,c,C=[],r,t,y=[],A=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
D=new THREE.Matrix4,n=[],P=new THREE.Vector4,O=new THREE.Vector4,U;this.projectObjects=function(i,m,s){var o=[],u,q;d=0;w.multiply(m.projectionMatrix,m.matrix);n[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);n[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);n[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);n[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);n[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
w.n33,w.n44-w.n34);n[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);m=0;for(u=n.length;m<u;m++){q=n[m];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}u=i.objects;i=0;for(m=u.length;i<m;i++){q=u[i];var v;if(!(v=!q.visible)){if(v=q instanceof THREE.Mesh){a:{v=void 0;for(var B=q.position,R=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),F=0;F<6;F++){v=n[F].x*B.x+n[F].y*B.y+n[F].z*B.z+n[F].w;if(v<=R){v=false;break a}}v=true}v=!v}v=v}if(!v){e=
g[d]=g[d]||new THREE.RenderableObject;A.copy(q.position);w.multiplyVector3(A);e.object=q;e.z=A.z;o.push(e);d++}}s&&o.sort(a);return o};this.projectScene=function(i,m,s){var o=[],u=m.near,q=m.far,v,B,R,F,W,H,I,K,X,M,Q,N,l,p,z,L;h=c=t=0;m.autoUpdateMatrix&&m.updateMatrix();w.multiply(m.projectionMatrix,m.matrix);H=this.projectObjects(i,m,true);i=0;for(v=H.length;i<v;i++){I=H[i].object;if(I.visible){I.autoUpdateMatrix&&I.updateMatrix();K=I.matrix;X=I.rotationMatrix;M=I.materials;Q=I.overdraw;if(I instanceof
THREE.Mesh){N=I.geometry;l=N.vertices;B=0;for(R=l.length;B<R;B++){p=l[B];p.positionWorld.copy(p.position);K.multiplyVector3(p.positionWorld);F=p.positionScreen;F.copy(p.positionWorld);w.multiplyVector4(F);F.x/=F.w;F.y/=F.w;p.__visible=F.z>u&&F.z<q}N=N.faces;B=0;for(R=N.length;B<R;B++){p=N[B];if(p instanceof THREE.Face3){F=l[p.a];W=l[p.b];z=l[p.c];if(F.__visible&&W.__visible&&z.__visible)if(I.doubleSided||I.flipSided!=(z.positionScreen.x-F.positionScreen.x)*(W.positionScreen.y-F.positionScreen.y)-
(z.positionScreen.y-F.positionScreen.y)*(W.positionScreen.x-F.positionScreen.x)<0){f=k[h]=k[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(W.positionWorld);f.v3.positionWorld.copy(z.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(W.positionScreen);f.v3.positionScreen.copy(z.positionScreen);f.normalWorld.copy(p.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(p.centroid);K.multiplyVector3(f.centroidWorld);
f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);z=p.vertexNormals;U=f.vertexNormalsWorld;F=0;for(W=z.length;F<W;F++){L=U[F]=U[F]||new THREE.Vector3;L.copy(z[F]);X.multiplyVector3(L)}f.z=f.centroidScreen.z;f.meshMaterials=M;f.faceMaterials=p.materials;f.overdraw=Q;if(I.geometry.uvs[B]){f.uvs[0]=I.geometry.uvs[B][0];f.uvs[1]=I.geometry.uvs[B][1];f.uvs[2]=I.geometry.uvs[B][2]}o.push(f);h++}}else if(p instanceof THREE.Face4){F=l[p.a];W=l[p.b];z=l[p.c];L=l[p.d];if(F.__visible&&
W.__visible&&z.__visible&&L.__visible)if(I.doubleSided||I.flipSided!=((L.positionScreen.x-F.positionScreen.x)*(W.positionScreen.y-F.positionScreen.y)-(L.positionScreen.y-F.positionScreen.y)*(W.positionScreen.x-F.positionScreen.x)<0||(W.positionScreen.x-z.positionScreen.x)*(L.positionScreen.y-z.positionScreen.y)-(W.positionScreen.y-z.positionScreen.y)*(L.positionScreen.x-z.positionScreen.x)<0)){f=k[h]=k[h]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(W.positionWorld);
f.v3.positionWorld.copy(L.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(W.positionScreen);f.v3.positionScreen.copy(L.positionScreen);f.normalWorld.copy(p.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(p.centroid);K.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=M;f.faceMaterials=p.materials;f.overdraw=Q;if(I.geometry.uvs[B]){f.uvs[0]=I.geometry.uvs[B][0];
f.uvs[1]=I.geometry.uvs[B][1];f.uvs[2]=I.geometry.uvs[B][3]}o.push(f);h++;j=k[h]=k[h]||new THREE.RenderableFace3;j.v1.positionWorld.copy(W.positionWorld);j.v2.positionWorld.copy(z.positionWorld);j.v3.positionWorld.copy(L.positionWorld);j.v1.positionScreen.copy(W.positionScreen);j.v2.positionScreen.copy(z.positionScreen);j.v3.positionScreen.copy(L.positionScreen);j.normalWorld.copy(f.normalWorld);j.centroidWorld.copy(f.centroidWorld);j.centroidScreen.copy(f.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
M;j.faceMaterials=p.materials;j.overdraw=Q;if(I.geometry.uvs[B]){j.uvs[0]=I.geometry.uvs[B][1];j.uvs[1]=I.geometry.uvs[B][2];j.uvs[2]=I.geometry.uvs[B][3]}o.push(j);h++}}}}else if(I instanceof THREE.Line){D.multiply(w,K);l=I.geometry.vertices;p=l[0];p.positionScreen.copy(p.position);D.multiplyVector4(p.positionScreen);B=1;for(R=l.length;B<R;B++){F=l[B];F.positionScreen.copy(F.position);D.multiplyVector4(F.positionScreen);W=l[B-1];P.copy(F.positionScreen);O.copy(W.positionScreen);if(b(P,O)){P.multiplyScalar(1/
P.w);O.multiplyScalar(1/O.w);x=C[c]=C[c]||new THREE.RenderableLine;x.v1.positionScreen.copy(P);x.v2.positionScreen.copy(O);x.z=Math.max(P.z,O.z);x.materials=I.materials;o.push(x);c++}}}else if(I instanceof THREE.Particle){G.set(I.position.x,I.position.y,I.position.z,1);w.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){r=y[t]=y[t]||new THREE.RenderableParticle;r.x=G.x/G.w;r.y=G.y/G.w;r.z=G.z;r.rotation=I.rotation.z;r.scale.x=I.scale.x*Math.abs(r.x-(G.x+m.projectionMatrix.n11)/(G.w+m.projectionMatrix.n14));
r.scale.y=I.scale.y*Math.abs(r.y-(G.y+m.projectionMatrix.n22)/(G.w+m.projectionMatrix.n24));r.materials=I.materials;o.push(r);t++}}}}s&&o.sort(a);return o};this.unprojectVector=function(i,m){var s=new THREE.Matrix4;s.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));s.multiplyVector3(i);return i}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,f;this.domElement=document.createElement("div");this.setSize=function(j,h){e=j;d=h;g=e/2;f=d/2};this.render=function(j,h){var k,x,c,C,r,t,y,A;a=b.projectScene(j,h);k=0;for(x=a.length;k<x;k++){r=a[k];if(r instanceof THREE.RenderableParticle){y=r.x*g+g;A=r.y*f+f;c=0;for(C=r.material.length;c<C;c++){t=r.material[c];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=y+"px";t.style.top=A+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,f,j,h=e.getContext("2d"),k=1,x=0,c=null,C=null,r=1,t,y,A,G,w,D,n,P,O,U=new THREE.Color,i=new THREE.Color,m=new THREE.Color,s=new THREE.Color,o=new THREE.Color,u,q,v,B,R,F,W,H,I,K=new THREE.Rectangle,X=new THREE.Rectangle,M=new THREE.Rectangle,Q=false,N=new THREE.Color,l=new THREE.Color,p=new THREE.Color,z=new THREE.Color,L=Math.PI*2,S=new THREE.Vector3,ca,ga,oa,ea,sa,wa,pa=16;ca=document.createElement("canvas");
ca.width=ca.height=2;ga=ca.getContext("2d");ga.fillStyle="rgba(0,0,0,1)";ga.fillRect(0,0,2,2);oa=ga.getImageData(0,0,2,2);ea=oa.data;sa=document.createElement("canvas");sa.width=sa.height=pa;wa=sa.getContext("2d");wa.translate(-pa/2,-pa/2);wa.scale(pa,pa);pa--;this.domElement=e;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,qa){d=ja;g=qa;f=d/2;j=g/2;e.width=d;e.height=g;K.set(-f,-j,f,j)};this.clear=function(){if(!X.isEmpty()){X.inflate(1);X.minSelf(K);h.clearRect(X.getX(),
X.getY(),X.getWidth(),X.getHeight());X.empty()}};this.render=function(ja,qa){function La(E){var Y,V,J,T=E.lights;l.setRGB(0,0,0);p.setRGB(0,0,0);z.setRGB(0,0,0);E=0;for(Y=T.length;E<Y;E++){V=T[E];J=V.color;if(V instanceof THREE.AmbientLight){l.r+=J.r;l.g+=J.g;l.b+=J.b}else if(V instanceof THREE.DirectionalLight){p.r+=J.r;p.g+=J.g;p.b+=J.b}else if(V instanceof THREE.PointLight){z.r+=J.r;z.g+=J.g;z.b+=J.b}}}function xa(E,Y,V,J){var T,Z,ba,da,fa=E.lights;E=0;for(T=fa.length;E<T;E++){Z=fa[E];ba=Z.color;
da=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=V.dot(Z.position)*da;if(Z>0){J.r+=ba.r*Z;J.g+=ba.g*Z;J.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){S.sub(Z.position,Y);S.normalize();Z=V.dot(S)*da;if(Z>0){J.r+=ba.r*Z;J.g+=ba.g*Z;J.b+=ba.b*Z}}}}function Ma(E,Y,V){if(V.opacity!=0){Ca(V.opacity);ya(V.blending);var J,T,Z,ba,da,fa;if(V instanceof THREE.ParticleBasicMaterial){if(V.map){ba=V.map;da=ba.width>>1;fa=ba.height>>1;T=Y.scale.x*f;Z=Y.scale.y*j;V=T*da;J=Z*fa;M.set(E.x-V,E.y-J,E.x+V,
E.y+J);if(K.instersects(M)){h.save();h.translate(E.x,E.y);h.rotate(-Y.rotation);h.scale(T,-Z);h.translate(-da,-fa);h.drawImage(ba,0,0);h.restore()}}}else if(V instanceof THREE.ParticleCircleMaterial){if(Q){N.r=l.r+p.r+z.r;N.g=l.g+p.g+z.g;N.b=l.b+p.b+z.b;U.r=V.color.r*N.r;U.g=V.color.g*N.g;U.b=V.color.b*N.b;U.updateStyleString()}else U.__styleString=V.color.__styleString;V=Y.scale.x*f;J=Y.scale.y*j;M.set(E.x-V,E.y-J,E.x+V,E.y+J);if(K.instersects(M)){T=U.__styleString;if(C!=T)h.fillStyle=C=T;h.save();
h.translate(E.x,E.y);h.rotate(-Y.rotation);h.scale(V,J);h.beginPath();h.arc(0,0,1,0,L,true);h.closePath();h.fill();h.restore()}}}}function Na(E,Y,V,J){if(J.opacity!=0){Ca(J.opacity);ya(J.blending);h.beginPath();h.moveTo(E.positionScreen.x,E.positionScreen.y);h.lineTo(Y.positionScreen.x,Y.positionScreen.y);h.closePath();if(J instanceof THREE.LineBasicMaterial){U.__styleString=J.color.__styleString;E=J.linewidth;if(r!=E)h.lineWidth=r=E;E=U.__styleString;if(c!=E)h.strokeStyle=c=E;h.stroke();M.inflate(J.linewidth*
2)}}}function Ha(E,Y,V,J,T,Z){if(T.opacity!=0){Ca(T.opacity);ya(T.blending);G=E.positionScreen.x;w=E.positionScreen.y;D=Y.positionScreen.x;n=Y.positionScreen.y;P=V.positionScreen.x;O=V.positionScreen.y;h.beginPath();h.moveTo(G,w);h.lineTo(D,n);h.lineTo(P,O);h.lineTo(G,w);h.closePath();if(T instanceof THREE.MeshBasicMaterial)if(T.map)T.map.image.loaded&&T.map.mapping instanceof THREE.UVMapping&&ta(G,w,D,n,P,O,T.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(T.env_map){if(T.env_map.image.loaded)if(T.env_map.mapping instanceof
THREE.SphericalReflectionMapping){E=qa.matrix;S.copy(J.vertexNormalsWorld[0]);B=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;R=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;S.copy(J.vertexNormalsWorld[1]);F=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;W=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;S.copy(J.vertexNormalsWorld[2]);H=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;I=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;ta(G,w,D,n,P,O,T.env_map.image,B,R,F,W,H,I)}}else T.wireframe?za(T.color.__styleString,T.wireframe_linewidth):
Aa(T.color.__styleString);else if(T instanceof THREE.MeshLambertMaterial){if(T.map&&!T.wireframe){T.map.mapping instanceof THREE.UVMapping&&ta(G,w,D,n,P,O,T.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);ya(THREE.SubtractiveBlending)}if(Q)if(!T.wireframe&&T.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){i.r=m.r=s.r=l.r;i.g=m.g=s.g=l.g;i.b=m.b=s.b=l.b;xa(Z,J.v1.positionWorld,J.vertexNormalsWorld[0],i);xa(Z,J.v2.positionWorld,J.vertexNormalsWorld[1],m);xa(Z,
J.v3.positionWorld,J.vertexNormalsWorld[2],s);o.r=(m.r+s.r)*0.5;o.g=(m.g+s.g)*0.5;o.b=(m.b+s.b)*0.5;v=Ia(i,m,s,o);ta(G,w,D,n,P,O,v,0,0,1,0,0,1)}else{N.r=l.r;N.g=l.g;N.b=l.b;xa(Z,J.centroidWorld,J.normalWorld,N);U.r=T.color.r*N.r;U.g=T.color.g*N.g;U.b=T.color.b*N.b;U.updateStyleString();T.wireframe?za(U.__styleString,T.wireframe_linewidth):Aa(U.__styleString)}else T.wireframe?za(T.color.__styleString,T.wireframe_linewidth):Aa(T.color.__styleString)}else if(T instanceof THREE.MeshDepthMaterial){u=qa.near;
q=qa.far;i.r=i.g=i.b=1-Da(E.positionScreen.z,u,q);m.r=m.g=m.b=1-Da(Y.positionScreen.z,u,q);s.r=s.g=s.b=1-Da(V.positionScreen.z,u,q);o.r=(m.r+s.r)*0.5;o.g=(m.g+s.g)*0.5;o.b=(m.b+s.b)*0.5;v=Ia(i,m,s,o);ta(G,w,D,n,P,O,v,0,0,1,0,0,1)}else if(T instanceof THREE.MeshNormalMaterial){U.r=Ea(J.normalWorld.x);U.g=Ea(J.normalWorld.y);U.b=Ea(J.normalWorld.z);U.updateStyleString();T.wireframe?za(U.__styleString,T.wireframe_linewidth):Aa(U.__styleString)}}}function za(E,Y){if(c!=E)h.strokeStyle=c=E;if(r!=Y)h.lineWidth=
r=Y;h.stroke();M.inflate(Y*2)}function Aa(E){if(C!=E)h.fillStyle=C=E;h.fill()}function ta(E,Y,V,J,T,Z,ba,da,fa,ka,ha,la,ua){var na,ma;na=ba.width-1;ma=ba.height-1;da*=na;fa*=ma;ka*=na;ha*=ma;la*=na;ua*=ma;V-=E;J-=Y;T-=E;Z-=Y;ka-=da;ha-=fa;la-=da;ua-=fa;ma=1/(ka*ua-la*ha);na=(ua*V-ha*T)*ma;ha=(ua*J-ha*Z)*ma;V=(ka*T-la*V)*ma;J=(ka*Z-la*J)*ma;E=E-na*da-V*fa;Y=Y-ha*da-J*fa;h.save();h.transform(na,ha,V,J,E,Y);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(E){if(k!=E)h.globalAlpha=k=E}function ya(E){if(x!=
E){switch(E){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}x=E}}function Ia(E,Y,V,J){var T=~~(E.r*255),Z=~~(E.g*255);E=~~(E.b*255);var ba=~~(Y.r*255),da=~~(Y.g*255);Y=~~(Y.b*255);var fa=~~(V.r*255),ka=~~(V.g*255);V=~~(V.b*255);var ha=~~(J.r*255),la=~~(J.g*255);J=~~(J.b*255);ea[0]=T<0?0:T>255?255:T;ea[1]=Z<0?0:Z>255?255:Z;ea[2]=E<0?0:E>
255?255:E;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=da<0?0:da>255?255:da;ea[6]=Y<0?0:Y>255?255:Y;ea[8]=fa<0?0:fa>255?255:fa;ea[9]=ka<0?0:ka>255?255:ka;ea[10]=V<0?0:V>255?255:V;ea[12]=ha<0?0:ha>255?255:ha;ea[13]=la<0?0:la>255?255:la;ea[14]=J<0?0:J>255?255:J;ga.putImageData(oa,0,0);wa.drawImage(ca,0,0);return sa}function Da(E,Y,V){E=(E-Y)/(V-Y);return E*E*(3-2*E)}function Ea(E){E=(E+1)*0.5;return E<0?0:E>1?1:E}function Fa(E,Y){var V=Y.x-E.x,J=Y.y-E.y,T=1/Math.sqrt(V*V+J*J);V*=T;J*=T;Y.x+=V;Y.y+=J;E.x-=V;E.y-=
J}var Ba,Ja,$,ia,ra,Ga,Ka,va;h.setTransform(1,0,0,-1,f,j);this.autoClear&&this.clear();a=b.projectScene(ja,qa,this.sortElements);(Q=ja.lights.length>0)&&La(ja);Ba=0;for(Ja=a.length;Ba<Ja;Ba++){$=a[Ba];M.empty();if($ instanceof THREE.RenderableParticle){t=$;t.x*=f;t.y*=j;ia=0;for(ra=$.materials.length;ia<ra;ia++)Ma(t,$,$.materials[ia],ja)}else if($ instanceof THREE.RenderableLine){t=$.v1;y=$.v2;t.positionScreen.x*=f;t.positionScreen.y*=j;y.positionScreen.x*=f;y.positionScreen.y*=j;M.addPoint(t.positionScreen.x,
t.positionScreen.y);M.addPoint(y.positionScreen.x,y.positionScreen.y);if(K.instersects(M)){ia=0;for(ra=$.materials.length;ia<ra;)Na(t,y,$,$.materials[ia++],ja)}}else if($ instanceof THREE.RenderableFace3){t=$.v1;y=$.v2;A=$.v3;t.positionScreen.x*=f;t.positionScreen.y*=j;y.positionScreen.x*=f;y.positionScreen.y*=j;A.positionScreen.x*=f;A.positionScreen.y*=j;if($.overdraw){Fa(t.positionScreen,y.positionScreen);Fa(y.positionScreen,A.positionScreen);Fa(A.positionScreen,t.positionScreen)}M.add3Points(t.positionScreen.x,
t.positionScreen.y,y.positionScreen.x,y.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(K.instersects(M)){ia=0;for(ra=$.meshMaterials.length;ia<ra;){va=$.meshMaterials[ia++];if(va instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(va=$.faceMaterials[Ga++])&&Ha(t,y,A,$,va,ja)}else Ha(t,y,A,$,va,ja)}}}X.addRectangle(M)}h.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(H,I,K){var X,M,Q,N;X=0;for(M=H.lights.length;X<M;X++){Q=H.lights[X];if(Q instanceof THREE.DirectionalLight){N=I.normalWorld.dot(Q.position)*Q.intensity;if(N>0){K.r+=Q.color.r*N;K.g+=Q.color.g*N;K.b+=Q.color.b*N}}else if(Q instanceof THREE.PointLight){s.sub(Q.position,I.centroidWorld);s.normalize();N=I.normalWorld.dot(s)*Q.intensity;if(N>0){K.r+=Q.color.r*N;K.g+=Q.color.g*N;K.b+=Q.color.b*N}}}}function b(H,I,K,X,M,Q){v=d(B++);v.setAttribute("d","M "+H.positionScreen.x+
" "+H.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(D){P.r=O.r;P.g=O.g;P.b=O.b;a(Q,X,P);n.r=M.color.r*P.r;n.g=M.color.g*P.g;n.b=M.color.b*P.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m=1-M.__2near/(M.__farPlusNear-X.z*M.__farMinusNear);
n.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));M.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);h.appendChild(v)}function e(H,I,K,X,M,Q,N){v=d(B++);v.setAttribute("d",
"M "+H.positionScreen.x+" "+H.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(D){P.r=O.r;P.g=O.g;P.b=O.b;a(N,M,P);n.r=Q.color.r*P.r;n.g=Q.color.g*P.g;n.b=Q.color.b*P.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){m=
1-Q.__2near/(Q.__farPlusNear-M.z*Q.__farMinusNear);n.setRGB(m,m,m)}else Q instanceof THREE.MeshNormalMaterial&&n.setRGB(g(M.normalWorld.x),g(M.normalWorld.y),g(M.normalWorld.z));Q.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+Q.opacity);h.appendChild(v)}
function d(H){if(o[H]==null){o[H]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&o[H].setAttribute("shape-rendering","crispEdges");return o[H]}return o[H]}function g(H){return H<0?Math.min((1+H)*0.5,0.5):0.5+Math.min(H*0.5,0.5)}var f=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,x,c,C,r,t,y,A,G=new THREE.Rectangle,w=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),P=new THREE.Color(16777215),O=new THREE.Color(0),U=new THREE.Color(0),
i=new THREE.Color(0),m,s=new THREE.Vector3,o=[],u=[],q=[],v,B,R,F,W=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(H){switch(H){case "high":W=1;break;case "low":W=0}};this.setSize=function(H,I){k=H;x=I;c=k/2;C=x/2;h.setAttribute("viewBox",-c+" "+-C+" "+k+" "+x);h.setAttribute("width",k);h.setAttribute("height",x);G.set(-c,-C,c,C)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(H,I){var K,X,
M,Q,N,l,p,z;this.autoClear&&this.clear();f=j.projectScene(H,I,this.sortElements);F=R=B=0;if(D=H.lights.length>0){p=H.lights;O.setRGB(0,0,0);U.setRGB(0,0,0);i.setRGB(0,0,0);K=0;for(X=p.length;K<X;K++){M=p[K];Q=M.color;if(M instanceof THREE.AmbientLight){O.r+=Q.r;O.g+=Q.g;O.b+=Q.b}else if(M instanceof THREE.DirectionalLight){U.r+=Q.r;U.g+=Q.g;U.b+=Q.b}else if(M instanceof THREE.PointLight){i.r+=Q.r;i.g+=Q.g;i.b+=Q.b}}}K=0;for(X=f.length;K<X;K++){p=f[K];w.empty();if(p instanceof THREE.RenderableParticle){r=
p;r.x*=c;r.y*=-C;M=0;for(Q=p.materials.length;M<Q;M++)if(z=p.materials[M]){N=r;l=p;z=z;var L=R++;if(u[L]==null){u[L]=document.createElementNS("http://www.w3.org/2000/svg","circle");W==0&&u[L].setAttribute("shape-rendering","crispEdges")}v=u[L];v.setAttribute("cx",N.x);v.setAttribute("cy",N.y);v.setAttribute("r",l.scale.x*c);if(z instanceof THREE.ParticleCircleMaterial){if(D){P.r=O.r+U.r+i.r;P.g=O.g+U.g+i.g;P.b=O.b+U.b+i.b;n.r=z.color.r*P.r;n.g=z.color.g*P.g;n.b=z.color.b*P.b;n.updateStyleString()}else n=
z.color;v.setAttribute("style","fill: "+n.__styleString)}h.appendChild(v)}}else if(p instanceof THREE.RenderableLine){r=p.v1;t=p.v2;r.positionScreen.x*=c;r.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);if(G.instersects(w)){M=0;for(Q=p.materials.length;M<Q;)if(z=p.materials[M++]){N=r;l=t;z=z;L=F++;if(q[L]==null){q[L]=document.createElementNS("http://www.w3.org/2000/svg","line");W==
0&&q[L].setAttribute("shape-rendering","crispEdges")}v=q[L];v.setAttribute("x1",N.positionScreen.x);v.setAttribute("y1",N.positionScreen.y);v.setAttribute("x2",l.positionScreen.x);v.setAttribute("y2",l.positionScreen.y);if(z instanceof THREE.LineBasicMaterial){n.__styleString=z.color.__styleString;v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+z.linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.linecap+"; stroke-linejoin: "+z.linejoin);h.appendChild(v)}}}}else if(p instanceof
THREE.RenderableFace3){r=p.v1;t=p.v2;y=p.v3;r.positionScreen.x*=c;r.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;y.positionScreen.x*=c;y.positionScreen.y*=-C;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);if(G.instersects(w)){M=0;for(Q=p.meshMaterials.length;M<Q;){z=p.meshMaterials[M++];if(z instanceof THREE.MeshFaceMaterial){N=0;for(l=p.faceMaterials.length;N<l;)(z=p.faceMaterials[N++])&&
b(r,t,y,p,z,H)}else z&&b(r,t,y,p,z,H)}}}else if(p instanceof THREE.RenderableFace4){r=p.v1;t=p.v2;y=p.v3;A=p.v4;r.positionScreen.x*=c;r.positionScreen.y*=-C;t.positionScreen.x*=c;t.positionScreen.y*=-C;y.positionScreen.x*=c;y.positionScreen.y*=-C;A.positionScreen.x*=c;A.positionScreen.y*=-C;w.addPoint(r.positionScreen.x,r.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(w)){M=
0;for(Q=p.meshMaterials.length;M<Q;){z=p.meshMaterials[M++];if(z instanceof THREE.MeshFaceMaterial){N=0;for(l=p.faceMaterials.length;N<l;)(z=p.faceMaterials[N++])&&e(r,t,y,A,p,z,H)}else z&&e(r,t,y,A,p,z,H)}}}}}};
THREE.WebGLRenderer=function(a,b){function e(i,m,s){var o=c.createProgram();s=["#ifdef GL_ES\nprecision highp float;\n#endif",s?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var u=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(o,h("fragment",s+i));c.attachShader(o,h("vertex",u+m));c.linkProgram(o);c.getProgramParameter(o,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(o,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");o.uniforms={};o.attributes={};return o}function d(i,m){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.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(var s=0;s<6;++s)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[s]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
o);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}function g(i,o){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
k(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,o){var s,p,u;s=0;for(p=o.length;s<p;s++){u=o[s];i.uniforms[u]=c.getUniformLocation(i,u)}}function j(i,o){var s,p,u;s=0;for(p=o.length;s<p;s++){u=o[s];i.attributes[u]=c.getAttribLocation(i,u)}}function h(i,o){var s;if(i=="fragment")s=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")s=c.createShader(c.VERTEX_SHADER);c.shaderSource(s,
o);c.compileShader(s);if(!c.getShaderParameter(s,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(s));return null}return s}function k(i){switch(i){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}return 0}var x=document.createElement("canvas"),c,B,r,t=new THREE.Matrix4,y,A=new Float32Array(16),I=new Float32Array(16),w=new Float32Array(16),C=new Float32Array(9),n=new Float32Array(16),O=function(i,o){if(i){var s,p,u,l=pointLights=maxDirLights=maxPointLights=0;s=0;for(p=i.lights.length;s<p;s++){u=i.lights[s];u instanceof THREE.DirectionalLight&&l++;u instanceof
THREE.PointLight&&pointLights++}if(pointLights+l<=o){maxDirLights=l;maxPointLights=pointLights}else{maxDirLights=Math.ceil(o*l/(pointLights+l));maxPointLights=o-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:o-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=x;this.autoClear=true;try{c=x.getContext("experimental-webgl",{antialias:aa})}catch(L){}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(0,0,0,0);B=r=function(i,o,s){var p=[i?"#define MAX_DIR_LIGHTS "+i:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",o?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",o?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",o?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",o?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",o?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",o?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
u=[i?"#define MAX_DIR_LIGHTS "+i:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
o?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",o?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",o?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",o?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",o?"float pointSpecularWeight = 0.0;":"",o?"if ( pointDotNormalHalf >= 0.0 )":
"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;":
m);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}function g(i,m){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
k(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,m){var s,o,u;s=0;for(o=m.length;s<o;s++){u=m[s];i.uniforms[u]=c.getUniformLocation(i,u)}}function j(i,m){var s,o,u;s=0;for(o=m.length;s<o;s++){u=m[s];i.attributes[u]=c.getAttribLocation(i,u)}}function h(i,m){var s;if(i=="fragment")s=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")s=c.createShader(c.VERTEX_SHADER);c.shaderSource(s,
m);c.compileShader(s);if(!c.getShaderParameter(s,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(s));return null}return s}function k(i){switch(i){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}return 0}var x=document.createElement("canvas"),c,C,r,t=new THREE.Matrix4,y,A=new Float32Array(16),G=new Float32Array(16),w=new Float32Array(16),D=new Float32Array(9),n=new Float32Array(16),P=function(i,m){if(i){var s,o,u,q=pointLights=maxDirLights=maxPointLights=0;s=0;for(o=i.lights.length;s<o;s++){u=i.lights[s];u instanceof THREE.DirectionalLight&&q++;u instanceof
THREE.PointLight&&pointLights++}if(pointLights+q<=m){maxDirLights=q;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*q/(pointLights+q));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a,4);fog=a?a.fog:null;aa=b!=undefined?b:true;this.domElement=x;this.autoClear=true;try{c=x.getContext("experimental-webgl",{antialias:aa})}catch(O){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,
1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);C=r=function(i,m,s){var o=[i?"#define MAX_DIR_LIGHTS "+i:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":
"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
"",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
u=[i?"#define MAX_DIR_LIGHTS "+i:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
m?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",m?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",m?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",m?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",m?"float pointSpecularWeight = 0.0;":"",m?"if ( pointDotNormalHalf >= 0.0 )":
"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;":
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
p=e(u,p,s);c.useProgram(p);f(p,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);s&&f(p,["fogColor","fogNear","fogFar"]);i&&f(p,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(p,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(p.uniforms.enableMap,0);c.uniform1i(p.uniforms.tMap,0);c.uniform1i(p.uniforms.enableCubeMap,0);c.uniform1i(p.uniforms.tCube,1);c.uniform1i(p.uniforms.mixEnvMap,0);c.uniform1i(p.uniforms.useRefract,0);j(p,["position","normal","uv"]);return p}(O.directional,O.point,fog);this.setSize=function(i,o){x.width=i;x.height=o;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,o){var s,p,u,l,v,
z=[],J=[],S=[];l=[];v=[];c.uniform1i(i.uniforms.enableLighting,o.length);s=0;for(p=o.length;s<p;s++){u=o[s];if(u instanceof THREE.AmbientLight)z.push(u);else if(u instanceof THREE.DirectionalLight)S.push(u);else u instanceof THREE.PointLight&&J.push(u)}s=u=l=v=0;for(p=z.length;s<p;s++){u+=z[s].color.r;l+=z[s].color.g;v+=z[s].color.b}c.uniform3f(i.uniforms.ambientLightColor,u,l,v);l=[];v=[];s=0;for(p=S.length;s<p;s++){u=S[s];l.push(u.color.r*u.intensity);l.push(u.color.g*u.intensity);l.push(u.color.b*
u.intensity);v.push(u.position.x);v.push(u.position.y);v.push(u.position.z)}if(S.length){c.uniform1i(i.uniforms.directionalLightNumber,S.length);c.uniform3fv(i.uniforms.directionalLightDirection,v);c.uniform3fv(i.uniforms.directionalLightColor,l)}l=[];v=[];s=0;for(p=J.length;s<p;s++){u=J[s];l.push(u.color.r*u.intensity);l.push(u.color.g*u.intensity);l.push(u.color.b*u.intensity);v.push(u.position.x);v.push(u.position.y);v.push(u.position.z)}if(J.length){c.uniform1i(i.uniforms.pointLightNumber,J.length);
c.uniform3fv(i.uniforms.pointLightPosition,v);c.uniform3fv(i.uniforms.pointLightColor,l)}};this.createBuffers=function(i,o){var s,p,u,l,v,z,J,S,Q,H=[],V=[],M=[],W=[],N=[],F=[],G=0,m=i.geometry.geometryChunks[o],q;u=false;s=0;for(p=i.materials.length;s<p;s++){meshMaterial=i.materials[s];if(meshMaterial instanceof THREE.MeshFaceMaterial){v=0;for(q=m.materials.length;v<q;v++)if(m.materials[v]&&m.materials[v].shading!=undefined&&m.materials[v].shading==THREE.SmoothShading){u=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){u=true;break}if(u)break}q=u;s=0;for(p=m.faces.length;s<p;s++){u=m.faces[s];l=i.geometry.faces[u];v=l.vertexNormals;faceNormal=l.normal;u=i.geometry.uvs[u];if(l instanceof THREE.Face3){z=i.geometry.vertices[l.a].position;J=i.geometry.vertices[l.b].position;S=i.geometry.vertices[l.c].position;M.push(z.x,z.y,z.z);M.push(J.x,J.y,J.z);M.push(S.x,S.y,S.z);if(i.geometry.hasTangents){z=i.geometry.vertices[l.a].tangent;J=i.geometry.vertices[l.b].tangent;
S=i.geometry.vertices[l.c].tangent;N.push(z.x,z.y,z.z,z.w);N.push(J.x,J.y,J.z,J.w);N.push(S.x,S.y,S.z,S.w)}if(v.length==3&&q)for(l=0;l<3;l++)W.push(v[l].x,v[l].y,v[l].z);else for(l=0;l<3;l++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(u)for(l=0;l<3;l++)F.push(u[l].u,u[l].v);H.push(G,G+1,G+2);V.push(G,G+1);V.push(G,G+2);V.push(G+1,G+2);G+=3}else if(l instanceof THREE.Face4){z=i.geometry.vertices[l.a].position;J=i.geometry.vertices[l.b].position;S=i.geometry.vertices[l.c].position;Q=i.geometry.vertices[l.d].position;
M.push(z.x,z.y,z.z);M.push(J.x,J.y,J.z);M.push(S.x,S.y,S.z);M.push(Q.x,Q.y,Q.z);if(i.geometry.hasTangents){z=i.geometry.vertices[l.a].tangent;J=i.geometry.vertices[l.b].tangent;S=i.geometry.vertices[l.c].tangent;l=i.geometry.vertices[l.d].tangent;N.push(z.x,z.y,z.z,z.w);N.push(J.x,J.y,J.z,J.w);N.push(S.x,S.y,S.z,S.w);N.push(l.x,l.y,l.z,l.w)}if(v.length==4&&q)for(l=0;l<4;l++)W.push(v[l].x,v[l].y,v[l].z);else for(l=0;l<4;l++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(u)for(l=0;l<4;l++)F.push(u[l].u,
u[l].v);H.push(G,G+1,G+2);H.push(G,G+2,G+3);V.push(G,G+1);V.push(G,G+2);V.push(G,G+3);V.push(G+1,G+2);V.push(G+2,G+3);G+=4}}if(M.length){m.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,m.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(M),c.STATIC_DRAW);m.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,m.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW);if(i.geometry.hasTangents){m.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,m.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(N),c.STATIC_DRAW)}if(F.length>0){m.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,m.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}m.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);m.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
m.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);m.__webGLFaceCount=H.length;m.__webGLLineCount=V.length}};this.renderBuffer=function(i,o,s,p,u){var l,v,z,J,S,Q,H,V,M;if(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshDepthMaterial||p instanceof THREE.MeshNormalMaterial){if(!p.program){if(p instanceof THREE.MeshDepthMaterial){H=T.depth;p.fragment_shader=H.fragment_shader;p.vertex_shader=H.vertex_shader;p.uniforms=H.uniforms;p.uniforms.mNear.value=
p.near;p.uniforms.mFar.value=p.far}else if(p instanceof THREE.MeshNormalMaterial){H=T.normal;p.fragment_shader=H.fragment_shader;p.vertex_shader=H.vertex_shader;p.uniforms=H.uniforms}p.program=e(p.fragment_shader,p.vertex_shader,null);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in p.uniforms)H.push(M);f(p.program,H);j(p.program,["position","normal","uv","tangent"])}M=p.program}else M=r;if(M!=B){c.useProgram(M);B=M}M==r&&this.setupLights(M,
o);this.loadCamera(M,i);this.loadMatrices(M);if(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshDepthMaterial||p instanceof THREE.MeshNormalMaterial){z=p.wireframe;J=p.wireframe_linewidth;i=M;o=p.uniforms;var W;for(l in o){V=o[l].type;H=o[l].value;W=i.uniforms[l];if(V=="i")c.uniform1i(W,H);else if(V=="f")c.uniform1f(W,H);else if(V=="v3")c.uniform3f(W,H.x,H.y,H.z);else if(V=="c")c.uniform3f(W,H.r,H.g,H.b);else if(V=="t"){c.uniform1i(W,H);if(V=o[l].texture)V.image instanceof Array&&V.image.length==
6?d(V,H):g(V,H)}}}if(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshBasicMaterial){l=p.color;v=p.opacity;z=p.wireframe;J=p.wireframe_linewidth;S=p.map;Q=p.env_map;o=p.combine==THREE.MixOperation;i=p.reflectivity;V=p.env_map&&p.env_map.mapping instanceof THREE.CubeRefractionMapping;H=p.refraction_ratio;c.uniform4f(M.uniforms.mColor,l.r*v,l.g*v,l.b*v,v);c.uniform1i(M.uniforms.mixEnvMap,o);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract,
V);c.uniform1f(M.uniforms.mRefractionRatio,H);if(s){c.uniform1f(M.uniforms.fogNear,s.near);c.uniform1f(M.uniforms.fogFar,s.far);c.uniform3f(M.uniforms.fogColor,s.color.r,s.color.g,s.color.b)}}if(p instanceof THREE.MeshPhongMaterial){s=p.ambient;l=p.specular;p=p.shininess;c.uniform4f(M.uniforms.mAmbient,s.r,s.g,s.b,v);c.uniform4f(M.uniforms.mSpecular,l.r,l.g,l.b,v);c.uniform1f(M.uniforms.mShininess,p);c.uniform1i(M.uniforms.material,2)}else if(p instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material,
1);else p instanceof THREE.MeshBasicMaterial&&c.uniform1i(M.uniforms.material,0);if(S){g(S,0);c.uniform1i(M.uniforms.tMap,0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap,0);if(Q){d(Q,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);v=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,u.__webGLVertexBuffer);c.vertexAttribPointer(v.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.position);if(v.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLNormalBuffer);c.vertexAttribPointer(v.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.normal)}if(v.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLTangentBuffer);c.vertexAttribPointer(v.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(u.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLUVBuffer);c.vertexAttribPointer(v.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.uv)}else c.disableVertexAttribArray(v.uv);if(z){c.lineWidth(J);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);c.drawElements(c.LINES,u.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,u.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,o,s,p,u,l,v){var z,J,S,Q,H;S=0;for(Q=p.materials.length;S<Q;S++){z=p.materials[S];if(z instanceof THREE.MeshFaceMaterial){z=0;for(J=u.materials.length;z<J;z++)if((H=u.materials[z])&&H.blending==l&&H.opacity<1==v){this.setBlending(H.blending);
this.renderBuffer(i,o,s,H,u)}}else if((H=z)&&H.blending==l&&H.opacity<1==v){this.setBlending(H.blending);this.renderBuffer(i,o,s,H,u)}}};this.render=function(i,o){var s,p,u,l,v=i.lights,z=i.fog;this.initWebGLObjects(i);this.autoClear&&this.clear();o.autoUpdateMatrix&&o.updateMatrix();A.set(o.matrix.flatten());w.set(o.projectionMatrix.flatten());s=0;for(p=i.__webGLObjects.length;s<p;s++){u=i.__webGLObjects[s];l=u.object;u=u.buffer;if(l.visible){this.setupMatrices(l,o);this.renderPass(o,v,z,l,u,THREE.NormalBlending,
false)}}s=0;for(p=i.__webGLObjects.length;s<p;s++){u=i.__webGLObjects[s];l=u.object;u=u.buffer;if(l.visible){this.setupMatrices(l,o);this.renderPass(o,v,z,l,u,THREE.AdditiveBlending,false);this.renderPass(o,v,z,l,u,THREE.SubtractiveBlending,false);this.renderPass(o,v,z,l,u,THREE.AdditiveBlending,true);this.renderPass(o,v,z,l,u,THREE.SubtractiveBlending,true);this.renderPass(o,v,z,l,u,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var o,s,p,u,l,v;if(!i.__webGLObjects){i.__webGLObjects=
[];i.__webGLObjectsMap={}}o=0;for(s=i.objects.length;o<s;o++){p=i.objects[o];if(i.__webGLObjectsMap[p.id]==undefined)i.__webGLObjectsMap[p.id]={};v=i.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(l in p.geometry.geometryChunks){u=p.geometry.geometryChunks[l];u.__webGLVertexBuffer||this.createBuffers(p,l);if(v[l]==undefined){u={buffer:u,object:p};i.__webGLObjects.push(u);v[l]=1}}}};this.removeObject=function(i,o){var s,p;for(s=i.__webGLObjects.length-1;s>=0;s--){p=i.__webGLObjects[s].object;
o==p&&i.__webGLObjects.splice(s,1)}};this.setupMatrices=function(i,o){i.autoUpdateMatrix&&i.updateMatrix();t.multiply(o.matrix,i.matrix);I.set(t.flatten());y=THREE.Matrix4.makeInvert3x3(t).transpose();C.set(y.m);n.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,A);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,I);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(i.uniforms.objectMatrix,
false,n)};this.loadCamera=function(i,o){c.uniform3f(i.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(i){switch(i){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(i,o){if(i){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);
else i=="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};var T={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}",
o=e(u,o,s);c.useProgram(o);f(o,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);s&&f(o,["fogColor","fogNear","fogFar"]);i&&f(o,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&f(o,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(o.uniforms.enableMap,0);c.uniform1i(o.uniforms.tMap,0);c.uniform1i(o.uniforms.enableCubeMap,0);c.uniform1i(o.uniforms.tCube,1);c.uniform1i(o.uniforms.mixEnvMap,0);c.uniform1i(o.uniforms.useRefract,0);j(o,["position","normal","uv"]);return o}(P.directional,P.point,fog);this.setSize=function(i,m){x.width=i;x.height=m;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,m){var s,o,u,q,v,
B=[],R=[],F=[];q=[];v=[];c.uniform1i(i.uniforms.enableLighting,m.length);s=0;for(o=m.length;s<o;s++){u=m[s];if(u instanceof THREE.AmbientLight)B.push(u);else if(u instanceof THREE.DirectionalLight)F.push(u);else u instanceof THREE.PointLight&&R.push(u)}s=u=q=v=0;for(o=B.length;s<o;s++){u+=B[s].color.r;q+=B[s].color.g;v+=B[s].color.b}c.uniform3f(i.uniforms.ambientLightColor,u,q,v);q=[];v=[];s=0;for(o=F.length;s<o;s++){u=F[s];q.push(u.color.r*u.intensity);q.push(u.color.g*u.intensity);q.push(u.color.b*
u.intensity);v.push(u.position.x);v.push(u.position.y);v.push(u.position.z)}if(F.length){c.uniform1i(i.uniforms.directionalLightNumber,F.length);c.uniform3fv(i.uniforms.directionalLightDirection,v);c.uniform3fv(i.uniforms.directionalLightColor,q)}q=[];v=[];s=0;for(o=R.length;s<o;s++){u=R[s];q.push(u.color.r*u.intensity);q.push(u.color.g*u.intensity);q.push(u.color.b*u.intensity);v.push(u.position.x);v.push(u.position.y);v.push(u.position.z)}if(R.length){c.uniform1i(i.uniforms.pointLightNumber,R.length);
c.uniform3fv(i.uniforms.pointLightPosition,v);c.uniform3fv(i.uniforms.pointLightColor,q)}};this.createBuffers=function(i,m){var s,o,u,q,v,B,R,F,W,H=[],I=[],K=[],X=[],M=[],Q=[],N=0,l=i.geometry.geometryChunks[m],p;u=false;s=0;for(o=i.materials.length;s<o;s++){meshMaterial=i.materials[s];if(meshMaterial instanceof THREE.MeshFaceMaterial){v=0;for(p=l.materials.length;v<p;v++)if(l.materials[v]&&l.materials[v].shading!=undefined&&l.materials[v].shading==THREE.SmoothShading){u=true;break}}else if(meshMaterial&&
meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){u=true;break}if(u)break}p=u;s=0;for(o=l.faces.length;s<o;s++){u=l.faces[s];q=i.geometry.faces[u];v=q.vertexNormals;faceNormal=q.normal;u=i.geometry.uvs[u];if(q instanceof THREE.Face3){B=i.geometry.vertices[q.a].position;R=i.geometry.vertices[q.b].position;F=i.geometry.vertices[q.c].position;K.push(B.x,B.y,B.z);K.push(R.x,R.y,R.z);K.push(F.x,F.y,F.z);if(i.geometry.hasTangents){B=i.geometry.vertices[q.a].tangent;R=i.geometry.vertices[q.b].tangent;
F=i.geometry.vertices[q.c].tangent;M.push(B.x,B.y,B.z,B.w);M.push(R.x,R.y,R.z,R.w);M.push(F.x,F.y,F.z,F.w)}if(v.length==3&&p)for(q=0;q<3;q++)X.push(v[q].x,v[q].y,v[q].z);else for(q=0;q<3;q++)X.push(faceNormal.x,faceNormal.y,faceNormal.z);if(u)for(q=0;q<3;q++)Q.push(u[q].u,u[q].v);H.push(N,N+1,N+2);I.push(N,N+1);I.push(N,N+2);I.push(N+1,N+2);N+=3}else if(q instanceof THREE.Face4){B=i.geometry.vertices[q.a].position;R=i.geometry.vertices[q.b].position;F=i.geometry.vertices[q.c].position;W=i.geometry.vertices[q.d].position;
K.push(B.x,B.y,B.z);K.push(R.x,R.y,R.z);K.push(F.x,F.y,F.z);K.push(W.x,W.y,W.z);if(i.geometry.hasTangents){B=i.geometry.vertices[q.a].tangent;R=i.geometry.vertices[q.b].tangent;F=i.geometry.vertices[q.c].tangent;q=i.geometry.vertices[q.d].tangent;M.push(B.x,B.y,B.z,B.w);M.push(R.x,R.y,R.z,R.w);M.push(F.x,F.y,F.z,F.w);M.push(q.x,q.y,q.z,q.w)}if(v.length==4&&p)for(q=0;q<4;q++)X.push(v[q].x,v[q].y,v[q].z);else for(q=0;q<4;q++)X.push(faceNormal.x,faceNormal.y,faceNormal.z);if(u)for(q=0;q<4;q++)Q.push(u[q].u,
u[q].v);H.push(N,N+1,N+2);H.push(N,N+2,N+3);I.push(N,N+1);I.push(N,N+2);I.push(N,N+3);I.push(N+1,N+2);I.push(N+2,N+3);N+=4}}if(K.length){l.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,l.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW);l.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW);if(i.geometry.hasTangents){l.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(M),c.STATIC_DRAW)}if(Q.length>0){l.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}l.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);l.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
l.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);l.__webGLFaceCount=H.length;l.__webGLLineCount=I.length}};this.renderBuffer=function(i,m,s,o,u){var q,v,B,R,F,W,H,I,K;if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshDepthMaterial||o instanceof THREE.MeshNormalMaterial){if(!o.program){if(o instanceof THREE.MeshDepthMaterial){H=U.depth;o.fragment_shader=H.fragment_shader;o.vertex_shader=H.vertex_shader;o.uniforms=H.uniforms;o.uniforms.mNear.value=
i.near;o.uniforms.mFar.value=i.far}else if(o instanceof THREE.MeshNormalMaterial){H=U.normal;o.fragment_shader=H.fragment_shader;o.vertex_shader=H.vertex_shader;o.uniforms=H.uniforms}o.program=e(o.fragment_shader,o.vertex_shader,null);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(K in o.uniforms)H.push(K);f(o.program,H);j(o.program,["position","normal","uv","tangent"])}K=o.program}else K=r;if(K!=C){c.useProgram(K);C=K}K==r&&this.setupLights(K,
m);this.loadCamera(K,i);this.loadMatrices(K);if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshDepthMaterial||o instanceof THREE.MeshNormalMaterial){B=o.wireframe;R=o.wireframe_linewidth;i=K;m=o.uniforms;var X;for(q in m){I=m[q].type;H=m[q].value;X=i.uniforms[q];if(I=="i")c.uniform1i(X,H);else if(I=="f")c.uniform1f(X,H);else if(I=="v3")c.uniform3f(X,H.x,H.y,H.z);else if(I=="c")c.uniform3f(X,H.r,H.g,H.b);else if(I=="t"){c.uniform1i(X,H);if(I=m[q].texture)I.image instanceof Array&&I.image.length==
6?d(I,H):g(I,H)}}}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshBasicMaterial){q=o.color;v=o.opacity;B=o.wireframe;R=o.wireframe_linewidth;F=o.map;W=o.env_map;m=o.combine==THREE.MixOperation;i=o.reflectivity;I=o.env_map&&o.env_map.mapping instanceof THREE.CubeRefractionMapping;H=o.refraction_ratio;c.uniform4f(K.uniforms.mColor,q.r*v,q.g*v,q.b*v,v);c.uniform1i(K.uniforms.mixEnvMap,m);c.uniform1f(K.uniforms.mReflectivity,i);c.uniform1i(K.uniforms.useRefract,
I);c.uniform1f(K.uniforms.mRefractionRatio,H);if(s){c.uniform1f(K.uniforms.fogNear,s.near);c.uniform1f(K.uniforms.fogFar,s.far);c.uniform3f(K.uniforms.fogColor,s.color.r,s.color.g,s.color.b)}}if(o instanceof THREE.MeshPhongMaterial){s=o.ambient;q=o.specular;o=o.shininess;c.uniform4f(K.uniforms.mAmbient,s.r,s.g,s.b,v);c.uniform4f(K.uniforms.mSpecular,q.r,q.g,q.b,v);c.uniform1f(K.uniforms.mShininess,o);c.uniform1i(K.uniforms.material,2)}else if(o instanceof THREE.MeshLambertMaterial)c.uniform1i(K.uniforms.material,
1);else o instanceof THREE.MeshBasicMaterial&&c.uniform1i(K.uniforms.material,0);if(F){g(F,0);c.uniform1i(K.uniforms.tMap,0);c.uniform1i(K.uniforms.enableMap,1)}else c.uniform1i(K.uniforms.enableMap,0);if(W){d(W,1);c.uniform1i(K.uniforms.tCube,1);c.uniform1i(K.uniforms.enableCubeMap,1)}else c.uniform1i(K.uniforms.enableCubeMap,0);v=K.attributes;c.bindBuffer(c.ARRAY_BUFFER,u.__webGLVertexBuffer);c.vertexAttribPointer(v.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.position);if(v.normal>=
0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLNormalBuffer);c.vertexAttribPointer(v.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.normal)}if(v.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLTangentBuffer);c.vertexAttribPointer(v.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(u.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLUVBuffer);c.vertexAttribPointer(v.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.uv)}else c.disableVertexAttribArray(v.uv);if(B){c.lineWidth(R);
c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);c.drawElements(c.LINES,u.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,u.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,m,s,o,u,q,v){var B,R,F,W,H;F=0;for(W=o.materials.length;F<W;F++){B=o.materials[F];if(B instanceof THREE.MeshFaceMaterial){B=0;for(R=u.materials.length;B<R;B++)if((H=u.materials[B])&&H.blending==q&&H.opacity<1==v){this.setBlending(H.blending);
this.renderBuffer(i,m,s,H,u)}}else if((H=B)&&H.blending==q&&H.opacity<1==v){this.setBlending(H.blending);this.renderBuffer(i,m,s,H,u)}}};this.render=function(i,m){var s,o,u,q,v=i.lights,B=i.fog;this.initWebGLObjects(i);this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();A.set(m.matrix.flatten());w.set(m.projectionMatrix.flatten());s=0;for(o=i.__webGLObjects.length;s<o;s++){u=i.__webGLObjects[s];q=u.object;u=u.buffer;if(q.visible){this.setupMatrices(q,m);this.renderPass(m,v,B,q,u,THREE.NormalBlending,
false)}}s=0;for(o=i.__webGLObjects.length;s<o;s++){u=i.__webGLObjects[s];q=u.object;u=u.buffer;if(q.visible){this.setupMatrices(q,m);this.renderPass(m,v,B,q,u,THREE.AdditiveBlending,false);this.renderPass(m,v,B,q,u,THREE.SubtractiveBlending,false);this.renderPass(m,v,B,q,u,THREE.AdditiveBlending,true);this.renderPass(m,v,B,q,u,THREE.SubtractiveBlending,true);this.renderPass(m,v,B,q,u,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var m,s,o,u,q,v;if(!i.__webGLObjects){i.__webGLObjects=
[];i.__webGLObjectsMap={}}m=0;for(s=i.objects.length;m<s;m++){o=i.objects[m];if(i.__webGLObjectsMap[o.id]==undefined)i.__webGLObjectsMap[o.id]={};v=i.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh)for(q in o.geometry.geometryChunks){u=o.geometry.geometryChunks[q];u.__webGLVertexBuffer||this.createBuffers(o,q);if(v[q]==undefined){u={buffer:u,object:o};i.__webGLObjects.push(u);v[q]=1}}}};this.removeObject=function(i,m){var s,o;for(s=i.__webGLObjects.length-1;s>=0;s--){o=i.__webGLObjects[s].object;
m==o&&i.__webGLObjects.splice(s,1)}};this.setupMatrices=function(i,m){i.autoUpdateMatrix&&i.updateMatrix();t.multiply(m.matrix,i.matrix);G.set(t.flatten());y=THREE.Matrix4.makeInvert3x3(t).transpose();D.set(y.m);n.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,A);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(i.uniforms.objectMatrix,
false,n)};this.loadCamera=function(i,m){c.uniform3f(i.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(i){switch(i){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(i,m){if(i){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);
else i=="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};var U={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}"}}};
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,d=a.vertices.length,g=e?b.geometry:b,f=a.vertices,j=g.vertices,h=a.faces,k=g.faces,x=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var c=0,B=j.length;c<B;c++){var r=new THREE.Vertex(j[c].position.clone());e&&b.matrix.multiplyVector3(r.position);f.push(r)}c=0;for(B=k.length;c<B;c++){j=k[c];var t,y=j.vertexNormals;if(j instanceof THREE.Face3)t=new THREE.Face3(j.a+d,j.b+d,j.c+d);else if(j instanceof THREE.Face4)t=new THREE.Face4(j.a+d,j.b+
d,j.c+d,j.d+d);t.centroid.copy(j.centroid);t.normal.copy(j.normal);e=0;for(f=y.length;e<f;e++){r=y[e];t.vertexNormals.push(r.clone())}t.materials=j.materials.slice();h.push(t)}c=0;for(B=g.length;c<B;c++){d=g[c];h=[];e=0;for(f=d.length;e<f;e++)h.push(new THREE.UV(d[e].u,d[e].v));x.push(h)}}},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,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,f=a.vertices,j=g.vertices,h=a.faces,k=g.faces,x=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var c=0,C=j.length;c<C;c++){var r=new THREE.Vertex(j[c].position.clone());e&&b.matrix.multiplyVector3(r.position);f.push(r)}c=0;for(C=k.length;c<C;c++){j=k[c];var t,y=j.vertexNormals;if(j instanceof THREE.Face3)t=new THREE.Face3(j.a+d,j.b+d,j.c+d);else if(j instanceof THREE.Face4)t=new THREE.Face4(j.a+d,j.b+
d,j.c+d,j.d+d);t.centroid.copy(j.centroid);t.normal.copy(j.normal);e=0;for(f=y.length;e<f;e++){r=y[e];t.vertexNormals.push(r.clone())}t.materials=j.materials.slice();h.push(t)}c=0;for(C=g.length;c<C;c++){d=g[c];h=[];e=0;for(f=d.length;e<f;e++)h.push(new THREE.UV(d[e].u,d[e].v));x.push(h)}}},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,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
new Image;d[b].loaded=0;d[b].onload=function(){d.loadCount+=1;this.loaded=true};d[b].src=a[b]}return d}},SceneUtils={addMesh:function(a,b,e,d,g,f,j,h,k,x){b=new THREE.Mesh(b,x);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=d;b.position.y=g;b.position.z=f;b.rotation.x=j;b.rotation.y=h;b.rotation.z=k;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=e;e=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,
uniforms:d.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 d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));
mesh=new THREE.Mesh(new Cube(b,b,b,1,1,d,true),new THREE.MeshFaceMaterial);a.addObject(mesh);return mesh},addPanoramaCubePlanes:function(a,b,e){var d=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,
@@ -195,37 +195,37 @@ normal:{uniforms:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,
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 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = 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( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\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 vLightWeighting;\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;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\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,e,d,g,f,j,h){function k(A,I,w,C,n,O,L,T){var i,o=d||1,s=g||1,p=o+1,u=s+1,l=n/2,v=O/2;n=n/o;O=O/s;var z=x.vertices.length;if(A=="x"&&I=="y"||A=="y"&&I=="x")i="z";else if(A=="x"&&I=="z"||A=="z"&&I=="x")i="y";else if(A=="z"&&I=="y"||A=="y"&&I=="z")i="x";for(iy=0;iy<u;iy++)for(ix=0;ix<
p;ix++){var J=new THREE.Vector3;J[A]=(ix*n-l)*w;J[I]=(iy*O-v)*C;J[i]=L;x.vertices.push(new THREE.Vertex(J))}for(iy=0;iy<s;iy++)for(ix=0;ix<o;ix++){x.faces.push(new THREE.Face4(ix+p*iy+z,ix+p*(iy+1)+z,ix+1+p*(iy+1)+z,ix+1+p*iy+z,null,T));x.uvs.push([new THREE.UV(ix/o,iy/s),new THREE.UV(ix/o,(iy+1)/s),new THREE.UV((ix+1)/o,(iy+1)/s),new THREE.UV((ix+1)/o,iy/s)])}}THREE.Geometry.call(this);var x=this,c=a/2,B=b/2,r=e/2;j=j?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=f;else{this.materials=
[];for(var t=0;t<6;t++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var y in h)if(this.sides[y]!=undefined)this.sides[y]=h[y];this.sides.px&&k("z","y",1*j,-1,e,b,-c,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,e,b,c,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,e,B,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,e,-B,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,r,this.materials[4]);this.sides.nz&&
k("x","y",-1*j,-1,a,b,-r,this.materials[5]);(function(){for(var A=[],I=[],w=0,C=x.vertices.length;w<C;w++){for(var n=x.vertices[w],O=false,L=0,T=A.length;L<T;L++){var i=A[L];if(n.position.x==i.position.x&&n.position.y==i.position.y&&n.position.z==i.position.z){I[w]=L;O=true;break}}if(!O){I[w]=A.length;A.push(new THREE.Vertex(n.position.clone()))}}w=0;for(C=x.faces.length;w<C;w++){n=x.faces[w];n.a=I[n.a];n.b=I[n.b];n.c=I[n.c];n.d=I[n.d]}x.vertices=A})();this.computeCentroids();this.computeFaceNormals();
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,e,d,g,f,j,h){function k(A,G,w,D,n,P,O,U){var i,m=d||1,s=g||1,o=m+1,u=s+1,q=n/2,v=P/2;n=n/m;P=P/s;var B=x.vertices.length;if(A=="x"&&G=="y"||A=="y"&&G=="x")i="z";else if(A=="x"&&G=="z"||A=="z"&&G=="x")i="y";else if(A=="z"&&G=="y"||A=="y"&&G=="z")i="x";for(iy=0;iy<u;iy++)for(ix=0;ix<
o;ix++){var R=new THREE.Vector3;R[A]=(ix*n-q)*w;R[G]=(iy*P-v)*D;R[i]=O;x.vertices.push(new THREE.Vertex(R))}for(iy=0;iy<s;iy++)for(ix=0;ix<m;ix++){x.faces.push(new THREE.Face4(ix+o*iy+B,ix+o*(iy+1)+B,ix+1+o*(iy+1)+B,ix+1+o*iy+B,null,U));x.uvs.push([new THREE.UV(ix/m,iy/s),new THREE.UV(ix/m,(iy+1)/s),new THREE.UV((ix+1)/m,(iy+1)/s),new THREE.UV((ix+1)/m,iy/s)])}}THREE.Geometry.call(this);var x=this,c=a/2,C=b/2,r=e/2;j=j?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=f;else{this.materials=
[];for(var t=0;t<6;t++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var y in h)if(this.sides[y]!=undefined)this.sides[y]=h[y];this.sides.px&&k("z","y",1*j,-1,e,b,-c,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,e,b,c,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,e,C,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,e,-C,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,r,this.materials[4]);this.sides.nz&&
k("x","y",-1*j,-1,a,b,-r,this.materials[5]);(function(){for(var A=[],G=[],w=0,D=x.vertices.length;w<D;w++){for(var n=x.vertices[w],P=false,O=0,U=A.length;O<U;O++){var i=A[O];if(n.position.x==i.position.x&&n.position.y==i.position.y&&n.position.z==i.position.z){G[w]=O;P=true;break}}if(!P){G[w]=A.length;A.push(new THREE.Vertex(n.position.clone()))}}w=0;for(D=x.faces.length;w<D;w++){n=x.faces[w];n.a=G[n.a];n.b=G[n.b];n.c=G[n.c];n.d=G[n.d]}x.vertices=A})();this.computeCentroids();this.computeFaceNormals();
this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,e,d,g){function f(x,c,B){j.vertices.push(new THREE.Vertex(new THREE.Vector3(x,c,B)))}THREE.Geometry.call(this);var j=this,h=Math.PI,k;for(k=0;k<a;k++)f(Math.sin(2*h*k/a)*b,Math.cos(2*h*k/a)*b,0);for(k=0;k<a;k++)f(Math.sin(2*h*k/a)*e,Math.cos(2*h*k/a)*e,d);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(e!=0){f(0,0,-g);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){f(0,0,d+g);for(k=a+a/2;k<
var Cylinder=function(a,b,e,d,g){function f(x,c,C){j.vertices.push(new THREE.Vertex(new THREE.Vector3(x,c,C)))}THREE.Geometry.call(this);var j=this,h=Math.PI,k;for(k=0;k<a;k++)f(Math.sin(2*h*k/a)*b,Math.cos(2*h*k/a)*b,0);for(k=0;k<a;k++)f(Math.sin(2*h*k/a)*e,Math.cos(2*h*k/a)*e,d);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(e!=0){f(0,0,-g);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){f(0,0,d+g);for(k=a+a/2;k<
2*a;k++)j.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-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,d){THREE.Geometry.call(this);var g,f=a/2,j=b/2;e=e||1;d=d||1;var h=e+1,k=d+1;a=a/e;var x=b/d;for(g=0;g<k;g++)for(b=0;b<h;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*x-j),0)));for(g=0;g<d;g++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+h*g,b+h*(g+1),b+1+h*(g+1),b+1+h*g));this.uvs.push([new THREE.UV(b/e,g/d),new THREE.UV(b/e,(g+1)/d),new THREE.UV((b+1)/e,(g+1)/d),new THREE.UV((b+1)/e,g/d)])}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 d,g=Math.PI,f=Math.max(3,b||8),j=Math.max(2,e||6);b=[];for(e=0;e<j+1;e++){d=e/j;var h=a*Math.cos(d*g),k=a*Math.sin(d*g),x=[],c=0;for(d=0;d<f;d++){var B=2*d/f,r=k*Math.sin(B*g);B=k*Math.cos(B*g);(e==0||e==j)&&d>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,h,r)))-1);x.push(c)}b.push(x)}var t,y,A;g=b.length;for(e=0;e<g;e++){f=b[e].length;if(e>0)for(d=0;d<f;d++){x=d==f-1;j=b[e][x?0:d+1];h=b[e][x?f-1:d];k=b[e-1][x?f-1:d];x=b[e-1][x?
0:d+1];r=e/(g-1);t=(e-1)/(g-1);y=(d+1)/f;B=d/f;c=new THREE.UV(1-y,r);r=new THREE.UV(1-B,r);B=new THREE.UV(1-B,t);var I=new THREE.UV(1-y,t);if(e<b.length-1){t=this.vertices[j].position.clone();y=this.vertices[h].position.clone();A=this.vertices[k].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,h,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,r,B])}if(e>1){t=this.vertices[j].position.clone();
y=this.vertices[k].position.clone();A=this.vertices[x].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,k,x,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,B,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,f=Math.max(3,b||8),j=Math.max(2,e||6);b=[];for(e=0;e<j+1;e++){d=e/j;var h=a*Math.cos(d*g),k=a*Math.sin(d*g),x=[],c=0;for(d=0;d<f;d++){var C=2*d/f,r=k*Math.sin(C*g);C=k*Math.cos(C*g);(e==0||e==j)&&d>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,h,r)))-1);x.push(c)}b.push(x)}var t,y,A;g=b.length;for(e=0;e<g;e++){f=b[e].length;if(e>0)for(d=0;d<f;d++){x=d==f-1;j=b[e][x?0:d+1];h=b[e][x?f-1:d];k=b[e-1][x?f-1:d];x=b[e-1][x?
0:d+1];r=e/(g-1);t=(e-1)/(g-1);y=(d+1)/f;C=d/f;c=new THREE.UV(1-y,r);r=new THREE.UV(1-C,r);C=new THREE.UV(1-C,t);var G=new THREE.UV(1-y,t);if(e<b.length-1){t=this.vertices[j].position.clone();y=this.vertices[h].position.clone();A=this.vertices[k].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,h,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,r,C])}if(e>1){t=this.vertices[j].position.clone();
y=this.vertices[k].position.clone();A=this.vertices[x].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,k,x,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,C,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
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,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(f){THREE.Loader.prototype.loadAjaxBuffers(f.data.buffers,
f.data.materials,b,e,g)};a.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var f=new XMLHttpRequest,j=d+"/"+a,h=0;f.onreadystatechange=function(){if(f.readyState==4)f.status==200||f.status==0?THREE.Loader.prototype.createBinModel(f.responseText,e,d,b):alert("Couldn't load ["+j+"] ["+f.status+"]");else if(f.readyState==3){if(g){if(h==0)h=f.getResponseHeader("Content-Length");g({total:h,loaded:f.responseText.length})}}else if(f.readyState==
2)h=f.getResponseHeader("Content-Length")};f.open("GET",j,true);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)},createBinModel:function(a,b,e,d){var g=function(f){function j(m,q){var D=c(m,q),P=c(m,q+1),Y=c(m,q+2),Z=c(m,q+3),fa=(Z<<1&255|Y>>7)-127;D=(Y&127)<<16|P<<8|D;if(D==0&&fa==-127)return 0;return(1-2*(Z>>7))*(1+D*Math.pow(2,-23))*Math.pow(2,fa)}function h(m,q){var D=c(m,q),P=c(m,q+1),Y=c(m,q+2);return(c(m,q+3)<<24)+(Y<<16)+
(P<<8)+D}function k(m,q){var D=c(m,q);return(c(m,q+1)<<8)+D}function x(m,q){var D=c(m,q);return D>127?D-256:D}function c(m,q){return m.charCodeAt(q)&255}function B(m){var q,D,P;q=h(a,m);D=h(a,m+T);P=h(a,m+i);m=k(a,m+o);THREE.Loader.prototype.f3(w,q,D,P,m)}function r(m){var q,D,P,Y,Z,fa;q=h(a,m);D=h(a,m+T);P=h(a,m+i);Y=k(a,m+o);Z=h(a,m+s);fa=h(a,m+p);m=h(a,m+u);THREE.Loader.prototype.f3n(w,O,q,D,P,Y,Z,fa,m)}function t(m){var q,D,P,Y;q=h(a,m);D=h(a,m+l);P=h(a,m+v);Y=h(a,m+z);m=k(a,m+J);THREE.Loader.prototype.f4(w,
q,D,P,Y,m)}function y(m){var q,D,P,Y,Z,fa,na,pa;q=h(a,m);D=h(a,m+l);P=h(a,m+v);Y=h(a,m+z);Z=k(a,m+J);fa=h(a,m+S);na=h(a,m+Q);pa=h(a,m+H);m=h(a,m+V);THREE.Loader.prototype.f4n(w,O,q,D,P,Y,Z,fa,na,pa,m)}function A(m){var q,D;q=h(a,m);D=h(a,m+M);m=h(a,m+W);THREE.Loader.prototype.uv3(w,L[q*2],L[q*2+1],L[D*2],L[D*2+1],L[m*2],L[m*2+1])}function I(m){var q,D,P;q=h(a,m);D=h(a,m+N);P=h(a,m+F);m=h(a,m+G);THREE.Loader.prototype.uv4(w,L[q*2],L[q*2+1],L[D*2],L[D*2+1],L[P*2],L[P*2+1],L[m*2],L[m*2+1])}var w=this,
C=0,n,O=[],L=[],T,i,o,s,p,u,l,v,z,J,S,Q,H,V,M,W,N,F,G;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,f);n={signature:a.substr(C,8),header_bytes:c(a,C+8),vertex_coordinate_bytes:c(a,C+9),normal_coordinate_bytes:c(a,C+10),uv_coordinate_bytes:c(a,C+11),vertex_index_bytes:c(a,C+12),normal_index_bytes:c(a,C+13),uv_index_bytes:c(a,C+14),material_index_bytes:c(a,C+15),nvertices:h(a,C+16),nnormals:h(a,C+16+4),nuvs:h(a,C+16+8),ntri_flat:h(a,C+16+12),ntri_smooth:h(a,C+16+16),ntri_flat_uv:h(a,
C+16+20),ntri_smooth_uv:h(a,C+16+24),nquad_flat:h(a,C+16+28),nquad_smooth:h(a,C+16+32),nquad_flat_uv:h(a,C+16+36),nquad_smooth_uv:h(a,C+16+40)};C+=n.header_bytes;T=n.vertex_index_bytes;i=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;s=n.vertex_index_bytes*3+n.material_index_bytes;p=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;u=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;l=n.vertex_index_bytes;v=n.vertex_index_bytes*2;z=n.vertex_index_bytes*3;J=n.vertex_index_bytes*
4;S=n.vertex_index_bytes*4+n.material_index_bytes;Q=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;H=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;M=n.uv_index_bytes;W=n.uv_index_bytes*2;N=n.uv_index_bytes;F=n.uv_index_bytes*2;G=n.uv_index_bytes*3;C+=function(m){var q,D,P,Y=n.vertex_coordinate_bytes*3,Z=m+n.nvertices*Y;for(m=m;m<Z;m+=Y){q=j(a,m);D=j(a,m+n.vertex_coordinate_bytes);P=j(a,
m+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,q,D,P)}return n.nvertices*Y}(C);C+=function(m){var q,D,P,Y=n.normal_coordinate_bytes*3,Z=m+n.nnormals*Y;for(m=m;m<Z;m+=Y){q=x(a,m);D=x(a,m+n.normal_coordinate_bytes);P=x(a,m+n.normal_coordinate_bytes*2);O.push(q/127,D/127,P/127)}return n.nnormals*Y}(C);C+=function(m){var q,D,P=n.uv_coordinate_bytes*2,Y=m+n.nuvs*P;for(m=m;m<Y;m+=P){q=j(a,m);D=j(a,m+n.uv_coordinate_bytes);L.push(q,D)}return n.nuvs*P}(C);C+=function(m){var q,D=n.vertex_index_bytes*
3+n.material_index_bytes,P=m+n.ntri_flat*D;for(q=m;q<P;q+=D)B(q);return P-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,P=m+n.ntri_smooth*D;for(q=m;q<P;q+=D)r(q);return P-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*3+n.material_index_bytes,P=D+n.uv_index_bytes*3,Y=m+n.ntri_flat_uv*P;for(q=m;q<Y;q+=P){B(q);A(q+D)}return Y-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,P=D+n.uv_index_bytes*3,
Y=m+n.ntri_smooth_uv*P;for(q=m;q<Y;q+=P){r(q);A(q+D)}return Y-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*4+n.material_index_bytes,P=m+n.nquad_flat*D;for(q=m;q<P;q+=D)t(q);return P-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,P=m+n.nquad_smooth*D;for(q=m;q<P;q+=D)y(q);return P-m}(C);C+=function(m){var q,D=n.vertex_index_bytes*4+n.material_index_bytes,P=D+n.uv_index_bytes*4,Y=m+n.nquad_flat_uv*P;for(q=m;q<Y;q+=P){t(q);I(q+D)}return Y-m}(C);
C+=function(m){var q,D=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,P=D+n.uv_index_bytes*4,Y=m+n.nquad_smooth_uv*P;for(q=m;q<Y;q+=P){y(q);I(q+D)}return Y-m}(C);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 d=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var j,h,k,x,c;j=0;for(h=
2)h=f.getResponseHeader("Content-Length")};f.open("GET",j,true);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)},createBinModel:function(a,b,e,d){var g=function(f){function j(l,p){var z=c(l,p),L=c(l,p+1),S=c(l,p+2),ca=c(l,p+3),ga=(ca<<1&255|S>>7)-127;z=(S&127)<<16|L<<8|z;if(z==0&&ga==-127)return 0;return(1-2*(ca>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ga)}function h(l,p){var z=c(l,p),L=c(l,p+1),S=c(l,p+2);return(c(l,p+3)<<24)+(S<<
16)+(L<<8)+z}function k(l,p){var z=c(l,p);return(c(l,p+1)<<8)+z}function x(l,p){var z=c(l,p);return z>127?z-256:z}function c(l,p){return l.charCodeAt(p)&255}function C(l){var p,z,L;p=h(a,l);z=h(a,l+U);L=h(a,l+i);l=k(a,l+m);THREE.Loader.prototype.f3(w,p,z,L,l)}function r(l){var p,z,L,S,ca,ga;p=h(a,l);z=h(a,l+U);L=h(a,l+i);S=k(a,l+m);ca=h(a,l+s);ga=h(a,l+o);l=h(a,l+u);THREE.Loader.prototype.f3n(w,P,p,z,L,S,ca,ga,l)}function t(l){var p,z,L,S;p=h(a,l);z=h(a,l+q);L=h(a,l+v);S=h(a,l+B);l=k(a,l+R);THREE.Loader.prototype.f4(w,
p,z,L,S,l)}function y(l){var p,z,L,S,ca,ga,oa,ea;p=h(a,l);z=h(a,l+q);L=h(a,l+v);S=h(a,l+B);ca=k(a,l+R);ga=h(a,l+F);oa=h(a,l+W);ea=h(a,l+H);l=h(a,l+I);THREE.Loader.prototype.f4n(w,P,p,z,L,S,ca,ga,oa,ea,l)}function A(l){var p,z;p=h(a,l);z=h(a,l+K);l=h(a,l+X);THREE.Loader.prototype.uv3(w,O[p*2],O[p*2+1],O[z*2],O[z*2+1],O[l*2],O[l*2+1])}function G(l){var p,z,L;p=h(a,l);z=h(a,l+M);L=h(a,l+Q);l=h(a,l+N);THREE.Loader.prototype.uv4(w,O[p*2],O[p*2+1],O[z*2],O[z*2+1],O[L*2],O[L*2+1],O[l*2],O[l*2+1])}var w=
this,D=0,n,P=[],O=[],U,i,m,s,o,u,q,v,B,R,F,W,H,I,K,X,M,Q,N;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,f);n={signature:a.substr(D,8),header_bytes:c(a,D+8),vertex_coordinate_bytes:c(a,D+9),normal_coordinate_bytes:c(a,D+10),uv_coordinate_bytes:c(a,D+11),vertex_index_bytes:c(a,D+12),normal_index_bytes:c(a,D+13),uv_index_bytes:c(a,D+14),material_index_bytes:c(a,D+15),nvertices:h(a,D+16),nnormals:h(a,D+16+4),nuvs:h(a,D+16+8),ntri_flat:h(a,D+16+12),ntri_smooth:h(a,D+16+16),ntri_flat_uv:h(a,
D+16+20),ntri_smooth_uv:h(a,D+16+24),nquad_flat:h(a,D+16+28),nquad_smooth:h(a,D+16+32),nquad_flat_uv:h(a,D+16+36),nquad_smooth_uv:h(a,D+16+40)};D+=n.header_bytes;U=n.vertex_index_bytes;i=n.vertex_index_bytes*2;m=n.vertex_index_bytes*3;s=n.vertex_index_bytes*3+n.material_index_bytes;o=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;u=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;q=n.vertex_index_bytes;v=n.vertex_index_bytes*2;B=n.vertex_index_bytes*3;R=n.vertex_index_bytes*
4;F=n.vertex_index_bytes*4+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;H=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;I=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;K=n.uv_index_bytes;X=n.uv_index_bytes*2;M=n.uv_index_bytes;Q=n.uv_index_bytes*2;N=n.uv_index_bytes*3;D+=function(l){var p,z,L,S=n.vertex_coordinate_bytes*3,ca=l+n.nvertices*S;for(l=l;l<ca;l+=S){p=j(a,l);z=j(a,l+n.vertex_coordinate_bytes);L=
j(a,l+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,p,z,L)}return n.nvertices*S}(D);D+=function(l){var p,z,L,S=n.normal_coordinate_bytes*3,ca=l+n.nnormals*S;for(l=l;l<ca;l+=S){p=x(a,l);z=x(a,l+n.normal_coordinate_bytes);L=x(a,l+n.normal_coordinate_bytes*2);P.push(p/127,z/127,L/127)}return n.nnormals*S}(D);D+=function(l){var p,z,L=n.uv_coordinate_bytes*2,S=l+n.nuvs*L;for(l=l;l<S;l+=L){p=j(a,l);z=j(a,l+n.uv_coordinate_bytes);O.push(p,z)}return n.nuvs*L}(D);D+=function(l){var p,z=n.vertex_index_bytes*
3+n.material_index_bytes,L=l+n.ntri_flat*z;for(p=l;p<L;p+=z)C(p);return L-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,L=l+n.ntri_smooth*z;for(p=l;p<L;p+=z)r(p);return L-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*3+n.material_index_bytes,L=z+n.uv_index_bytes*3,S=l+n.ntri_flat_uv*L;for(p=l;p<S;p+=L){C(p);A(p+z)}return S-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,L=z+n.uv_index_bytes*3,
S=l+n.ntri_smooth_uv*L;for(p=l;p<S;p+=L){r(p);A(p+z)}return S-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*4+n.material_index_bytes,L=l+n.nquad_flat*z;for(p=l;p<L;p+=z)t(p);return L-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,L=l+n.nquad_smooth*z;for(p=l;p<L;p+=z)y(p);return L-l}(D);D+=function(l){var p,z=n.vertex_index_bytes*4+n.material_index_bytes,L=z+n.uv_index_bytes*4,S=l+n.nquad_flat_uv*L;for(p=l;p<S;p+=L){t(p);G(p+z)}return S-l}(D);
D+=function(l){var p,z=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,L=z+n.uv_index_bytes*4,S=l+n.nquad_smooth_uv*L;for(p=l;p<S;p+=L){y(p);G(p+z)}return S-l}(D);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 d=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var j,h,k,x,c;j=0;for(h=
a.vertices.length;j<h;j+=3){k=a.vertices[j];x=a.vertices[j+1];c=a.vertices[j+2];THREE.Loader.prototype.v(f,k,x,c)}})();(function(){function j(y,A){THREE.Loader.prototype.f3(f,y[A],y[A+1],y[A+2],y[A+3])}function h(y,A){THREE.Loader.prototype.f3n(f,a.normals,y[A],y[A+1],y[A+2],y[A+3],y[A+4],y[A+5],y[A+6])}function k(y,A){THREE.Loader.prototype.f4(f,y[A],y[A+1],y[A+2],y[A+3],y[A+4])}function x(y,A){THREE.Loader.prototype.f4n(f,a.normals,y[A],y[A+1],y[A+2],y[A+3],y[A+4],y[A+5],y[A+6],y[A+7],y[A+8])}function c(y,
A){var I,w,C;I=y[A];w=y[A+1];C=y[A+2];THREE.Loader.prototype.uv3(f,a.uvs[I*2],a.uvs[I*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[C*2],a.uvs[C*2+1])}function B(y,A){var I,w,C,n;I=y[A];w=y[A+1];C=y[A+2];n=y[A+3];THREE.Loader.prototype.uv4(f,a.uvs[I*2],a.uvs[I*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[C*2],a.uvs[C*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,t;r=0;for(t=a.triangles.length;r<t;r+=4)j(a.triangles,r);r=0;for(t=a.triangles_uv.length;r<t;r+=7){j(a.triangles_uv,r);c(a.triangles_uv,r+4)}r=0;for(t=a.triangles_n.length;r<
t;r+=7)h(a.triangles_n,r);r=0;for(t=a.triangles_n_uv.length;r<t;r+=10){h(a.triangles_n_uv,r);c(a.triangles_n_uv,r+7)}r=0;for(t=a.quads.length;r<t;r+=5)k(a.quads,r);r=0;for(t=a.quads_uv.length;r<t;r+=9){k(a.quads_uv,r);B(a.quads_uv,r+5)}r=0;for(t=a.quads_n.length;r<t;r+=9)x(a.quads_n,r);r=0;for(t=a.quads_n_uv.length;r<t;r+=13){x(a.quads_n_uv,r);B(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,g){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[g]))},f4:function(a,b,e,d,g,f){a.faces.push(new THREE.Face4(b,e,d,g,null,a.materials[f]))},f3n:function(a,b,e,d,g,f,j,h,k){f=a.materials[f];var x=b[h*3],c=b[h*3+1];h=b[h*3+2];var B=b[k*3],r=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(e,d,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(x,c,h),new THREE.Vector3(B,
r,k)],f))},f4n:function(a,b,e,d,g,f,j,h,k,x,c){j=a.materials[j];var B=b[k*3],r=b[k*3+1];k=b[k*3+2];var t=b[x*3],y=b[x*3+1];x=b[x*3+2];var A=b[c*3],I=b[c*3+1];c=b[c*3+2];a.faces.push(new THREE.Face4(e,d,g,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(B,r,k),new THREE.Vector3(t,y,x),new THREE.Vector3(A,I,c)],j))},uv3:function(a,b,e,d,g,f,j){var h=[];h.push(new THREE.UV(b,e));h.push(new THREE.UV(d,g));h.push(new THREE.UV(f,j));a.uvs.push(h)},uv4:function(a,b,e,d,g,f,j,h,k){var x=[];
A){var G,w,D;G=y[A];w=y[A+1];D=y[A+2];THREE.Loader.prototype.uv3(f,a.uvs[G*2],a.uvs[G*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[D*2],a.uvs[D*2+1])}function C(y,A){var G,w,D,n;G=y[A];w=y[A+1];D=y[A+2];n=y[A+3];THREE.Loader.prototype.uv4(f,a.uvs[G*2],a.uvs[G*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[D*2],a.uvs[D*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,t;r=0;for(t=a.triangles.length;r<t;r+=4)j(a.triangles,r);r=0;for(t=a.triangles_uv.length;r<t;r+=7){j(a.triangles_uv,r);c(a.triangles_uv,r+4)}r=0;for(t=a.triangles_n.length;r<
t;r+=7)h(a.triangles_n,r);r=0;for(t=a.triangles_n_uv.length;r<t;r+=10){h(a.triangles_n_uv,r);c(a.triangles_n_uv,r+7)}r=0;for(t=a.quads.length;r<t;r+=5)k(a.quads,r);r=0;for(t=a.quads_uv.length;r<t;r+=9){k(a.quads_uv,r);C(a.quads_uv,r+5)}r=0;for(t=a.quads_n.length;r<t;r+=9)x(a.quads_n,r);r=0;for(t=a.quads_n_uv.length;r<t;r+=13){x(a.quads_n_uv,r);C(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,g){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[g]))},f4:function(a,b,e,d,g,f){a.faces.push(new THREE.Face4(b,e,d,g,null,a.materials[f]))},f3n:function(a,b,e,d,g,f,j,h,k){f=a.materials[f];var x=b[h*3],c=b[h*3+1];h=b[h*3+2];var C=b[k*3],r=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(e,d,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(x,c,h),new THREE.Vector3(C,
r,k)],f))},f4n:function(a,b,e,d,g,f,j,h,k,x,c){j=a.materials[j];var C=b[k*3],r=b[k*3+1];k=b[k*3+2];var t=b[x*3],y=b[x*3+1];x=b[x*3+2];var A=b[c*3],G=b[c*3+1];c=b[c*3+2];a.faces.push(new THREE.Face4(e,d,g,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(C,r,k),new THREE.Vector3(t,y,x),new THREE.Vector3(A,G,c)],j))},uv3:function(a,b,e,d,g,f,j){var h=[];h.push(new THREE.UV(b,e));h.push(new THREE.UV(d,g));h.push(new THREE.UV(f,j));a.uvs.push(h)},uv4:function(a,b,e,d,g,f,j,h,k){var x=[];
x.push(new THREE.UV(b,e));x.push(new THREE.UV(d,g));x.push(new THREE.UV(f,j));x.push(new THREE.UV(h,k));a.uvs.push(x)},init_materials:function(a,b,e){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],e)]},createMaterial:function(a,b){function e(f){f=Math.log(f)/Math.LN2;return Math.floor(f)==f}var d,g;if(a.map_diffuse&&b){g=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!e(this.width)||
!e(this.height)){var f=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),j=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));d.map.image.width=f;d.map.image.height=j;d.map.image.getContext("2d").drawImage(this,0,0,f,j)}else d.map.image=this;d.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;d=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else d=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
new THREE.MeshLambertMaterial({color:15658734});return d}};
+1 -1
View File
@@ -41,7 +41,7 @@
info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - orthographic view';
container.appendChild( info );
camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, - 2000, 1000 );
camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 1000 );
camera.position.x = 200;
camera.position.y = 100;
+14 -12
View File
@@ -29,6 +29,7 @@
var particleLight, pointLight;
init();
// loop();
setInterval( loop, 1000 / 60 );
function init() {
@@ -69,18 +70,19 @@
var geometry = new Sphere( 100, 14, 7, false );
var materials = [];
materials.push( { material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true } );
//materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ), overdraw: false, doubleSided: true } );
materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true } );
materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
// materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } );
var materials = [
{ material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true },
{ material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true },
{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false },
{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false },
{ material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false },
{ material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false },
{ material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
{ material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
{ material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false }
];
for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
+1 -1
View File
@@ -73,7 +73,7 @@
// Plane
var material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } );
var material = new THREE.MeshDepthMaterial();
plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
plane.rotation.x = - 90 * ( Math.PI / 180 );
+2 -2
View File
@@ -16,7 +16,7 @@
<body>
<pre id="log"></pre>
<script type="text/javascript" src="../build/ThreeExtras.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
@@ -78,7 +78,7 @@
materials.push( { material: new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ), overdraw: false, doubleSided: true } );
materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
materials.push( { material: new THREE.MeshLambertMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
+14 -1
View File
@@ -4,13 +4,18 @@
THREE.Camera = function ( fov, aspect, near, far ) {
this.fov = fov;
this.aspect = aspect;
this.near = near;
this.far = far;
this.position = new THREE.Vector3();
this.target = { position: new THREE.Vector3() };
this.up = new THREE.Vector3( 0, 1, 0 );
this.matrix = new THREE.Matrix4();
this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far );
this.projectionMatrix = null;
this.autoUpdateMatrix = true;
@@ -45,6 +50,14 @@ THREE.Camera = function ( fov, aspect, near, far ) {
};
this.updateProjectionMatrix = function () {
this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
};
this.updateProjectionMatrix();
this.toString = function () {
return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';
+1 -1
View File
@@ -13,7 +13,7 @@ THREE.Vertex = function ( position, normal ) {
this.normalScreen = new THREE.Vector3();
this.tangent = new THREE.Vector4();
this.__visible = true;
}
-11
View File
@@ -2,8 +2,6 @@
* @author mr.doob / http://mrdoob.com/
*
* parameters = {
* near: <float>,
* far: <float>,
* opacity: <float>,
* blending: THREE.NormalBlending
* }
@@ -11,9 +9,6 @@
THREE.MeshDepthMaterial = function ( parameters ) {
this.near = 1;
this.far = 1000;
this.opacity = 1;
this.shading = THREE.SmoothShading;
this.blending = THREE.NormalBlending;
@@ -25,17 +20,11 @@ THREE.MeshDepthMaterial = function ( parameters ) {
if ( parameters ) {
if ( parameters.near !== undefined ) this.near = parameters.near;
if ( parameters.far !== undefined ) this.far = parameters.far;
if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
if ( parameters.blending !== undefined ) this.blending = parameters.blending;
}
this.__2near = 2 * this.near;
this.__farPlusNear = this.far + this.near;
this.__farMinusNear = this.far - this.near;
};
THREE.MeshDepthMaterial.prototype = {
+19 -7
View File
@@ -25,7 +25,8 @@ THREE.CanvasRenderer = function () {
_color2 = new THREE.Color(),
_color3 = new THREE.Color(),
_color4 = new THREE.Color(),
_2near, _farPlusNear, _farMinusNear,
_near, _far,
_bitmap,
_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
@@ -575,13 +576,12 @@ THREE.CanvasRenderer = function () {
_color.setRGB( _w, _w, _w );
*/
_2near = material.__2near;
_farPlusNear = material.__farPlusNear;
_farMinusNear = material.__farMinusNear;
_near = camera.near;
_far = camera.far;
_color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) );
_color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) );
_color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) );
_color1.r = _color1.g = _color1.b = 1 - smoothstep( v1.positionScreen.z, _near, _far );
_color2.r = _color2.g = _color2.b = 1 - smoothstep( v2.positionScreen.z, _near, _far );
_color3.r = _color3.g = _color3.b = 1 - smoothstep( v3.positionScreen.z, _near, _far );
_color4.r = ( _color2.r + _color3.r ) * 0.5;
_color4.g = ( _color2.g + _color3.g ) * 0.5;
@@ -789,6 +789,18 @@ THREE.CanvasRenderer = function () {
}
function smoothstep( value, min, max ) {
/*
if ( value <= min ) return 0;
if ( value >= max ) return 1;
*/
var x = ( value - min ) / ( max - min );
return x * x * ( 3 - 2 * x );
}
function normalToComponent( normal ) {
var component = ( normal + 1 ) * 0.5;
+5 -7
View File
@@ -64,7 +64,7 @@ THREE.Projector = function() {
this.projectScene = function ( scene, camera, sort ) {
var renderList = [],
var renderList = [], near = camera.near, far = camera.far,
o, ol, v, vl, f, fl, n, nl, objects, object,
objectMatrix, objectRotationMatrix, objectMaterials, objectOverdraw,
geometry, vertices, vertex, vertexPositionScreen,
@@ -99,7 +99,7 @@ THREE.Projector = function() {
vertices = geometry.vertices;
for ( v = 0, vl = vertices.length; v < vl; v++ ) {
for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
vertex = vertices[ v ];
@@ -110,12 +110,10 @@ THREE.Projector = function() {
vertexPositionScreen.copy( vertex.positionWorld );
_projScreenMatrix.multiplyVector4( vertexPositionScreen );
// Perform the perspective divide. TODO: This should be be performend
// post clipping (imagine if the vertex lies at the same location as
// the camera, causing a divide by w = 0).
vertexPositionScreen.multiplyScalar( 1 / vertexPositionScreen.w );
vertexPositionScreen.x /= vertexPositionScreen.w;
vertexPositionScreen.y /= vertexPositionScreen.w;
vertex.__visible = vertexPositionScreen.z > 0 && vertexPositionScreen.z < 1;
vertex.__visible = vertexPositionScreen.z > near && vertexPositionScreen.z < far;
}
+2 -2
View File
@@ -390,8 +390,8 @@ THREE.WebGLRenderer = function ( scene, antialias ) {
setMaterialShaders( material, ShaderLib[ 'depth' ] );
material.uniforms.mNear.value = material.near;
material.uniforms.mFar.value = material.far;
material.uniforms.mNear.value = camera.near;
material.uniforms.mFar.value = camera.far;
} else if ( material instanceof THREE.MeshNormalMaterial ) {
+2 -2
View File
@@ -189,8 +189,8 @@ THREE.WebGLRenderer2 = function ( antialias ) {
} else if ( material instanceof THREE.MeshDepthMaterial ) {
_gl.uniform1f( uniforms.mNear, material.near );
_gl.uniform1f( uniforms.mFar, material.far );
_gl.uniform1f( uniforms.mNear, camera.near );
_gl.uniform1f( uniforms.mFar, camera.far );
_gl.uniform1f( uniforms.mOpacity, material.opacity );
}