!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3927)}({1302:function(t,e){t.exports=function(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1303:function(t,e){t.exports=function(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}},1304:function(t,e){t.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}},1305:function(t,e){t.exports=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}},1306:function(t,e){t.exports=function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],f=e[10],p=e[11],d=e[12],m=e[13],v=e[14],g=e[15],y=r*s-n*a,x=r*u-i*a,w=r*c-o*a,b=n*u-i*s,M=n*c-o*s,_=i*c-o*u,E=h*m-l*d,S=h*v-f*d,A=h*g-p*d,T=l*v-f*m,L=l*g-p*m,R=f*g-p*v,C=y*R-x*L+w*T+b*A-M*S+_*E;if(!C)return null;return C=1/C,t[0]=(s*R-u*L+c*T)*C,t[1]=(i*L-n*R-o*T)*C,t[2]=(m*_-v*M+g*b)*C,t[3]=(f*M-l*_-p*b)*C,t[4]=(u*A-a*R-c*S)*C,t[5]=(r*R-i*A+o*S)*C,t[6]=(v*w-d*_-g*x)*C,t[7]=(h*_-f*w+p*x)*C,t[8]=(a*L-s*A+c*E)*C,t[9]=(n*A-r*L-o*E)*C,t[10]=(d*M-m*w+g*y)*C,t[11]=(l*w-h*M-p*y)*C,t[12]=(s*S-a*T-u*E)*C,t[13]=(r*T-n*S+i*E)*C,t[14]=(m*x-d*b-v*y)*C,t[15]=(h*b-l*x+f*y)*C,t}},1307:function(t,e){t.exports=function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],h=e[8],l=e[9],f=e[10],p=e[11],d=e[12],m=e[13],v=e[14],g=e[15];return t[0]=s*(f*g-p*v)-l*(u*g-c*v)+m*(u*p-c*f),t[1]=-(n*(f*g-p*v)-l*(i*g-o*v)+m*(i*p-o*f)),t[2]=n*(u*g-c*v)-s*(i*g-o*v)+m*(i*c-o*u),t[3]=-(n*(u*p-c*f)-s*(i*p-o*f)+l*(i*c-o*u)),t[4]=-(a*(f*g-p*v)-h*(u*g-c*v)+d*(u*p-c*f)),t[5]=r*(f*g-p*v)-h*(i*g-o*v)+d*(i*p-o*f),t[6]=-(r*(u*g-c*v)-a*(i*g-o*v)+d*(i*c-o*u)),t[7]=r*(u*p-c*f)-a*(i*p-o*f)+h*(i*c-o*u),t[8]=a*(l*g-p*m)-h*(s*g-c*m)+d*(s*p-c*l),t[9]=-(r*(l*g-p*m)-h*(n*g-o*m)+d*(n*p-o*l)),t[10]=r*(s*g-c*m)-a*(n*g-o*m)+d*(n*c-o*s),t[11]=-(r*(s*p-c*l)-a*(n*p-o*l)+h*(n*c-o*s)),t[12]=-(a*(l*v-f*m)-h*(s*v-u*m)+d*(s*f-u*l)),t[13]=r*(l*v-f*m)-h*(n*v-i*m)+d*(n*f-i*l),t[14]=-(r*(s*v-u*m)-a*(n*v-i*m)+d*(n*u-i*s)),t[15]=r*(s*f-u*l)-a*(n*f-i*l)+h*(n*u-i*s),t}},1308:function(t,e){t.exports=function(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],s=t[6],u=t[7],c=t[8],h=t[9],l=t[10],f=t[11],p=t[12],d=t[13],m=t[14],v=t[15];return(e*a-r*o)*(l*v-f*m)-(e*s-n*o)*(h*v-f*d)+(e*u-i*o)*(h*m-l*d)+(r*s-n*a)*(c*v-f*p)-(r*u-i*a)*(c*m-l*p)+(n*u-i*s)*(c*d-h*p)}},1309:function(t,e){t.exports=function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],f=e[9],p=e[10],d=e[11],m=e[12],v=e[13],g=e[14],y=e[15],x=r[0],w=r[1],b=r[2],M=r[3];return t[0]=x*n+w*s+b*l+M*m,t[1]=x*i+w*u+b*f+M*v,t[2]=x*o+w*c+b*p+M*g,t[3]=x*a+w*h+b*d+M*y,x=r[4],w=r[5],b=r[6],M=r[7],t[4]=x*n+w*s+b*l+M*m,t[5]=x*i+w*u+b*f+M*v,t[6]=x*o+w*c+b*p+M*g,t[7]=x*a+w*h+b*d+M*y,x=r[8],w=r[9],b=r[10],M=r[11],t[8]=x*n+w*s+b*l+M*m,t[9]=x*i+w*u+b*f+M*v,t[10]=x*o+w*c+b*p+M*g,t[11]=x*a+w*h+b*d+M*y,x=r[12],w=r[13],b=r[14],M=r[15],t[12]=x*n+w*s+b*l+M*m,t[13]=x*i+w*u+b*f+M*v,t[14]=x*o+w*c+b*p+M*g,t[15]=x*a+w*h+b*d+M*y,t}},1310:function(t,e){t.exports=function(t,e,r){var n,i,o,a,s,u,c,h,l,f,p,d,m=r[0],v=r[1],g=r[2];e===t?(t[12]=e[0]*m+e[4]*v+e[8]*g+e[12],t[13]=e[1]*m+e[5]*v+e[9]*g+e[13],t[14]=e[2]*m+e[6]*v+e[10]*g+e[14],t[15]=e[3]*m+e[7]*v+e[11]*g+e[15]):(n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],h=e[7],l=e[8],f=e[9],p=e[10],d=e[11],t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=u,t[6]=c,t[7]=h,t[8]=l,t[9]=f,t[10]=p,t[11]=d,t[12]=n*m+s*v+l*g+e[12],t[13]=i*m+u*v+f*g+e[13],t[14]=o*m+c*v+p*g+e[14],t[15]=a*m+h*v+d*g+e[15]);return t}},1311:function(t,e){t.exports=function(t,e,r){var n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}},1312:function(t,e){t.exports=function(t,e,r,n){var i,o,a,s,u,c,h,l,f,p,d,m,v,g,y,x,w,b,M,_,E,S,A,T,L=n[0],R=n[1],C=n[2],P=Math.sqrt(L*L+R*R+C*C);if(Math.abs(P)<1e-6)return null;L*=P=1/P,R*=P,C*=P,i=Math.sin(r),o=Math.cos(r),a=1-o,s=e[0],u=e[1],c=e[2],h=e[3],l=e[4],f=e[5],p=e[6],d=e[7],m=e[8],v=e[9],g=e[10],y=e[11],x=L*L*a+o,w=R*L*a+C*i,b=C*L*a-R*i,M=L*R*a-C*i,_=R*R*a+o,E=C*R*a+L*i,S=L*C*a+R*i,A=R*C*a-L*i,T=C*C*a+o,t[0]=s*x+l*w+m*b,t[1]=u*x+f*w+v*b,t[2]=c*x+p*w+g*b,t[3]=h*x+d*w+y*b,t[4]=s*M+l*_+m*E,t[5]=u*M+f*_+v*E,t[6]=c*M+p*_+g*E,t[7]=h*M+d*_+y*E,t[8]=s*S+l*A+m*T,t[9]=u*S+f*A+v*T,t[10]=c*S+p*A+g*T,t[11]=h*S+d*A+y*T,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t}},1313:function(t,e){t.exports=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],h=e[9],l=e[10],f=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t[4]=o*i+c*n,t[5]=a*i+h*n,t[6]=s*i+l*n,t[7]=u*i+f*n,t[8]=c*i-o*n,t[9]=h*i-a*n,t[10]=l*i-s*n,t[11]=f*i-u*n,t}},1314:function(t,e){t.exports=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],u=e[3],c=e[8],h=e[9],l=e[10],f=e[11];e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t[0]=o*i-c*n,t[1]=a*i-h*n,t[2]=s*i-l*n,t[3]=u*i-f*n,t[8]=o*n+c*i,t[9]=a*n+h*i,t[10]=s*n+l*i,t[11]=u*n+f*i,t}},1315:function(t,e){t.exports=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],u=e[3],c=e[4],h=e[5],l=e[6],f=e[7];e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t[0]=o*i+c*n,t[1]=a*i+h*n,t[2]=s*i+l*n,t[3]=u*i+f*n,t[4]=c*i-o*n,t[5]=h*i-a*n,t[6]=l*i-s*n,t[7]=f*i-u*n,t}},1316:function(t,e){t.exports=function(t,e,r){var n,i,o,a=r[0],s=r[1],u=r[2],c=Math.sqrt(a*a+s*s+u*u);if(Math.abs(c)<1e-6)return null;return a*=c=1/c,s*=c,u*=c,n=Math.sin(e),i=Math.cos(e),o=1-i,t[0]=a*a*o+i,t[1]=s*a*o+u*n,t[2]=u*a*o-s*n,t[3]=0,t[4]=a*s*o-u*n,t[5]=s*s*o+i,t[6]=u*s*o+a*n,t[7]=0,t[8]=a*u*o+s*n,t[9]=s*u*o-a*n,t[10]=u*u*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1317:function(t,e){t.exports=function(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=n+n,u=i+i,c=o+o,h=n*s,l=n*u,f=n*c,p=i*u,d=i*c,m=o*c,v=a*s,g=a*u,y=a*c;return t[0]=1-(p+m),t[1]=l+y,t[2]=f-g,t[3]=0,t[4]=l-y,t[5]=1-(h+m),t[6]=d+v,t[7]=0,t[8]=f+g,t[9]=d-v,t[10]=1-(h+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}},1318:function(t,e){t.exports=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1319:function(t,e){t.exports=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}},1320:function(t,e){t.exports=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1321:function(t,e){t.exports=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1322:function(t,e){t.exports=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1323:function(t,e){t.exports=function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,u=i+i,c=r*a,h=n*a,l=n*s,f=i*a,p=i*s,d=i*u,m=o*a,v=o*s,g=o*u;return t[0]=1-l-d,t[1]=h+g,t[2]=f-v,t[3]=0,t[4]=h-g,t[5]=1-c-d,t[6]=p+m,t[7]=0,t[8]=f+v,t[9]=p-m,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}},1324:function(t,e){t.exports=function(t,e,r,n,i,o,a){var s=1/(r-e),u=1/(i-n),c=1/(o-a);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*u,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*u,t[10]=(a+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*c,t[15]=0,t}},1325:function(t,e){t.exports=function(t,e,r,n,i){var o=1/Math.tan(e/2),a=1/(n-i);return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*a,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*a,t[15]=0,t}},1326:function(t,e){t.exports=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),u=2/(a+s),c=2/(i+o);return t[0]=u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(a-s)*u*.5,t[9]=(i-o)*c*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}},1327:function(t,e){t.exports=function(t,e,r,n,i,o,a){var s=1/(e-r),u=1/(n-i),c=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*u,t[14]=(a+o)*c,t[15]=1,t}},1328:function(t,e){t.exports=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}},1329:function(t,e){t.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},1330:function(t,e,r){t.exports=function(t,e){var r=n(t[0],t[1],t[2]),a=n(e[0],e[1],e[2]);i(r,r),i(a,a);var s=o(r,a);return s>1?0:Math.acos(s)};var n=r(526),i=r(349),o=r(350)},1331:function(t,e){t.exports=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}},1332:function(t,e,r){t.exports=function(t,e){var r=t[0],i=t[1],o=t[2],a=e[0],s=e[1],u=e[2];return Math.abs(r-a)<=n*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(o-u)<=n*Math.max(1,Math.abs(o),Math.abs(u))};var n=r(524)},1333:function(t,e){t.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},1334:function(t,e,r){t.exports=r(333)},1335:function(t,e,r){t.exports=r(527)},1336:function(t,e,r){t.exports=r(528)},1337:function(t,e){t.exports=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}},1338:function(t,e){t.exports=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}},1339:function(t,e){t.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},1340:function(t,e){t.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},1341:function(t,e){t.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},1342:function(t,e,r){t.exports=r(381)},1343:function(t,e,r){t.exports=r(382)},1344:function(t,e,r){t.exports=r(383)},1345:function(t,e,r){t.exports=r(384)},1346:function(t,e){t.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}},1347:function(t,e){t.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}},1348:function(t,e){t.exports=function(t,e,r,n){var i=e[0],o=e[1],a=e[2];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=a+n*(r[2]-a),t}},1349:function(t,e){t.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t}},135:function(t,e,r){"use strict";var n=r(529),i=r(334);t.exports={convert:function(t,e,r){if(e=void 0===e?n.TYPED_ARRAY:e,-1===[n.FLAT_ARRAY,n.ARRAY_OF_ARRAYS,n.TYPED_ARRAY,n.ARRAY_OF_TYPED_ARRAYS,n.NDARRAY].indexOf(e))throw new Error("geo-convert-position-format: Unknown target format "+e);var o,a=n.identify(t);if(a===n.FLAT_ARRAY)o=new Float32Array(t);else if(a===n.TYPED_ARRAY)o=new Float32Array(t);else if(a===n.ARRAY_OF_ARRAYS){o=[];for(var s=0;s * @license MIT */ t.exports=function(t){return null!=t&&(r(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&r(t.slice(0,0))}(t)||!!t._isBuffer)}},1361:function(t,e,r){"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){for(var e,r=c(t),n=r[0],a=r[1],s=new o(function(t,e,r){return 3*(e+r)/4-r}(0,n,a)),u=0,h=a>0?n-4:n,l=0;l>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,s[u++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function l(t,e,r){for(var n,i=[],o=e;o>1,h=-7,l=r?i-1:0,f=r?-1:1,p=t[e+l];for(l+=f,o=p&(1<<-h)-1,p>>=-h,h+=s;h>0;o=256*o+t[e+l],l+=f,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+l],l+=f,h-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,h=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=h?(s=0,a=h):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*m}},1363:function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},1364:function(t,e,r){"use strict";var n=r(1365);t.exports=function(t){var e=new function(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1};e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},1365:function(t,e,r){"use strict";var n=r(1366);t.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var o=[],a=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],c=[],h=0;h0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+l+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[h]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+l+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[h])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),h=0;h0,u=[],c=[],h=0,l=0;for(n=0;n0&&u.push("var "+c.join(",")),n=o-1;n>=0;--n)h=t[n],u.push(["for(i",n,"=0;i",n,"0&&u.push(["index[",l,"]-=s",l].join("")),u.push(["++index[",h,"]"].join(""))),u.push("}")}return u.join("\n")}function o(t,e,r){for(var n=t.body,i=[],o=[],a=0;a0&&y.push("shape=SS.slice(0)"),t.indexArgs.length>0){var x=new Array(r);for(u=0;u0&&g.push("var "+y.join(",")),u=0;u3&&g.push(o(t.pre,t,s));var _=o(t.body,t,s),E=function(t){for(var e=0,r=t[0].length;e0,c=[],h=0;h0;){"].join("")),c.push(["if(j",h,"<",s,"){"].join("")),c.push(["s",e[h],"=j",h].join("")),c.push(["j",h,"=0"].join("")),c.push(["}else{s",e[h],"=",s].join("")),c.push(["j",h,"-=",s,"}"].join("")),u&&c.push(["index[",e[h],"]=j",h].join(""));for(h=0;h3&&g.push(o(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+g.join("\n")+"\n----------");var S=[t.funcName||"unnamed","_cwise_loop_",a[0].join("s"),"m",E,function(t){for(var e=new Array(t.length),r=!0,n=0;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}(s)].join("");return new Function(["function ",S,"(",v.join(","),"){",g.join("\n"),"} return ",S].join(""))()}},2112:function(t,e,r){"use strict";var n=r(2582),i=r(2481);t.exports=function(t,e){var r=i(t),o=i(e);if(0===r)return[n(0),n(1)];if(0===o)return[n(0),n(0)];o<0&&(t=t.neg(),e=e.neg());var a=t.gcd(e);if(a.cmpn(1))return[t.div(a),e.div(a)];return[t,e]}},2149:function(t,e,r){"use strict";function n(t,e,r,n,i){var o=["function ",t,"(a,l,h,",n.join(","),"){",i?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a[m]"];return i?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),i?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}t.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},2150:function(t,e,r){(function(t){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var a;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{a=r(3972).Buffer}catch(t){}function s(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),a=e;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,a=o%n,s=Math.min(o,o-a)+r,c=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,l=67108863&u,f=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=f;p++){var d=c-p|0;h+=(a=(i=0|t.words[d])*(o=0|e.words[p])+l)/67108864|0,l=67108863&a}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var f=h[t],p=l[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var m=d.modn(p).toString(t);r=(d=d.idivn(p)).isZero()?m+r:c[f-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return n(void 0!==a),this.toArrayLike(a,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===e,c=new t(o),h=this.clone();if(u){for(s=0;!h.isZero();s++)a=h.andln(255),h.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==o&&a>26,this.words[a]=67108863&e;if(0===o&&a>>13,p=0|a[1],d=8191&p,m=p>>>13,v=0|a[2],g=8191&v,y=v>>>13,x=0|a[3],w=8191&x,b=x>>>13,M=0|a[4],_=8191&M,E=M>>>13,S=0|a[5],A=8191&S,T=S>>>13,L=0|a[6],R=8191&L,C=L>>>13,P=0|a[7],I=8191&P,N=P>>>13,F=0|a[8],U=8191&F,O=F>>>13,D=0|a[9],k=8191&D,B=D>>>13,z=0|s[0],j=8191&z,G=z>>>13,V=0|s[1],H=8191&V,W=V>>>13,Y=0|s[2],X=8191&Y,q=Y>>>13,Z=0|s[3],J=8191&Z,Q=Z>>>13,K=0|s[4],$=8191&K,tt=K>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],ot=8191&it,at=it>>>13,st=0|s[7],ut=8191&st,ct=st>>>13,ht=0|s[8],lt=8191&ht,ft=ht>>>13,pt=0|s[9],dt=8191&pt,mt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(c+(n=Math.imul(l,j))|0)+((8191&(i=(i=Math.imul(l,G))+Math.imul(f,j)|0))<<13)|0;c=((o=Math.imul(f,G))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(d,j),i=(i=Math.imul(d,G))+Math.imul(m,j)|0,o=Math.imul(m,G);var gt=(c+(n=n+Math.imul(l,H)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(f,H)|0))<<13)|0;c=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,j),i=(i=Math.imul(g,G))+Math.imul(y,j)|0,o=Math.imul(y,G),n=n+Math.imul(d,H)|0,i=(i=i+Math.imul(d,W)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,W)|0;var yt=(c+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,q)|0)+Math.imul(f,X)|0))<<13)|0;c=((o=o+Math.imul(f,q)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,G))+Math.imul(b,j)|0,o=Math.imul(b,G),n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(y,H)|0,o=o+Math.imul(y,W)|0,n=n+Math.imul(d,X)|0,i=(i=i+Math.imul(d,q)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,q)|0;var xt=(c+(n=n+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,Q)|0)+Math.imul(f,J)|0))<<13)|0;c=((o=o+Math.imul(f,Q)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,G))+Math.imul(E,j)|0,o=Math.imul(E,G),n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(g,X)|0,i=(i=i+Math.imul(g,q)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,q)|0,n=n+Math.imul(d,J)|0,i=(i=i+Math.imul(d,Q)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,Q)|0;var wt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(f,$)|0))<<13)|0;c=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,G))+Math.imul(T,j)|0,o=Math.imul(T,G),n=n+Math.imul(_,H)|0,i=(i=i+Math.imul(_,W)|0)+Math.imul(E,H)|0,o=o+Math.imul(E,W)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,q)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,q)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Q)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Q)|0,n=n+Math.imul(d,$)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,tt)|0;var bt=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,G))+Math.imul(C,j)|0,o=Math.imul(C,G),n=n+Math.imul(A,H)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,q)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,q)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Q)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Q)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,tt)|0,n=n+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var Mt=(c+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,at)|0)+Math.imul(f,ot)|0))<<13)|0;c=((o=o+Math.imul(f,at)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,G))+Math.imul(N,j)|0,o=Math.imul(N,G),n=n+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,q)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,q)|0,n=n+Math.imul(_,J)|0,i=(i=i+Math.imul(_,Q)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,Q)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0,n=n+Math.imul(d,ot)|0,i=(i=i+Math.imul(d,at)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,at)|0;var _t=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(f,ut)|0))<<13)|0;c=((o=o+Math.imul(f,ct)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(U,j),i=(i=Math.imul(U,G))+Math.imul(O,j)|0,o=Math.imul(O,G),n=n+Math.imul(I,H)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(N,H)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,q)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,Q)|0)+Math.imul(T,J)|0,o=o+Math.imul(T,Q)|0,n=n+Math.imul(_,$)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(E,$)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,at)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,at)|0,n=n+Math.imul(d,ut)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ct)|0;var Et=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;c=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,G))+Math.imul(B,j)|0,o=Math.imul(B,G),n=n+Math.imul(U,H)|0,i=(i=i+Math.imul(U,W)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,W)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,q)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,q)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,Q)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,Q)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,at)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,at)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0,n=n+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ft)|0)+Math.imul(m,lt)|0,o=o+Math.imul(m,ft)|0;var St=(c+(n=n+Math.imul(l,dt)|0)|0)+((8191&(i=(i=i+Math.imul(l,mt)|0)+Math.imul(f,dt)|0))<<13)|0;c=((o=o+Math.imul(f,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,W))+Math.imul(B,H)|0,o=Math.imul(B,W),n=n+Math.imul(U,X)|0,i=(i=i+Math.imul(U,q)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,q)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Q)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,Q)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0,n=n+Math.imul(g,lt)|0,i=(i=i+Math.imul(g,ft)|0)+Math.imul(y,lt)|0,o=o+Math.imul(y,ft)|0;var At=(c+(n=n+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,mt)|0)+Math.imul(m,dt)|0))<<13)|0;c=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(k,X),i=(i=Math.imul(k,q))+Math.imul(B,X)|0,o=Math.imul(B,q),n=n+Math.imul(U,J)|0,i=(i=i+Math.imul(U,Q)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Q)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(N,$)|0,o=o+Math.imul(N,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,at)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,at)|0,n=n+Math.imul(_,ut)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,ct)|0,n=n+Math.imul(w,lt)|0,i=(i=i+Math.imul(w,ft)|0)+Math.imul(b,lt)|0,o=o+Math.imul(b,ft)|0;var Tt=(c+(n=n+Math.imul(g,dt)|0)|0)+((8191&(i=(i=i+Math.imul(g,mt)|0)+Math.imul(y,dt)|0))<<13)|0;c=((o=o+Math.imul(y,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(k,J),i=(i=Math.imul(k,Q))+Math.imul(B,J)|0,o=Math.imul(B,Q),n=n+Math.imul(U,$)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,at)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,at)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ct)|0,n=n+Math.imul(_,lt)|0,i=(i=i+Math.imul(_,ft)|0)+Math.imul(E,lt)|0,o=o+Math.imul(E,ft)|0;var Lt=(c+(n=n+Math.imul(w,dt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(b,dt)|0))<<13)|0;c=((o=o+Math.imul(b,mt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(k,$),i=(i=Math.imul(k,tt))+Math.imul(B,$)|0,o=Math.imul(B,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,at)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,at)|0,n=n+Math.imul(R,ut)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(T,lt)|0,o=o+Math.imul(T,ft)|0;var Rt=(c+(n=n+Math.imul(_,dt)|0)|0)+((8191&(i=(i=i+Math.imul(_,mt)|0)+Math.imul(E,dt)|0))<<13)|0;c=((o=o+Math.imul(E,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(k,rt),i=(i=Math.imul(k,nt))+Math.imul(B,rt)|0,o=Math.imul(B,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,at)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,at)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(N,ut)|0,o=o+Math.imul(N,ct)|0,n=n+Math.imul(R,lt)|0,i=(i=i+Math.imul(R,ft)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ft)|0;var Ct=(c+(n=n+Math.imul(A,dt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(T,dt)|0))<<13)|0;c=((o=o+Math.imul(T,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(k,ot),i=(i=Math.imul(k,at))+Math.imul(B,ot)|0,o=Math.imul(B,at),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ct)|0,n=n+Math.imul(I,lt)|0,i=(i=i+Math.imul(I,ft)|0)+Math.imul(N,lt)|0,o=o+Math.imul(N,ft)|0;var Pt=(c+(n=n+Math.imul(R,dt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,dt)|0))<<13)|0;c=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(k,ut),i=(i=Math.imul(k,ct))+Math.imul(B,ut)|0,o=Math.imul(B,ct),n=n+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ft)|0)+Math.imul(O,lt)|0,o=o+Math.imul(O,ft)|0;var It=(c+(n=n+Math.imul(I,dt)|0)|0)+((8191&(i=(i=i+Math.imul(I,mt)|0)+Math.imul(N,dt)|0))<<13)|0;c=((o=o+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(k,lt),i=(i=Math.imul(k,ft))+Math.imul(B,lt)|0,o=Math.imul(B,ft);var Nt=(c+(n=n+Math.imul(U,dt)|0)|0)+((8191&(i=(i=i+Math.imul(U,mt)|0)+Math.imul(O,dt)|0))<<13)|0;c=((o=o+Math.imul(O,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Ft=(c+(n=Math.imul(k,dt))|0)+((8191&(i=(i=Math.imul(k,mt))+Math.imul(B,dt)|0))<<13)|0;return c=((o=Math.imul(B,mt))+(i>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,u[0]=vt,u[1]=gt,u[2]=yt,u[3]=xt,u[4]=wt,u[5]=bt,u[6]=Mt,u[7]=_t,u[8]=Et,u[9]=St,u[10]=At,u[11]=Tt,u[12]=Lt,u[13]=Rt,u[14]=Ct,u[15]=Pt,u[16]=It,u[17]=Nt,u[18]=Ft,0!==c&&(u[19]=c,r.length++),r};function d(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(p=f),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?f(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):d(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*e;a>=26,e+=i/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(e=0;e>>26-r}a&&(this.words[e]=a,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==h||c>=i);c--){var l=0|this.words[c];this.words[c]=h<<26-o|l>>>o,h=l&s}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==e){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;l--){var f=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(f=Math.min(f/a|0,67108863),n._ishlnsubmul(i,f,l);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=f)}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(t)),{div:i,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,a,s},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},o.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),l=e.clone();!e.isZero();){for(var f=0,p=1;0==(e.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(h),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var d=0,m=1;0==(r.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(h),u.isub(l)),s.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),a.isub(u)):(r.isub(e),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,f=1;0==(r.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(s)):(r.isub(e),s.isub(a))}return(i=0===e.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new M(t)},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function x(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(y,g),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new x;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new b}return v[t]=e,e},M.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),d=a;0!==p.cmp(s);){for(var m=p,v=0;0!==m.cmp(s);v++)m=m.redSqr();n(v=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===h)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)}).call(this,r(29)(t))},2151:function(module,exports,__webpack_require__){"use strict";(function(global){var numeric=exports;void 0!==global&&(global.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(t,e){var r,n,i;for(void 0===e&&(e=15),n=.5,r=new Date;;){for(i=n*=2;i>3;i-=4)t(),t(),t(),t();for(;i>0;)t(),i--;if(new Date-r>e)break}for(i=n;i>3;i-=4)t(),t(),t(),t();for(;i>0;)t(),i--;return 1e3*(3*n-1)/(new Date-r)},numeric._myIndexOf=function(t){var e,r=this.length;for(e=0;enumeric.largeArray)return e.push("...Large Array..."),!0;for(u=!1,e.push("["),n=0;n0&&(e.push(","),u&&e.push("\n ")),u=t(r[n]);return e.push("]"),!0}e.push("{");u=!1;for(n in r)r.hasOwnProperty(n)&&(u&&e.push(",\n"),u=!0,e.push(n),e.push(": \n"),t(r[n]));return e.push("}"),!0}(t),e.join("")},numeric.parseDate=function(t){return function t(e){if("string"==typeof e)return Date.parse(e.replace(/-/g,"/"));if(!(e instanceof Array))throw new Error("parseDate: parameter must be arrays of strings");var r,n=[];for(r=0;r0){for(i[u]=[],e=0;e>>8^i[255&(o^t[n])];return-1^o}var r,n,i,o,a,s,u,c,h,l,f=t[0].length,p=t[0][0].length,d=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,p>>24&255,p>>16&255,p>>8&255,255&p,f>>24&255,f>>16&255,f>>8&255,255&f,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(l=e(d,12,29),d[29]=l>>24&255,d[30]=l>>16&255,d[31]=l>>8&255,d[32]=255&l,r=1,n=0,u=0;u>8&255,d.push(a),d.push(s),d.push(255&~a),d.push(255&~s),0===u&&d.push(0),c=0;c255?255:a<0?0:Math.round(a)))%65521))%65521,d.push(a);d.push(0)}return h=(n<<16)+r,d.push(h>>24&255),d.push(h>>16&255),d.push(h>>8&255),d.push(255&h),o=d.length-41,d[33]=o>>24&255,d[34]=o>>16&255,d[35]=o>>8&255,d[36]=255&o,l=e(d,37),d.push(l>>24&255),d.push(l>>16&255),d.push(l>>8&255),d.push(255&l),d.push(0),d.push(0),d.push(0),d.push(0),d.push(73),d.push(69),d.push(78),d.push(68),d.push(174),d.push(66),d.push(96),d.push(130),"data:image/png;base64,"+function(t){var e,r,n,i,o,a,s,u=t.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="";for(e=0;e>4),a=((15&n)<<2)+((i=t[e+2])>>6),s=63&i,e+1>=u?a=s=64:e+2>=u&&(s=64),h+=c.charAt(r>>2)+c.charAt(o)+c.charAt(a)+c.charAt(s);return h}(d)},numeric._dim=function(t){for(var e=[];"object"==typeof t;)e.push(t.length),t=t[0];return e},numeric.dim=function(t){var e;return"object"==typeof t?"object"==typeof(e=t[0])?"object"==typeof e[0]?numeric._dim(t):[t.length,e.length]:[t.length]:[]},numeric.mapreduce=function(t,e){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+e+';\nif(typeof x === "number") { var xi = x; '+t+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+t+";\n xi = x[i-1];\n "+t+";\n}\nif(i === 0) {\n xi = x[i];\n "+t+"\n}\nreturn accum;")},numeric.mapreduce2=function(t,e){return Function("x","var n = x.length;\nvar i,xi;\n"+e+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+t+";\n}\nreturn accum;")},numeric.same=function t(e,r){var n,i;if(!(e instanceof Array&&r instanceof Array))return!1;if((i=e.length)!==r.length)return!1;for(n=0;n=0;n-=2)o[n+1]=e,o[n]=e;return-1===n&&(o[0]=e),o}for(n=i-1;n>=0;n--)o[n]=numeric.rep(t,e,r+1);return o},numeric.dotMMsmall=function(t,e){var r,n,i,o,a,s,u,c,h,l,f;for(o=t.length,a=e.length,s=e[0].length,u=Array(o),r=o-1;r>=0;r--){for(c=Array(s),h=t[r],i=s-1;i>=0;i--){for(l=h[a-1]*e[a-1][i],n=a-2;n>=1;n-=2)f=n-1,l+=h[n]*e[n][i]+h[f]*e[f][i];0===n&&(l+=h[0]*e[0][i]),c[i]=l}u[r]=c}return u},numeric._getCol=function(t,e,r){var n;for(n=t.length-1;n>0;--n)r[n]=t[n][e],r[--n]=t[n][e];0===n&&(r[0]=t[0][e])},numeric.dotMMbig=function(t,e){var r,n,i,o=numeric._getCol,a=e.length,s=Array(a),u=t.length,c=e[0].length,h=new Array(u),l=numeric.dotVV;for(--a,n=--u;-1!==n;--n)h[n]=Array(c);for(n=--c;-1!==n;--n)for(o(e,n,s),i=u;-1!==i;--i)0,r=t[i],h[i][n]=l(r,s);return h},numeric.dotMV=function(t,e){var r,n=t.length,i=(e.length,Array(n)),o=numeric.dotVV;for(r=n-1;r>=0;r--)i[r]=o(t[r],e);return i},numeric.dotVM=function(t,e){var r,n,i,o,a,s,u;for(i=t.length,o=e[0].length,a=Array(o),n=o-1;n>=0;n--){for(s=t[i-1]*e[i-1][n],r=i-2;r>=1;r-=2)u=r-1,s+=t[r]*e[r][n]+t[u]*e[u][n];0===r&&(s+=t[0]*e[0][n]),a[n]=s}return a},numeric.dotVV=function(t,e){var r,n,i=t.length,o=t[i-1]*e[i-1];for(r=i-2;r>=1;r-=2)n=r-1,o+=t[r]*e[r]+t[n]*e[n];return 0===r&&(o+=t[0]*e[0]),o},numeric.dot=function(t,e){var r=numeric.dim;switch(1e3*r(t).length+r(e).length){case 2002:return e.length<10?numeric.dotMMsmall(t,e):numeric.dotMMbig(t,e);case 2001:return numeric.dotMV(t,e);case 1002:return numeric.dotVM(t,e);case 1001:return numeric.dotVV(t,e);case 1e3:return numeric.mulVS(t,e);case 1:return numeric.mulSV(t,e);case 0:return t*e;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(t){var e,r,n,i,o=t.length,a=Array(o);for(e=o-1;e>=0;e--){for(i=Array(o),r=e+2,n=o-1;n>=r;n-=2)i[n]=0,i[n-1]=0;for(n>e&&(i[n]=0),i[e]=t[e],n=e-1;n>=1;n-=2)i[n]=0,i[n-1]=0;0===n&&(i[0]=0),a[e]=i}return a},numeric.getDiag=function(t){var e,r=Math.min(t.length,t[0].length),n=Array(r);for(e=r-1;e>=1;--e)n[e]=t[e][e],n[--e]=t[e][e];return 0===e&&(n[0]=t[0][0]),n},numeric.identity=function(t){return numeric.diag(numeric.rep([t],1))},numeric.pointwise=function(t,e,r){void 0===r&&(r="");var n,i,o=[],a=/\[i\]$/,s="",u=!1;for(n=0;n=0;i--) ret[i] = arguments.callee("+t.join(",")+",_s,_k+1);\n return ret;\n}\n"+r+"\nfor(i=_n-1;i!==-1;--i) {\n "+e+"\n}\nreturn ret;",Function.apply(null,o)},numeric.pointwise2=function(t,e,r){void 0===r&&(r="");var n,i,o=[],a=/\[i\]$/,s="",u=!1;for(n=0;n=0;a--)t("object"==typeof e?e[a]:e,"object"==typeof r?r[a]:r,n,i+1,o);else o(e,r)},numeric._biforeach2=function t(e,r,n,i,o){if(i===n.length-1)return o(e,r);var a,s=n[i],u=Array(s);for(a=s-1;a>=0;--a)u[a]=t("object"==typeof e?e[a]:e,"object"==typeof r?r[a]:r,n,i+1,o);return u},numeric._foreach=function t(e,r,n,i){var o;if(n!==r.length-1)for(o=r[n]-1;o>=0;o--)t(e[o],r,n+1,i);else i(e)},numeric._foreach2=function t(e,r,n,i){if(n===r.length-1)return i(e);var o,a=r[n],s=Array(a);for(o=a-1;o>=0;o--)s[o]=t(e[o],r,n+1,i);return s},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var t,e;for(t=0;tm&&(d=o,m=s);for(r=f[d],f[d]=f[a],f[a]=r,i=p[d],p[d]=p[a],p[a]=i,t=r[a],s=a;s!==l;++s)r[s]/=t;for(s=l-1;-1!==s;--s)i[s]/=t;for(o=h-1;-1!==o;--o)if(o!==a){for(e=f[o],n=p[o],t=e[a],s=a+1;s!==l;++s)e[s]-=r[s]*t;for(s=l-1;s>0;--s)n[s]-=i[s]*t,n[--s]-=i[s]*t;0===s&&(n[0]-=i[0]*t)}}return p},numeric.det=function(t){var e=numeric.dim(t);if(2!==e.length||e[0]!==e[1])throw new Error("numeric: det() only works on square matrices");var r,n,i,o,a,s,u,c,h=e[0],l=1,f=numeric.clone(t);for(n=0;nMath.abs(f[i][n])&&(i=r);for(i!==n&&(u=f[i],f[i]=f[n],f[n]=u,l*=-1),o=f[n],r=n+1;r=1;e-=2){for(i=t[e],n=t[e-1],r=s-1;r>=1;--r)(o=u[r])[e]=i[r],o[e-1]=n[r],(o=u[--r])[e]=i[r],o[e-1]=n[r];0===r&&((o=u[0])[e]=i[0],o[e-1]=n[0])}if(0===e){for(n=t[0],r=s-1;r>=1;--r)u[r][0]=n[r],u[--r][0]=n[r];0===r&&(u[0][0]=n[0])}return u},numeric.negtranspose=function(t){var e,r,n,i,o,a=t.length,s=t[0].length,u=Array(s);for(r=0;r=1;e-=2){for(i=t[e],n=t[e-1],r=s-1;r>=1;--r)(o=u[r])[e]=-i[r],o[e-1]=-n[r],(o=u[--r])[e]=-i[r],o[e-1]=-n[r];0===r&&((o=u[0])[e]=-i[0],o[e-1]=-n[0])}if(0===e){for(n=t[0],r=s-1;r>=1;--r)u[r][0]=-n[r],u[--r][0]=-n[r];0===r&&(u[0][0]=-n[0])}return u},numeric._random=function t(e,r){var n,i,o=e[r],a=Array(o);if(r===e.length-1){for(i=Math.random,n=o-1;n>=1;n-=2)a[n]=i(),a[n-1]=i();return 0===n&&(a[0]=i()),a}for(n=o-1;n>=0;n--)a[n]=t(e,r+1);return a},numeric.random=function(t){return numeric._random(t,0)},numeric.norm2=function(t){return Math.sqrt(numeric.norm2Squared(t))},numeric.linspace=function(t,e,r){if(void 0===r&&(r=Math.max(Math.round(e-t)+1,1)),r<2)return 1===r?[t]:[];var n,i=Array(r);for(n=--r;n>=0;n--)i[n]=(n*e+(r-n)*t)/r;return i},numeric.getBlock=function(t,e,r){var n=numeric.dim(t);return function t(i,o){var a,s=e[o],u=r[o]-s,c=Array(u);if(o===n.length-1){for(a=u;a>=0;a--)c[a]=i[a+s];return c}for(a=u;a>=0;a--)c[a]=t(i[a+s],o+1);return c}(t,0)},numeric.setBlock=function(t,e,r,n){var i=numeric.dim(t);return function t(n,o,a){var s,u=e[a],c=r[a]-u;if(a===i.length-1)for(s=c;s>=0;s--)n[s+u]=o[s];for(s=c;s>=0;s--)t(n[s+u],o[s],a+1)}(t,n,0),t},numeric.getRange=function(t,e,r){var n,i,o,a,s=e.length,u=r.length,c=Array(s);for(n=s-1;-1!==n;--n)for(c[n]=Array(u),o=c[n],a=t[e[n]],i=u-1;-1!==i;--i)o[i]=a[r[i]];return c},numeric.blockMatrix=function(t){var e=numeric.dim(t);if(e.length<4)return numeric.blockMatrix([t]);var r,n,i,o,a,s=e[0],u=e[1];for(r=0,n=0,i=0;i=0;o--){for(i=Array(c),s=t[o],a=c-1;a>=3;--a)i[a]=s*e[a],i[--a]=s*e[a],i[--a]=s*e[a],i[--a]=s*e[a];for(;a>=0;)i[a]=s*e[a],--a;h[o]=i}return h},numeric.T=function(t,e){this.x=t,this.y=e},numeric.t=function(t,e){return new numeric.T(t,e)},numeric.Tbinop=function(t,e,r,n,i){var o;numeric.indexOf;if("string"!=typeof i)for(o in i="",numeric)numeric.hasOwnProperty(o)&&(t.indexOf(o)>=0||e.indexOf(o)>=0||r.indexOf(o)>=0||n.indexOf(o)>=0)&&o.length>1&&(i+="var "+o+" = numeric."+o+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+i+"\nif(x.y) { if(y.y) { return new numeric.T("+n+");\n }\n return new numeric.T("+r+");\n}\nif(y.y) {\n return new numeric.T("+e+");\n}\nreturn new numeric.T("+t+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var t=numeric.mul,e=numeric.div;if(this.y){var r=numeric.add(t(this.x,this.x),t(this.y,this.y));return new numeric.T(e(this.x,r),e(numeric.neg(this.y),r))}return new T(e(1,this.x))},numeric.T.prototype.div=function(t){if(t instanceof numeric.T||(t=new numeric.T(t)),t.y)return this.mul(t.reciprocal());var e=numeric.div;return this.y?new numeric.T(e(this.x,t.x),e(this.y,t.x)):new numeric.T(e(this.x,t.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var t=numeric.transpose,e=this.x,r=this.y;return r?new numeric.T(t(e),t(r)):new numeric.T(t(e))},numeric.T.prototype.transjugate=function(){var t=numeric.transpose,e=this.x,r=this.y;return r?new numeric.T(t(e),numeric.negtranspose(r)):new numeric.T(t(e))},numeric.Tunop=function(t,e,r){return"string"!=typeof r&&(r=""),Function("var x = this;\n"+r+"\nif(x.y) { "+e+";\n}\n"+t+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var t=this;if(void 0===t.y)return new numeric.T(numeric.inv(t.x));var e,r,n,i,o,a,s,u,c,h,l,f,p,d,m,v,g,y,x=t.x.length,w=numeric.identity(x),b=numeric.rep([x,x],0),M=numeric.clone(t.x),_=numeric.clone(t.y);for(c=0;cf&&(l=h,f=p);for(l!==c&&(y=M[c],M[c]=M[l],M[l]=y,y=_[c],_[c]=_[l],_[l]=y,y=w[c],w[c]=w[l],w[l]=y,y=b[c],b[c]=b[l],b[l]=y),e=M[c],r=_[c],o=w[c],a=b[c],d=e[c],m=r[c],h=c+1;h0;c--)for(o=w[c],a=b[c],h=c-1;h>=0;h--)for(s=w[h],u=b[h],d=M[h][c],m=_[h][c],l=x-1;l>=0;l--)v=o[l],g=a[l],s[l]-=d*v-m*g,u[l]-=d*g+m*v;return new numeric.T(w,b)},numeric.T.prototype.get=function(t){var e,r=this.x,n=this.y,i=0,o=t.length;if(n){for(;i=0?1:-1)*numeric.norm2(t);e[0]+=r;var n=numeric.norm2(e);if(0===n)throw new Error("eig: internal error");return numeric.div(e,n)},numeric.toUpperHessenberg=function(t){var e=numeric.dim(t);if(2!==e.length||e[0]!==e[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var r,n,i,o,a,s,u,c,h,l,f=e[0],p=numeric.clone(t),d=numeric.identity(f);for(n=0;n0){for(a=numeric.house(o),s=numeric.getBlock(p,[n+1,n],[f-1,f-1]),u=numeric.tensor(a,numeric.dot(a,s)),r=n+1;r=4*u)S=.5*(c+Math.sqrt(c*c-4*u)),A=.5*(c-Math.sqrt(c*c-4*u)),h=numeric.add(numeric.sub(numeric.dot(h,h),numeric.mul(h,S+A)),numeric.diag(numeric.rep([3],S*A)));else h=numeric.add(numeric.sub(numeric.dot(h,h),numeric.mul(h,c)),numeric.diag(numeric.rep([3],u)));for(r=[h[0][0],h[1][0],h[2][0]],n=numeric.house(r),p=[t[0],t[1],t[2]],d=numeric.tensor(n,numeric.dot(n,p)),v=0;v<3;v++)for(f=t[v],m=d[v],y=0;y=0?((v=(a-(f=h<0?-.5*(h-A(l)):-.5*(h+A(l))))*(a-f)+s*s)>(g=u*u+(c-f)*(c-f))?(d=(a-f)/(v=A(v)),m=s/v):(d=u/(g=A(g)),m=(c-f)/g),i=new w([[m,-d],[d,m]]),E.setRows(r,o,i.dot(E.getRows(r,o)))):(f=-.5*h,p=.5*A(-l),(v=(a-f)*(a-f)+s*s)>(g=u*u+(c-f)*(c-f))?(d=(a-f)/(v=A(v+p*p)),m=s/v,f=0,p/=v):(d=u/(g=A(g+p*p)),m=(c-f)/g,f=p/g,p=0),i=new w([[m,-d],[d,m]],[[f,p],[p,-f]]),E.setRows(r,o,i.dot(E.getRows(r,o))))}var T=E.dot(t).dot(E.transjugate()),L=(b=t.length,numeric.T.identity(b));for(o=0;o0)for(n=o-1;n>=0;n--){var R=T.get([n,n]),C=T.get([o,o]);numeric.neq(R.x,C.x)||numeric.neq(R.y,C.y)?(f=T.getRow(n).getBlock([n],[o-1]),p=L.getRow(o).getBlock([n],[o-1]),L.set([o,n],T.get([n,o]).neg().sub(f.dot(p)).div(R.sub(C)))):L.setRow(o,L.getRow(n))}for(o=0;o=o.length;)o[o.length]=0;0!==e[n]&&o[n]++}var a=o.length,s=Array(a+1);for(s[0]=0,r=0;r=u){if(i[h]=p[c],0===c)return;++h,s=l[--c],u=f[c]}else 0===n[a=o[r[s]]]?(n[a]=1,l[c]=s,p[++c]=a,s=e[a],f[c]=u=e[a+1]):++s},numeric.ccsLPSolve=function(t,e,r,n,i,o,a){var s,u,c,h,l,f,p,d,m,v=t[0],g=t[1],y=t[2],x=(v.length,e[0]),w=e[1],b=e[2];for(u=x[i],c=x[i+1],n.length=0,s=u;so&&(a=i,o=s);for(b(y[r])=c){if(i[l]=o[d[h]],0===h)return;++l,u=f[--h],c=p[h]}else 0===n[s=r[u]]?(n[s]=1,f[h]=u,d[++h]=s,u=e[s=o[s]],p[h]=c=e[s+1]):++u}},numeric.ccsLPSolve0=function(t,e,r,n,i,o,a,s){var u,c,h,l,f,p,d,m,v,g=t[0],y=t[1],x=t[2],w=(g.length,e[0]),b=e[1],M=e[2];for(c=w[i],h=w[i+1],n.length=0,u=c;uo&&(a=i,o=s);for(b(y[M[r]])r[n]&&(r[n]=e.length),e)e.hasOwnProperty(i)&&t(e[i],r,n+1);return r},numeric.sclone=function t(e,r,n){void 0===r&&(r=0),void 0===n&&(n=numeric.sdim(e).length);var i,o=Array(e.length);if(r===n-1){for(i in e)e.hasOwnProperty(i)&&(o[i]=e[i]);return o}for(i in e)e.hasOwnProperty(i)&&(o[i]=t(e[i],r+1,n));return o},numeric.sdiag=function(t){var e,r,n=t.length,i=Array(n);for(e=n-1;e>=1;e-=2)r=e-1,i[e]=[],i[e][e]=t[e],i[r]=[],i[r][r]=t[r];return 0===e&&(i[0]=[],i[0][0]=t[e]),i},numeric.sidentity=function(t){return numeric.sdiag(numeric.rep([t],1))},numeric.stranspose=function(t){var e,r,n,i=[];t.length;for(e in t)if(t.hasOwnProperty(e))for(r in n=t[e])n.hasOwnProperty(r)&&("object"!=typeof i[r]&&(i[r]=[]),i[r][e]=n[r]);return i},numeric.sLUP=function(t,e){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(t,e){var r,n,i,o,a,s,u,c=t.length,h=(e.length,numeric.stranspose(e)),l=h.length,f=Array(c);for(i=c-1;i>=0;i--){for(u=[],r=t[i],a=l-1;a>=0;a--){for(o in s=0,n=h[a],r)r.hasOwnProperty(o)&&o in n&&(s+=r[o]*n[o]);s&&(u[a]=s)}f[i]=u}return f},numeric.sdotMV=function(t,e){var r,n,i,o,a=t.length,s=Array(a);for(n=a-1;n>=0;n--){for(i in o=0,r=t[n])r.hasOwnProperty(i)&&e[i]&&(o+=r[i]*e[i]);o&&(s[n]=o)}return s},numeric.sdotVM=function(t,e){var r,n,i,o,a=[];for(r in t)if(t.hasOwnProperty(r))for(n in i=e[r],o=t[r],i)i.hasOwnProperty(n)&&(a[n]||(a[n]=0),a[n]+=o*i[n]);return a},numeric.sdotVV=function(t,e){var r,n=0;for(r in t)t[r]&&e[r]&&(n+=t[r]*e[r]);return n},numeric.sdot=function(t,e){var r=numeric.sdim(t).length,n=numeric.sdim(e).length;switch(1e3*r+n){case 0:return t*e;case 1001:return numeric.sdotVV(t,e);case 2001:return numeric.sdotMV(t,e);case 1002:return numeric.sdotVM(t,e);case 2002:return numeric.sdotMM(t,e);default:throw new Error("numeric.sdot not implemented for tensors of order "+r+" and "+n)}},numeric.sscatter=function(t){var e,r,n,i,o=t[0].length,a=t.length,s=[];for(r=o-1;r>=0;--r)if(t[a-1][r]){for(i=s,n=0;n=0;--o)r[o]=[];for(o=i;o>=0;--o)r[o].push(n[o]);r[i+1].push(a)}}else t(a,r,n);return n.length>i&&n.pop(),r},numeric.cLU=function(t){var e,r,n,i,o,a,s=t[0],u=t[1],c=t[2],h=s.length,l=0;for(e=0;el&&(l=s[e]);l++;var f,p=Array(l),d=Array(l),m=numeric.rep([l],1/0),v=numeric.rep([l],-1/0);for(n=0;nv[e]&&(v[e]=r);for(e=0;ev[e+1]&&(v[e+1]=v[e]);for(e=l-1;e>=1;e--)m[e]=0;r--){for(;l[n]>r;)a[r]-=f[n]*a[l[n]],n--;a[r]/=f[n],n--}return a},numeric.cgrid=function(t,e){"number"==typeof t&&(t=[t,t]);var r,n,i,o=numeric.rep(t,-1);if("function"!=typeof e)switch(e){case"L":e=function(e,r){return e>=t[0]/2||ri&&(i=o[n]);for(i++,r=numeric.rep([i],0),n=0;n1;)i[n=a((e+r)/2)]<=t?e=n:r=n;return this._at(t,e)}o=t.length;var s,u=Array(o);for(s=o-1;-1!==s;--s)u[s]=this.at(t[s]);return u},numeric.Spline.prototype.diff=function(){var t,e,r,n=this.x,i=this.yl,o=this.yr,a=this.kl,s=this.kr,u=i.length,c=a,h=s,l=Array(u),f=Array(u),p=numeric.add,d=numeric.mul,m=numeric.div,v=numeric.sub;for(t=u-1;-1!==t;--t)e=n[t+1]-n[t],r=v(o[t+1],i[t]),l[t]=m(p(d(r,6),d(a[t],-4*e),d(s[t+1],-2*e)),e*e),f[t+1]=m(p(d(r,-6),d(a[t],2*e),d(s[t+1],4*e)),e*e);return new numeric.Spline(n,c,h,l,f)},numeric.Spline.prototype.roots=function(){function t(t){return t*t}var e=[],r=this.x,n=this.yl,i=this.yr,o=this.kl,a=this.kr;"number"==typeof n[0]&&(n=[n],i=[i],o=[o],a=[a]);var s,u,c,h,l,f,p,d,m,v,g,y,x,w,b,M,_,E,S,A,T,L,R,C=n.length,P=r.length-1,I=(e=Array(C),Math.sqrt);for(s=0;s!==C;++s){for(h=n[s],l=i[s],f=o[s],p=a[s],d=[],u=0;u!==P;u++){for(u>0&&l[u]*h[u]<0&&d.push(r[u]),M=r[u+1]-r[u],r[u],g=h[u],y=l[u+1],m=f[u]/M,x=(v=p[u+1]/M)+3*g+2*m-3*y,w=3*(v+m+2*(g-y)),(b=t(m-v+3*(g-y))+12*v*g)<=0?_=(E=x/w)>r[u]&&Er[u]&&Er[u]&&S0)T=L,E=S;else{for(var N=0;!((R=(E*L-S*T)/(E-S))<=T||R>=L);)if((A=this._at(R,u))*S>0)L=R,S=A,-1===N&&(E*=.5),N=-1;else{if(!(A*E>0))break;T=R,E=A,1===N&&(S*=.5),N=1}d.push(R),T=_[c+1],E=this._at(T,u)}else d.push(T),T=L,E=S;0===S&&d.push(L)}e[s]=d}return"number"==typeof this.yl[0]?e[0]:e},numeric.spline=function(t,e,r,n){var i,o=t.length,a=[],s=[],u=[],c=numeric.sub,h=numeric.mul,l=numeric.add;for(i=o-2;i>=0;i--)s[i]=t[i+1]-t[i],u[i]=c(e[i+1],e[i]);"string"!=typeof r&&"string"!=typeof n||(r=n="periodic");var f=[[],[],[]];switch(typeof r){case"undefined":a[0]=h(3/(s[0]*s[0]),u[0]),f[0].push(0,0),f[1].push(0,1),f[2].push(2/s[0],1/s[0]);break;case"string":a[0]=l(h(3/(s[o-2]*s[o-2]),u[o-2]),h(3/(s[0]*s[0]),u[0])),f[0].push(0,0,0),f[1].push(o-2,0,1),f[2].push(1/s[o-2],2/s[o-2]+2/s[0],1/s[0]);break;default:a[0]=r,f[0].push(0),f[1].push(0),f[2].push(1)}for(i=1;i20)throw new Error("Numerical gradient fails");if(d[i]=e[i]+x,o=t(d),d[i]=e[i]-x,a=t(d),d[i]=e[i],isNaN(o)||isNaN(a))x/=16;else{if(m[i]=(o-a)/(2*x),s=e[i]-x,u=e[i],c=e[i]+x,h=(o-n)/x,l=(n-a)/x,f=p(v(m[i]),v(n),v(o),v(a),v(s),v(u),v(c),1e-8),!(g(p(v(h-m[i]),v(l-m[i]),v(h-l))/f,x/f)>.001))break;x/=16}}return m},numeric.uncmin=function(t,e,r,n,i,o,a){var s=numeric.gradient;void 0===a&&(a={}),void 0===r&&(r=1e-8),void 0===n&&(n=function(e){return s(t,e)}),void 0===i&&(i=1e3);var u,c,h=(e=numeric.clone(e)).length,l=t(e);if(isNaN(l))throw new Error("uncmin: f(x0) is a NaN!");var f=Math.max,p=numeric.norm2;r=f(r,numeric.epsilon);var d,m,v,g,y,x,w,b,M,_,E=a.Hinv||numeric.identity(h),S=numeric.dot,A=(numeric.inv,numeric.sub),T=numeric.add,L=numeric.tensor,R=numeric.div,C=numeric.mul,P=numeric.all,I=numeric.isFinite,N=numeric.neg,F=0,U="";for(m=n(e);F=.1*M*c||isNaN(u));)M*=.5,++F;if(M*_1;)s[n=i(.5*(e+r))]<=t?e=n:r=n;return this._at(t,e)},numeric.dopri=function(t,e,r,n,i,o,a){void 0===i&&(i=1e-6),void 0===o&&(o=1e3);var s,u,c,h,l,f,p,d,m,v,g,y,x,w=[t],b=[r],M=[n(t,r)],_=[],E=[.075,.225],S=[44/45,-56/15,32/9],A=[19372/6561,-25360/2187,64448/6561,-212/729],T=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],L=[35/384,0,500/1113,125/192,-2187/6784,11/84],R=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],C=[.2,.3,.8,8/9,1,1],P=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],I=0,N=(e-t)/10,F=0,U=numeric.add,O=numeric.mul,D=(Math.max,Math.min),k=Math.abs,B=numeric.norminf,z=Math.pow,j=numeric.any,G=numeric.lt,V=numeric.and,H=(numeric.sub,new numeric.Dopri(w,b,M,_,-1,""));for("function"==typeof a&&(g=a(t,r));te&&(N=e-t),s=n(t+C[0]*N,U(r,O(.2*N,M[I]))),u=n(t+C[1]*N,U(U(r,O(E[0]*N,M[I])),O(E[1]*N,s))),c=n(t+C[2]*N,U(U(U(r,O(S[0]*N,M[I])),O(S[1]*N,s)),O(S[2]*N,u))),h=n(t+C[3]*N,U(U(U(U(r,O(A[0]*N,M[I])),O(A[1]*N,s)),O(A[2]*N,u)),O(A[3]*N,c))),l=n(t+C[4]*N,U(U(U(U(U(r,O(T[0]*N,M[I])),O(T[1]*N,s)),O(T[2]*N,u)),O(T[3]*N,c)),O(T[4]*N,h))),f=n(t+N,m=U(U(U(U(U(r,O(M[I],N*L[0])),O(u,N*L[2])),O(c,N*L[3])),O(h,N*L[4])),O(l,N*L[5]))),(v="number"==typeof(p=U(U(U(U(U(O(M[I],N*P[0]),O(u,N*P[2])),O(c,N*P[3])),O(h,N*P[4])),O(l,N*P[5])),O(f,N*P[6])))?k(p):B(p))>i){if(t+(N=.2*N*z(i/v,.25))===t){H.msg="Step size became too small";break}}else{if(_[I]=U(U(U(U(U(U(r,O(M[I],N*R[0])),O(u,N*R[2])),O(c,N*R[3])),O(h,N*R[4])),O(l,N*R[5])),O(f,N*R[6])),w[++I]=t+N,b[I]=m,M[I]=f,"function"==typeof a){var W,Y,X=t,q=t+.5*N;if(y=a(q,_[I-1]),j(x=V(G(g,0),G(0,y)))||(X=q,g=y,y=a(q=t+N,m),x=V(G(g,0),G(0,y))),j(x)){for(var Z,J,Q=0,K=1,$=1;;){if("number"==typeof g)Y=($*y*X-K*g*q)/($*y-K*g);else for(Y=q,d=g.length-1;-1!==d;--d)g[d]<0&&y[d]>0&&(Y=D(Y,($*y[d]*X-K*g[d]*q)/($*y[d]-K*g[d])));if(Y<=X||Y>=q)break;J=a(Y,W=H._at(Y,I-1)),j(Z=V(G(g,0),G(0,J)))?(q=Y,y=J,x=Z,$=1,-1===Q?K*=.5:K=1,Q=-1):(X=Y,g=J,K=1,1===Q?$*=.5:$=1,Q=1)}return m=H._at(.5*(t+Y),I-1),H.f[I]=n(Y,W),H.x[I]=Y,H.y[I]=W,H.ymid[I-1]=m,H.events=x,H.iterations=F,H}}t+=N,r=m,g=y,N=D(.8*N*z(i/v,.25),4*N)}return H.iterations=F,H},numeric.LU=function(t,e){e=e||!1;var r,n,i,o,a,s,u,c,h,l=Math.abs,f=t.length,p=f-1,d=new Array(f);for(e||(t=numeric.clone(t)),i=0;i=0;--r){for(o=s[r],n=r+1;nU)&&(w=U),h=v(t,f(w,T)),u=d(F,L),I=g-1;-1!==I;--I)u[I][I]+=1;var O=m(C,d(e,N=R(u,m(h,w),!0))),D=1;for(I=y-1;-1!==I;--I)O[I]<0&&(D=E(D,-.999*O[I]));if(!S(A(C=p(r,d(e,s=p(o,f(N,D)))),0)))return{solution:o,message:"",iterations:c};if(o=s,w=0);if(x)return{solution:s,message:"Unbounded",iterations:c}}return{solution:o,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(t,e,r,n,i){var o=t.length,a=r.length,s=(numeric.sum,numeric.log,numeric.mul,numeric.sub),u=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([o],0).concat([1])),h=numeric.rep([a,1],-1),l=numeric.blockMatrix([[e,h]]),f=r,p=numeric.rep([o],0).concat(Math.max(0,numeric.sup(numeric.neg(r)))+1),d=numeric.__solveLP(c,l,f,n,i,p,!1),m=numeric.clone(d.solution);if(m.length=o,numeric.inf(s(r,u(e,m)))<0)return{solution:NaN,message:"Infeasible",iterations:d.iterations};var v=numeric.__solveLP(t,e,r,n,i-d.iterations,m,!0);return v.iterations+=d.iterations,v},numeric.solveLP=function(t,e,r,n,i,o,a){if(void 0===a&&(a=1e3),void 0===o&&(o=numeric.epsilon),void 0===n)return numeric._solveLP(t,e,r,o,a);var s,u=n.length,c=n[0].length,h=e.length,l=numeric.echelonize(n),f=numeric.rep([c],0),p=l.P,d=[];for(s=p.length-1;-1!==s;--s)f[p[s]]=1;for(s=c-1;-1!==s;--s)0===f[s]&&d.push(s);var m=numeric.getRange,v=numeric.linspace(0,u-1),g=numeric.linspace(0,h-1),y=m(n,v,d),x=m(e,g,p),w=m(e,g,d),b=numeric.dot,M=numeric.sub,_=b(x,l.I),E=M(w,b(_,y)),S=M(r,b(_,i)),A=Array(p.length),T=Array(d.length);for(s=p.length-1;-1!==s;--s)A[s]=t[p[s]];for(s=d.length-1;-1!==s;--s)T[s]=t[d[s]];var L=M(T,b(A,b(l.I,y))),R=numeric._solveLP(L,E,S,o,a),C=R.solution;if(C!=C)return R;var P=b(l.I,M(i,b(y,C))),I=Array(t.length);for(s=p.length-1;-1!==s;--s)I[p[s]]=P[s];for(s=d.length-1;-1!==s;--s)I[d[s]]=C[s];return{solution:I,message:R.message,iterations:R.iterations}},numeric.MPStoLP=function(t){t instanceof String&&t.split("\n");var e,r,n,i,o=0,a=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],s=t.length,u=0,c={},h=[],l=0,f={},p=0,d=[],m=[],v=[];function g(r){throw new Error("MPStoLP: "+r+"\nLine "+e+": "+t[e]+"\nCurrent state: "+a[o]+"\n")}for(e=0;e=o;)t/=2,e/=2,n>>>=1;return(t+n)/e},n},a=e.pow(r,6),i=e.pow(2,i),o=2*i,s(e.random(),t)}([],numeric.seedrandom,256,0,52),function(t){function e(t){if("object"!=typeof t)return t;var r,n=[],i=t.length;for(r=0;rh)d[y]=P;else if(d[y]=-Math.abs(P),P>0){for(g=1;g<=n;g+=1)a[g][v]=-a[g][v];s[v]=-s[v]}}for(v=1;v<=f;v+=1)d[S+l[v]]=0;for(T=0,C=0,v=1;v<=c;v+=1)d[S+v]=1;v-=1){for(P=d[v],x=(y=E+v*(v+3)/2)-v,g=v+1;g<=f;g+=1)P-=d[y]*d[_+g],y+=g;if(P/=d[x],d[_+v]=P,l[v]h)d[S+T]=P;else if(d[S+T]=-Math.abs(P),P>0){for(g=1;g<=n;g+=1)a[g][T]=-a[g][T];s[T]=-s[T]}return 700}for(l[f+=1]=T,y=E+(f-1)*f/2+1,v=1;v<=f-1;v+=1)d[y]=d[v],y+=1;if(f===n)d[y]=d[n];else{for(v=n;v>=f+1&&0!==d[v]&&(F=Math.max(Math.abs(d[v-1]),Math.abs(d[v])),U=Math.min(Math.abs(d[v-1]),Math.abs(d[v])),C=d[v-1]>=0?Math.abs(F*Math.sqrt(1+U*U/(F*F))):-Math.abs(F*Math.sqrt(1+U*U/(F*F))),F=d[v-1]/C,U=d[v]/C,1!==F);v-=1)if(0===F)for(d[v-1]=U*C,g=1;g<=n;g+=1)C=t[g][v-1],t[g][v-1]=t[g][v],t[g][v]=C;else for(d[v-1]=C,O=U/(1+F),g=1;g<=n;g+=1)C=F*t[g][v-1]+U*t[g][v],t[g][v]=O*(t[g][v-1]+C)-t[g][v],t[g][v-1]=C;d[y]=d[f]}return 0}function W(){if(0===d[x=(y=E+b*(b+1)/2+1)+b])return 798;if(F=Math.max(Math.abs(d[x-1]),Math.abs(d[x])),U=Math.min(Math.abs(d[x-1]),Math.abs(d[x])),C=d[x-1]>=0?Math.abs(F*Math.sqrt(1+U*U/(F*F))):-Math.abs(F*Math.sqrt(1+U*U/(F*F))),F=d[x-1]/C,U=d[x]/C,1===F)return 798;if(0===F){for(v=b+1;v<=f;v+=1)C=d[x-1],d[x-1]=d[x],d[x]=C,x+=v;for(v=1;v<=n;v+=1)C=t[v][b],t[v][b]=t[v][b+1],t[v][b+1]=C}else{for(O=U/(1+F),v=b+1;v<=f;v+=1)C=F*d[x-1]+U*d[x],d[x]=O*(d[x-1]+C)-d[x],d[x-1]=C,x+=v;for(v=1;v<=n;v+=1)C=F*t[v][b]+U*t[v][b+1],t[v][b+1]=O*(t[v][b]+C)-t[v][b+1],t[v][b]=C}return 0}function Y(){for(x=y-b,v=1;v<=b;v+=1)d[x]=d[y],y+=1,x+=1;return d[A+b]=d[A+b+1],l[b]=l[b+1],(b+=1)(e=Math.abs(e))?t*Math.sqrt(1+e*e/t/t):0==e?t:e*Math.sqrt(1+t*t/e/e)}var v=0,g=0,y=0,x=0,w=0,b=0,M=0;for(o=0;o=0&&(g=-g),y=v*g-M,c[o][o]=v-g,a=u;a=0&&(g=-g),y=v*g-M,c[o][o+1]=v-g,a=u;ax&&(x=w)}for(o=l-1;-1!=o;o+=-1){if(0!=g){for(y=g*c[o][o+1],a=u;a=49)throw"Error: no convergence.";for(x=p[u],g=m(v=(((w=p[s-1])-b)*(w+b)+((g=f[s-1])-(y=f[s]))*(g+y))/(2*y*w),1),v=v<0?((x-b)*(x+b)+y*(w/(v-g)-y))/x:((x-b)*(x+b)+y*(w/(v+g)-y))/x,i=1,M=1,o=u+1;o=0;a--)if(p[a]=0;--i) {","var d=ra[i]-rb[i];","if(d){return d;}","}","return 0;"].join("\n")),e.saturateAbs=new Function("x",["if(x >= 0.0) {","if(x <= 1.0) {","return x;","}","} else if(x >= -1.0) {","return -x;","}","return 1.0;"].join("\n")),e.EPSILON=1e-6,e.POSITIVE_INFINITY=1<<30,e.NEGATIVE_INFINITY=-(1<<30)},2153:function(t,e,r){"use strict";"use restrict";var n=r(611),i=r(2154).CROSS_STENCIL,o=n.beginStencil;function a(t,e){for(var r=e[0],n=0;n0){for(f=0;f<3;++f)a(r[f],e);a(n,e),a(s,e)}return t},e.fullRepair=function(t){e.resort(t),e.resurface(t),e.removeDuplicates(t)}},2154:function(t,e){function r(t){for(var e=[],r=Math.ceil(t),n=-r;n<=r;++n)for(var i=-r;i<=r;++i)for(var o=-r;o<=r;++o)e.push(n),e.push(i),e.push(o);return new Int32Array(e)}function n(t,e){if(t===Number.POSITIVE_INFINITY)return r(e);for(var n=[],i=0|Math.ceil(e),o=Math.pow(e,t),a=-i;a<=i;++a)for(var s=-i;s<=i;++s)for(var u=-i;u<=i;++u)Math.pow(Math.abs(a),t)+Math.pow(Math.abs(s),t)+Math.pow(Math.abs(u),t)<=o&&(n.push(a),n.push(s),n.push(u));return n}var i,o;!function(){for(var t=[],e=0;e<8;++e){for(var r=[0,0,0],n=0;n<3;++n)0!=(e&1<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(i())}).call(this,r(99))},2476:function(t,e,r){"use strict";t.exports=function(t,e,r){var i=t*e,o=n*t,a=o-(o-t),s=t-a,u=n*e,c=u-(u-e),h=e-c,l=s*h-(i-a*c-s*c-a*h);if(r)return r[0]=l,r[1]=i,r;return[l,i]};var n=+(Math.pow(2,27)+1)},2477:function(t,e){e.vertex_stars=function(t){for(var e=t.faces,r=t.vertex_count||function(t){for(var e=0,r=0;r0?h=h.ushln(c):c<0&&(l=l.ushln(-c));return s(h,l)}},2480:function(t,e,r){(function(e){var r=!1;if("undefined"!=typeof Float64Array){var n=new Float64Array(1),i=new Uint32Array(n.buffer);if(n[0]=1,r=!0,1072693248===i[1]){t.exports=function(t){return n[0]=t,[i[0],i[1]]},t.exports.pack=function(t,e){return i[0]=t,i[1]=e,n[0]},t.exports.lo=function(t){return n[0]=t,i[0]},t.exports.hi=function(t){return n[0]=t,i[1]}}else if(1072693248===i[0]){t.exports=function(t){return n[0]=t,[i[1],i[0]]},t.exports.pack=function(t,e){return i[1]=t,i[0]=e,n[0]},t.exports.lo=function(t){return n[0]=t,i[1]},t.exports.hi=function(t){return n[0]=t,i[0]}}else r=!1}if(!r){var o=new e(8);t.exports=function(t){return o.writeDoubleLE(t,0,!0),[o.readUInt32LE(0,!0),o.readUInt32LE(4,!0)]},t.exports.pack=function(t,e){return o.writeUInt32LE(t,0,!0),o.writeUInt32LE(e,4,!0),o.readDoubleLE(0,!0)},t.exports.lo=function(t){return o.writeDoubleLE(t,0,!0),o.readUInt32LE(0,!0)},t.exports.hi=function(t){return o.writeDoubleLE(t,0,!0),o.readUInt32LE(4,!0)}}t.exports.sign=function(e){return t.exports.hi(e)>>>31},t.exports.exponent=function(e){return(t.exports.hi(e)<<1>>>21)-1023},t.exports.fraction=function(e){var r=t.exports.lo(e),n=t.exports.hi(e),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},t.exports.denormalized=function(e){return!(2146435072&t.exports.hi(e))}}).call(this,r(335).Buffer)},2481:function(t,e,r){"use strict";var n=r(2150);t.exports=function(t){return t.cmp(new n(0))}},2573:function(t,e,r){"use strict";var n=r(2476),i=r(2574),o=r(2575),a=r(2576),s=5;function u(t,e){for(var r=new Array(t.length-1),n=1;n>1;return["sum(",h(t.slice(0,e)),",",h(t.slice(e)),")"].join("")}function l(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(o<=0)return a;n=i+o}else{if(!(i<0))return a;if(o>=0)return a;n=-(i+o)}var s=3.3306690738754716e-16*n;return a>=s||a<=-s?a:p(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],o=e[0]-n[0],a=r[0]-n[0],s=t[1]-n[1],u=e[1]-n[1],c=r[1]-n[1],h=t[2]-n[2],l=e[2]-n[2],f=r[2]-n[2],p=o*c,m=a*u,v=a*s,g=i*c,y=i*u,x=o*s,w=h*(p-m)+l*(v-g)+f*(y-x),b=7.771561172376103e-16*((Math.abs(p)+Math.abs(m))*Math.abs(h)+(Math.abs(v)+Math.abs(g))*Math.abs(l)+(Math.abs(y)+Math.abs(x))*Math.abs(f));return w>b||-w>b?w:d(t,e,r,n)}];!function(){for(;m.length<=s;)m.push(f(m.length));for(var e=[],r=["slow"],n=0;n<=s;++n)e.push("a"+n),r.push("o"+n);var i=["function getOrientation(",e.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(n=2;n<=s;++n)i.push("case ",n,":return o",n,"(",e.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n?(i=l,(u+=1)=n?(i=l,(u+=1)e[2]?1:0)}function g(t,e,r){if(0!==t.length){if(e)for(var n=0;n=0;--o){var x=e[h=(T=n[o])[0]],w=x[0],b=x[1],M=t[w],_=t[b];if((M[0]-_[0]||M[1]-_[1])<0){var E=w;w=b,b=E}x[0]=w;var S,A=x[1]=T[1];for(i&&(S=x[2]);o>0&&n[o-1][0]===h;){var T,L=(T=n[--o])[1];i?e.push([A,L,S]):e.push([A,L]),A=L}i?e.push([A,b,S]):e.push([A,b])}return f}(t,e,f,v,r));return g(e,y,r),!!y||(f.length>0||v.length>0)}},2579:function(t,e,r){"use strict";t.exports={init:function(t){var e=i.nextPow2(t);s.length>>1;o(p,T);for(var L=0,R=0,_=0;_=a)d(c,h,R--,C=C-a|0);else if(C>=0)d(s,u,L--,C);else if(C<=-a){C=-C-a|0;for(var P=0;P>>1;o(p,L);for(var R=0,C=0,P=0,E=0;E>1==p[2*E+3]>>1&&(N=2,E+=1),I<0){for(var F=-(I>>1)-1,U=0;U>1)-1;0===N?d(s,u,R--,F):1===N?d(c,h,C--,F):2===N&&d(l,f,P--,F)}}},scanBipartite:function(t,e,r,n,i,c,h,l,f,v,g,y){var x=0,w=2*t,b=e,M=e+t,_=1,E=1;n?E=a:_=a;for(var S=i;S>>1;o(p,R);for(var C=0,S=0;S=a?(I=!n,A-=a):(I=!!n,A-=1),I)m(s,u,C++,A);else{var N=y[A],F=w*A,U=g[F+e+1],O=g[F+e+1+t];t:for(var D=0;D>>1;o(p,_);for(var E=0,x=0;x<_;++x){var S=0|p[2*x+1];if(S<0){var w=-S;if(w>=a)s[E++]=w-a;else{var A=d[w-=1],T=v*w,L=f[T+e+1],R=f[T+e+1+t];t:for(var C=0;C=0;--C)if(s[C]===w){for(var F=C+1;F=0&&i.push("lo=e[k+n]");t.indexOf("hi")>=0&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},2581:function(t,e,r){"use strict";r(2150);t.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},2582:function(t,e,r){"use strict";var n=r(2150),i=r(2480);t.exports=function(t){var e=i.exponent(t);return e<52?new n(t):new n(t*Math.pow(2,52-e)).ushln(e-52)}},2583:function(t,e,r){"use strict";var n=r(2112);t.exports=function(t,e){return n(t[0].mul(e[1]),t[1].mul(e[0]))}},2584:function(t,e,r){"use strict";var n=r(2112);t.exports=function(t,e){return n(t[0].mul(e[0]),t[1].mul(e[1]))}},2585:function(t,e,r){"use strict";var n=r(2112);t.exports=function(t,e){return n(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},2586:function(t,e){t.exports=function(t,e){var i=t.length,o=t.length-e.length;if(o)return o;switch(i){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||r(t[0],t[1])-r(e[0],e[1]);case 3:var a=t[0]+t[1],s=e[0]+e[1];if(o=a+t[2]-(s+e[2]))return o;var u=r(t[0],t[1]),c=r(e[0],e[1]);return r(u,t[2])-r(c,e[2])||r(u+t[2],a)-r(c+e[2],s);case 4:var h=t[0],l=t[1],f=t[2],p=t[3],d=e[0],m=e[1],v=e[2],g=e[3];return h+l+f+p-(d+m+v+g)||r(h,l,f,p)-r(d,m,v,g,d)||r(h+l,h+f,h+p,l+f,l+p,f+p)-r(d+m,d+v,d+g,m+v,m+g,v+g)||r(h+l+f,h+l+p,h+f+p,l+f+p)-r(d+m+v,d+m+g,d+v+g,m+v+g);default:for(var y=t.slice().sort(n),x=e.slice().sort(n),w=0;w=0; --i) {","var d = a[i]-b[i];","if(d) return d;","}","return 0;"].join("\n"));t.exports=function(t,e,r){t.cells&&(r=t.faceNormals,e=t.positions,t=t.cells);var c=n(t,e,1),h=(r=r||i.faceNormals(c.cells,c.positions),[]);for(var l in c.grid){var f=c.grid[l].coord,p=o(c,r,f);isNaN(p)||Math.abs(p)>1||(p<0?h.push([f[0],f[1],f[2],1,-p]):h.push([f[0],f[1],f[2],0,p]))}h.sort(u);var d=new Array(h.length+1),m=new Array(h.length+1),v=new Array(h.length+1),g=new Array(h.length+1),y=new Array(h.length+1);d[0]=m[0]=v[0]=a.NEGATIVE_INFINITY,g[0]=0,y[0]=1;for(var x=0;x=s)){var p=h+c(l),d=t.grid[p];d?d.cells.push(n):t.grid[p]=new a([l,u],[n])}}}}(t,e,r,i);break;case 3:!function(t,e,r,n){for(var i=[0,0,0],s=3*t.tolerance*t.tolerance,u=e[2];u<=r[2];++u){var c=h(u)<<2;i[2]=t.tolerance*u;for(var l=e[1];l<=r[1];++l){var f=c+(h(l)<<1);i[1]=t.tolerance*l;for(var p=e[0];p<=r[0];++p){i[0]=t.tolerance*p;var d=o(t.cells[n],t.positions,i);if(!(isNaN(d)||d>=s)){var m=f+h(p),v=t.grid[m];v?v.cells.push(n):t.grid[m]=new a([p,l,u],[n])}}}}}(t,e,r,i);break;default:!function t(e,r,i,s,c,h){if(c<0){var l=n.mul(e.tolerance,h),f=o(e.cells[s],e.positions,l);if(isNaN(f)||f>=r.length*e.tolerance*e.tolerance)return;var p=u(h),d=e.grid[p];d?d.cells.push(s):e.grid[p]=new a(h.slice(0),[s])}else for(h[c]=r[c];h[c]<=i[c];++h[c])t(e,r,i,s,c-1,h)}(t,e,r,i,s-1,new Array(s))}}a.prototype.closestCells=function(t,e){for(var r=this.cells,n=Number.POSITIVE_INFINITY,i=[],a=[],s=new Array(e.length),u=0;uo&&(o=l,a=!0):l>o&&(o=l,a=!1)}var v=Math.sqrt(i.distance);return a?v:-v}},2591:function(t,e,r){"use strict";"use restrict";var n=r(2152),i=n.POSITIVE_INFINITY,o=n.NEGATIVE_INFINITY,a=new Int32Array(128);function s(t,e,r,n,i){this.volume=t,this.stencil=e,this.ptrs=r,this.coord=n,this.frontier=i,3*a.length=e-1)){l+=1;for(var f=2;f>=0;--f){var p=t[f][l]-n[h+f],d=s[f];if(p=0;--f)s[f]=t[f][l]-n[h+f];u=0;break}if(p>d)continue t}a[u++]=c}}for(c=0;cMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+r+"_set("+u.join(",")+",v){"),i?o.push("return this.data.set("+h+",v)}"):o.push("return this.data["+h+"]=v}"),o.push("proto.get=function "+r+"_get("+u.join(",")+"){"),i?o.push("return this.data.get("+h+")}"):o.push("return this.data["+h+"]}"),o.push("proto.index=function "+r+"_index(",u.join(),"){return "+h+"}"),o.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(this.data,"+a.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+a.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=a.map(function(t){return"a"+t+"=this.shape["+t+"]"}),d=a.map(function(t){return"c"+t+"=this.stride["+t+"]"});o.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var m=0;m=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");o.push("return new "+r+"(this.data,"+a.map(function(t){return"a"+t}).join(",")+","+a.map(function(t){return"c"+t}).join(",")+",b)}"),o.push("proto.step=function "+r+"_step("+u.join(",")+"){var "+a.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+a.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");return o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+a.map(function(t){return"shape["+t+"]"}).join(",")+","+a.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",o.join("\n"))(c[t],s)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=function(t,e,r,n){if(void 0===t)return(0,c.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var a=e.length;if(void 0===r){r=new Array(a);for(var s=a-1,h=1;s>=0;--s)r[s]=h,h*=e[s]}if(void 0===n)for(n=0,s=0;s * @license MIT */ var n=r(1361),i=r(1362),o=r(1363);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(n)return z(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var h=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,f=0;fi&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(h=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},u.prototype.compare=function(t,e,r,n,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,a=r-e,s=Math.min(o,a),c=this.slice(n,i),h=t.slice(e,r),l=0;li)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return M(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function N(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function F(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,o){return o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,o){return o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){var r,n=this.length;if(t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(30))},349:function(t,e){t.exports=function(t,e){var r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o);return t}},350:function(t,e){t.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},351:function(t,e,r){"use strict";(function(t,n){var i=r(532),o=r(582);t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:o([32,0]),UINT16:o([32,0]),UINT32:o([32,0]),INT8:o([32,0]),INT16:o([32,0]),INT32:o([32,0]),FLOAT:o([32,0]),DOUBLE:o([32,0]),DATA:o([32,0]),UINT8C:o([32,0]),BUFFER:o([32,0])});var a="undefined"!=typeof Uint8ClampedArray,s=t.__TYPEDARRAY_POOL;s.UINT8C||(s.UINT8C=o([32,0])),s.BUFFER||(s.BUFFER=o([32,0]));var u=s.DATA,c=s.BUFFER;function h(t){if(t){var e=t.length||t.byteLength,r=i.log2(e);u[r].push(t)}}function l(t){t=i.nextPow2(t);var e=i.log2(t),r=u[e];return r.length>0?r.pop():new ArrayBuffer(t)}function f(t){return new Uint8Array(l(t),0,t)}function p(t){return new Uint16Array(l(2*t),0,t)}function d(t){return new Uint32Array(l(4*t),0,t)}function m(t){return new Int8Array(l(t),0,t)}function v(t){return new Int16Array(l(2*t),0,t)}function g(t){return new Int32Array(l(4*t),0,t)}function y(t){return new Float32Array(l(4*t),0,t)}function x(t){return new Float64Array(l(8*t),0,t)}function w(t){return a?new Uint8ClampedArray(l(t),0,t):f(t)}function b(t){return new DataView(l(t),0,t)}function M(t){t=i.nextPow2(t);var e=i.log2(t),r=c[e];return r.length>0?r.pop():new n(t)}e.free=function(t){if(n.isBuffer(t))c[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|i.log2(e);u[r].push(t)}},e.freeUint8=e.freeUint16=e.freeUint32=e.freeInt8=e.freeInt16=e.freeInt32=e.freeFloat32=e.freeFloat=e.freeFloat64=e.freeDouble=e.freeUint8Clamped=e.freeDataView=function(t){h(t.buffer)},e.freeArrayBuffer=h,e.freeBuffer=function(t){c[i.log2(t.length)].push(t)},e.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return l(t);switch(e){case"uint8":return f(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return m(t);case"int16":return v(t);case"int32":return g(t);case"float":case"float32":return y(t);case"double":case"float64":return x(t);case"uint8_clamped":return w(t);case"buffer":return M(t);case"data":case"dataview":return b(t);default:return null}return null},e.mallocArrayBuffer=l,e.mallocUint8=f,e.mallocUint16=p,e.mallocUint32=d,e.mallocInt8=m,e.mallocInt16=v,e.mallocInt32=g,e.mallocFloat32=e.mallocFloat=y,e.mallocFloat64=e.mallocDouble=x,e.mallocUint8Clamped=w,e.mallocDataView=b,e.mallocBuffer=M,e.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,u[t].length=0,c[t].length=0}}).call(this,r(30),r(335).Buffer)},353:function(t,e){e.vertexNormals=function(t,e,r){for(var n=e.length,i=new Array(n),o=void 0===r?1e-6:r,a=0;ao){var w=i[c],b=1/Math.sqrt(v*y);for(x=0;x<3;++x){var M=(x+1)%3,_=(x+2)%3;w[x]+=b*(g[M]*m[_]-g[_]*m[M])}}}for(a=0;ao)for(b=1/Math.sqrt(E),x=0;x<3;++x)w[x]*=b;else for(x=0;x<3;++x)w[x]=0}return i},e.faceNormals=function(t,e,r){for(var n=t.length,i=new Array(n),o=void 0===r?1e-6:r,a=0;ao?1/Math.sqrt(p):0;for(c=0;c<3;++c)f[c]*=p;i[a]=f}return i}},381:function(t,e){t.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}},382:function(t,e){t.exports=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}},383:function(t,e){t.exports=function(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}},384:function(t,e){t.exports=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}},3927:function(t,e,r){r(8),r(135),r(3928),r(523),r(233),r(245),r(3939),r(3940),r(3947),r(3948),r(353),r(3949),r(3950),r(3963),r(3964),r(2578),r(3986),r(3987),r(3991),r(3993),r(3994),r(4006),r(2589),r(2590),r(611),r(4010),r(4011),r(4012),r(2154),r(4014),r(2588),r(2151),t.exports=r(4015)},3928:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new n.default(t);return r.build(),r.collectFaces(e.skipTriangulation)};var n=function(t){return t&&t.__esModule?t:{default:t}}(r(3929));t.exports=e.default},3929:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function t(t,e){for(var r=0;rthis.tolerance?this.addVertexToFace(i,e):this.unclaimed.add(i)}else this.unclaimed.addAll(r)}},{key:"resolveUnclaimedPoints",value:function(t){for(var e=this.unclaimed.first(),r=e;r;r=e){e=r.next;for(var n=this.tolerance,i=void 0,o=0;on&&(n=s,i=a),n>1e3*this.tolerance)break}}i&&this.addVertexToFace(r,i)}}},{key:"computeExtremes",value:function(){var t=[],e=[],r=[],n=[],i=void 0,o=void 0;for(i=0;i<3;i+=1)r[i]=n[i]=this.vertices[0];for(i=0;i<3;i+=1)t[i]=e[i]=this.vertices[0].point[i];for(i=1;ie[o]&&(e[o]=s[o],n[o]=a)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(t[0]),Math.abs(e[0]))+Math.max(Math.abs(t[1]),Math.abs(e[1]))+Math.max(Math.abs(t[2]),Math.abs(e[2]))),p.enabled&&p("tolerance %d",this.tolerance),[r,n]}},{key:"createInitialSimplex",value:function(){var t,e,r=this.vertices,i=this.computeExtremes(),u=n(i,2),c=u[0],h=u[1],f=void 0,p=void 0,d=void 0,m=void 0,v=0,g=0;for(d=0;d<3;d+=1){var y=h[d].point[d]-c[d].point[d];y>v&&(v=y,g=d)}for(t=c[g],e=h[g],v=0,d=0;dv&&(v=w,f=x)}}var b=(0,a.default)([],t.point,e.point,f.point),M=(0,s.default)(t.point,b);for(v=-1,d=0;dv&&(v=E,p=_)}}var S=[];if((0,s.default)(p.point,b)-M<0)for(S.push(l.default.createTriangle(t,e,f),l.default.createTriangle(p,e,t),l.default.createTriangle(p,f,e),l.default.createTriangle(p,t,f)),d=0;d<3;d+=1){var A=(d+1)%3;S[d+1].getEdge(2).setOpposite(S[0].getEdge(A)),S[d+1].getEdge(1).setOpposite(S[A+1].getEdge(0))}else for(S.push(l.default.createTriangle(t,f,e),l.default.createTriangle(p,t,e),l.default.createTriangle(p,e,f),l.default.createTriangle(p,f,t)),d=0;d<3;d+=1){var T=(d+1)%3;S[d+1].getEdge(2).setOpposite(S[0].getEdge((3-d)%3)),S[d+1].getEdge(0).setOpposite(S[T+1].getEdge(1))}for(d=0;d<4;d+=1)this.faces.push(S[d]);for(d=0;dv&&(v=C,R=S[m])}R&&this.addVertexToFace(L,R)}}}},{key:"reindexFaceAndVertices",value:function(){for(var t=[],e=0;er&&(r=i,t=e)}return t}}},{key:"computeHorizon",value:function(t,e,r,n){this.deleteFaceVertices(r),r.mark=h.DELETED;var i=void 0;i=e?e.next:e=r.getEdge(0);do{var o=i.opposite,a=o.face;a.mark===h.VISIBLE&&(a.distanceToPlane(t)>this.tolerance?this.computeHorizon(t,o,a,n):n.push(i)),i=i.next}while(i!==e)}},{key:"addAdjoiningFace",value:function(t,e){var r=l.default.createTriangle(t,e.tail(),e.head());return this.faces.push(r),r.getEdge(-1).setOpposite(e.opposite),r.getEdge(0)}},{key:"addNewFaces",value:function(t,e){this.newFaces=[];for(var r=void 0,n=void 0,i=0;i=t.nVertices)throw Error("merge recursion limit exceeded");var o=r.opposite.face,a=!1;if(2===e)(this.oppositeFaceDistance(r)>-this.tolerance||this.oppositeFaceDistance(r.opposite)>-this.tolerance)&&(a=!0);else if(t.area>o.area?this.oppositeFaceDistance(r)>-this.tolerance?a=!0:this.oppositeFaceDistance(r.opposite)>-this.tolerance&&(n=!1):this.oppositeFaceDistance(r.opposite)>-this.tolerance?a=!0:this.oppositeFaceDistance(r)>-this.tolerance&&(n=!1),a){p("face merge");for(var s=t.mergeAdjacentFaces(r,[]),u=0;u0;)e=e.next,t-=1;for(;t<0;)e=e.prev,t+=1;return e}},{key:"computeNormal",value:function(){var t=this.edge,e=t.next,r=e.next,n=(0,a.default)([],e.head().point,t.head().point),i=[],l=[];for(this.nVertices=2,this.normal=[0,0,0];r!==t;)(0,u.default)(l,n),(0,a.default)(n,r.head().point,t.head().point),(0,o.default)(this.normal,this.normal,(0,s.default)(i,l,n)),r=r.next,this.nVertices+=1;this.area=(0,c.default)(this.normal),this.normal=(0,h.default)(this.normal,this.normal,1/this.area)}},{key:"computeNormalMinArea",value:function(t){if(this.computeNormal(),this.arear&&(e=n,r=o),n=n.next}while(n!==this.edge);var s=e.tail().point,u=e.head().point,c=(0,a.default)([],u,s),p=Math.sqrt(r);(0,h.default)(c,c,1/p);var d=(0,i.default)(this.normal,c);(0,l.default)(this.normal,this.normal,c,-d),(0,f.default)(this.normal,this.normal)}}},{key:"computeCentroid",value:function(){this.centroid=[0,0,0];var t=this.edge;do{(0,o.default)(this.centroid,this.centroid,t.head().point),t=t.next}while(t!==this.edge);(0,h.default)(this.centroid,this.centroid,1/this.nVertices)}},{key:"computeNormalAndCentroid",value:function(t){void 0!==t?this.computeNormalMinArea(t):this.computeNormal(),this.computeCentroid(),this.offset=(0,i.default)(this.normal,this.centroid)}},{key:"distanceToPlane",value:function(t){return(0,i.default)(this.normal,t)-this.offset}},{key:"connectHalfEdges",value:function(t,e){var r=void 0;if(t.opposite.face===e.opposite.face){var n=e.opposite.face,i=void 0;t===this.edge&&(this.edge=e),3===n.nVertices?(i=e.opposite.prev.opposite,n.mark=g,r=n):(i=e.opposite.next,n.edge===i.prev&&(n.edge=i),i.prev=i.prev.prev,i.prev.next=i),e.prev=t.prev,e.prev.next=e,e.setOpposite(i),n.computeNormalAndCentroid()}else t.next=e,e.prev=t;return r}},{key:"mergeAdjacentFaces",value:function(t,e){var r=t.opposite,n=r.face;e.push(n),n.mark=g;for(var i=t.prev,o=t.next,a=r.prev,s=r.next;i.opposite.face===n;)i=i.prev,s=s.next;for(;o.opposite.face===n;)o=o.next,a=a.prev;var u=void 0;for(u=s;u!==a.next;u=u.next)u.face=this;this.edge=o;var c=void 0;return(c=this.connectHalfEdges(a,o))&&e.push(c),(c=this.connectHalfEdges(i,s))&&e.push(c),this.computeNormalAndCentroid(),e}},{key:"collectIndices",value:function(){var t=[],e=this.edge;do{t.push(e.head().index),e=e.next}while(e!==this.edge);return t}}],[{key:"createTriangle",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=new t,a=new p.default(e,o),s=new p.default(r,o),u=new p.default(n,o);return a.next=u.prev=s,s.next=a.prev=u,u.next=s.prev=a,o.edge=a,o.computeNormalAndCentroid(i),m.enabled&&m("face created %j",o.collectIndices()),o}}]),t}();e.default=y},3936:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var s=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*a;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*i;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(t);if("number"===u&&!1===isNaN(t))return e.long?function(t){return s(t,o,"day")||s(t,i,"hour")||s(t,n,"minute")||s(t,r,"second")||t+" ms"}(t):function(t){if(t>=o)return Math.round(t/o)+"d";if(t>=i)return Math.round(t/i)+"h";if(t>=n)return Math.round(t/n)+"m";if(t>=r)return Math.round(t/r)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},3939:function(t,e,r){var n;!function(){"use strict";var e=1/1048576;function r(t,r,n,i){var o,a,s,u,c,h,l,f,p,d,m=t[r][0],v=t[r][1],g=t[n][0],y=t[n][1],x=t[i][0],w=t[i][1],b=Math.abs(v-y),M=Math.abs(y-w);if(bM?s*(o-c)+l:u*(o-h)+f),{i:r,j:n,k:i,x:o,y:a,r:(p=g-o)*p+(d=y-a)*d}}function i(t){var e,r,n,i,o,a;for(r=t.length;r;)for(i=t[--r],n=t[--r],e=r;e;)if(a=t[--e],n===(o=t[--e])&&i===a||n===a&&i===o){t.splice(r,2),t.splice(e,2);break}}n={triangulate:function(t,n){var o,a,s,u,c,h,l,f,p,d,m,v,g=t.length;if(g<3)return[];if(t=t.slice(0),n)for(o=g;o--;)t[o]=t[o][n];for(s=new Array(g),o=g;o--;)s[o]=o;for(s.sort(function(e,r){return t[r][0]-t[e][0]}),u=function(t){var e,r,n,i,o,a,s=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(e=t.length;e--;)t[e][0]c&&(c=t[e][0]),t[e][1]h&&(h=t[e][1]);return n=h-u,[[(o=s+.5*(r=c-s))-20*(i=Math.max(r,n)),(a=u+.5*n)-i],[o,a+20*i],[o+20*i,a-i]]}(t),t.push(u[0],u[1],u[2]),c=[r(t,g+0,g+1,g+2)],h=[],l=[],o=s.length;o--;l.length=0){for(v=s[o],a=c.length;a--;)(f=t[v][0]-c[a].x)>0&&f*f>c[a].r?(h.push(c[a]),c.splice(a,1)):f*f+(p=t[v][1]-c[a].y)*p-c[a].r>e||(l.push(c[a].i,c[a].j,c[a].j,c[a].k,c[a].k,c[a].i),c.splice(a,1));for(i(l),a=l.length;a;)m=l[--a],d=l[--a],c.push(r(t,d,m,v))}for(o=c.length;o--;)h.push(c[o]);for(c.length=0,o=h.length;o--;)h[o].it[0][0]&&e[0]>t[1][0]&&e[0]>t[2][0]||e[1]t[0][1]&&e[1]>t[1][1]&&e[1]>t[2][1])return null;var r=t[1][0]-t[0][0],n=t[2][0]-t[0][0],i=t[1][1]-t[0][1],o=t[2][1]-t[0][1],a=r*o-n*i;if(0===a)return null;var s=(o*(e[0]-t[0][0])-n*(e[1]-t[0][1]))/a,u=(r*(e[1]-t[0][1])-i*(e[0]-t[0][0]))/a;return s<0||u<0||s+u>1?null:[s,u]}},t.exports=n}()},3940:function(t,e,r){"use strict";var n=r(3941),i=r(3943),o=r(3944),a=r(3946);function s(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function c(t,e,r){return e in t?t[e]:r}t.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var h=!!c(r,"delaunay",!0),l=!!c(r,"interior",!0),f=!!c(r,"exterior",!0),p=!!c(r,"infinity",!1);if(!l&&!f||0===t.length)return[];var d=n(t,e);if(h||l!==f||p){for(var m=i(t.length,function(t){return t.map(s).sort(u)}(e)),v=0;v1&&i(r[f[p-2]],r[f[p-1]],o)>0;)t.push([f[p-1],f[p-2],a]),p-=1;f.length=p,f.push(a);var d=h.upperIds;for(p=d.length;p>1&&i(r[d[p-2]],r[d[p-1]],o)<0;)t.push([d[p-2],d[p-1],a]),p-=1;d.length=p,d.push(a)}}function p(t,e){var r;return(r=t.a[0]g[0]&&i.push(new c(g,v,s,l),new c(v,g,a,l))}i.sort(h);for(var y=i[0].a[0]-(1+Math.abs(i[0].a[0]))*Math.pow(2,-52),x=[new u([y,1],[y,0],-1,[],[],[],[])],w=[],l=0,b=i.length;l=0}}(),o.removeTriangle=function(t,e,r){var n=this.stars;a(n[t],e,r),a(n[e],r,t),a(n[r],t,e)},o.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},o.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n0;){for(var h=r.pop(),s=r.pop(),l=-1,f=-1,u=a[s],d=1;d=0||(e.flip(s,h),i(t,e,r,l,s,f),i(t,e,r,s,f,l),i(t,e,r,f,h,l),i(t,e,r,h,l,f)))}}},3945:function(t,e,r){"use strict";var n=r(2476),i=r(2574),o=r(2576),a=r(2575),s=6;function u(t,e){for(var r=new Array(t.length-1),n=1;n>1;return["sum(",c(t.slice(0,e)),",",c(t.slice(e)),")"].join("")}function h(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return h(e,t)}function l(t){return!0&t?"-":""}function f(t){if(2===t.length)return[["diff(",h(t[0][0],t[1][1]),",",h(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r0||u.length>0;){for(;s.length>0;){var p=s.pop();if(c[p]!==-a){c[p]=a;h[p];for(var d=0;d<3;++d){var m=f[3*p+d];m>=0&&0===c[m]&&(l[3*p+d]?u.push(m):(s.push(m),c[m]=a))}}}var v=u;u=s,s=v,u.length=0,a=-a}var g=function(t,e,r){for(var n=0,i=0;i80*r){n=u=t[0],s=c=t[1];for(var w=r;wu&&(u=h),p>c&&(c=p);m=0!==(m=Math.max(u-n,c-s))?1/m:0}return a(y,x,r,n,s,m),x}function i(t,e,r,n,i){var o,a;if(i===S(t,e,r,n)>0)for(o=e;o=e;o-=n)a=M(o,t[o],t[o+1],a);return a&&y(a,a.next)&&(_(a),a=a.next),a}function o(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!y(n,n.next)&&0!==g(n.prev,n,n.next))n=n.next;else{if(_(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function a(t,e,r,n,i,l,f){if(t){!f&&l&&function(t,e,r,n){var i=t;do{null===i.z&&(i.z=p(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,r,n,i,o,a,s,u,c=1;do{for(r=t,t=null,o=null,a=0;r;){for(a++,n=r,s=0,e=0;e0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;r=n}o.nextZ=null,c*=2}while(a>1)}(i)}(t,n,i,l);for(var d,m,v=t;t.prev!==t.next;)if(d=t.prev,m=t.next,l?u(t,n,i,l):s(t))e.push(d.i/r),e.push(t.i/r),e.push(m.i/r),_(t),t=m.next,v=m.next;else if((t=m)===v){f?1===f?a(t=c(t,e,r),e,r,n,i,l,2):2===f&&h(t,e,r,n,i,l):a(o(t),e,r,n,i,l,1);break}}}function s(t){var e=t.prev,r=t,n=t.next;if(g(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(m(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&g(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function u(t,e,r,n){var i=t.prev,o=t,a=t.next;if(g(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,h=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,l=p(s,u,e,r,n),f=p(c,h,e,r,n),d=t.prevZ,v=t.nextZ;d&&d.z>=l&&v&&v.z<=f;){if(d!==t.prev&&d!==t.next&&m(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&g(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,v!==t.prev&&v!==t.next&&m(i.x,i.y,o.x,o.y,a.x,a.y,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;d&&d.z>=l;){if(d!==t.prev&&d!==t.next&&m(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&g(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=f;){if(v!==t.prev&&v!==t.next&&m(i.x,i.y,o.x,o.y,a.x,a.y,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function c(t,e,r){var n=t;do{var i=n.prev,o=n.next.next;!y(i,o)&&x(i,n,n.next,o)&&w(i,o)&&w(o,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(o.i/r),_(n),_(n.next),n=t=o),n=n.next}while(n!==t);return n}function h(t,e,r,n,i,s){var u=t;do{for(var c=u.next.next;c!==u.prev;){if(u.i!==c.i&&v(u,c)){var h=b(u,c);return u=o(u,u.next),h=o(h,h.next),a(u,e,r,n,i,s),void a(h,e,r,n,i,s)}c=c.next}u=u.next}while(u!==t)}function l(t,e){return t.x-e.x}function f(t,e){if(e=function(t,e){var r,n=e,i=t.x,o=t.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x=n.x&&n.x>=h&&i!==n.x&&m(or.x)&&w(n,t)&&(r=n,f=u),n=n.next;return r}(t,e)){var r=b(e,t);o(r,r.next)}}function p(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,r=t;do{e.x=0&&(t-a)*(n-s)-(r-a)*(e-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&x(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)}function g(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,r,n){return!!(y(t,e)&&y(r,n)||y(t,n)&&y(r,e))||g(t,e,r)>0!=g(t,e,n)>0&&g(r,n,t)>0!=g(r,n,e)>0}function w(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var r=new E(t.i,t.x,t.y),n=new E(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function M(t,e,r,n){var i=new E(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function _(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function E(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(t,e,r,n){for(var i=0,o=e,a=r-n;o0&&(n+=t[i-1].length,r.holes.push(n))}return r}},3948:function(t,e){t.exports=function(t){if(3!==t.length)throw new TypeError("must provide triangle array of length 3");for(var e=t[0].length,r=new Array(e),n=0;n0?1<1e-6&&(T=S/A);for(var L=0;L<3;++L)b[L]=u[L]*(v[L]+_[L]+T*(E[L]-_[L]))+c[L];l.push(b)}var R=n[g];for(h=0;h1e-6&&(l=n/l);for(var d=0;d<3;++d)h[d]=a[d]*(h[d]+o[d]+l*(u[d]-o[d]))+s[d];return c.push(h),c.length-1}for(p[2]=0;p[2]>1):0}i[e]=a}}();var o=new Array(4096);!function(){for(var t=0;to.length){var v=o.length;for(o.length=2*p[2];v1e-6){R=L/R;for(b=0,w=1;b<3;++b,w<<=1){var C=A&w,P=T&w;E[b]+=C!==P?C?1-R:R:C?1:0}}}var I=1/S;for(c=0;c<3;++c)E[c]=s[c]*(f[c]+I*E[c])+u[c];o[g]=h.length,h.push(E);for(c=0;c<3;++c)if(_&1<1e-6){var x=i[u],w=1/Math.sqrt(m*g);for(y=0;y<3;++y){var b=(y+1)%3,M=(y+2)%3;x[y]+=w*(v[b]*d[M]-v[M]*d[b])}}}for(o=0;o1e-6)for(w=1/Math.sqrt(_),y=0;y<3;++y)x[y]*=w;else for(y=0;y<3;++y)x[y]=0}return i},e.face_normals=function(t){for(var e=t.positions,r=t.faces,n=r.length,i=new Array(n),o=0;o1e-6?1/Math.sqrt(f):0;for(u=0;u<3;++u)l[u]*=f;i[o]=l}return i}},3955:function(t,e,r){r(3956);var n=r(3960).BinaryHeap,i=r(2477).vertex_stars,o=1e-6;function a(t,e,r,n,i,a){for(var s=new Array(3),u=new Array(3),c=0,h=0;h<3;++h)s[h]=e[h]-t[h],c+=s[h]*s[h],u[h]=r[h]-t[h];if(c0;){var l=a.pop();if(!(l.v in u)){var f=l.d,p=l.v;u[p]=f;for(var d=i[p],m=e[p],v=0;vo));++f)for(var p=n[l],d=0;do)){var g=e[m[2]];vs&&(e[m[2]]=Math.min(g,v),c=!1)}}}}}(0,l,e,u,r,c,h),l}},3956:function(t,e,r){var n=r(3957),i=Array.prototype.slice,o=Object.prototype.hasOwnProperty,a=t.exports=h;function s(t,e){return n.isUndefined(e)?""+e:n.isNumber(e)&&!isFinite(e)?e.toString():n.isFunction(e)||n.isRegExp(e)?e.toString():e}function u(t,e){return n.isString(t)?t.length=0;s--)if(u[s]!=c[s])return!1;for(s=u.length-1;s>=0;s--)if(a=u[s],!l(t[a],e[a]))return!1;return!0}(t,e):t==e}function f(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function p(t,e){return!(!t||!e)&&("[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e||!0===e.call({},t))}function d(t,e,r,i){var o;n.isString(r)&&(i=r,r=null);try{e()}catch(t){o=t}if(i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),t&&!o&&c(o,r,"Missing expected exception"+i),!t&&p(o,r)&&c(o,r,"Got unwanted exception"+i),t&&o&&r&&!p(o,r)||!t&&o)throw o}a.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return u(JSON.stringify(t.actual,s),128)+" "+t.operator+" "+u(JSON.stringify(t.expected,s),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||c;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},n.inherits(a.AssertionError,Error),a.fail=c,a.ok=h,a.equal=function(t,e,r){t!=e&&c(t,e,r,"==",a.equal)},a.notEqual=function(t,e,r){t==e&&c(t,e,r,"!=",a.notEqual)},a.deepEqual=function(t,e,r){l(t,e)||c(t,e,r,"deepEqual",a.deepEqual)},a.notDeepEqual=function(t,e,r){l(t,e)&&c(t,e,r,"notDeepEqual",a.notDeepEqual)},a.strictEqual=function(t,e,r){t!==e&&c(t,e,r,"===",a.strictEqual)},a.notStrictEqual=function(t,e,r){t===e&&c(t,e,r,"!==",a.notStrictEqual)},a.throws=function(t,e,r){d.apply(this,[!0].concat(i.call(arguments)))},a.doesNotThrow=function(t,e){d.apply(this,[!1].concat(i.call(arguments)))},a.ifError=function(t){if(t)throw t};var m=Object.keys||function(t){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e}},3957:function(t,e,r){(function(t,n){var i=/%[sdj%]/g;e.format=function(t){if(!g(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(r)?n.showHidden=r:r&&e._extend(n,r),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),h(n,t,n.depth)}function u(t,e){var r=s.styles[e];return r?"["+s.colors[r][0]+"m"+t+"["+s.colors[r][1]+"m":t}function c(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&_(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return g(i)||(i=h(t,i,n)),i}var o=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(v(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),M(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(_(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(x(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(b(r))return t.stylize(Date.prototype.toString.call(r),"date");if(M(r))return l(r)}var c,w="",E=!1,S=["{","}"];(p(r)&&(E=!0,S=["[","]"]),_(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return x(r)&&(w=" "+RegExp.prototype.toString.call(r)),b(r)&&(w=" "+Date.prototype.toUTCString.call(r)),M(r)&&(w=" "+l(r)),0!==a.length||E&&0!=r.length?n<0?x(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=E?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,S)):S[0]+w+S[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),T(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=m(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),y(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function m(t){return null===t}function v(t){return"number"==typeof t}function g(t){return"string"==typeof t}function y(t){return void 0===t}function x(t){return w(t)&&"[object RegExp]"===E(t)}function w(t){return"object"==typeof t&&null!==t}function b(t){return w(t)&&"[object Date]"===E(t)}function M(t){return w(t)&&("[object Error]"===E(t)||t instanceof Error)}function _(t){return"function"==typeof t}function E(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(y(o)&&(o=Object({NODE_ENV:"production"}).NODE_DEBUG||""),t=t.toUpperCase(),!a[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=p,e.isBoolean=d,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=v,e.isString=g,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=y,e.isRegExp=x,e.isObject=w,e.isDate=b,e.isError=M,e.isFunction=_,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(3958);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(3959),e._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,r(30),r(99))},3958:function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},3959:function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},3960:function(t,e,r){function n(t){this.content=[],this.scoreFunction=t}n.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},remove:function(t){for(var e=this.content.length,r=0;r0;){var r=Math.floor((t+1)/2)-1,n=this.content[r];if(!(this.scoreFunction(e)>1,o=2*i+1;function a(t,e,r){return t+o*(e+o*r)}for(var s=new Array(6*o*o),u=[],c=0;c<3;++c)for(var h=(c+1)%3,l=(c+2)%3,f=0;f<2;++f){var p=2*c+f,d=new Array(3);d[h]=-i,d[l]=-i,d[c]=(1-2*f)*i;for(var m=0;m.5)){e[0]-=i*r[0],e[1]-=i*r[1],e[2]-=i*r[2];var a=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=a,e[1]/=a,e[2]/=a;break}}for(var s=[0,0,0],u=0,c=0;c<3;++c){var h=(c+1)%3,l=(c+2)%3;s[c]=e[h]*r[l]-e[l]*r[h],u+=s[c]*s[c]}u=Math.sqrt(u);for(var c=0;c<3;++c)s[c]/=u;return[s,e,r]}},3964:function(t,e,r){"use strict";t.exports=function(t,e){if(!Array.isArray(t))throw new Error("poly-to-pslg: Error, invalid polygon");if(0===t.length)return{points:[],edges:[]};var r=!0;"nested"in(e=e||{})?r=!!e.nested:2===t[0].length&&"number"==typeof t[0][0]&&(r=!1);r||(t=[t]);for(var i=[],o=[],a=0;a>>1;if(!(h<=0)){var l,f=i.mallocDouble(2*h*s),p=i.mallocInt32(s);if((s=u(t,h,f,p))>0){if(1===h&&n)o.init(s),l=o.sweepComplete(h,r,0,s,f,p,0,s,f,p);else{var d=i.mallocDouble(2*h*c),m=i.mallocInt32(c);(c=u(e,h,d,m))>0&&(o.init(s+c),l=1===h?o.sweepBipartite(h,r,0,s,f,p,0,c,d,m):a(h,r,n,s,f,p,c,d,m),i.free(d),i.free(m))}i.free(f),i.free(p)}return l}}}function h(t,e){n.push([t,e])}},3966:function(t,e,r){"use strict";t.exports=function(t,e){e<=4*n?i(0,e-1,t):function t(e,r,l){var f=(r-e+1)/6|0,p=e+f,d=r-f,m=e+r>>1,v=m-f,g=m+f,y=p,x=v,w=m,b=g,M=d,_=e+1,E=r-1,S=0;c(y,x,l)&&(S=y,y=x,x=S);c(b,M,l)&&(S=b,b=M,M=S);c(y,w,l)&&(S=y,y=w,w=S);c(x,w,l)&&(S=x,x=w,w=S);c(y,b,l)&&(S=y,y=b,b=S);c(w,b,l)&&(S=w,w=b,b=S);c(x,M,l)&&(S=x,x=M,M=S);c(x,w,l)&&(S=x,x=w,w=S);c(b,M,l)&&(S=b,b=M,M=S);var A=l[2*x];var T=l[2*x+1];var L=l[2*b];var R=l[2*b+1];var C=2*y;var P=2*w;var I=2*M;var N=2*p;var F=2*m;var U=2*d;for(var O=0;O<2;++O){var D=l[C+O],k=l[P+O],B=l[I+O];l[N+O]=D,l[F+O]=k,l[U+O]=B}a(v,e,l);a(g,r,l);for(var z=_;z<=E;++z)if(h(z,A,T,l))z!==_&&o(z,_,l),++_;else if(!h(z,L,R,l))for(;;){if(h(E,L,R,l)){h(E,A,T,l)?(s(z,_,E,l),++_,--E):(o(z,E,l),--E);break}if(--Et;){var c=r[u-2],h=r[u-1];if(cr[e+1])}function h(t,e,r,n){var i=n[t*=2];return i0;){var F=(I-=1)*w,U=M[F],O=M[F+1],D=M[F+2],k=M[F+3],B=M[F+4],z=M[F+5],j=I*b,G=_[j],V=_[j+1],H=1&z,W=!!(16&z),Y=h,X=T,q=R,Z=C;if(H&&(Y=R,X=C,q=h,Z=T),!(2&z&&(D=v(t,U,O,D,Y,X,V),O>=D)||4&z&&(O=g(t,U,O,D,Y,X,G))>=D)){var J=D-O,Q=B-k;if(W){if(t*J*(J+Q)=p0)&&!(p1>=hi)",["p0","p1"]),m=h("lo===p0",["p0"]),v=h("lo"+d+"-"+p+"){"),t?(_(!0,!1),M.push("}else{"),_(!1,!1)):(M.push("if("+a+"){"),_(!0,!0),M.push("}else{"),_(!0,!1),M.push("}}else{if("+a+"){"),_(!1,!0),M.push("}else{"),_(!1,!1),M.push("}")),M.push("}}return "+e);var E=r.join("")+M.join("");return new Function(E)()}e.partial=b(!1),e.full=b(!0)},3969:function(t,e,r){"use strict";t.exports=function(t,e,r,a,s,u){if(a<=r+1)return r;var c=r,h=a,l=a+r>>>1,f=2*t,p=l,d=s[f*l+e];for(;c=x?(p=y,d=x):g>=b?(p=v,d=g):(p=w,d=b):x>=b?(p=y,d=x):b>=g?(p=v,d=g):(p=w,d=b);for(var M=f*(h-1),_=f*p,E=0;Er&&i[l+e]>c;--h,l-=a){for(var f=l,p=l+a,d=0;d0&&a>0||o<0&&a<0)return!1;var s=n(r,t,e),u=n(i,t,e);if(s>0&&u>0||s<0&&u<0)return!1;if(0===o&&0===a&&0===s&&0===u)return function(t,e,r,n){for(var i=0;i<2;++i){var o=t[i],a=e[i],s=Math.min(o,a),u=Math.max(o,a),c=r[i],h=n[i],l=Math.min(c,h),f=Math.max(c,h);if(f20)return 52;return r+32}},3978:function(t,e,r){"use strict";t.exports=function(t){for(var e=new Array(t.length),r=0;r>>0;t.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-i:i;var r=n.hi(t),a=n.lo(t);e>t==t>0?a===o?(r+=1,a=0):a+=1:0===a?(a=o,r-=1):a-=1;return n.pack(a,r)}},3980:function(t,e,r){"use strict";t.exports=function(t,e,r,n){var o=s(e,t),l=s(n,r),f=h(o,l);if(0===a(f))return null;var p=s(t,r),d=h(l,p),m=i(d,f),v=c(o,m);return u(t,v)};var n=r(2584),i=r(2583),o=r(2585),a=r(3981),s=r(3982),u=r(3983),c=r(3985);function h(t,e){return o(n(t[0],e[1]),n(t[1],e[0]))}},3981:function(t,e,r){"use strict";var n=r(2481);t.exports=function(t){return n(t[0])*n(t[1])}},3982:function(t,e,r){"use strict";var n=r(2585);t.exports=function(t,e){for(var r=t.length,i=new Array(r),o=0;o>1,s=o(t[a],e);s<=0?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function h(t,e){for(var r=new Array(t.length),i=0,a=r.length;i=t.length||0!==o(t[v],s)););}return r}function l(t,e){if(e<0)return[];for(var r=[],i=(1<>>h&1&&c.push(i[h]);e.push(c)}return s(e)},e.skeleton=l,e.boundary=function(t){for(var e=[],r=0,n=t.length;r0){var c=t[r-1];if(0===n(s,c)&&o(c)!==u){r-=1;continue}}t[r++]=s}}return t.length=r,t}},3990:function(t,e,r){"use strict";var n=r(2586),i=r(2587);t.exports=function(t,e){return n(t,e)||i(t)-i(e)}},3991:function(t,e,r){"use strict";var n=r(3992),i=r(582);t.exports={fromList:c,fromDictionary:function(t,e,r){return c(Object.keys(t).map(function(e){var r=e.split(",");return[0|r[0],0|r[1],t[e]]}),e,r)},fromDense:function(t){var e=[],r=t.length;if(0===r)return c([],0,0);for(var n=t[0].length,i=0;io&&e.push([i,s,u])}return c(e,r,n)},fromNDArray:function(t){var e=[],r=t.shape[0],n=t.shape[1];if(t.stride[1]>t.stride[0])for(var i=0;i=e||a[1]>=r)){for(;no&&(t[i++]=a)}}return t.length=i,t}(t,e||1/0,r||1/0);var n=[],i=[],s=[],c=[],h=new Float64Array(t.length);e=e||0,r=r||0;for(var l=0;l0)-(t<0)},e.abs=function(t){var e=t>>31;return(t^e)-e},e.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},e.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},e.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},e.countTrailingZeros=n,e.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},e.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},e.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},e.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},e.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},e.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},e.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},e.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},3996:function(t,e,r){"use strict";var n=r(3997),i=r(3998),o=r(3999),a=r(4e3),s=new Float64Array(4);t.exports=function(t,e,r,u){switch(u||(s.lengthn&&((l=a/o)<0?l=0:l>1&&(l=1));var f=1-l,p=0;for(s=0;s=c?(E=1,y=c+2*f+d):y=f*(E=-f/c)+d):(E=0,p>=0?(S=0,y=d):-p>=l?(S=1,y=l+2*p+d):y=p*(S=-p/l)+d);else if(S<0)S=0,f>=0?(E=0,y=d):-f>=c?(E=1,y=c+2*f+d):y=f*(E=-f/c)+d;else{var A=1/_;y=(E*=A)*(c*E+h*(S*=A)+2*f)+S*(h*E+l*S+2*p)+d}else E<0?(w=l+p)>(x=h+f)?(b=w-x)>=(M=c-2*h+l)?(E=1,S=0,y=c+2*f+d):y=(E=b/M)*(c*E+h*(S=1-E)+2*f)+S*(h*E+l*S+2*p)+d:(E=0,w<=0?(S=1,y=l+2*p+d):p>=0?(S=0,y=d):y=p*(S=-p/l)+d):S<0?(w=c+f)>(x=h+p)?(b=w-x)>=(M=c-2*h+l)?(S=1,E=0,y=l+2*p+d):y=(E=1-(S=b/M))*(c*E+h*S+2*f)+S*(h*E+l*S+2*p)+d:(S=0,w<=0?(E=1,y=c+2*f+d):f>=0?(E=0,y=d):y=f*(E=-f/c)+d):(b=l+p-h-f)<=0?(E=0,S=1,y=l+2*p+d):b>=(M=c-2*h+l)?(E=1,S=0,y=c+2*f+d):y=(E=b/M)*(c*E+h*(S=1-E)+2*f)+S*(h*E+l*S+2*p)+d;var T=1-E-S;for(u=0;u0)){if(isNaN(m.value[0]))break;var v=m.solution;for(u=0;u1e-6){var y=n[s],x=1/Math.sqrt(d*v);for(g=0;g<3;++g){var w=(g+1)%3,b=(g+2)%3;y[g]+=x*(m[w]*p[b]-m[b]*p[w])}}}for(i=0;i1e-6)for(x=1/Math.sqrt(M),g=0;g<3;++g)y[g]*=x;else for(g=0;g<3;++g)y[g]=0}return n},e.faceNormals=function(t,e){for(var r=t.length,n=new Array(r),i=0;i1e-6?1/Math.sqrt(l):0;for(s=0;s<3;++s)h[s]*=l;n[i]=h}return n}},4002:function(t,e,r){"use strict";"use restrict";var n=r(2152).NEGATIVE_INFINITY;function i(t,e,r){var n=this.coords;t:for(;e<=r;){for(var i=e+r>>1,o=2;o>=0;--o){var a=n[o][i]-t[o];if(a<0){e=i+1;continue t}if(a>0){r=i-1;continue t}}return i}return Math.max(0,r)}function o(t,e,r){t?(this.coords=t,this.distances=e,this.phases=r):(this.coords=[[n],[n],[n]],this.distances=[1],this.phases=[0])}function a(t,e,r){t?(this.coords=t,this.distances=e,this.phases=r):(this.coords=[new Int32Array(1),new Int32Array(1),new Int32Array(1)],this.distances=new Float32Array(1),this.phases=new Int32Array(1),this.coords[0][0]=this.coords[1][0]=this.coords[2][0]=n,this.distances[0]=1)}o.prototype.clone=function(){return new o([this.coords[0].slice(0),this.coords[1].slice(0),this.coords[2].slice(0)],this.distances.slice(0),this.phases.slice(0))},o.prototype.length=function(){return this.phases.length},o.prototype.pop=function(){this.coords[0].pop(),this.coords[1].pop(),this.coords[2].pop(),this.distances.pop(),this.phases.pop()},o.prototype.push=function(t,e,r,n,i){var o=this.coords;o[0].push(t),o[1].push(e),o[2].push(r),this.distances.push(n),this.phases.push(i)},o.prototype.bisect=i,o.prototype.toStatic=function(){return new a([new Int32Array(this.coords[0]),new Int32Array(this.coords[1]),new Int32Array(this.coords[2])],new Float32Array(this.distances),new Int32Array(this.phases))},a.prototype.clone=function(){return new a([new Int32Array(this.coords[0]),new Int32Array(this.coords[1]),new Int32Array(this.coords[2])],new Float64Array(this.distances),new Int32Array(this.phases))},a.prototype.length=function(){return this.phases.length};var s=Array.prototype.slice;a.prototype.toDynamic=function(){return new o([s.call(this.coords[0],0),s.call(this.coords[1],0),s.call(this.coords[2],0)],s.call(this.distances,0),s.call(this.phases,0))},a.prototype.bisect=i,e.StaticVolume=a,e.DynamicVolume=o},4003:function(t,e,r){"use strict";"use restrict";var n=r(2152),i=n.POSITIVE_INFINITY,o=n.NEGATIVE_INFINITY,a=r(2591).StencilIterator,s=new Array(128);function u(t,e,r,n,i,o){this.volumes=t,this.stencil=e,this.ptrs=r,this.coord=n,this.stencil_len=i,this.frontier=o}!function(){for(var t=0;t<128;++t)s[t]=0}(),u.prototype.clone=function(){return new u(this.volumes,this.stencil,new Int32Array(this.ptrs),new Int32Array(this.coord),this.stencil_len)},u.prototype.hasNext=function(){return this.coord[0]=d-1)){v+=1;for(var g=2;g>=0;--g){var y=p[g][v]-e[m+g],x=n[g];if(y=0;--g)n[g]=p[g][v]-e[m+g];u=0;break}if(y>x)continue t}s[u++]=c}}}for(h=0;h=0;--r)if(m=y,h=x[r]-E|0,l=w[r]-S|0,!((f=b[r]-A|0)<0||f>=o[2]))for(l<0?h=l=0:l>=o[1]?(h=o[0]-1,l=o[1]-1):h<0?h=0:h>=o[0]&&(h=o[0]-1),y=h+o[0]*(l+o[1]*f),d=_[r],p=M[r],i=m-1;i>=y;--i)v.data[i]=p,g.data[i]=d;return{phase:v,distance:g}},e.array2rle=function(t,e,r){var n,a,s,u=new i.DynamicVolume,c=e.shape,h=c[0],l=c[1],f=c[2];if(t)if(r){for(s=0;s=0){var a=h[o],s=function(t){return"AssignmentExpression"===t.parent.type&&t.parent.left===t?"="===t.parent.operator?g:g|y:"UpdateExpression"===t.parent.type?g|y:y}(r);s&g&&(a.lvalue=!0),s&y&&(a.rvalue=!0),++a.count,v(r,a.name)}else(function(t){if("eval"===t)throw new Error("cwise-parser: eval() not allowed");return"undefined"!=typeof window?t in window:void 0!==e?t in e:"undefined"!=typeof self&&t in self})(i)||v(r,function(t){var e=u+t.replace(/\_/g,"__");return d.push(e),e}(i))}else if("Literal"===r.type)"string"==typeof r.value&&v(r,function(t){return"'"+t.replace(/\_/g,"\\_").replace(/\'/g,"'")+"'"}(r.value));else{if("WithStatement"===r.type)throw new Error("cwise-parser: with() statements not allowed");for(var l=Object.keys(r),f=0,p=l.length;f=48&&t<=57}function b(t){return"0123456789abcdefABCDEF".indexOf(t)>=0}function M(t){return"01234567".indexOf(t)>=0}function _(t){return 32===t||9===t||11===t||12===t||160===t||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0}function E(t){return 10===t||13===t||8232===t||8233===t}function S(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||92===t||t>=128&&s.NonAsciiIdentifierStart.test(String.fromCharCode(t))}function A(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||92===t||t>=128&&s.NonAsciiIdentifierPart.test(String.fromCharCode(t))}function T(t){switch(t){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function L(t){return"eval"===t||"arguments"===t}function R(t,e,r,n,i){var o;x("number"==typeof r,"Comment must have valid position"),g.lastCommentStart>=r||(g.lastCommentStart=r,o={type:t,value:e},y.range&&(o.range=[r,n]),y.loc&&(o.loc=i),y.comments.push(o),y.attachComment&&(y.leadingComments.push(o),y.trailingComments.push(o)))}function C(t){var e,r,n,i;for(e=l-t,r={start:{line:f,column:l-p-t}};l=d&&Y({},a.UnexpectedToken,"ILLEGAL");else if(42===r){if(47===c.charCodeAt(l+1))return++l,++l,void(y.comments&&(n=c.slice(t+2,l-2),e.end={line:f,column:l-p},R("Block",n,t,l,e)));++l}else++l;Y({},a.UnexpectedToken,"ILLEGAL")}function I(){var t,e;for(e=0===l;l>>="===(i=c.substr(l,4))?(l+=4,{type:e.Punctuator,value:i,lineNumber:f,lineStart:p,start:o,end:l}):">>>"===(n=i.substr(0,3))||"<<="===n||">>="===n?(l+=3,{type:e.Punctuator,value:n,lineNumber:f,lineStart:p,start:o,end:l}):(r=n.substr(0,2),u===r[1]&&"+-<>&|".indexOf(u)>=0||"=>"===r?(l+=2,{type:e.Punctuator,value:r,lineNumber:f,lineStart:p,start:o,end:l}):"<>=!+-*%&|^/".indexOf(u)>=0?(++l,{type:e.Punctuator,value:u,lineNumber:f,lineStart:p,start:o,end:l}):void Y({},a.UnexpectedToken,"ILLEGAL"))}function D(){var t,r,n;if(x(w((n=c[l]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),r=l,t="","."!==n){if(t=c[l++],n=c[l],"0"===t){if("x"===n||"X"===n)return++l,function(t){var r="";for(;l0&&(n=y.tokens[y.tokens.length-1]).range[0]===t&&"Punctuator"===n.type&&("/"!==n.value&&"/="!==n.value||y.tokens.pop()),y.tokens.push({type:"RegularExpression",value:r.literal,range:[t,l],loc:e})),r}function z(){var t;return I(),l>=d?{type:e.EOF,lineNumber:f,lineStart:p,start:l,end:l}:S(t=c.charCodeAt(l))?U():40===t||41===t||59===t?O():39===t||34===t?function(){var t,r,n,i,o,s,u,h,m="",v=!1;u=f,h=p,x("'"===(t=c[l])||'"'===t,"String literal must starts with a quote"),r=l,++l;for(;l=0&&l=0?O():B()}return B()}if("Keyword"===t.type&&"this"!==t.value)return B();return O()}():O()}function j(){var t,n,i;return I(),t={start:{line:f,column:l-p}},n=z(),t.end={line:f,column:l-p},n.type!==e.EOF&&(i=c.slice(n.start,n.end),y.tokens.push({type:r[n.type],value:i,range:[n.start,n.end],loc:t})),n}function G(){var t;return l=(t=v).end,f=t.lineNumber,p=t.lineStart,v=void 0!==y.tokens?j():z(),l=t.end,f=t.lineNumber,p=t.lineStart,t}function V(){var t,e,r;t=l,e=f,r=p,v=void 0!==y.tokens?j():z(),l=t,f=e,p=r}function H(t,e){this.line=t,this.column=e}function W(){var t,e,r,n;return t=l,e=f,r=p,I(),n=f!==e,l=t,f=e,p=r,n}function Y(t,e){var r,n=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,function(t,e){return x(e":case"<=":case">=":case"instanceof":n=7;break;case"in":n=r?7:0;break;case"<<":case">>":case">>>":n=8;break;case"+":case"-":n=9;break;case"*":case"/":case"%":n=11}return n}function pt(){var t,e,r,n,i;return i=v,t=function(){var t,e,r,n,i,o,a,s,u,c;if(t=v,u=lt(),0===(i=ft(n=v,g.allowIn)))return u;n.prec=i,G(),e=[t,v],a=lt(),o=[u,n,a];for(;(i=ft(v,g.allowIn))>0;){for(;o.length>2&&i<=o[o.length-2].prec;)a=o.pop(),s=o.pop().value,u=o.pop(),r=m.createBinaryExpression(s,u,a),e.pop(),t=e[e.length-1],m.markEnd(r,t),o.push(r);(n=G()).prec=i,o.push(n),e.push(v),r=lt(),o.push(r)}c=o.length-1,r=o[c],e.pop();for(;c>1;)r=m.createBinaryExpression(o[c-1].value,o[c-2],r),c-=2,t=e.pop(),m.markEnd(r,t);return r}(),Q("?")&&(G(),e=g.allowIn,g.allowIn=!0,r=dt(),g.allowIn=e,Z(":"),n=dt(),t=m.createConditionalExpression(t,r,n),m.markEnd(t,i)),t}function dt(){var t,r,n,o,s;return t=v,s=v,o=r=pt(),function(){var t;if(v.type!==e.Punctuator)return!1;return"="===(t=v.value)||"*="===t||"/="===t||"%="===t||"+="===t||"-="===t||"<<="===t||">>="===t||">>>="===t||"&="===t||"^="===t||"|="===t}()&&(tt(r)||X({},a.InvalidLHSInAssignment),h&&r.type===i.Identifier&&L(r.name)&&X(t,a.StrictLHSAssignment),t=G(),n=dt(),o=m.markEnd(m.createAssignmentExpression(t.value,r,n),s)),o}function mt(){var t,e=v;if(t=dt(),Q(",")){for(t=m.createSequenceExpression([t]);l",r[e.Identifier]="Identifier",r[e.Keyword]="Keyword",r[e.NullLiteral]="Null",r[e.NumericLiteral]="Numeric",r[e.Punctuator]="Punctuator",r[e.StringLiteral]="String",r[e.RegularExpression]="RegularExpression",n=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],i={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},o={Data:1,Get:2,Set:4},a={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},s={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},u={name:"SyntaxTree",processComment:function(t){var e,r;if(!(t.type===i.Program&&t.body.length>0)){for(y.trailingComments.length>0?y.trailingComments[0].range[0]>=t.range[1]?(r=y.trailingComments,y.trailingComments=[]):y.trailingComments.length=0:y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments&&y.bottomRightStack[y.bottomRightStack.length-1].trailingComments[0].range[0]>=t.range[1]&&(r=y.bottomRightStack[y.bottomRightStack.length-1].trailingComments,delete y.bottomRightStack[y.bottomRightStack.length-1].trailingComments);y.bottomRightStack.length>0&&y.bottomRightStack[y.bottomRightStack.length-1].range[0]>=t.range[0];)e=y.bottomRightStack.pop();e?e.leadingComments&&e.leadingComments[e.leadingComments.length-1].range[1]<=t.range[0]&&(t.leadingComments=e.leadingComments,delete e.leadingComments):y.leadingComments.length>0&&y.leadingComments[y.leadingComments.length-1].range[1]<=t.range[0]&&(t.leadingComments=y.leadingComments,y.leadingComments=[]),r&&(t.trailingComments=r),y.bottomRightStack.push(t)}},markEnd:function(t,e){return y.range&&(t.range=[e.start,l]),y.loc&&(t.loc=new function(t,e,r,n){this.start=new H(t,e),this.end=new H(r,n)}(void 0===e.startLineNumber?e.lineNumber:e.startLineNumber,e.start-(void 0===e.startLineStart?e.lineStart:e.startLineStart),f,l-p),this.postProcess(t)),y.attachComment&&this.processComment(t),t},postProcess:function(t){return y.source&&(t.loc.source=y.source),t},createArrayExpression:function(t){return{type:i.ArrayExpression,elements:t}},createAssignmentExpression:function(t,e,r){return{type:i.AssignmentExpression,operator:t,left:e,right:r}},createBinaryExpression:function(t,e,r){var n="||"===t||"&&"===t?i.LogicalExpression:i.BinaryExpression;return{type:n,operator:t,left:e,right:r}},createBlockStatement:function(t){return{type:i.BlockStatement,body:t}},createBreakStatement:function(t){return{type:i.BreakStatement,label:t}},createCallExpression:function(t,e){return{type:i.CallExpression,callee:t,arguments:e}},createCatchClause:function(t,e){return{type:i.CatchClause,param:t,body:e}},createConditionalExpression:function(t,e,r){return{type:i.ConditionalExpression,test:t,consequent:e,alternate:r}},createContinueStatement:function(t){return{type:i.ContinueStatement,label:t}},createDebuggerStatement:function(){return{type:i.DebuggerStatement}},createDoWhileStatement:function(t,e){return{type:i.DoWhileStatement,body:t,test:e}},createEmptyStatement:function(){return{type:i.EmptyStatement}},createExpressionStatement:function(t){return{type:i.ExpressionStatement,expression:t}},createForStatement:function(t,e,r,n){return{type:i.ForStatement,init:t,test:e,update:r,body:n}},createForInStatement:function(t,e,r){return{type:i.ForInStatement,left:t,right:e,body:r,each:!1}},createFunctionDeclaration:function(t,e,r,n){return{type:i.FunctionDeclaration,id:t,params:e,defaults:r,body:n,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(t,e,r,n){return{type:i.FunctionExpression,id:t,params:e,defaults:r,body:n,rest:null,generator:!1,expression:!1}},createIdentifier:function(t){return{type:i.Identifier,name:t}},createIfStatement:function(t,e,r){return{type:i.IfStatement,test:t,consequent:e,alternate:r}},createLabeledStatement:function(t,e){return{type:i.LabeledStatement,label:t,body:e}},createLiteral:function(t){return{type:i.Literal,value:t.value,raw:c.slice(t.start,t.end)}},createMemberExpression:function(t,e,r){return{type:i.MemberExpression,computed:"["===t,object:e,property:r}},createNewExpression:function(t,e){return{type:i.NewExpression,callee:t,arguments:e}},createObjectExpression:function(t){return{type:i.ObjectExpression,properties:t}},createPostfixExpression:function(t,e){return{type:i.UpdateExpression,operator:t,argument:e,prefix:!1}},createProgram:function(t){return{type:i.Program,body:t}},createProperty:function(t,e,r){return{type:i.Property,key:e,value:r,kind:t}},createReturnStatement:function(t){return{type:i.ReturnStatement,argument:t}},createSequenceExpression:function(t){return{type:i.SequenceExpression,expressions:t}},createSwitchCase:function(t,e){return{type:i.SwitchCase,test:t,consequent:e}},createSwitchStatement:function(t,e){return{type:i.SwitchStatement,discriminant:t,cases:e}},createThisExpression:function(){return{type:i.ThisExpression}},createThrowStatement:function(t){return{type:i.ThrowStatement,argument:t}},createTryStatement:function(t,e,r,n){return{type:i.TryStatement,block:t,guardedHandlers:e,handlers:r,finalizer:n}},createUnaryExpression:function(t,e){return"++"===t||"--"===t?{type:i.UpdateExpression,operator:t,argument:e,prefix:!0}:{type:i.UnaryExpression,operator:t,argument:e,prefix:!0}},createVariableDeclaration:function(t,e){return{type:i.VariableDeclaration,declarations:t,kind:e}},createVariableDeclarator:function(t,e){return{type:i.VariableDeclarator,id:t,init:e}},createWhileStatement:function(t,e){return{type:i.WhileStatement,test:t,body:e}},createWithStatement:function(t,e){return{type:i.WithStatement,object:t,body:e}}},t.version="1.2.5",t.tokenize=function(t,r){var n,i;n=String,"string"==typeof t||t instanceof String||(t=n(t));m=u,l=0,f=(c=t).length>0?1:0,p=0,d=c.length,v=null,g={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},(r=r||{}).tokens=!0,y.tokens=[],y.tokenize=!0,y.openParenToken=-1,y.openCurlyToken=-1,y.range="boolean"==typeof r.range&&r.range,y.loc="boolean"==typeof r.loc&&r.loc,"boolean"==typeof r.comment&&r.comment&&(y.comments=[]);"boolean"==typeof r.tolerant&&r.tolerant&&(y.errors=[]);try{if(V(),v.type===e.EOF)return y.tokens;for(G();v.type!==e.EOF;)try{G()}catch(t){if(v,y.errors){y.errors.push(t);break}throw t}Rt(),i=y.tokens,void 0!==y.comments&&(i.comments=y.comments),void 0!==y.errors&&(i.errors=y.errors)}catch(t){throw t}finally{y={}}return i},t.parse=function(t,e){var r,n;n=String,"string"==typeof t||t instanceof String||(t=n(t));m=u,l=0,f=(c=t).length>0?1:0,p=0,d=c.length,v=null,g={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},y={},void 0!==e&&(y.range="boolean"==typeof e.range&&e.range,y.loc="boolean"==typeof e.loc&&e.loc,y.attachComment="boolean"==typeof e.attachComment&&e.attachComment,y.loc&&null!==e.source&&void 0!==e.source&&(y.source=n(e.source)),"boolean"==typeof e.tokens&&e.tokens&&(y.tokens=[]),"boolean"==typeof e.comment&&e.comment&&(y.comments=[]),"boolean"==typeof e.tolerant&&e.tolerant&&(y.errors=[]),y.attachComment&&(y.range=!0,y.comments=[],y.bottomRightStack=[],y.trailingComments=[],y.leadingComments=[]));try{r=Lt(),void 0!==y.comments&&(r.comments=y.comments),void 0!==y.tokens&&(Rt(),r.tokens=y.tokens),void 0!==y.errors&&(r.errors=y.errors)}catch(t){throw t}finally{y={}}return r},t.Syntax=function(){var t,e={};for(t in"function"==typeof Object.create&&(e=Object.create(null)),i)i.hasOwnProperty(t)&&(e[t]=i[t]);return"function"==typeof Object.freeze&&Object.freeze(e),e}()})?n.apply(e,i):n)||(t.exports=o)}()},4010:function(t,e,r){"use strict";var n=r(611),i=new Function("return 1.0");function o(t,e,r,o){o||(o=i);var a=new n.DynamicVolume,s=new Int32Array(3),u=new Int32Array(3);for(s[2]=t[2];s[2]=e[h])continue t;var x=a(v);if(!u[x]){var w=o(v);e:for(var b=0;b<3;++b)for(d=-1;d<=1;++d){v[b]+=d;var M=o(v);if(v[b]-=d,M!==w){c.push([v[0],v[1],v[2],n.saturateAbs(s(v)),w]);break e}}u[x]=!0}}}c.sort(n.compareCoord);var _=new Array(c.length+1),E=new Array(c.length+1),S=new Array(c.length+1),A=new Array(c.length+1),T=new Array(c.length+1);_[0]=E[0]=S[0]=n.NEGATIVE_INFINITY,A[0]=1,T[0]=0;for(h=0;h>1,n(u[h])===f?p=u[h]+1:d=u[h]-1;a.push(u.slice(0))}u[h]=l}return s(t,e,a,n,o)}e.marching=s,e.adaptive=u;var c=new Function("dist_func","x","return dist_func(x) <= 0 ? 1 : 0;");function h(t){return c.bind(null,t)}e.solid={dense:function(t,e,r){return o(t,e,h(r),r)},marching:function(t,e,r,n){return s(t,e,r,h(n),n)},adaptive:function(t,e,r,n){return u(t,e,r,h(n),n)}}},4011:function(t,e,r){"use strict";"use restrict";var n=r(611),i=r(2154),o=n.NEGATIVE_INFINITY,a=n.POSITIVE_INFINITY,s=n.EPSILON,u=i.CUBE_STENCIL,c=n.compareCoord,h=n.beginStencil,l=new Int32Array([6,5,3,0,0,0,1,1,2,2,4,4]),f=new Int32Array([7,7,7,1,2,4,3,5,3,6,5,6]),p=new Int32Array([0,1,2,0,1,2,1,2,0,2,0,1]),d=new Int16Array(256);!function(){for(var t=0;t<256;++t)for(var e=0,r=0;r<12;++r){!(t&1<=v[T])continue t;var L=S.ptrs,R=0;for(T=0;T<8;++T){var C=L[T];M[T]=w[C];var P=b[C];_[T]=P,R|=n(b[L[T]])?0:1<=g.length-1)continue e;var G=g[E[T]+1];for(z=2;z>=0;--z){var V=(0|Math.ceil(G[z]))-A[z]+(T&1<=0)break}for(T=0;T<3;++T)if(A[T]<=i[T])continue t;var H=_[7];for(T=0;T<3;++T)if(I&1<=0&&s[n[h.ptrs[u]]].push(h.coord[0],h.coord[1],h.coord[2],d,0);else s[f].push(h.coord[0],h.coord[1],h.coord[2],d,p)}for(u=0;ue?1:0},p=function(t,e,r,n,i){var o;if(null==r&&(r=0),null==i&&(i=a),r<0)throw new Error("lo must be non-negative");for(null==n&&(n=t.length);rr;0<=r?e++:e--)c.push(e);return c}.apply(this).reverse()).length;nm;0<=m?++h:--h)v.push(c(t,r));return v},y=function(t,e,r,n){var i,o,s;for(null==n&&(n=a),i=t[r];r>e&&n(i,o=t[s=r-1>>1])<0;)t[r]=o,r=s;return t[r]=i},x=function(t,e,r){var n,i,o,s,u;for(null==r&&(r=a),i=t.length,u=e,o=t[e],n=2*e+1;n0)-(t<0)},e.abs=function(t){var e=t>>31;return(t^e)-e},e.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=r=((t>>>=e)>255)<<3,e|=r=((t>>>=r)>15)<<2,(e|=r=((t>>>=r)>3)<<1)|(t>>>=r)>>1},e.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},e.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},e.countTrailingZeros=n,e.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},e.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},e.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},e.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},e.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},e.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},e.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},e.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},559:function(t,e,r){var n=r(522);t.exports=function(t,e,r,i){var o,a,s,u,c,h,l,f,p,d,m=e[0],v=e[1],g=e[2],y=i[0],x=i[1],w=i[2],b=r[0],M=r[1],_=r[2];if(Math.abs(m-b)<1e-6&&Math.abs(v-M)<1e-6&&Math.abs(g-_)<1e-6)return n(t);l=m-b,f=v-M,p=g-_,d=1/Math.sqrt(l*l+f*f+p*p),o=x*(p*=d)-w*(f*=d),a=w*(l*=d)-y*p,s=y*f-x*l,(d=Math.sqrt(o*o+a*a+s*s))?(o*=d=1/d,a*=d,s*=d):(o=0,a=0,s=0);u=f*s-p*a,c=p*o-l*s,h=l*a-f*o,(d=Math.sqrt(u*u+c*c+h*h))?(u*=d=1/d,c*=d,h*=d):(u=0,c=0,h=0);return t[0]=o,t[1]=u,t[2]=l,t[3]=0,t[4]=a,t[5]=c,t[6]=f,t[7]=0,t[8]=s,t[9]=h,t[10]=p,t[11]=0,t[12]=-(o*m+a*v+s*g),t[13]=-(u*m+c*v+h*g),t[14]=-(l*m+f*v+p*g),t[15]=1,t}},560:function(t,e){t.exports=function(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[0],s=r[1],u=r[2];return t[0]=i*u-o*s,t[1]=o*a-n*u,t[2]=n*s-i*a,t}},582:function(t,e,r){"use strict";t.exports=function(t,e){switch(void 0===e&&(e=0),typeof t){case"number":if(t>0)return function(t,e){var r,n;for(r=new Array(t),n=0;n0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,r[i]=e[19===i?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},random16:function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*he.DEG2RAD},radToDeg:function(t){return t*he.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};function le(t,e){this.x=t||0,this.y=e||0}function fe(t,e,r,n,i,o,a,s,u,c){Object.defineProperty(this,"id",{value:de()}),this.uuid=he.generateUUID(),this.name="",this.sourceFile="",this.image=void 0!==t?t:fe.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:fe.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:lt,this.wrapT=void 0!==n?n:lt,this.magFilter=void 0!==i?i:gt,this.minFilter=void 0!==o?o:xt,this.anisotropy=void 0!==u?u:1,this.format=void 0!==a?a:Ut,this.type=void 0!==s?s:bt,this.offset=new le(0,0),this.repeat=new le(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:ee,this.version=0,this.onUpdate=null}le.prototype={constructor:le,isVector2:!0,get width(){return this.x},set width(t){this.x=t},get height(){return this.y},set height(t){this.y=t},set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new le,e=new le),t.set(r,r),e.set(n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromAttribute:function(t,e,r){return void 0===r&&(r=0),e=e*t.itemSize+r,this.x=t.array[e],this.y=t.array[e+1],this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}},fe.DEFAULT_IMAGE=void 0,fe.DEFAULT_MAPPING=300,fe.prototype={constructor:fe,isTexture:!0,set needsUpdate(t){!0===t&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=he.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case ht:t.x=t.x-Math.floor(t.x);break;case lt:t.x=t.x<0?0:1;break;case ft:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case ht:t.y=t.y-Math.floor(t.y);break;case lt:t.y=t.y<0?0:1;break;case ft:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}},Object.assign(fe.prototype,e.prototype);var pe=0;function de(){return pe++}function me(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function ve(t,e,r){this.uuid=he.generateUUID(),this.width=t,this.height=e,this.scissor=new me(0,0,t,e),this.scissorTest=!1,this.viewport=new me(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=gt),this.texture=new fe(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function ge(t,e,r){ve.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function ye(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function xe(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function we(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function be(t,e,r,n,i,o,a,s,u,c){t=void 0!==t?t:[],e=void 0!==e?e:rt,fe.call(this,t,e,r,n,i,o,a,s,u,c),this.flipY=!1}me.prototype={constructor:me,isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],u=o[8],c=o[1],h=o[5],l=o[9],f=o[2],p=o[6],d=o[10];if(Math.abs(s-c)<.01&&Math.abs(u-f)<.01&&Math.abs(l-p)<.01){if(Math.abs(s+c)<.1&&Math.abs(u+f)<.1&&Math.abs(l+p)<.1&&Math.abs(a+h+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,v=(h+1)/2,g=(d+1)/2,y=(s+c)/4,x=(u+f)/4,w=(l+p)/4;return m>v&&m>g?m<.01?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(m),n=y/r,i=x/r):v>g?v<.01?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(v),r=y/n,i=w/n):g<.01?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(g),r=x/i,n=w/i),this.set(r,n,i,e),this}var b=Math.sqrt((p-l)*(p-l)+(u-f)*(u-f)+(c-s)*(c-s));return Math.abs(b)<.001&&(b=1),this.x=(p-l)/b,this.y=(u-f)/b,this.z=(c-s)/b,this.w=Math.acos((a+h+d-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new me,e=new me),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromAttribute:function(t,e,r){return void 0===r&&(r=0),e=e*t.itemSize+r,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this.w=t.array[e+3],this}},Object.assign(ve.prototype,e.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ge.prototype=Object.create(ve.prototype),ge.prototype.constructor=ge,ge.prototype.isWebGLRenderTargetCube=!0,ye.prototype={constructor:ye,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!1===(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=Math.cos(t._x/2),n=Math.cos(t._y/2),i=Math.cos(t._z/2),o=Math.sin(t._x/2),a=Math.sin(t._y/2),s=Math.sin(t._z/2),u=t.order;return"XYZ"===u?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"YXZ"===u?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"ZXY"===u?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"ZYX"===u?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"YZX"===u?(this._x=o*n*i+r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i-o*a*s):"XZY"===u&&(this._x=o*n*i-r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i+o*a*s),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],u=r[9],c=r[2],h=r[6],l=r[10],f=n+s+l;return f>0?(e=.5/Math.sqrt(f+1),this._w=.25/e,this._x=(h-u)*e,this._y=(o-c)*e,this._z=(a-i)*e):n>s&&n>l?(e=2*Math.sqrt(1+n-s-l),this._w=(h-u)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+c)/e):s>l?(e=2*Math.sqrt(1+s-n-l),this._w=(o-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(u+h)/e):(e=2*Math.sqrt(1+l-n-s),this._w=(a-i)/e,this._x=(o+c)/e,this._y=(u+h)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(r,n){return void 0===t&&(t=new xe),(e=r.dot(n)+1)<1e-6?(e=0,Math.abs(r.x)>Math.abs(r.z)?t.set(-r.y,r.x,0):t.set(0,-r.z,r.y)):t.crossVectors(r,n),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,u=e._z,c=e._w;return this._x=r*c+o*a+n*u-i*s,this._y=n*c+o*s+i*a-r*u,this._z=i*c+o*u+r*s-n*a,this._w=o*c-r*a-n*s-i*u,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var u=Math.atan2(s,a),c=Math.sin((1-e)*u)/s,h=Math.sin(e*u)/s;return this._w=o*c+this._w*h,this._x=r*c+this._x*h,this._y=n*c+this._y*h,this._z=i*c+this._z*h,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(ye,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],u=r[n+1],c=r[n+2],h=r[n+3],l=i[o+0],f=i[o+1],p=i[o+2],d=i[o+3];if(h!==d||s!==l||u!==f||c!==p){var m=1-a,v=s*l+u*f+c*p+h*d,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),w=Math.atan2(x,v*g);m=Math.sin(m*w)/x,a=Math.sin(a*w)/x}var b=a*g;if(s=s*m+l*b,u=u*m+f*b,c=c*m+p*b,h=h*m+d*b,m===1-a){var M=1/Math.sqrt(s*s+u*u+c*c+h*h);s*=M,u*=M,c*=M,h*=M}}t[e]=s,t[e+1]=u,t[e+2]=c,t[e+3]=h}}),xe.prototype={constructor:xe,isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t;return function(e){return!1===(e&&e.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===t&&(t=new ye),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t;return function(e,r){return void 0===t&&(t=new ye),this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n+i[12],this.y=i[1]*e+i[5]*r+i[9]*n+i[13],this.z=i[2]*e+i[6]*r+i[10]*n+i[14],this},applyProjection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,u=s*e+o*n-a*r,c=s*r+a*e-i*n,h=s*n+i*r-o*e,l=-i*e-o*r-a*n;return this.x=u*s+l*-i+c*-a-h*-o,this.y=c*s+l*-o+h*-i-u*-a,this.z=h*s+l*-a+u*-o-c*-i,this},project:function(){var t;return function(e){return void 0===t&&(t=new we),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyProjection(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new we),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyProjection(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new xe,e=new xe),t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new xe),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new xe),this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(he.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var r=t;t=e,e=r}return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromAttribute:function(t,e,r){return void 0===r&&(r=0),e=e*t.itemSize+r,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this}},we.prototype={constructor:we,isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,u,c,h,l,f,p,d,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=r,v[12]=n,v[1]=i,v[5]=o,v[9]=a,v[13]=s,v[2]=u,v[6]=c,v[10]=h,v[14]=l,v[3]=f,v[7]=p,v[11]=d,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new we).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new xe);var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){!1===(t&&t.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),u=Math.sin(n),c=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){var l=o*c,f=o*h,p=a*c,d=a*h;e[0]=s*c,e[4]=-s*h,e[8]=u,e[1]=f+p*u,e[5]=l-d*u,e[9]=-a*s,e[2]=d-l*u,e[6]=p+f*u,e[10]=o*s}else if("YXZ"===t.order){var m=s*c,v=s*h,g=u*c,y=u*h;e[0]=m+y*a,e[4]=g*a-v,e[8]=o*u,e[1]=o*h,e[5]=o*c,e[9]=-a,e[2]=v*a-g,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*c,v=s*h,g=u*c,y=u*h;e[0]=m-y*a,e[4]=-o*h,e[8]=g+v*a,e[1]=v+g*a,e[5]=o*c,e[9]=y-m*a,e[2]=-o*u,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var l=o*c,f=o*h,p=a*c,d=a*h;e[0]=s*c,e[4]=p*u-f,e[8]=l*u+d,e[1]=s*h,e[5]=d*u+l,e[9]=f*u-p,e[2]=-u,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var x=o*s,w=o*u,b=a*s,M=a*u;e[0]=s*c,e[4]=M-x*h,e[8]=b*h+w,e[1]=h,e[5]=o*c,e[9]=-a*c,e[2]=-u*c,e[6]=w*h+b,e[10]=x-M*h}else if("XZY"===t.order){var x=o*s,w=o*u,b=a*s,M=a*u;e[0]=s*c,e[4]=-h,e[8]=u*c,e[1]=x*h+M,e[5]=o*c,e[9]=w*h-b,e[2]=b*h-w,e[6]=a*c,e[10]=M*h+x}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t.x,n=t.y,i=t.z,o=t.w,a=r+r,s=n+n,u=i+i,c=r*a,h=r*s,l=r*u,f=n*s,p=n*u,d=i*u,m=o*a,v=o*s,g=o*u;return e[0]=1-(f+d),e[4]=h-g,e[8]=l+v,e[1]=h+g,e[5]=1-(c+d),e[9]=p-m,e[2]=l-v,e[6]=p+m,e[10]=1-(c+f),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t,e,r;return function(n,i,o){void 0===t&&(t=new xe,e=new xe,r=new xe);var a=this.elements;return r.subVectors(n,i).normalize(),0===r.lengthSq()&&(r.z=1),t.crossVectors(o,r).normalize(),0===t.lengthSq()&&(r.z+=1e-4,t.crossVectors(o,r).normalize()),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],u=r[12],c=r[1],h=r[5],l=r[9],f=r[13],p=r[2],d=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],w=r[15],b=n[0],M=n[4],_=n[8],E=n[12],S=n[1],A=n[5],T=n[9],L=n[13],R=n[2],C=n[6],P=n[10],I=n[14],N=n[3],F=n[7],U=n[11],O=n[15];return i[0]=o*b+a*S+s*R+u*N,i[4]=o*M+a*A+s*C+u*F,i[8]=o*_+a*T+s*P+u*U,i[12]=o*E+a*L+s*I+u*O,i[1]=c*b+h*S+l*R+f*N,i[5]=c*M+h*A+l*C+f*F,i[9]=c*_+h*T+l*P+f*U,i[13]=c*E+h*L+l*I+f*O,i[2]=p*b+d*S+m*R+v*N,i[6]=p*M+d*A+m*C+v*F,i[10]=p*_+d*T+m*P+v*U,i[14]=p*E+d*L+m*I+v*O,i[3]=g*b+y*S+x*R+w*N,i[7]=g*M+y*A+x*C+w*F,i[11]=g*_+y*T+x*P+w*U,i[15]=g*E+y*L+x*I+w*O,this},multiplyToArray:function(t,e,r){var n=this.elements;return this.multiplyMatrices(t,e),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=n[3],r[4]=n[4],r[5]=n[5],r[6]=n[6],r[7]=n[7],r[8]=n[8],r[9]=n[9],r[10]=n[10],r[11]=n[11],r[12]=n[12],r[13]=n[13],r[14]=n[14],r[15]=n[15],this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToVector3Array:function(){var t;return function(e,r,n){void 0===t&&(t=new xe),void 0===r&&(r=0),void 0===n&&(n=e.length);for(var i=0,o=r;i0)return t;var i=e*r,o=Se[i];if(void 0===o&&(o=new Float32Array(i),Se[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function Le(t,e){var r=Ae[e];void 0===r&&(r=new Int32Array(e),Ae[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function Re(t,e){t.uniform1f(this.addr,e)}function Ce(t,e){t.uniform1i(this.addr,e)}function Pe(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function Ie(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function Ne(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function Fe(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function Ue(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function Oe(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function De(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Me,n)}function ke(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||_e,n)}function Be(t,e){t.uniform2iv(this.addr,e)}function ze(t,e){t.uniform3iv(this.addr,e)}function je(t,e){t.uniform4iv(this.addr,e)}function Ge(t,e){t.uniform1fv(this.addr,e)}function Ve(t,e){t.uniform1iv(this.addr,e)}function He(t,e){t.uniform2fv(this.addr,Te(e,this.size,2))}function We(t,e){t.uniform3fv(this.addr,Te(e,this.size,3))}function Ye(t,e){t.uniform4fv(this.addr,Te(e,this.size,4))}function Xe(t,e){t.uniformMatrix2fv(this.addr,!1,Te(e,this.size,4))}function qe(t,e){t.uniformMatrix3fv(this.addr,!1,Te(e,this.size,9))}function Ze(t,e){t.uniformMatrix4fv(this.addr,!1,Te(e,this.size,16))}function Je(t,e,r){var n=e.length,i=Le(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Me,i[o])}function Qe(t,e,r){var n=e.length,i=Le(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||_e,i[o])}function Ke(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return Re;case 35664:return Pe;case 35665:return Ie;case 35666:return Ne;case 35674:return Fe;case 35675:return Ue;case 35676:return Oe;case 35678:return De;case 35680:return ke;case 5124:case 35670:return Ce;case 35667:case 35671:return Be;case 35668:case 35672:return ze;case 35669:case 35673:return je}}(e.type)}function $e(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ge;case 35664:return He;case 35665:return We;case 35666:return Ye;case 35674:return Xe;case 35675:return qe;case 35676:return Ze;case 35678:return Je;case 35680:return Qe;case 5124:case 35670:return Ve;case 35667:case 35671:return Be;case 35668:case 35672:return ze;case 35669:case 35673:return je}}(e.type)}function tr(t){this.id=t,Ee.call(this)}tr.prototype.setValue=function(t,e){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var o=r[n];o.setValue(t,e[o.id])}};var er=/([\w\d_]+)(\])?(\[|\.)?/g;function rr(t,e){t.seq.push(e),t.map[e.id]=e}function nr(t,e,r){var n=t.name,i=n.length;for(er.lastIndex=0;;){var o=er.exec(n),a=er.lastIndex,s=o[1],u="]"===o[2],c=o[3];if(u&&(s|=0),void 0===c||"["===c&&a+2===i){rr(r,void 0===c?new Ke(s,t,e):new $e(s,t,e));break}var h=r.map,l=h[s];void 0===l&&(l=new tr(s),rr(r,l)),r=l}}function ir(t,e,r){Ee.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i!==n;++i){var o=t.getActiveUniform(e,i),a=o.name,s=t.getUniformLocation(e,a);nr(o,s,this)}}ir.prototype.setValue=function(t,e,r){var n=this.map[e];void 0!==n&&n.setValue(t,r,this.renderer)},ir.prototype.set=function(t,e,r){var n=this.map[r];void 0!==n&&n.setValue(t,e[r],this.renderer)},ir.prototype.setOptional=function(t,e,r){var n=e[r];void 0!==n&&this.setValue(t,r,n)},ir.upload=function(t,e,r,n){for(var i=0,o=e.length;i!==o;++i){var a=e[i],s=r[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,n)}},ir.seqWithValue=function(t,e){for(var r=[],n=0,i=t.length;n!==i;++n){var o=t[n];o.id in e&&r.push(o)}return r};var or={merge:function(t){for(var e={},r=0;r 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include \n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include \n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\t\t\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include \n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n}\n",normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include \n}\n",normal_vert:"varying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};function sr(t,e,r){return void 0===e&&void 0===r?this.set(t):this.setRGB(t,e,r)}sr.prototype={constructor:sr,isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=he.euclideanModulo(e,1),r=he.clamp(r,0,1),n=he.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,u=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,u)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c=r[1],h=c.length;if(3===h)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}if(t&&t.length>0){var c=ur[t];void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),u=Math.min(i,o,a),c=(u+s)/2;if(u===s)e=0,r=0;else{var h=s-u;switch(r=c<=.5?h/(s+u):h/(2-s-u),s){case i:e=(o-a)/h+(o.001&&R.scale>.001&&(b.x=R.x,b.y=R.y,b.z=R.z,x=R.size*R.scale/d.w,w.x=x*v,w.y=x,h.uniform3f(s.screenPosition,b.x,b.y,b.z),h.uniform2f(s.scale,w.x,w.y),h.uniform1f(s.rotation,R.rotation),h.uniform1f(s.opacity,R.opacity),h.uniform3f(s.color,R.color.r,R.color.g,R.color.b),l.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),t.setTexture2D(R.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0))}}}l.enable(h.CULL_FACE),l.enable(h.DEPTH_TEST),l.setDepthWrite(!0),t.resetGLState()}}}function pr(t,e){var r,n,i,o,a,s,u=t.context,c=t.state,h=new xe,l=new ye,f=new xe;function p(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),c=new Uint16Array([0,1,2,0,2,3]);r=u.createBuffer(),n=u.createBuffer(),u.bindBuffer(u.ARRAY_BUFFER,r),u.bufferData(u.ARRAY_BUFFER,e,u.STATIC_DRAW),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,n),u.bufferData(u.ELEMENT_ARRAY_BUFFER,c,u.STATIC_DRAW),i=function(){var e=u.createProgram(),r=u.createShader(u.VERTEX_SHADER),n=u.createShader(u.FRAGMENT_SHADER);return u.shaderSource(r,["precision "+t.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),u.shaderSource(n,["precision "+t.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),u.compileShader(r),u.compileShader(n),u.attachShader(e,r),u.attachShader(e,n),u.linkProgram(e),e}(),o={position:u.getAttribLocation(i,"position"),uv:u.getAttribLocation(i,"uv")},a={uvOffset:u.getUniformLocation(i,"uvOffset"),uvScale:u.getUniformLocation(i,"uvScale"),rotation:u.getUniformLocation(i,"rotation"),scale:u.getUniformLocation(i,"scale"),color:u.getUniformLocation(i,"color"),map:u.getUniformLocation(i,"map"),opacity:u.getUniformLocation(i,"opacity"),modelViewMatrix:u.getUniformLocation(i,"modelViewMatrix"),projectionMatrix:u.getUniformLocation(i,"projectionMatrix"),fogType:u.getUniformLocation(i,"fogType"),fogDensity:u.getUniformLocation(i,"fogDensity"),fogNear:u.getUniformLocation(i,"fogNear"),fogFar:u.getUniformLocation(i,"fogFar"),fogColor:u.getUniformLocation(i,"fogColor"),alphaTest:u.getUniformLocation(i,"alphaTest")};var h=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");h.width=8,h.height=8;var l=h.getContext("2d");l.fillStyle="white",l.fillRect(0,0,8,8),(s=new fe(h)).needsUpdate=!0}function d(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(m,v){if(0!==e.length){void 0===i&&p(),u.useProgram(i),c.initAttributes(),c.enableAttribute(o.position),c.enableAttribute(o.uv),c.disableUnusedAttributes(),c.disable(u.CULL_FACE),c.enable(u.BLEND),u.bindBuffer(u.ARRAY_BUFFER,r),u.vertexAttribPointer(o.position,2,u.FLOAT,!1,16,0),u.vertexAttribPointer(o.uv,2,u.FLOAT,!1,16,8),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,n),u.uniformMatrix4fv(a.projectionMatrix,!1,v.projectionMatrix.elements),c.activeTexture(u.TEXTURE0),u.uniform1i(a.map,0);var g=0,y=0,x=m.fog;x?(u.uniform3f(a.fogColor,x.color.r,x.color.g,x.color.b),x&&x.isFog?(u.uniform1f(a.fogNear,x.near),u.uniform1f(a.fogFar,x.far),u.uniform1i(a.fogType,1),g=1,y=1):x&&x.isFogExp2&&(u.uniform1f(a.fogDensity,x.density),u.uniform1i(a.fogType,2),g=2,y=2)):(u.uniform1i(a.fogType,0),g=0,y=0);for(var w=0,b=e.length;wthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){var r=e||new le;return r.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){var r=e||new le;return r.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new le;return function(e){var r=t.copy(e).clamp(this.min,this.max);return r.sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},dr.prototype={constructor:dr,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r){var n=this[e];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t;e&&(t={textures:{},images:{}});var r={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};function n(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,r.reflectivity=this.reflectivity),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==y&&(r.blending=this.blending),this.shading!==p&&(r.shading=this.shading),this.side!==c&&(r.side=this.side),this.vertexColors!==d&&(r.vertexColors=this.vertexColors),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),r.skinning=this.skinning,r.morphTargets=this.morphTargets,e){var i=n(t.textures),o=n(t.images);i.length>0&&(r.textures=i),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.shading=t.shading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(dr.prototype,e.prototype);var mr=0;function vr(){return mr++}function gr(t){dr.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function yr(t){dr.call(this),this.type="MeshDepthMaterial",this.depthPacking=ue,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function xr(t,e){this.min=void 0!==t?t:new xe(1/0,1/0,1/0),this.max=void 0!==e?e:new xe(-1/0,-1/0,-1/0)}function wr(t,e){this.center=void 0!==t?t:new xe,this.radius=void 0!==e?e:0}function br(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function Mr(t,e){this.normal=void 0!==t?t:new xe(1,0,0),this.constant=void 0!==e?e:0}function _r(t,e,r,n,i,o){this.planes=[void 0!==t?t:new Mr,void 0!==e?e:new Mr,void 0!==r?r:new Mr,void 0!==n?n:new Mr,void 0!==i?i:new Mr,void 0!==o?o:new Mr]}function Er(t,e,r,n){var i=t.context,o=t.state,a=new _r,u=new we,f=e.shadows,p=new le,d=new le(n.maxTextureSize,n.maxTextureSize),m=new xe,v=new xe,g=[],y=1,x=2,w=1+(y|x),b=new Array(w),M=new Array(w),_={},E=[new xe(1,0,0),new xe(-1,0,0),new xe(0,0,1),new xe(0,0,-1),new xe(0,1,0),new xe(0,-1,0)],S=[new xe(0,1,0),new xe(0,1,0),new xe(0,1,0),new xe(0,1,0),new xe(0,0,1),new xe(0,0,-1)],A=[new me,new me,new me,new me,new me,new me],T=new yr;T.depthPacking=ce,T.clipping=!0;for(var L=hr.distanceRGBA,R=or.clone(L.uniforms),C=0;C!==w;++C){var P=0!=(C&y),I=0!=(C&x),N=T.clone();N.morphTargets=P,N.skinning=I,b[C]=N;var F=new gr({defines:{USE_SHADOWMAP:""},uniforms:R,vertexShader:L.vertexShader,fragmentShader:L.fragmentShader,morphTargets:P,skinning:I,clipping:!0});M[C]=F}var U=this;function O(e,r,n,i){var o=e.geometry,a=null,s=b,u=e.customDepthMaterial;if(n&&(s=M,u=e.customDistanceMaterial),u)a=u;else{var f=!1;r.morphTargets&&(o&&o.isBufferGeometry?f=o.morphAttributes&&o.morphAttributes.position&&o.morphAttributes.position.length>0:o&&o.isGeometry&&(f=o.morphTargets&&o.morphTargets.length>0));var p=e.isSkinnedMesh&&r.skinning,d=0;f&&(d|=y),p&&(d|=x),a=s[d]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var m=a.uuid,v=r.uuid,g=_[m];void 0===g&&(g={},_[m]=g);var w=g[v];void 0===w&&(w=a.clone(),g[v]=w),a=w}a.visible=r.visible,a.wireframe=r.wireframe;var E=r.side;return U.renderSingleSided&&E==l&&(E=c),U.renderReverseSided&&(E===c?E=h:E===h&&(E=c)),a.side=E,a.clipShadows=r.clipShadows,a.clippingPlanes=r.clippingPlanes,a.wireframeLinewidth=r.wireframeLinewidth,a.linewidth=r.linewidth,n&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(i),a}function D(t,e,r){if(!1!==t.visible){var n=0!=(t.layers.mask&e.layers.mask);if(n&&(t.isMesh||t.isLine||t.isPoints)&&t.castShadow&&(!1===t.frustumCulled||!0===a.intersectsObject(t))){var i=t.material;!0===i.visible&&(t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),g.push(t))}for(var o=t.children,s=0,u=o.length;si&&(i=c),h>o&&(o=h),l>a&&(a=l)}this.min.set(e,r,n),this.max.set(i,o,a)},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){var r=e||new xe;return r.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t;return function(e){return void 0===t&&(t=new xe),this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){var r=e||new xe;return r.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new xe;return function(e){var r=t.copy(e).clamp(this.min,this.max);return r.sub(e).length()}}(),getBoundingSphere:function(){var t=new xe;return function(e){var r=e||new wr;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new xe,new xe,new xe,new xe,new xe,new xe,new xe,new xe];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},wr.prototype={constructor:wr,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new xr;return function(e,r){var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new xr;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}},br.prototype={constructor:br,isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,u){var c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=i,c[5]=s,c[6]=r,c[7]=o,c[8]=u,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]),this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToVector3Array:function(){var t;return function(e,r,n){void 0===t&&(t=new xe),void 0===r&&(r=0),void 0===n&&(n=e.length);for(var i=0,o=r;i1?void 0:n.copy(i).multiplyScalar(a).add(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){var e=t||new xe;return e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new xe,e=new br;return function(r,n){var i=this.coplanarPoint(t).applyMatrix4(r),o=n||e.getNormalMatrix(r),a=this.normal.applyMatrix3(o).normalize();return this.constant=-i.dot(a),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},_r.prototype={constructor:_r,set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],u=r[5],c=r[6],h=r[7],l=r[8],f=r[9],p=r[10],d=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return e[0].setComponents(a-n,h-s,d-l,y-m).normalize(),e[1].setComponents(a+n,h+s,d+l,y+m).normalize(),e[2].setComponents(a+i,h+u,d+f,y+v).normalize(),e[3].setComponents(a-i,h-u,d-f,y-v).normalize(),e[4].setComponents(a-o,h-c,d-p,y-g).normalize(),e[5].setComponents(a+o,h+c,d+p,y+g).normalize(),this},intersectsObject:function(){var t=new wr;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new wr;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++){var o=e[i].distanceToPoint(r);if(o0?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}},Sr.prototype={constructor:Sr,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){var r=e||new xe;return r.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new xe;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var r=e||new xe;r.subVectors(t,this.origin);var n=r.dot(this.direction);return n<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new xe;return function(e){var r=t.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(r).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new xe,e=new xe,r=new xe;return function(n,i,o,a){t.copy(n).add(i).multiplyScalar(.5),e.copy(i).sub(n).normalize(),r.copy(this.origin).sub(t);var s,u,c,h,l=.5*n.distanceTo(i),f=-this.direction.dot(e),p=r.dot(this.direction),d=-r.dot(e),m=r.lengthSq(),v=Math.abs(1-f*f);if(v>0)if(u=f*p-d,h=l*v,(s=f*d-p)>=0)if(u>=-h)if(u<=h){var g=1/v;c=(s*=g)*(s+f*(u*=g)+2*p)+u*(f*s+u+2*d)+m}else u=l,s=Math.max(0,-(f*u+p)),c=-s*s+u*(u+2*d)+m;else u=-l,s=Math.max(0,-(f*u+p)),c=-s*s+u*(u+2*d)+m;else u<=-h?(s=Math.max(0,-(-f*l+p)),u=s>0?-l:Math.min(Math.max(-l,-d),l),c=-s*s+u*(u+2*d)+m):u<=h?(s=0,u=Math.min(Math.max(-l,-d),l),c=u*(u+2*d)+m):(s=Math.max(0,-(f*l+p)),u=s>0?l:Math.min(Math.max(-l,-d),l),c=-s*s+u*(u+2*d)+m);else u=f>0?-l:l,s=Math.max(0,-(f*u+p)),c=-s*s+u*(u+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(u).add(t),c}}(),intersectSphere:function(){var t=new xe;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,u=n+a;return s<0&&u<0?null:s<0?this.at(u,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);if(0===e)return!0;var r=t.normal.dot(this.direction);return r*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,l=this.origin;return u>=0?(r=(t.min.x-l.x)*u,n=(t.max.x-l.x)*u):(r=(t.max.x-l.x)*u,n=(t.min.x-l.x)*u),c>=0?(i=(t.min.y-l.y)*c,o=(t.max.y-l.y)*c):(i=(t.max.y-l.y)*c,o=(t.min.y-l.y)*c),r>o||i>n?null:((i>r||r!=r)&&(r=i),(o=0?(a=(t.min.z-l.z)*h,s=(t.max.z-l.z)*h):(a=(t.max.z-l.z)*h,s=(t.min.z-l.z)*h),r>s||a>n?null:((a>r||r!=r)&&(r=a),(s=0?r:n,e)))},intersectsBox:function(){var t=new xe;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new xe,e=new xe,r=new xe,n=new xe;return function(i,o,a,s,u){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var c,h=this.direction.dot(n);if(h>0){if(s)return null;c=1}else{if(!(h<0))return null;c=-1,h=-h}t.subVectors(this.origin,i);var l=c*this.direction.dot(r.crossVectors(t,r));if(l<0)return null;var f=c*this.direction.dot(e.cross(t));if(f<0)return null;if(l+f>h)return null;var p=-c*t.dot(n);return p<0?null:this.at(p/h,u)}}(),applyMatrix4:function(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}},Ar.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Ar.DefaultOrder="XYZ",Ar.prototype={constructor:Ar,isEuler:!0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=he.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],u=i[1],c=i[5],h=i[9],l=i[2],f=i[6],p=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(f,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(u,c)):(this._y=Math.atan2(-l,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(f,-1,1)),Math.abs(f)<.99999?(this._y=Math.atan2(-l,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(u,o))):"ZYX"===e?(this._y=Math.asin(-n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(f,p),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,c))):"YZX"===e?(this._z=Math.asin(n(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-l,o)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===e?(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(f,c),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-h,p),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t;return function(e,r,n){return void 0===t&&(t=new we),t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new ye;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new xe(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Tr.prototype={constructor:Tr,set:function(t){this.mask=1<1){for(var e=0;e1)for(var e=0;e0){n.children=[];for(var i=0;i0&&(r.geometries=o),a.length>0&&(r.materials=a),s.length>0&&(r.textures=s),u.length>0&&(r.images=u)}return r.object=n,r;function c(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),Ir.barycoordFromPoint=function(){var t=new xe,e=new xe,r=new xe;return function(n,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),r.subVectors(n,i);var u=t.dot(t),c=t.dot(e),h=t.dot(r),l=e.dot(e),f=e.dot(r),p=u*l-c*c,d=s||new xe;if(0===p)return d.set(-2,-1,-1);var m=1/p,v=(l*h-c*f)*m,g=(u*f-c*h)*m;return d.set(1-v-g,g,v)}}(),Ir.containsPoint=function(){var t=new xe;return function(e,r,n,i){var o=Ir.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),Ir.prototype={constructor:Ir,set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new xe,e=new xe;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){var e=t||new xe;return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Ir.normal(this.a,this.b,this.c,t)},plane:function(t){var e=t||new Mr;return e.setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Ir.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Ir.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,r,n;return function(i,o){void 0===t&&(t=new Mr,e=[new Pr,new Pr,new Pr],r=new xe,n=new xe);var a=o||new xe,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var u=0;u0)for(var f=0;f0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new wr),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(!1!==(t&&t.isGeometry)){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,u=t.faces,c=this.faceVertexUvs[0],h=t.faceVertexUvs[0],l=this.colors,f=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new br).getNormalMatrix(e));for(var p=0,d=a.length;p=0;r--){var d=f[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.vertexColors.length>0,x=0;if(x=_(x=_(x=_(x=_(x=_(x=_(x=_(x=_(x,0,0),1,!0),2,!1),3,d),4,m),5,v),6,g),7,y),a.push(x),a.push(p.a,p.b,p.c),a.push(p.materialIndex),d){var w=this.faceVertexUvs[0][i];a.push(A(w[0]),A(w[1]),A(w[2]))}if(m&&a.push(E(p.normal)),v){var b=p.vertexNormals;a.push(E(b[0]),E(b[1]),E(b[2]))}if(g&&a.push(S(p.color)),y){var M=p.vertexColors;a.push(S(M[0]),S(M[1]),S(M[2]))}}function _(t,e,r){return r?t|1<0&&(t.data.colors=c),l.length>0&&(t.data.uvs=[l]),t.data.faces=a,t},clone:function(){return(new Br).copy(this)},copy:function(t){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]],this.colors=[];for(var e=t.vertices,r=0,n=e.length;r65535?Uint32Array:Uint16Array)(u),h=new Float32Array(3*s),l=new Float32Array(3*s),f=new Float32Array(2*s),p=0,d=0,m=0,v=0,g=0;function y(t,e,r,n,i,o,s,u,y,x,w){for(var b=o/y,M=s/x,_=o/2,E=s/2,S=u/2,A=y+1,T=x+1,L=0,R=0,C=new xe,P=0;P0?1:-1,l[p]=C.x,l[p+1]=C.y,l[p+2]=C.z,f[d]=N/y,f[d+1]=1-P/x,p+=3,d+=2,L+=1}for(P=0;P65535?Uint32Array:Uint16Array)(a*s*6),g=0;g0,a=i[1]&&i[1].length>0,s=t.morphTargets,u=s.length;if(u>0){e=[];for(var c=0;c0){h=[];for(var c=0;c0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Ur(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Ur(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Ur(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Ur(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=t.vertices.length>65535?Uint32Array:Uint16Array,s=new a(3*t.indices.length);this.setIndex(new Ur(s,1).copyIndicesArray(t.indices))}for(var u in this.groups=t.groups,t.morphTargets){for(var c=[],h=t.morphTargets[u],l=0,f=h.length;l0){var m=new kr(4*t.skinIndices.length,4);this.addAttribute("skinIndex",m.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var v=new kr(4*t.skinWeights.length,4);this.addAttribute("skinWeight",v.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position.array;void 0!==t?this.boundingBox.setFromArray(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new xr,e=new xe;return function(){null===this.boundingSphere&&(this.boundingSphere=new wr);var r=this.attributes.position;if(r){var n=r.array,i=this.boundingSphere.center;t.setFromArray(n),t.getCenter(i);for(var o=0,a=0,s=n.length;a0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var u=this.boundingSphere;return null!==u&&(t.data.boundingSphere={center:u.center.toArray(),radius:u.radius}),t},clone:function(){return(new Vr).copy(this)},copy:function(t){var e=t.index;null!==e&&this.setIndex(e.clone());var r=t.attributes;for(var n in r){var i=r[n];this.addAttribute(n,i.clone())}for(var o=t.groups,a=0,s=o.length;a0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,r=t.length;ee.far?null:{distance:u,point:v.clone(),object:t}}function x(t,e,r,a,s,u,h,l){n.fromArray(a,3*u),i.fromArray(a,3*h),o.fromArray(a,3*l);var d=y(t,e,r,n,i,o,m);return d&&(s&&(c.fromArray(s,2*u),f.fromArray(s,2*h),p.fromArray(s,2*l),d.uv=g(m,n,i,o,c,f,p)),d.face=new Nr(u,h,l,Ir.normal(n,i,o)),d.faceIndex=u),d}return function(h,l){var d,v,w=this.geometry,b=this.material,M=this.matrixWorld;if(void 0!==b&&(null===w.boundingSphere&&w.computeBoundingSphere(),r.copy(w.boundingSphere),r.applyMatrix4(M),!1!==h.ray.intersectsSphere(r)&&(t.getInverse(M),e.copy(h.ray).applyMatrix4(t),null===w.boundingBox||!1!==e.intersectsBox(w.boundingBox))))if(w&&w.isBufferGeometry){var _,E,S,A=w.index,T=w.attributes,L=T.position.array;if(void 0!==T.uv&&(d=T.uv.array),null!==A)for(var R=A.array,C=0,P=R.length;C0&&(d=B);for(var z=0,j=k.length;z/g,function(t,e){var r=ar[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return rn(r)})}function nn(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,y=function(t,e,r){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(tn).join("\n")}(o,n,t.extensions),x=function(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(a),w=i.createProgram();r.isRawShaderMaterial?(m=[x,"\n"].filter(tn).join("\n"),v=[y,x,"\n"].filter(tn).join("\n")):(m=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__webglShader.name,x,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(tn).join("\n"),v=[y,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__webglShader.name,x,n.alphaTest?"#define ALPHATEST "+n.alphaTest:"","#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.envMap?"#define "+p:"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",n.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",n.toneMapping!==Q?"#define TONE_MAPPING":"",n.toneMapping!==Q?ar.tonemapping_pars_fragment:"",n.toneMapping!==Q?function(t,e){var r;switch(e){case K:r="Linear";break;case $:r="Reinhard";break;case tt:r="Uncharted2";break;case et:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",n.toneMapping):"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?ar.encodings_pars_fragment:"",n.mapEncoding?$r("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?$r("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?$r("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?function(t,e){var r=Kr(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(tn).join("\n")),c=en(c=rn(c),n),h=en(h=rn(h),n),r.isShaderMaterial||(c=nn(c),h=nn(h));var b=m+c,M=v+h,_=Jr(i,i.VERTEX_SHADER,b),E=Jr(i,i.FRAGMENT_SHADER,M);i.attachShader(w,_),i.attachShader(w,E),void 0!==r.index0AttributeName?i.bindAttribLocation(w,0,r.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(w,0,"position"),i.linkProgram(w);var S,A,T=i.getProgramInfoLog(w),L=i.getShaderInfoLog(_),R=i.getShaderInfoLog(E),C=!0,P=!0;return!1===i.getProgramParameter(w,i.LINK_STATUS)?(C=!1,console.error("THREE.WebGLProgram: shader error: ",i.getError(),"gl.VALIDATE_STATUS",i.getProgramParameter(w,i.VALIDATE_STATUS),"gl.getProgramInfoLog",T,L,R)):""!==T?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",T):""!==L&&""!==R||(P=!1),P&&(this.diagnostics={runnable:C,material:r,programLog:T,vertexShader:{log:L,prefix:m},fragmentShader:{log:R,prefix:v}}),i.deleteShader(_),i.deleteShader(E),this.getUniforms=function(){return void 0===S&&(S=new ir(i,w,t)),S},this.getAttributes=function(){return void 0===A&&(A=function(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:r.side===l,flipSided:r.side===h,depthPacking:void 0!==r.depthPacking&&r.depthPacking};return g},this.getProgramCode=function(t,e){var r=[];if(e.shaderID?r.push(e.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var o=0;o65535?Uint32Array:Uint16Array)(o),1);return i(m,t.ELEMENT_ARRAY_BUFFER),n.wireframe=m,m},update:function(e){var r=n.get(e);e.geometry.isGeometry&&r.updateFromObject(e);var o=r.index,a=r.attributes;for(var s in null!==o&&i(o,t.ELEMENT_ARRAY_BUFFER),a)i(a[s],t.ARRAY_BUFFER);var u=r.morphAttributes;for(var s in u)for(var c=u[s],h=0,l=c.length;he||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r);var i=n.getContext("2d");return i.drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+n.width+"x"+n.height,t),n}return t}function h(t){return he.isPowerOfTwo(t.width)&&he.isPowerOfTwo(t.height)}function l(e){return e===dt||e===mt||e===vt?t.NEAREST:t.LINEAR}function f(e){var r=e.target;r.removeEventListener("dispose",f),function(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.delete(e)}(r),s.textures--}function p(e){var r=e.target;r.removeEventListener("dispose",p),function(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e&&e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.delete(e.texture),n.delete(e)}}(r),s.textures--}function d(e,a){var l=n.get(e);if(e.version>0&&l.__version!==e.version){var p=e.image;if(void 0===p)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==p.complete)return void function(e,n,a){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",f),e.__webglTexture=t.createTexture(),s.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var l=c(n.image,i.maxTextureSize);(function(t){return t.wrapS!==lt||t.wrapT!==lt||t.minFilter!==dt&&t.minFilter!==gt})(n)&&!1===h(l)&&(l=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");e.width=he.nearestPowerOfTwo(t.width),e.height=he.nearestPowerOfTwo(t.height);var r=e.getContext("2d");return r.drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}(l));var p=h(l),d=o(n.format),v=o(n.type);m(t.TEXTURE_2D,n,p);var g,y=n.mipmaps;if(n&&n.isDepthTexture){var x=t.DEPTH_COMPONENT;if(n.type===Tt){if(!u)throw new Error("Float Depth Texture only supported in WebGL2.0");x=t.DEPTH_COMPONENT32F}else u&&(x=t.DEPTH_COMPONENT16);n.format===zt&&(x=t.DEPTH_STENCIL),r.texImage2D(t.TEXTURE_2D,0,x,l.width,l.height,0,d,v,null)}else if(n&&n.isDataTexture)if(y.length>0&&p){for(var w=0,b=y.length;w-1?r.compressedTexImage2D(t.TEXTURE_2D,w,d,g.width,g.height,0,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(t.TEXTURE_2D,w,d,g.width,g.height,0,d,v,g.data);else if(y.length>0&&p){for(var w=0,b=y.length;w1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function v(e,i,a,s){var u=o(i.texture.format),c=o(i.texture.type);r.texImage2D(s,0,u,i.width,i.height,0,u,c,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function g(e,r){t.bindRenderbuffer(t.RENDERBUFFER,e),r.depthBuffer&&!r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):r.depthBuffer&&r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,r.width,r.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function y(e){var r=n.get(e),i=e&&e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),d(r.depthTexture,0);var i=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===Bt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==zt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=t.createRenderbuffer(),g(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),g(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=d,this.setTextureCube=function(e,a){var u=n.get(e);if(6===e.image.length)if(e.version>0&&u.__version!==e.version){u.__image__webglTextureCube||(e.addEventListener("dispose",f),u.__image__webglTextureCube=t.createTexture(),s.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var l=e&&e.isCompressedTexture,p=e.image[0]&&e.image[0].isDataTexture,d=[],v=0;v<6;v++)d[v]=l||p?p?e.image[v].image:e.image[v]:c(e.image[v],i.maxCubemapSize);var g=d[0],y=h(g),x=o(e.format),w=o(e.type);m(t.TEXTURE_CUBE_MAP,e,y);for(var v=0;v<6;v++)if(l)for(var b,M=d[v].mipmaps,_=0,E=M.length;_-1?r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,_,x,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,_,x,b.width,b.height,0,x,w,b.data);else p?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,d[v].width,d[v].height,0,x,w,d[v].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,w,d[v]);e.generateMipmaps&&y&&t.generateMipmap(t.TEXTURE_CUBE_MAP),u.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",p),o.__webglTexture=t.createTexture(),s.textures++;var a=e&&e.isWebGLRenderTargetCube,u=h(e);if(a){i.__webglFramebuffer=[];for(var c=0;c<6;c++)i.__webglFramebuffer[c]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(a){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,u);for(var c=0;c<6;c++)v(i.__webglFramebuffer[c],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+c);e.texture.generateMipmaps&&u&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,u),v(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&u&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&y(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(i.generateMipmaps&&h(e)&&i.minFilter!==dt&&i.minFilter!==gt){var o=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function hn(t){console.log("THREE.WebGLRenderer",r);var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),s=void 0!==t.context?t.context:null,u=void 0!==t.alpha&&t.alpha,c=void 0===t.depth||t.depth,p=void 0===t.stencil||t.stencil,m=void 0!==t.antialias&&t.antialias,v=void 0===t.premultipliedAlpha||t.premultipliedAlpha,_=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,q=[],Z=[],J=-1,Q=[],$=-1,tt=new Float32Array(8),et=[],rt=[];this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=K,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var nt,it=this,ot=null,at=null,st=null,ut=-1,ct="",pt=null,wt=new me,kt=null,Jt=new me,Qt=0,ee=new sr(0),re=0,ne=e.width,ie=e.height,oe=1,ae=new me(0,0,ne,ie),se=!1,ue=new me(0,0,ne,ie),ce=new _r,he=new function(){var t=this,e=null,r=0,n=!1,i=!1,o=new Mr,a=new br,s={value:null,needsUpdate:!1};function u(){s.value!==e&&(s.value=e,s.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(e,r,n,i){var u=null!==e?e.length:0,c=null;if(0!==u){if(c=s.value,!0!==i||null===c){var h=n+4*u,l=r.matrixWorldInverse;a.getNormalMatrix(l),(null===c||c.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==r.precision?r.precision:"highp",a=i(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_TEXTURE_SIZE),l=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),f=t.getParameter(t.MAX_VERTEX_ATTRIBS),p=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),d=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=c>0,g=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var r=e.get("EXT_texture_filter_anisotropic");return n=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:u,maxVertexTextures:c,maxTextureSize:h,maxCubemapSize:l,maxAttributes:f,maxVertexUniforms:p,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:v&&g}}(nt,_e,t),Se=new function(t,e,r){var a=new function(){var e=!1,r=new me,n=null,i=new me;return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,o,a){r.set(e,n,o,a),!1===i.equals(r)&&(t.clearColor(e,n,o,a),i.copy(r))},reset:function(){e=!1,n=null,i.set(0,0,0,1)}}},s=new function(){var e=!1,r=null,n=null,i=null;return{setTest:function(e){e?J(t.DEPTH_TEST):Q(t.DEPTH_TEST)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case z:t.depthFunc(t.NEVER);break;case j:t.depthFunc(t.ALWAYS);break;case G:t.depthFunc(t.LESS);break;case V:t.depthFunc(t.LEQUAL);break;case H:t.depthFunc(t.EQUAL);break;case W:t.depthFunc(t.GEQUAL);break;case Y:t.depthFunc(t.GREATER);break;case X:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}},u=new function(){var e=!1,r=null,n=null,i=null,o=null,a=null,s=null,u=null,c=null;return{setTest:function(e){e?J(t.STENCIL_TEST):Q(t.STENCIL_TEST)},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,a){n===e&&i===r&&o===a||(t.stencilFunc(e,r,a),n=e,i=r,o=a)},setOp:function(e,r,n){a===e&&s===r&&u===n||(t.stencilOp(e,r,n),a=e,s=r,u=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,r=null,n=null,i=null,o=null,a=null,s=null,u=null,c=null}}},c=t.getParameter(t.MAX_VERTEX_ATTRIBS),h=new Uint8Array(c),l=new Uint8Array(c),f=new Uint8Array(c),p={},d=null,m=null,v=null,_=null,E=null,S=null,A=null,T=null,L=!1,R=null,C=null,P=null,I=null,N=null,F=null,U=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),O=null,D={},k=new me,B=new me;function q(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var h=0;h=0&&t.numSupportedMorphNormals++}var l=n.__webglShader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=he.numPlanes,n.numIntersection=he.numIntersection,l.clippingPlanes=he.uniform),n.fog=e,n.lightsHash=ye.hash,t.lights&&(l.ambientLightColor.value=ye.ambient,l.directionalLights.value=ye.directional,l.spotLights.value=ye.spot,l.pointLights.value=ye.point,l.hemisphereLights.value=ye.hemi,l.directionalShadowMap.value=ye.directionalShadowMap,l.directionalShadowMatrix.value=ye.directionalShadowMatrix,l.spotShadowMap.value=ye.spotShadowMap,l.spotShadowMatrix.value=ye.spotShadowMatrix,l.pointShadowMap.value=ye.pointShadowMap,l.pointShadowMatrix.value=ye.pointShadowMatrix);var f=n.program.getUniforms(),p=ir.seqWithValue(f.seq,l);n.uniformsList=p}(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,u=!1,c=i.program,h=c.getUniforms(),l=i.__webglShader.uniforms;if(c.id!==ot&&(nt.useProgram(c.program),ot=c.id,a=!0,s=!0,u=!0),r.id!==ut&&(ut=r.id,s=!0),a||t!==pt){if(h.set(nt,t,"projectionMatrix"),Ee.logarithmicDepthBuffer&&h.setValue(nt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==pt&&(pt=t,s=!0,u=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var f=h.map.cameraPosition;void 0!==f&&f.setValue(nt,ge.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&h.setValue(nt,"viewMatrix",t.matrixWorldInverse),h.set(nt,it,"toneMappingExposure"),h.set(nt,it,"toneMappingWhitePoint")}if(r.skinning){h.setOptional(nt,n,"bindMatrix"),h.setOptional(nt,n,"bindMatrixInverse");var p=n.skeleton;p&&(Ee.floatVertexTextures&&p.useVertexTexture?(h.set(nt,p,"boneTexture"),h.set(nt,p,"boneTextureWidth"),h.set(nt,p,"boneTextureHeight")):h.setOptional(nt,p,"boneMatrices"))}return s&&(r.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(l,u),e&&r.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(l,e),(r.isMeshBasicMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshDepthMaterial)&&function(t,e){var r;if(t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}(l,r),r.isLineBasicMaterial?rr(l,r):r.isLineDashedMaterial?(rr(l,r),function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(l,r)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*oe,t.scale.value=.5*ie,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}(l,r):r.isMeshLambertMaterial?function(t,e){e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(l,r):r.isMeshPhongMaterial?function(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(l,r):r.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,nr(t,e)}(l,r):r.isMeshStandardMaterial?nr(l,r):r.isMeshDepthMaterial?r.displacementMap&&(l.displacementMap.value=r.displacementMap,l.displacementScale.value=r.displacementScale,l.displacementBias.value=r.displacementBias):r.isMeshNormalMaterial&&(l.opacity.value=r.opacity),ir.upload(nt,i.uniformsList,l,it)),h.set(nt,n,"modelViewMatrix"),h.set(nt,n,"normalMatrix"),h.setValue(nt,"modelMatrix",n.matrixWorld),c}function rr(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function nr(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function ar(t){var e;if(t===ht)return nt.REPEAT;if(t===lt)return nt.CLAMP_TO_EDGE;if(t===ft)return nt.MIRRORED_REPEAT;if(t===dt)return nt.NEAREST;if(t===mt)return nt.NEAREST_MIPMAP_NEAREST;if(t===vt)return nt.NEAREST_MIPMAP_LINEAR;if(t===gt)return nt.LINEAR;if(t===yt)return nt.LINEAR_MIPMAP_NEAREST;if(t===xt)return nt.LINEAR_MIPMAP_LINEAR;if(t===bt)return nt.UNSIGNED_BYTE;if(t===Rt)return nt.UNSIGNED_SHORT_4_4_4_4;if(t===Ct)return nt.UNSIGNED_SHORT_5_5_5_1;if(t===Pt)return nt.UNSIGNED_SHORT_5_6_5;if(t===Mt)return nt.BYTE;if(t===_t)return nt.SHORT;if(t===Et)return nt.UNSIGNED_SHORT;if(t===St)return nt.INT;if(t===At)return nt.UNSIGNED_INT;if(t===Tt)return nt.FLOAT;if(t===Lt&&null!==(e=_e.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(t===Nt)return nt.ALPHA;if(t===Ft)return nt.RGB;if(t===Ut)return nt.RGBA;if(t===Ot)return nt.LUMINANCE;if(t===Dt)return nt.LUMINANCE_ALPHA;if(t===Bt)return nt.DEPTH_COMPONENT;if(t===zt)return nt.DEPTH_STENCIL;if(t===E)return nt.FUNC_ADD;if(t===S)return nt.FUNC_SUBTRACT;if(t===A)return nt.FUNC_REVERSE_SUBTRACT;if(t===R)return nt.ZERO;if(t===C)return nt.ONE;if(t===P)return nt.SRC_COLOR;if(t===I)return nt.ONE_MINUS_SRC_COLOR;if(t===N)return nt.SRC_ALPHA;if(t===F)return nt.ONE_MINUS_SRC_ALPHA;if(t===U)return nt.DST_ALPHA;if(t===O)return nt.ONE_MINUS_DST_ALPHA;if(t===D)return nt.DST_COLOR;if(t===k)return nt.ONE_MINUS_DST_COLOR;if(t===B)return nt.SRC_ALPHA_SATURATE;if((t===jt||t===Gt||t===Vt||t===Ht)&&null!==(e=_e.get("WEBGL_compressed_texture_s3tc"))){if(t===jt)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Gt)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===Vt)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Ht)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===Wt||t===Yt||t===Xt||t===qt)&&null!==(e=_e.get("WEBGL_compressed_texture_pvrtc"))){if(t===Wt)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===Yt)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===Xt)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===qt)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===Zt&&null!==(e=_e.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===T||t===L)&&null!==(e=_e.get("EXT_blend_minmax"))){if(t===T)return e.MIN_EXT;if(t===L)return e.MAX_EXT}return t===It&&null!==(e=_e.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}this.getContext=function(){return nt},this.getContextAttributes=function(){return nt.getContextAttributes()},this.forceContextLoss=function(){_e.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return Ee.getMaxAnisotropy()},this.getPrecision=function(){return Ee.precision},this.getPixelRatio=function(){return oe},this.setPixelRatio=function(t){void 0!==t&&(oe=t,this.setSize(ue.z,ue.w,!1))},this.getSize=function(){return{width:ne,height:ie}},this.setSize=function(t,r,n){ne=t,ie=r,e.width=t*oe,e.height=r*oe,!1!==n&&(e.style.width=t+"px",e.style.height=r+"px"),this.setViewport(0,0,t,r)},this.setViewport=function(t,e,r,n){Se.viewport(ue.set(t,e,r,n))},this.setScissor=function(t,e,r,n){Se.scissor(ae.set(t,e,r,n))},this.setScissorTest=function(t){Se.setScissorTest(se=t)},this.getClearColor=function(){return ee},this.setClearColor=function(t,e){ee.set(t),re=void 0!==e?e:1,Be(ee.r,ee.g,ee.b,re)},this.getClearAlpha=function(){return re},this.setClearAlpha=function(t){re=t,Be(ee.r,ee.g,ee.b,re)},this.clear=function(t,e,r){var n=0;(void 0===t||t)&&(n|=nt.COLOR_BUFFER_BIT),(void 0===e||e)&&(n|=nt.DEPTH_BUFFER_BIT),(void 0===r||r)&&(n|=nt.STENCIL_BUFFER_BIT),nt.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,r,n){this.setRenderTarget(t),this.clear(e,r,n)},this.resetGLState=je,this.dispose=function(){Q=[],$=-1,Z=[],J=-1,e.removeEventListener("webglcontextlost",We,!1)},this.renderBufferImmediate=function(t,e,r){Se.initAttributes();var n=Ae.get(t);t.hasPositions&&!n.position&&(n.position=nt.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=nt.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=nt.createBuffer()),t.hasColors&&!n.color&&(n.color=nt.createBuffer());var i=e.getAttributes();if(t.hasPositions&&(nt.bindBuffer(nt.ARRAY_BUFFER,n.position),nt.bufferData(nt.ARRAY_BUFFER,t.positionArray,nt.DYNAMIC_DRAW),Se.enableAttribute(i.position),nt.vertexAttribPointer(i.position,3,nt.FLOAT,!1,0,0)),t.hasNormals){if(nt.bindBuffer(nt.ARRAY_BUFFER,n.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&r.shading===f)for(var o=0,a=3*t.count;o8&&(h.length=8);for(var d=r.morphAttributes,l=0,f=h.length;l=0){var h=o[u];if(void 0!==h){var l=nt.FLOAT,f=h.array,p=h.normalized;f instanceof Float32Array?l=nt.FLOAT:f instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):f instanceof Uint16Array?l=nt.UNSIGNED_SHORT:f instanceof Int16Array?l=nt.SHORT:f instanceof Uint32Array?l=nt.UNSIGNED_INT:f instanceof Int32Array?l=nt.INT:f instanceof Int8Array?l=nt.BYTE:f instanceof Uint8Array&&(l=nt.UNSIGNED_BYTE);var d=h.itemSize,m=Le.getAttributeBuffer(h);if(h.isInterleavedBufferAttribute){var v=h.data,g=v.stride,y=h.offset;v&&v.isInstancedInterleavedBuffer?(Se.enableAttributeAndDivisor(c,v.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=v.meshPerAttribute*v.count)):Se.enableAttribute(c),nt.bindBuffer(nt.ARRAY_BUFFER,m),nt.vertexAttribPointer(c,d,l,p,g*v.array.BYTES_PER_ELEMENT,(n*g+y)*v.array.BYTES_PER_ELEMENT)}else h.isInstancedBufferAttribute?(Se.enableAttributeAndDivisor(c,h.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=h.meshPerAttribute*h.count)):Se.enableAttribute(c),nt.bindBuffer(nt.ARRAY_BUFFER,m),nt.vertexAttribPointer(c,d,l,p,0,n*d*h.array.BYTES_PER_ELEMENT)}else if(void 0!==s){var x=s[u];if(void 0!==x)switch(x.length){case 2:nt.vertexAttrib2fv(c,x);break;case 3:nt.vertexAttrib3fv(c,x);break;case 4:nt.vertexAttrib4fv(c,x);break;default:nt.vertexAttrib1fv(c,x)}}}}Se.disableUnusedAttributes()}}(n,a,r),null!==m&&nt.bindBuffer(nt.ELEMENT_ARRAY_BUFFER,Le.getAttributeBuffer(m)));var w=0;null!==m?w=m.count:void 0!==y&&(w=y.count);var b=r.drawRange.start*x,M=r.drawRange.count*x,_=null!==o?o.start*x:0,E=null!==o?o.count*x:1/0,S=Math.max(b,_),A=Math.min(w,b+M,_+E)-1,T=Math.max(0,A-S+1);if(0!==T){if(i.isMesh)if(!0===n.wireframe)Se.setLineWidth(n.wireframeLinewidth*ke()),g.setMode(nt.LINES);else switch(i.drawMode){case Kt:g.setMode(nt.TRIANGLES);break;case $t:g.setMode(nt.TRIANGLE_STRIP);break;case te:g.setMode(nt.TRIANGLE_FAN)}else if(i.isLine){var L=n.linewidth;void 0===L&&(L=1),Se.setLineWidth(L*ke()),i.isLineSegments?g.setMode(nt.LINES):g.setMode(nt.LINE_STRIP)}else i.isPoints&&g.setMode(nt.POINTS);r&&r.isInstancedBufferGeometry?r.maxInstancedCount>0&&g.renderInstances(r,S,T):g.render(S,T)}},this.render=function(t,e,r,n){if(void 0===e||!0===e.isCamera){ct="",ut=-1,pt=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),ve.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),ce.setFromMatrix(ve),q.length=0,J=-1,$=-1,et.length=0,rt.length=0,pe=this.localClippingEnabled,fe=he.init(this.clippingPlanes,pe,e),function t(e,r){if(!1!==e.visible){var n=0!=(e.layers.mask&r.layers.mask);if(n)if(e.isLight)q.push(e);else if(e.isSprite)!1!==e.frustumCulled&&!0!==function(t){return de.center.set(0,0,0),de.radius=.7071067811865476,de.applyMatrix4(t.matrixWorld),Ke(de)}(e)||et.push(e);else if(e.isLensFlare)rt.push(e);else if(e.isImmediateRenderObject)!0===it.sortObjects&&(ge.setFromMatrixPosition(e.matrixWorld),ge.applyProjection(ve)),Qe(e,null,e.material,ge.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!1===e.frustumCulled||!0===function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),de.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),Ke(de)}(e))){var i=e.material;if(!0===i.visible){!0===it.sortObjects&&(ge.setFromMatrixPosition(e.matrixWorld),ge.applyProjection(ve));var o=Le.update(e);if(i.isMultiMaterial)for(var a=o.groups,s=i.materials,u=0,c=a.length;u=Ee.maxTextures&&console.warn("WebGLRenderer: trying to use "+t+" texture units while this GPU supports only "+Ee.maxTextures),Qt+=1,t},this.setTexture2D=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),Te.setTexture2D(e,r)}}(),this.setTexture=function(){var t=!1;return function(e,r){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),Te.setTexture2D(e,r)}}(),this.setTextureCube=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?Te.setTextureCube(e,r):Te.setTextureCubeDynamic(e,r)}}(),this.getCurrentRenderTarget=function(){return at},this.setRenderTarget=function(t){at=t,t&&void 0===Ae.get(t).__webglFramebuffer&&Te.setupRenderTarget(t);var e,r=t&&t.isWebGLRenderTargetCube;if(t){var n=Ae.get(t);e=r?n.__webglFramebuffer[t.activeCubeFace]:n.__webglFramebuffer,wt.copy(t.scissor),kt=t.scissorTest,Jt.copy(t.viewport)}else e=null,wt.copy(ae).multiplyScalar(oe),kt=se,Jt.copy(ue).multiplyScalar(oe);if(st!==e&&(nt.bindFramebuffer(nt.FRAMEBUFFER,e),st=e),Se.scissor(wt),Se.setScissorTest(kt),Se.viewport(Jt),r){var i=Ae.get(t.texture);nt.framebufferTexture2D(nt.FRAMEBUFFER,nt.COLOR_ATTACHMENT0,nt.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,r,n,i,o){if(!1!==(t&&t.isWebGLRenderTarget)){var a=Ae.get(t).__webglFramebuffer;if(a){var s=!1;a!==st&&(nt.bindFramebuffer(nt.FRAMEBUFFER,a),s=!0);try{var u=t.texture,c=u.format,h=u.type;if(c!==Ut&&ar(c)!==nt.getParameter(nt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===bt||ar(h)===nt.getParameter(nt.IMPLEMENTATION_COLOR_READ_TYPE)||h===Tt&&(_e.get("OES_texture_float")||_e.get("WEBGL_color_buffer_float"))||h===Lt&&_e.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");nt.checkFramebufferStatus(nt.FRAMEBUFFER)===nt.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&nt.readPixels(e,r,n,i,ar(c),ar(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&nt.bindFramebuffer(nt.FRAMEBUFFER,st)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function ln(t,e){this.name="",this.color=new sr(t),this.density=void 0!==e?e:25e-5}function fn(t,e,r){this.name="",this.color=new sr(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function pn(){Lr.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function dn(t,e,r,n,i){Lr.call(this),this.lensFlares=[],this.positionScreen=new xe,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function mn(t){dr.call(this),this.type="SpriteMaterial",this.color=new sr(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function vn(t){Lr.call(this),this.type="Sprite",this.material=void 0!==t?t:new mn}function gn(){Lr.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function yn(t,e,r,n,i,o,a,s,u,c,h,l){fe.call(this,null,o,a,s,u,c,n,i,h,l),this.image={data:t,width:e,height:r},this.magFilter=void 0!==u?u:dt,this.minFilter=void 0!==c?c:dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function xn(t,e,r){if(this.useVertexTexture=void 0===r||r,this.identityMatrix=new we,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var n=Math.sqrt(4*this.bones.length);n=he.nextPowerOfTwo(Math.ceil(n)),n=Math.max(n,4),this.boneTextureWidth=n,this.boneTextureHeight=n,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new yn(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Ut,Tt)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var i=0,o=this.bones.length;i=t.HAVE_CURRENT_DATA&&(c.needsUpdate=!0)}()}function Rn(t,e,r,n,i,o,a,s,u,c,h,l){fe.call(this,null,o,a,s,u,c,n,i,h,l),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Cn(t,e,r,n,i,o,a,s,u){fe.call(this,t,e,r,n,i,o,a,s,u),this.needsUpdate=!0}function Pn(t,e,r,n,i,o,a,s,u,c){if((c=void 0!==c?c:Bt)!==Bt&&c!==zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");fe.call(this,null,n,i,o,a,s,c,r,u),this.image={width:t,height:e},this.type=void 0!==r?r:Et,this.magFilter=void 0!==a?a:dt,this.minFilter=void 0!==s?s:dt,this.flipY=!1,this.generateMipmaps=!1}function In(t){Vr.call(this);var e=[0,0],r={};function n(t,e){return t-e}var i=["a","b","c"];if(t&&t.isGeometry){for(var o=t.vertices,a=t.faces,s=0,u=new Uint32Array(6*a.length),c=0,h=a.length;c65535?Dr:Or)(m,1)),this.addAttribute("position",kr(u,3)),this.addAttribute("uv",kr(c,2)),this.computeVertexNormals()}function Fn(t,e,r){Br.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:r},this.fromBufferGeometry(new Nn(t,e,r)),this.mergeVertices()}function Un(t,e,r,n){Vr.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n},r=r||1;var i=[],o=[];function a(t,e,r,n){var i,o,a=Math.pow(2,n),u=[];for(i=0;i<=a;i++){u[i]=[];var c=t.clone().lerp(r,i/a),h=e.clone().lerp(r,i/a),l=a-i;for(o=0;o<=l;o++)u[i][o]=0===o&&i===a?c:c.clone().lerp(h,o/l)}for(i=0;i.9&&a<.1&&(e<.2&&(o[t+0]+=1),r<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",kr(i,3)),this.addAttribute("normal",kr(i.slice(),3)),this.addAttribute("uv",kr(o,2)),this.normalizeNormals(),this.boundingSphere=new wr(new xe,r)}function On(t,e){Un.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Dn(t,e){Br.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new On(t,e)),this.mergeVertices()}function kn(t,e){Un.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Bn(t,e){Br.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new kn(t,e)),this.mergeVertices()}function zn(t,e){var r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];Un.call(this,n,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function jn(t,e){Br.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new zn(t,e)),this.mergeVertices()}function Gn(t,e){var r=(1+Math.sqrt(5))/2,n=1/r,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n];Un.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Vn(t,e){Br.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Gn(t,e)),this.mergeVertices()}function Hn(t,e,r,n){Br.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n},this.fromBufferGeometry(new Un(t,e,r,n)),this.mergeVertices()}function Wn(t,e,r,n,i){Vr.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},e=e||64,r=r||1,n=n||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,u=new xe,c=new xe,h=new le,l=[],f=[],p=[],d=[];function m(i){var a=t.getPointAt(i/e),h=o.normals[i],p=o.binormals[i];for(s=0;s<=n;s++){var d=s/n*Math.PI*2,m=Math.sin(d),v=-Math.cos(d);c.x=v*h.x+m*p.x,c.y=v*h.y+m*p.y,c.z=v*h.z+m*p.z,c.normalize(),f.push(c.x,c.y,c.z),u.x=a.x+r*c.x,u.y=a.y+r*c.y,u.z=a.z+r*c.z,l.push(u.x,u.y,u.z)}}!function(){for(a=0;a65535?Dr:Or)(d,1)),this.addAttribute("position",kr(l,3)),this.addAttribute("normal",kr(f,3)),this.addAttribute("uv",kr(p,2))}function Yn(t,e,r,n,i,o){Br.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new Wn(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function Xn(t,e,r,n,i,o){Vr.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:i,q:o},t=t||100,e=e||40,r=Math.floor(r)||64,n=Math.floor(n)||8,i=i||2,o=o||3;var a,s,u=(n+1)*(r+1),c=n*r*2*3,h=new Ur(new(c>65535?Uint32Array:Uint16Array)(c),1),l=new Ur(new Float32Array(3*u),3),f=new Ur(new Float32Array(3*u),3),p=new Ur(new Float32Array(2*u),2),d=0,m=0,v=new xe,g=new xe,y=new le,x=new xe,w=new xe,b=new xe,M=new xe,_=new xe;for(a=0;a<=r;++a){var E=a/r*i*Math.PI*2;for(I(E,i,o,t,x),I(E+.01,i,o,t,w),M.subVectors(w,x),_.addVectors(w,x),b.crossVectors(M,_),_.crossVectors(b,M),b.normalize(),_.normalize(),s=0;s<=n;++s){var S=s/n*Math.PI*2,A=-e*Math.cos(S),T=e*Math.sin(S);v.x=x.x+(A*_.x+T*b.x),v.y=x.y+(A*_.y+T*b.y),v.z=x.z+(A*_.z+T*b.z),l.setXYZ(d,v.x,v.y,v.z),g.subVectors(v,x).normalize(),f.setXYZ(d,g.x,g.y,g.z),y.x=a/r,y.y=s/n,p.setXY(d,y.x,y.y),d++}}for(s=1;s<=r;s++)for(a=1;a<=n;a++){var L=(n+1)*(s-1)+(a-1),R=(n+1)*s+(a-1),C=(n+1)*s+a,P=(n+1)*(s-1)+a;h.setX(m,L),m++,h.setX(m,R),m++,h.setX(m,P),m++,h.setX(m,R),m++,h.setX(m,C),m++,h.setX(m,P),m++}function I(t,e,r,n,i){var o=Math.cos(t),a=Math.sin(t),s=r/e*t,u=Math.cos(s);i.x=n*(2+u)*.5*o,i.y=n*(2+u)*a*.5,i.z=n*Math.sin(s)*.5}this.setIndex(h),this.addAttribute("position",l),this.addAttribute("normal",f),this.addAttribute("uv",p)}function qn(t,e,r,n,i,o,a){Br.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:i,q:o},void 0!==a&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new Xn(t,e,r,n,i,o)),this.mergeVertices()}function Zn(t,e,r,n,i){Vr.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:n,arc:i},t=t||100,e=e||40,r=Math.floor(r)||8,n=Math.floor(n)||6,i=i||2*Math.PI;var o,a,s=(r+1)*(n+1),u=r*n*2*3,c=new(u>65535?Uint32Array:Uint16Array)(u),h=new Float32Array(3*s),l=new Float32Array(3*s),f=new Float32Array(2*s),p=0,d=0,m=0,v=new xe,g=new xe,y=new xe;for(o=0;o<=r;o++)for(a=0;a<=n;a++){var x=a/n*i,w=o/r*Math.PI*2;g.x=(t+e*Math.cos(w))*Math.cos(x),g.y=(t+e*Math.cos(w))*Math.sin(x),g.z=e*Math.sin(w),h[p]=g.x,h[p+1]=g.y,h[p+2]=g.z,v.x=t*Math.cos(x),v.y=t*Math.sin(x),y.subVectors(g,v).normalize(),l[p]=y.x,l[p+1]=y.y,l[p+2]=y.z,f[d]=a/n,f[d+1]=o/r,p+=3,d+=2}for(o=1;o<=r;o++)for(a=1;a<=n;a++){var b=(n+1)*o+a-1,M=(n+1)*(o-1)+a-1,_=(n+1)*(o-1)+a,E=(n+1)*o+a;c[m]=b,c[m+1]=M,c[m+2]=E,c[m+3]=M,c[m+4]=_,c[m+5]=E,m+=6}this.setIndex(new Ur(c,1)),this.addAttribute("position",new Ur(h,3)),this.addAttribute("normal",new Ur(l,3)),this.addAttribute("uv",new Ur(f,2))}function Jn(t,e,r,n,i){Br.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:n,arc:i},this.fromBufferGeometry(new Zn(t,e,r,n,i))}ln.prototype.isFogExp2=!0,ln.prototype.clone=function(){return new ln(this.color.getHex(),this.density)},ln.prototype.toJSON=function(t){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},fn.prototype.isFog=!0,fn.prototype.clone=function(){return new fn(this.color.getHex(),this.near,this.far)},fn.prototype.toJSON=function(t){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},pn.prototype=Object.create(Lr.prototype),pn.prototype.constructor=pn,pn.prototype.copy=function(t,e){return Lr.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},pn.prototype.toJSON=function(t){var e=Lr.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e},dn.prototype=Object.assign(Object.create(Lr.prototype),{constructor:dn,isLensFlare:!0,copy:function(t){Lr.prototype.copy.call(this,t),this.positionScreen.copy(t.positionScreen),this.customUpdateCallback=t.customUpdateCallback;for(var e=0,r=t.lensFlares.length;ei||r.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),gn.prototype=Object.assign(Object.create(Lr.prototype),{constructor:gn,copy:function(t){Lr.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa)){f.applyMatrix4(this.matrixWorld);var _=n.ray.origin.distanceTo(f);_n.far||i.push({distance:_,point:l.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else for(var y=0,x=v.length/3-1;ya)){f.applyMatrix4(this.matrixWorld);var _=n.ray.origin.distanceTo(f);_n.far||i.push({distance:_,point:l.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}else if(s&&s.isGeometry)for(var E=s.vertices,S=E.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var _=n.ray.origin.distanceTo(f);_n.far||i.push({distance:_,point:l.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),En.prototype=Object.assign(Object.create(_n.prototype),{constructor:En,isLineSegments:!0}),Sn.prototype=Object.create(dr.prototype),Sn.prototype.constructor=Sn,Sn.prototype.isPointsMaterial=!0,Sn.prototype.copy=function(t){return dr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},An.prototype=Object.assign(Object.create(Lr.prototype),{constructor:An,isPoints:!0,raycast:function(){var t=new we,e=new Sr,r=new wr;return function(n,i){var o=this,a=this.geometry,s=this.matrixWorld,u=n.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),r.copy(a.boundingSphere),r.applyMatrix4(s),!1!==n.ray.intersectsSphere(r)){t.getInverse(s),e.copy(n.ray).applyMatrix4(t);var c=u/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,l=new xe;if(a&&a.isBufferGeometry){var f=a.index,p=a.attributes,d=p.position.array;if(null!==f)for(var m=f.array,v=0,g=m.length;vn.far)return;i.push({distance:c,distanceToRay:Math.sqrt(a),point:u.clone(),index:r,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Tn.prototype=Object.assign(Object.create(Lr.prototype),{constructor:Tn}),Ln.prototype=Object.create(fe.prototype),Ln.prototype.constructor=Ln,Rn.prototype=Object.create(fe.prototype),Rn.prototype.constructor=Rn,Rn.prototype.isCompressedTexture=!0,Cn.prototype=Object.create(fe.prototype),Cn.prototype.constructor=Cn,Pn.prototype=Object.create(fe.prototype),Pn.prototype.constructor=Pn,Pn.prototype.isDepthTexture=!0,In.prototype=Object.create(Vr.prototype),In.prototype.constructor=In,Nn.prototype=Object.create(Vr.prototype),Nn.prototype.constructor=Nn,Fn.prototype=Object.create(Br.prototype),Fn.prototype.constructor=Fn,Un.prototype=Object.create(Vr.prototype),Un.prototype.constructor=Un,On.prototype=Object.create(Un.prototype),On.prototype.constructor=On,Dn.prototype=Object.create(Br.prototype),Dn.prototype.constructor=Dn,kn.prototype=Object.create(Un.prototype),kn.prototype.constructor=kn,Bn.prototype=Object.create(Br.prototype),Bn.prototype.constructor=Bn,zn.prototype=Object.create(Un.prototype),zn.prototype.constructor=zn,jn.prototype=Object.create(Br.prototype),jn.prototype.constructor=jn,Gn.prototype=Object.create(Un.prototype),Gn.prototype.constructor=Gn,Vn.prototype=Object.create(Br.prototype),Vn.prototype.constructor=Vn,Hn.prototype=Object.create(Br.prototype),Hn.prototype.constructor=Hn,Wn.prototype=Object.create(Vr.prototype),Wn.prototype.constructor=Wn,Yn.prototype=Object.create(Br.prototype),Yn.prototype.constructor=Yn,Xn.prototype=Object.create(Vr.prototype),Xn.prototype.constructor=Xn,qn.prototype=Object.create(Br.prototype),qn.prototype.constructor=qn,Zn.prototype=Object.create(Vr.prototype),Zn.prototype.constructor=Zn,Jn.prototype=Object.create(Br.prototype),Jn.prototype.constructor=Jn;var Qn={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i=-Number.EPSILON&&M>=-Number.EPSILON&&b>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],u=[],c=[];if(Qn.area(e)>0)for(o=0;o2;){if(l--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),r?c:s;if(h<=(i=o)&&(i=0),h<=(o=i+1)&&(o=0),h<=(a=o+1)&&(a=0),t(e,i,o,a,h,u)){var f,p,d,m,v;for(f=u[i],p=u[o],d=u[a],s.push([e[f],e[p],e[d]]),c.push([u[i],u[o],u[a]]),m=o,v=o+1;v2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var d;if(f>0){if(p<0||p>f)return[];if((d=c*h-u*l)<0||d>f)return[]}else{if(p>0||p0||d_?[]:y===_?o?[]:[v]:x<=_?[v,g]:[v,b])}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,u=n.x-t.x,c=n.y-t.y,h=i*s-o*a,l=i*c-o*u;if(Math.abs(h)>Number.EPSILON){var f=u*s-c*a;return h>0?l>=0&&f>=0:l>=0||f>=0}return l>0}r(t),e.forEach(r);for(var a,s,u,c,h,l,f={},p=t.concat(),d=0,m=e.length;di&&(s=0);var u=o(n[t],n[a],n[s],r[e]);if(!u)return!1;var c=r.length-1,h=e-1;h<0&&(h=c);var l=e+1;return l>c&&(l=0),!!(u=o(r[e],r[h],r[l],n[t]))}function s(t,e){var r,o;for(r=0;r0)return!0;return!1}var u=[];function c(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}for(var h,l,f,p,d,m,v,g,y,x,w=[],b=0,M=e.length;b0;){if(--E<0){console.log("Infinite Loop! Holes left:"+u.length+", Probably Hole outside Shape!");break}for(l=_;l=0)break;w[m]=!0}if(h>=0)break}}return n}(t,e),g=Qn.triangulate(v,!1);for(a=0,s=g.length;a0)&&_.push(E,S,T),(m!==r-1||s65535?Dr:Or)(_,1)),this.addAttribute("position",c),this.addAttribute("normal",h),this.addAttribute("uv",l),this.boundingSphere=new wr(new xe,t)}function ei(t,e,r,n,i,o,a){Br.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:i,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new ti(t,e,r,n,i,o,a))}function ri(t,e,r,n,i,o){Vr.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:r,phiSegments:n,thetaStart:i,thetaLength:o},t=t||20,e=e||50,i=void 0!==i?i:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8,n=void 0!==n?Math.max(1,n):1;var a,s,u,c=(r+1)*(n+1),h=r*n*2*3,l=new Ur(new(h>65535?Uint32Array:Uint16Array)(h),1),f=new Ur(new Float32Array(3*c),3),p=new Ur(new Float32Array(3*c),3),d=new Ur(new Float32Array(2*c),2),m=0,v=0,g=t,y=(e-t)/n,x=new xe,w=new le;for(s=0;s<=n;s++){for(u=0;u<=r;u++)a=i+u/r*o,x.x=g*Math.cos(a),x.y=g*Math.sin(a),f.setXYZ(m,x.x,x.y,x.z),p.setXYZ(m,0,0,1),w.x=(x.x/e+1)/2,w.y=(x.y/e+1)/2,d.setXY(m,w.x,w.y),m++;g+=y}for(s=0;s65535?Uint32Array:Uint16Array)(u),1),h=new Ur(new Float32Array(3*s),3),l=new Ur(new Float32Array(2*s),2),f=0,p=0,d=1/e,m=new xe,v=new le;for(o=0;o<=e;o++){var g=r+o*d*n,y=Math.sin(g),x=Math.cos(g);for(a=0;a<=t.length-1;a++)m.x=t[a].x*y,m.y=t[a].y,m.z=t[a].x*x,h.setXYZ(f,m.x,m.y,m.z),v.x=o/e,v.y=a/(t.length-1),l.setXY(f,v.x,v.y),f++}for(o=0;o0&&c++,e>0&&c++);var h=function(){var t=(n+1)*(i+1);return!1===o&&(t+=(n+1)*c+n*c),t}(),l=function(){var t=n*i*2*3;return!1===o&&(t+=n*c*3),t}(),f=new Ur(new(l>65535?Uint32Array:Uint16Array)(l),1),p=new Ur(new Float32Array(3*h),3),d=new Ur(new Float32Array(3*h),3),m=new Ur(new Float32Array(2*h),2),v=0,g=0,y=[],x=r/2,w=0;function b(r){var i,o,c,h=new le,l=new xe,y=0,b=!0===r?t:e,M=!0===r?1:-1;for(o=v,i=1;i<=n;i++)p.setXYZ(v,0,x*M,0),d.setXYZ(v,0,M,0),h.x=.5,h.y=.5,m.setXY(v,h.x,h.y),v++;for(c=v,i=0;i<=n;i++){var _=i/n,E=_*s+a,S=Math.cos(E),A=Math.sin(E);l.x=b*A,l.y=x*M,l.z=b*S,p.setXYZ(v,l.x,l.y,l.z),d.setXYZ(v,0,M,0),h.x=.5*S+.5,h.y=.5*A*M+.5,m.setXY(v,h.x,h.y),v++}for(i=0;i0&&b(!0),e>0&&b(!1)),this.setIndex(f),this.addAttribute("position",p),this.addAttribute("normal",d),this.addAttribute("uv",m)}function hi(t,e,r,n,i,o,a,s){Br.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new ci(t,e,r,n,i,o,a,s)),this.mergeVertices()}function li(t,e,r,n,i,o,a){hi.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function fi(t,e,r,n,i,o,a){ci.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function pi(t,e,r,n){Vr.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var i=e+2,o=new Float32Array(3*i),a=new Float32Array(3*i),s=new Float32Array(2*i);a[2]=1,s[0]=.5,s[1]=.5;for(var u=0,c=3,h=2;u<=e;u++,c+=3,h+=2){var l=r+u/e*n;o[c]=t*Math.cos(l),o[c+1]=t*Math.sin(l),a[c+2]=1,s[h]=(o[c]/t+1)/2,s[h+1]=(o[c+1]/t+1)/2}for(var f=[],c=1;c<=e;c++)f.push(c,c+1,0);this.setIndex(new Ur(new Uint16Array(f),1)),this.addAttribute("position",new Ur(o,3)),this.addAttribute("normal",new Ur(a,3)),this.addAttribute("uv",new Ur(s,2)),this.boundingSphere=new wr(new xe,t)}function di(t,e,r,n){Br.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new pi(t,e,r,n))}function mi(t,e,r,n,i,o){Br.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Wr(t,e,r,n,i,o)),this.mergeVertices()}Kn.prototype=Object.create(Br.prototype),Kn.prototype.constructor=Kn,Kn.prototype.addShapeList=function(t,e){for(var r=t.length,n=0;nNumber.EPSILON){var f=Math.sqrt(h),p=Math.sqrt(u*u+c*c),d=e.x-s/f,m=e.y+a/f,v=r.x-c/p,g=r.y+u/p,y=((v-d)*c-(g-m)*u)/(a*c-s*u);n=d+a*y-t.x,i=m+s*y-t.y;var x=n*n+i*i;if(x<=2)return new le(n,i);o=Math.sqrt(x/2)}else{var w=!1;a>Number.EPSILON?u>Number.EPSILON&&(w=!0):a<-Number.EPSILON?u<-Number.EPSILON&&(w=!0):Math.sign(s)===Math.sign(c)&&(w=!0),w?(n=-s,i=a,o=Math.sqrt(h)):(n=a,i=s,o=Math.sqrt(h/2))}return new le(n/o,i/o)}for(var k=[],B=0,z=T.length,j=z-1,G=B+1;B=0;R--){for(P=R/p,I=l*Math.cos(P*Math.PI/2),C=f*Math.sin(P*Math.PI/2),B=0,z=T.length;B=0;){r=B,(n=B-1)<0&&(n=t.length-1);var i=0,o=v+2*p;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);i.format=n?Ft:Ut,i.image=r,i.needsUpdate=!0,void 0!==e&&e(i)},r,n),i},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this}}),Di.prototype=Object.assign(Object.create(Lr.prototype),{constructor:Di,isLight:!0,copy:function(t){return Lr.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Lr.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),ki.prototype=Object.assign(Object.create(Di.prototype),{constructor:ki,isHemisphereLight:!0,copy:function(t){return Di.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Bi.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),zi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:zi,isSpotLightShadow:!0,update:function(t){var e=2*he.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||500,i=this.camera;e===i.fov&&r===i.aspect&&n===i.far||(i.fov=e,i.aspect=r,i.far=n,i.updateProjectionMatrix())}}),ji.prototype=Object.assign(Object.create(Di.prototype),{constructor:ji,isSpotLight:!0,copy:function(t){return Di.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Gi.prototype=Object.assign(Object.create(Di.prototype),{constructor:Gi,isPointLight:!0,copy:function(t){return Di.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Vi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Vi}),Hi.prototype=Object.assign(Object.create(Di.prototype),{constructor:Hi,isDirectionalLight:!0,copy:function(t){return Di.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Wi.prototype=Object.assign(Object.create(Di.prototype),{constructor:Wi,isAmbientLight:!0});var Yi,Xi={arraySlice:function(t,e,r){return Xi.isTypedArray(t)?new t.constructor(t.subarray(e,r)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,u=0;u!==e;++u)i[a++]=t[s+u];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};function qi(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Zi(t,e,r,n){qi.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ji(t,e,r,n){qi.call(this,t,e,r,n)}function Qi(t,e,r,n){qi.call(this,t,e,r,n)}function Ki(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=Xi.convertArray(e,this.TimeBufferType),this.values=Xi.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function $i(t,e,r,n){Ki.call(this,t,e,r,n)}function to(t,e,r,n){qi.call(this,t,e,r,n)}function eo(t,e,r,n){Ki.call(this,t,e,r,n)}function ro(t,e,r,n){Ki.call(this,t,e,r,n)}function no(t,e,r,n){Ki.call(this,t,e,r,n)}function io(t,e,r){Ki.call(this,t,e,r)}function oo(t,e,r,n){Ki.call(this,t,e,r,n)}function ao(t,e,r,n){Ki.apply(this,arguments)}function so(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=he.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function uo(t){this.manager=void 0!==t?t:Ri,this.textures={}}function co(t){this.manager=void 0!==t?t:Ri}function ho(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function lo(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Ri,this.withCredentials=!1}function fo(t){this.manager=void 0!==t?t:Ri,this.texturePath=""}function po(){}function mo(t,e){this.v1=t,this.v2=e}function vo(){this.curves=[],this.autoClose=!1}function go(t,e,r,n,i,o,a,s){this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}qi.prototype={constructor:qi,evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var s=e[1];t=i)break e}o=r,r=0}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=Xi.arraySlice(r,i,o),this.values=Xi.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("invalid value size in track",this),t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(console.error("track is empty",this),t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){console.error("time is not a valid number",this,a,s),t=!1;break}if(null!==o&&o>s){console.error("out of order keys",this,a,s,o),t=!1;break}o=s}if(void 0!==n&&Xi.isTypedArray(n))for(var a=0,u=n.length;a!==u;++a){var c=n[a];if(isNaN(c)){console.error("value is not a valid number",this,a,c),t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(var m=o*r,v=i*r,p=0;p!==r;++p)e[v+p]=e[m+p];++i}return i!==t.length&&(this.times=Xi.arraySlice(t,0,i),this.values=Xi.arraySlice(e,0,i*r)),this}},$i.prototype=Object.assign(Object.create(Yi),{constructor:$i,ValueTypeName:"vector"}),to.prototype=Object.assign(Object.create(qi.prototype),{constructor:to,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,u=(r-e)/(n-e),c=s+a;s!==c;s+=4)ye.slerpFlat(i,0,o,s-a,o,s,u);return i}}),eo.prototype=Object.assign(Object.create(Yi),{constructor:eo,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new to(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),ro.prototype=Object.assign(Object.create(Yi),{constructor:ro,ValueTypeName:"number"}),no.prototype=Object.assign(Object.create(Yi),{constructor:no,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),io.prototype=Object.assign(Object.create(Yi),{constructor:io,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),oo.prototype=Object.assign(Object.create(Yi),{constructor:oo,ValueTypeName:"color"}),ao.prototype=Yi,Yi.constructor=ao,Object.assign(ao,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=ao._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];Xi.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:Xi.convertArray(t.times,Array),values:Xi.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ro;case"vector":case"vector2":case"vector3":case"vector4":return $i;case"color":return oo;case"quaternion":return eo;case"bool":case"boolean":return io;case"string":return no}throw new Error("Unsupported typeName: "+t)}}),so.prototype={constructor:so,resetDuration:function(){for(var t=this.tracks,e=0,r=0,n=t.length;r!==n;++r){var i=this.tracks[r];e=Math.max(e,i.times[i.times.length-1])}this.duration=e},trim:function(){for(var t=0;t1){var c=u[1],h=n[c];h||(n[c]=h=[]),h.push(s)}}var l=[];for(var c in n)l.push(so.CreateFromMorphTargetSequence(c,n[c],e,r));return l},parseAnimation:function(t,e){if(!t)return console.error(" no animation in JSONLoader data"),null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];Xi.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],u=0;u1?t.skinWeights[n+1]:0,s=e>2?t.skinWeights[n+2]:0,u=e>3?t.skinWeights[n+3]:0;r.skinWeights.push(new me(o,a,s,u))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,l=e>2?t.skinIndices[n+2]:0,f=e>3?t.skinIndices[n+3]:0;r.skinIndices.push(new me(c,h,l,f))}r.bones=t.bones,r.bones&&r.bones.length>0&&(r.skinWeights.length!==r.skinIndices.length||r.skinIndices.length!==r.vertices.length)&&console.warn("When skinning, number of vertices ("+r.vertices.length+"), skinIndices ("+r.skinIndices.length+"), and skinWeights ("+r.skinWeights.length+") should match.")}(),function(e){if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=r.faces,l=t.morphColors[0].colors,n=0,i=h.length;n0&&(r.animations=e)}(),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};var i=ho.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:r,materials:i}}}),Object.assign(fo.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this,o=new Ci(i.manager);o.load(t,function(t){i.parse(JSON.parse(t),e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new lo,n=new co,i=0,o=t.length;i0){var o=new Li(e),a=new Fi(o);a.setCrossOrigin(this.crossOrigin);for(var s=0,u=t.length;s0?new bn(s,u):new Hr(s,u);break;case"LOD":i=new gn;break;case"Line":i=new _n(o(e.geometry),a(e.material),e.mode);break;case"LineSegments":i=new En(o(e.geometry),a(e.material));break;case"PointCloud":case"Points":i=new An(o(e.geometry),a(e.material));break;case"Sprite":i=new vn(a(e.material));break;case"Group":i=new Tn;break;default:i=new Lr}if(i.uuid=e.uuid,void 0!==e.name&&(i.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(i.position,i.quaternion,i.scale)):(void 0!==e.position&&i.position.fromArray(e.position),void 0!==e.rotation&&i.rotation.fromArray(e.rotation),void 0!==e.quaternion&&i.quaternion.fromArray(e.quaternion),void 0!==e.scale&&i.scale.fromArray(e.scale)),void 0!==e.castShadow&&(i.castShadow=e.castShadow),void 0!==e.receiveShadow&&(i.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(i.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(i.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&i.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(i.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.children)for(var c in e.children)i.add(this.parseObject(e.children[c],r,n));if("LOD"===e.type)for(var h=e.levels,l=0;l0)){u=i;break}u=i-1}if(n[i=u]===r){var c=i/(o-1);return c}var h=n[i],l=n[i+1],f=l-h,p=(r-h)/f,c=(i+p)/(o-1);return c},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e),i=this.getPoint(r),o=i.clone().sub(n);return o.normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new xe,a=[],s=[],u=[],c=new xe,h=new we;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new xe,u[0]=new xe;var l=Number.MAX_VALUE,f=Math.abs(a[0].x),p=Math.abs(a[0].y),d=Math.abs(a[0].z);for(f<=l&&(l=f,o.set(1,0,0)),p<=l&&(l=p,o.set(0,1,0)),d<=l&&o.set(0,0,1),c.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],c),u[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),u[r]=u[r-1].clone(),c.crossVectors(a[r-1],a[r]),c.length()>Number.EPSILON&&(c.normalize(),i=Math.acos(he.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(h.makeRotationAxis(c,i))),u[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(he.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(c.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(h.makeRotationAxis(a[r],i*r)),u[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:u}}},po.create=function(t,e){return t.prototype=Object.create(po.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},mo.prototype=Object.create(po.prototype),mo.prototype.constructor=mo,mo.prototype.isLineCurve=!0,mo.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},mo.prototype.getPointAt=function(t){return this.getPoint(t)},mo.prototype.getTangent=function(t){var e=this.v2.clone().sub(this.v1);return e.normalize()},vo.prototype=Object.assign(Object.create(po.prototype),{constructor:vo,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new mo(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Br,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:n+1],u=e[n>e.length-3?e.length-1:n+2],c=yo.interpolate;return new le(c(o.x,a.x,s.x,u.x,i),c(o.y,a.y,s.y,u.y,i))},wo.prototype=Object.create(po.prototype),wo.prototype.constructor=wo,wo.prototype.getPoint=function(t){var e=Qn.b3;return new le(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y))},wo.prototype.getTangent=function(t){var e=yo.tangentCubicBezier;return new le(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y)).normalize()},bo.prototype=Object.create(po.prototype),bo.prototype.constructor=bo,bo.prototype.getPoint=function(t){var e=Qn.b2;return new le(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y))},bo.prototype.getTangent=function(t){var e=yo.tangentQuadraticBezier;return new le(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y)).normalize()};var Mo,_o=Object.assign(Object.create(vo.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var c=u.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(u);var h=u.getPoint(1);this.currentPoint.copy(h)}});function Eo(){So.apply(this,arguments),this.holes=[]}function So(t){vo.call(this),this.currentPoint=new le,t&&this.fromPoints(t)}function Ao(){this.subPaths=[],this.currentPath=null}function To(t){this.data=t}function Lo(t){this.manager=void 0!==t?t:Ri}function Ro(){return void 0===Mo&&(Mo=new(window.AudioContext||window.webkitAudioContext)),Mo}function Co(t){this.manager=void 0!==t?t:Ri}function Po(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new qr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new qr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Io(t,e,r){Lr.call(this),this.type="CubeCamera";var n=new qr(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new xe(1,0,0)),this.add(n);var i=new qr(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new xe(-1,0,0)),this.add(i);var o=new qr(90,1,t,e);o.up.set(0,0,1),o.lookAt(new xe(0,1,0)),this.add(o);var a=new qr(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new xe(0,-1,0)),this.add(a);var s=new qr(90,1,t,e);s.up.set(0,-1,0),s.lookAt(new xe(0,0,1)),this.add(s);var u=new qr(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new xe(0,0,-1)),this.add(u);var c={format:Ft,magFilter:gt,minFilter:gt};this.renderTarget=new ge(r,r,c),this.updateCubeMap=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,c=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,i,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,s,r),r.texture.generateMipmaps=c,r.activeCubeFace=5,t.render(e,u,r),t.setRenderTarget(null)}}function No(){Lr.call(this),this.type="AudioListener",this.context=Ro(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Fo(t){Lr.call(this),this.type="Audio",this.context=t.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Uo(t){Fo.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Oo(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function Do(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function ko(t,e,r){this.path=e,this.parsedPath=r||ko.parseTrackName(e),this.node=ko.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Bo(t){this.uuid=he.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function zo(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,o=new Array(i),a={endingStart:Qt,endingEnd:Qt},s=0;s!==i;++s){var u=n[s].createInterpolant(null);o[s]=u,u.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Jt,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function jo(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Go(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Vo(){Vr.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Ho(t,e,r,n){this.uuid=he.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function Wo(t,e){this.uuid=he.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Yo(t,e,r){Wo.call(this,t,e),this.meshPerAttribute=r||1}function Xo(t,e,r){Ur.call(this,t,e),this.meshPerAttribute=r||1}function qo(t,e,r,n){this.ray=new Sr(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Zo(t,e){return t.distance-e.distance}function Jo(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,o=0,a=i.length;oNumber.EPSILON){if(c<0&&(a=e[o],u=-u,s=e[i],c=-c),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var h=c*(t.x-a.x)-u*(t.y-a.y);if(0===h)return!0;if(h<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n}var i=Qn.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,u,c=[];if(1===o.length)return s=o[0],(u=new Eo).curves=s.curves,c.push(u),c;var h=!i(o[0].getPoints());h=t?!h:h;var l,f,p=[],d=[],m=[],v=0;d[v]=void 0,m[v]=[];for(var g=0,y=o.length;g1){for(var x=!1,w=[],b=0,M=d.length;b0&&(x||(m=p))}for(var g=0,L=d.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n,i){ye.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}},ko.prototype={constructor:ko,getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,i=e.propertyIndex;if(t||(t=ko.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(r){var o=e.objectIndex;switch(r){case"materials":if(!t.material)return void console.error(" can not bind to material as node does not have a material",this);if(!t.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);t=t.skeleton.bones;for(var a=0;a=r){var l=r++,f=e[l];n[f.uuid]=h,e[h]=f,n[c]=l,e[l]=u;for(var p=0,d=o;p!==d;++p){var m=i[p],v=m[l],g=m[h];m[h]=v,m[l]=g}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,u=arguments.length;s!==u;++s){var c=arguments[s],h=c.uuid,l=i[h];if(void 0!==l)if(delete i[h],l0)for(var u=this._interpolants,c=this._propertyBindings,h=0,l=u.length;h!==l;++h)u[h].evaluate(a),c[h].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this.loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:Qt:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:Qt:2402)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}},Object.assign(jo.prototype,e.prototype,{clipAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?so.findByName(r,t):t,o=null!==i?i.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var u=a.actionByRoot[n];if(void 0!==u)return u;s=a.knownActions[0],null===i&&(i=s._clip)}if(null===i)return null;var c=new zo(this,i,e);return this._bindAction(c,s),this._addInactiveAction(c,o,n),c},existingAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?so.findByName(r,t):t,o=i?i.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[n]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,r=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var i=0;i!==e;++i)t[i].reset();for(var i=0;i!==n;++i)r[i].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1,a=0;a!==r;++a){var s=e[a];s.enabled&&s._update(n,t,i,o)}for(var u=this._bindings,c=this._nActiveBindings,a=0;a!==c;++a)u[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,r=t.uuid,n=this._actionsByClip,i=n[r];if(void 0!==i){for(var o=i.knownActions,a=0,s=o.length;a!==s;++a){var u=o[a];this._deactivateAction(u);var c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete n[r]}},uncacheRoot:function(t){var e=t.uuid,r=this._actionsByClip;for(var n in r){var i=r[n].actionByRoot,o=i[e];void 0!==o&&(this._deactivateAction(o),this._removeInactiveAction(o))}var a=this._bindingsByRootAndName,s=a[e];if(void 0!==s)for(var u in s){var c=s[u];c.restoreOriginalState(),this._removeInactiveBinding(c)}},uncacheAction:function(t,e){var r=this.existingAction(t,e);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}}),Object.assign(jo.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,u=this._bindingsByRootAndName,c=u[s];void 0===c&&(c={},u[s]=c);for(var h=0;h!==i;++h){var l=n[h],f=l.name,p=c[f];if(void 0!==p)o[h]=p;else{if(void 0!==(p=o[h])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,f));continue}var d=e&&e._propertyBindings[h].binding.parsedPath;++(p=new Do(ko.create(r,f,d),l.ValueTypeName,l.getValueSize())).referenceCount,this._addInactiveBinding(p,s,f),o[h]=p}a[h].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e1){var c=u[1];n[c]||(n[c]={start:1/0,end:-1/0});var h=n[c];oh.end&&(h.end=o),e||(e=c)}}for(var c in n){var h=n[c];this.createAnimation(c,h.start,h.end,t)}this.firstAnimation=e},$o.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},$o.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},$o.prototype.setAnimationFPS=function(t,e){var r=this.animationsMap[t];r&&(r.fps=e,r.duration=(r.end-r.start)/r.fps)},$o.prototype.setAnimationDuration=function(t,e){var r=this.animationsMap[t];r&&(r.duration=e,r.fps=(r.end-r.start)/r.duration)},$o.prototype.setAnimationWeight=function(t,e){var r=this.animationsMap[t];r&&(r.weight=e)},$o.prototype.setAnimationTime=function(t,e){var r=this.animationsMap[t];r&&(r.time=e)},$o.prototype.getAnimationTime=function(t){var e=0,r=this.animationsMap[t];return r&&(e=r.time),e},$o.prototype.getAnimationDuration=function(t){var e=-1,r=this.animationsMap[t];return r&&(e=r.duration),e},$o.prototype.playAnimation=function(t){var e=this.animationsMap[t];e?(e.time=0,e.active=!0):console.warn("THREE.MorphBlendMesh: animation["+t+"] undefined in .playAnimation()")},$o.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},$o.prototype.update=function(t){for(var e=0,r=this.animationsList.length;en.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var o=n.start+he.clamp(Math.floor(n.time/i),0,n.length-1),a=n.weight;o!==n.currentFrame&&(this.morphTargetInfluences[n.lastFrame]=0,this.morphTargetInfluences[n.currentFrame]=1*a,this.morphTargetInfluences[o]=0,n.lastFrame=n.currentFrame,n.currentFrame=o);var s=n.time%i/i;n.directionBackwards&&(s=1-s),n.currentFrame!==n.lastFrame?(this.morphTargetInfluences[n.currentFrame]=s*a,this.morphTargetInfluences[n.lastFrame]=(1-s)*a):this.morphTargetInfluences[n.currentFrame]=a}}},ta.prototype=Object.create(Lr.prototype),ta.prototype.constructor=ta,ta.prototype.isImmediateRenderObject=!0,ea.prototype=Object.create(En.prototype),ea.prototype.constructor=ea,ea.prototype.update=function(){var t=new xe,e=new xe,r=new br;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,u=a.faces,c=0,h=0,l=u.length;h.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),da.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},da.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},ma.prototype=Object.create(En.prototype),ma.prototype.constructor=ma;var va=function(){var t=new xe,e=new i,r=new i,n=new i;function i(){}return i.prototype.init=function(t,e,r,n){this.c0=t,this.c1=r,this.c2=-3*t+3*e-2*r-n,this.c3=2*t-2*e+r+n},i.prototype.initNonuniformCatmullRom=function(t,e,r,n,i,o,a){var s=(e-t)/i-(r-t)/(i+o)+(r-e)/o,u=(r-e)/o-(n-e)/(o+a)+(n-r)/a;s*=o,u*=o,this.init(e,r,s,u)},i.prototype.initCatmullRom=function(t,e,r,n,i){this.init(e,r,i*(r-t),i*(n-e))},i.prototype.calc=function(t){var e=t*t,r=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*r},po.create(function(t){this.points=t||[],this.closed=!1},function(i){var o,a,s,u,c,h,l,f,p=this.points;if((u=p.length)<2&&console.log("duh, you need at least 2 points"),o=(u-(this.closed?0:1))*i,a=Math.floor(o),s=o-a,this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/p.length)+1)*p.length:0===s&&a===u-1&&(a=u-2,s=1),this.closed||a>0?c=p[(a-1)%u]:(t.subVectors(p[0],p[1]).add(p[0]),c=t),h=p[a%u],l=p[(a+1)%u],this.closed||a+2e.length-2?e.length-1:n+1],u=e[n>e.length-3?e.length-1:n+2],c=yo.interpolate;return new xe(c(o.x,a.x,s.x,u.x,i),c(o.y,a.y,s.y,u.y,i),c(o.z,a.z,s.z,u.z,i))}),xa=po.create(function(t,e,r,n){this.v0=t,this.v1=e,this.v2=r,this.v3=n},function(t){var e=Qn.b3;return new xe(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y),e(t,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),wa=po.create(function(t,e,r){this.v0=t,this.v1=e,this.v2=r},function(t){var e=Qn.b2;return new xe(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y),e(t,this.v0.z,this.v1.z,this.v2.z))}),ba=po.create(function(t,e){this.v1=t,this.v2=e},function(t){if(1===t)return this.v2.clone();var e=new xe;return e.subVectors(this.v2,this.v1),e.multiplyScalar(t),e.add(this.v1),e});function Ma(t,e,r,n,i,o){go.call(this,t,e,r,r,n,i,o)}Ma.prototype=Object.create(go.prototype),Ma.prototype.constructor=Ma;var _a={createMultiMaterialObject:function(t,e){for(var r=new Tn,n=0,i=e.length;nthis.points.length-2?this.points.length-1:r+1,h[3]=r>this.points.length-3?this.points.length-1:r+2,a=this.points[h[0]],s=this.points[h[1]],u=this.points[h[2]],c=this.points[h[3]],o=n*(i=n*n),l.x=f(a.x,s.x,u.x,c.x,n,i,o),l.y=f(a.y,s.y,u.y,c.y,n,i,o),l.z=f(a.z,s.z,u.z,c.z,n,i,o),l},this.getControlPointsArray=function(){var t,e,r=this.points.length,n=[];for(t=0;t1)for(var r=1;r