/*@license
 AsyGL: Render Bezier patches and triangles via subdivision with WebGL.
  Copyright 2019-26: John C. Bowman and Supakorn "Jamie" Rassameemasmuang
  University of Alberta

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/* license for gl-matrix: 
Copyright (c) 2015-2025, Brandon Jones, Colin MacKenzie IV.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
(()=>{"use strict";var t={823(t,e,n){n.r(e),n.d(e,{ARRAY_TYPE:()=>i,EPSILON:()=>r,RANDOM:()=>a,equals:()=>l,setMatrixArrayType:()=>s,toRadian:()=>h});var r=1e-6,i="undefined"!=typeof Float32Array?Float32Array:Array,a=Math.random;function s(t){i=t}var o=Math.PI/180;function h(t){return t*o}function l(t,e){return Math.abs(t-e)<=r*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)})},409(t,e,n){n.r(e),n.d(e,{add:()=>L,adjoint:()=>m,clone:()=>s,copy:()=>o,create:()=>i,determinant:()=>d,equals:()=>_,exactEquals:()=>S,frob:()=>I,fromMat2d:()=>E,fromMat4:()=>a,fromQuat:()=>R,fromRotation:()=>x,fromScaling:()=>w,fromTranslation:()=>b,fromValues:()=>h,identity:()=>u,invert:()=>f,mul:()=>V,multiply:()=>v,multiplyScalar:()=>P,multiplyScalarAndAdd:()=>O,normalFromMat4:()=>A,projection:()=>T,rotate:()=>p,scale:()=>g,set:()=>l,str:()=>y,sub:()=>U,subtract:()=>N,translate:()=>M,transpose:()=>c});var r=n(823);function i(){var t=new r.ARRAY_TYPE(9);return r.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function a(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function s(t){var e=new r.ARRAY_TYPE(9);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}function o(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}function h(t,e,n,i,a,s,o,h,l){var u=new r.ARRAY_TYPE(9);return u[0]=t,u[1]=e,u[2]=n,u[3]=i,u[4]=a,u[5]=s,u[6]=o,u[7]=h,u[8]=l,u}function l(t,e,n,r,i,a,s,o,h,l){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=h,t[8]=l,t}function u(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function c(t,e){if(t===e){var n=e[1],r=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=r,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function f(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=e[6],l=e[7],u=e[8],c=u*s-o*l,f=-u*a+o*h,m=l*a-s*h,d=n*c+r*f+i*m;return d?(d=1/d,t[0]=c*d,t[1]=(-u*r+i*l)*d,t[2]=(o*r-i*s)*d,t[3]=f*d,t[4]=(u*n-i*h)*d,t[5]=(-o*n+i*a)*d,t[6]=m*d,t[7]=(-l*n+r*h)*d,t[8]=(s*n-r*a)*d,t):null}function m(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=e[6],l=e[7],u=e[8];return t[0]=s*u-o*l,t[1]=i*l-r*u,t[2]=r*o-i*s,t[3]=o*h-a*u,t[4]=n*u-i*h,t[5]=i*a-n*o,t[6]=a*l-s*h,t[7]=r*h-n*l,t[8]=n*s-r*a,t}function d(t){var e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],o=t[6],h=t[7],l=t[8];return e*(l*a-s*h)+n*(-l*i+s*o)+r*(h*i-a*o)}function v(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=e[8],f=n[0],m=n[1],d=n[2],v=n[3],M=n[4],p=n[5],g=n[6],b=n[7],x=n[8];return t[0]=f*r+m*s+d*l,t[1]=f*i+m*o+d*u,t[2]=f*a+m*h+d*c,t[3]=v*r+M*s+p*l,t[4]=v*i+M*o+p*u,t[5]=v*a+M*h+p*c,t[6]=g*r+b*s+x*l,t[7]=g*i+b*o+x*u,t[8]=g*a+b*h+x*c,t}function M(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=e[8],f=n[0],m=n[1];return t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=o,t[5]=h,t[6]=f*r+m*s+l,t[7]=f*i+m*o+u,t[8]=f*a+m*h+c,t}function p(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=e[8],f=Math.sin(n),m=Math.cos(n);return t[0]=m*r+f*s,t[1]=m*i+f*o,t[2]=m*a+f*h,t[3]=m*s-f*r,t[4]=m*o-f*i,t[5]=m*h-f*a,t[6]=l,t[7]=u,t[8]=c,t}function g(t,e,n){var r=n[0],i=n[1];return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function b(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t}function x(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function w(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function E(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t}function R(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=n+n,o=r+r,h=i+i,l=n*s,u=r*s,c=r*o,f=i*s,m=i*o,d=i*h,v=a*s,M=a*o,p=a*h;return t[0]=1-c-d,t[3]=u-p,t[6]=f+M,t[1]=u+p,t[4]=1-l-d,t[7]=m-v,t[2]=f-M,t[5]=m+v,t[8]=1-l-c,t}function A(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=e[6],l=e[7],u=e[8],c=e[9],f=e[10],m=e[11],d=e[12],v=e[13],M=e[14],p=e[15],g=n*o-r*s,b=n*h-i*s,x=n*l-a*s,w=r*h-i*o,E=r*l-a*o,R=i*l-a*h,A=u*v-c*d,T=u*M-f*d,y=u*p-m*d,I=c*M-f*v,L=c*p-m*v,N=f*p-m*M,P=g*N-b*L+x*I+w*y-E*T+R*A;return P?(P=1/P,t[0]=(o*N-h*L+l*I)*P,t[1]=(h*y-s*N-l*T)*P,t[2]=(s*L-o*y+l*A)*P,t[3]=(i*L-r*N-a*I)*P,t[4]=(n*N-i*y+a*T)*P,t[5]=(r*y-n*L-a*A)*P,t[6]=(v*R-M*E+p*w)*P,t[7]=(M*x-d*R-p*b)*P,t[8]=(d*E-v*x+p*g)*P,t):null}function T(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function y(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function I(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])}function L(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t}function N(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t}function P(t,e,n){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]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t}function O(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t}function S(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]}function _(t,e){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],h=t[5],l=t[6],u=t[7],c=t[8],f=e[0],m=e[1],d=e[2],v=e[3],M=e[4],p=e[5],g=e[6],b=e[7],x=e[8];return Math.abs(n-f)<=r.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(i-m)<=r.EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(a-d)<=r.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(s-v)<=r.EPSILON*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(o-M)<=r.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(h-p)<=r.EPSILON*Math.max(1,Math.abs(h),Math.abs(p))&&Math.abs(l-g)<=r.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-b)<=r.EPSILON*Math.max(1,Math.abs(u),Math.abs(b))&&Math.abs(c-x)<=r.EPSILON*Math.max(1,Math.abs(c),Math.abs(x))}var V=v,U=N},684(t,e,n){n.r(e),n.d(e,{add:()=>k,adjoint:()=>f,clone:()=>a,copy:()=>s,create:()=>i,determinant:()=>m,equals:()=>K,exactEquals:()=>Q,frob:()=>W,fromQuat:()=>V,fromQuat2:()=>L,fromRotation:()=>R,fromRotationTranslation:()=>I,fromRotationTranslationScale:()=>S,fromRotationTranslationScaleOrigin:()=>_,fromScaling:()=>E,fromTranslation:()=>w,fromValues:()=>o,fromXRotation:()=>A,fromYRotation:()=>T,fromZRotation:()=>y,frustum:()=>U,getRotation:()=>O,getScaling:()=>P,getTranslation:()=>N,identity:()=>l,invert:()=>c,lookAt:()=>X,mul:()=>J,multiply:()=>d,multiplyScalar:()=>$,multiplyScalarAndAdd:()=>Z,ortho:()=>z,orthoNO:()=>F,orthoZO:()=>C,perspective:()=>D,perspectiveFromFieldOfView:()=>q,perspectiveNO:()=>Y,perspectiveZO:()=>B,rotate:()=>p,rotateX:()=>g,rotateY:()=>b,rotateZ:()=>x,scale:()=>M,set:()=>h,str:()=>H,sub:()=>tt,subtract:()=>j,targetTo:()=>G,translate:()=>v,transpose:()=>u});var r=n(823);function i(){var t=new r.ARRAY_TYPE(16);return r.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function a(t){var e=new r.ARRAY_TYPE(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}function s(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}function o(t,e,n,i,a,s,o,h,l,u,c,f,m,d,v,M){var p=new r.ARRAY_TYPE(16);return p[0]=t,p[1]=e,p[2]=n,p[3]=i,p[4]=a,p[5]=s,p[6]=o,p[7]=h,p[8]=l,p[9]=u,p[10]=c,p[11]=f,p[12]=m,p[13]=d,p[14]=v,p[15]=M,p}function h(t,e,n,r,i,a,s,o,h,l,u,c,f,m,d,v,M){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=h,t[8]=l,t[9]=u,t[10]=c,t[11]=f,t[12]=m,t[13]=d,t[14]=v,t[15]=M,t}function l(t){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}function u(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],a=e[6],s=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=a,t[11]=e[14],t[12]=i,t[13]=s,t[14]=o}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}function c(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=e[6],l=e[7],u=e[8],c=e[9],f=e[10],m=e[11],d=e[12],v=e[13],M=e[14],p=e[15],g=n*o-r*s,b=n*h-i*s,x=n*l-a*s,w=r*h-i*o,E=r*l-a*o,R=i*l-a*h,A=u*v-c*d,T=u*M-f*d,y=u*p-m*d,I=c*M-f*v,L=c*p-m*v,N=f*p-m*M,P=g*N-b*L+x*I+w*y-E*T+R*A;return P?(P=1/P,t[0]=(o*N-h*L+l*I)*P,t[1]=(i*L-r*N-a*I)*P,t[2]=(v*R-M*E+p*w)*P,t[3]=(f*E-c*R-m*w)*P,t[4]=(h*y-s*N-l*T)*P,t[5]=(n*N-i*y+a*T)*P,t[6]=(M*x-d*R-p*b)*P,t[7]=(u*R-f*x+m*b)*P,t[8]=(s*L-o*y+l*A)*P,t[9]=(r*y-n*L-a*A)*P,t[10]=(d*E-v*x+p*g)*P,t[11]=(c*x-u*E-m*g)*P,t[12]=(o*T-s*I-h*A)*P,t[13]=(n*I-r*T+i*A)*P,t[14]=(v*b-d*w-M*g)*P,t[15]=(u*w-c*b+f*g)*P,t):null}function f(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=e[6],l=e[7],u=e[8],c=e[9],f=e[10],m=e[11],d=e[12],v=e[13],M=e[14],p=e[15];return t[0]=o*(f*p-m*M)-c*(h*p-l*M)+v*(h*m-l*f),t[1]=-(r*(f*p-m*M)-c*(i*p-a*M)+v*(i*m-a*f)),t[2]=r*(h*p-l*M)-o*(i*p-a*M)+v*(i*l-a*h),t[3]=-(r*(h*m-l*f)-o*(i*m-a*f)+c*(i*l-a*h)),t[4]=-(s*(f*p-m*M)-u*(h*p-l*M)+d*(h*m-l*f)),t[5]=n*(f*p-m*M)-u*(i*p-a*M)+d*(i*m-a*f),t[6]=-(n*(h*p-l*M)-s*(i*p-a*M)+d*(i*l-a*h)),t[7]=n*(h*m-l*f)-s*(i*m-a*f)+u*(i*l-a*h),t[8]=s*(c*p-m*v)-u*(o*p-l*v)+d*(o*m-l*c),t[9]=-(n*(c*p-m*v)-u*(r*p-a*v)+d*(r*m-a*c)),t[10]=n*(o*p-l*v)-s*(r*p-a*v)+d*(r*l-a*o),t[11]=-(n*(o*m-l*c)-s*(r*m-a*c)+u*(r*l-a*o)),t[12]=-(s*(c*M-f*v)-u*(o*M-h*v)+d*(o*f-h*c)),t[13]=n*(c*M-f*v)-u*(r*M-i*v)+d*(r*f-i*c),t[14]=-(n*(o*M-h*v)-s*(r*M-i*v)+d*(r*h-i*o)),t[15]=n*(o*f-h*c)-s*(r*f-i*c)+u*(r*h-i*o),t}function m(t){var e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],o=t[6],h=t[7],l=t[8],u=t[9],c=t[10],f=t[11],m=t[12],d=t[13],v=t[14],M=t[15];return(e*s-n*a)*(c*M-f*v)-(e*o-r*a)*(u*M-f*d)+(e*h-i*a)*(u*v-c*d)+(n*o-r*s)*(l*M-f*m)-(n*h-i*s)*(l*v-c*m)+(r*h-i*o)*(l*d-u*m)}function d(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=e[8],f=e[9],m=e[10],d=e[11],v=e[12],M=e[13],p=e[14],g=e[15],b=n[0],x=n[1],w=n[2],E=n[3];return t[0]=b*r+x*o+w*c+E*v,t[1]=b*i+x*h+w*f+E*M,t[2]=b*a+x*l+w*m+E*p,t[3]=b*s+x*u+w*d+E*g,b=n[4],x=n[5],w=n[6],E=n[7],t[4]=b*r+x*o+w*c+E*v,t[5]=b*i+x*h+w*f+E*M,t[6]=b*a+x*l+w*m+E*p,t[7]=b*s+x*u+w*d+E*g,b=n[8],x=n[9],w=n[10],E=n[11],t[8]=b*r+x*o+w*c+E*v,t[9]=b*i+x*h+w*f+E*M,t[10]=b*a+x*l+w*m+E*p,t[11]=b*s+x*u+w*d+E*g,b=n[12],x=n[13],w=n[14],E=n[15],t[12]=b*r+x*o+w*c+E*v,t[13]=b*i+x*h+w*f+E*M,t[14]=b*a+x*l+w*m+E*p,t[15]=b*s+x*u+w*d+E*g,t}function v(t,e,n){var r,i,a,s,o,h,l,u,c,f,m,d,v=n[0],M=n[1],p=n[2];return e===t?(t[12]=e[0]*v+e[4]*M+e[8]*p+e[12],t[13]=e[1]*v+e[5]*M+e[9]*p+e[13],t[14]=e[2]*v+e[6]*M+e[10]*p+e[14],t[15]=e[3]*v+e[7]*M+e[11]*p+e[15]):(r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=e[8],f=e[9],m=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=o,t[5]=h,t[6]=l,t[7]=u,t[8]=c,t[9]=f,t[10]=m,t[11]=d,t[12]=r*v+o*M+c*p+e[12],t[13]=i*v+h*M+f*p+e[13],t[14]=a*v+l*M+m*p+e[14],t[15]=s*v+u*M+d*p+e[15]),t}function M(t,e,n){var r=n[0],i=n[1],a=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function p(t,e,n,i){var a,s,o,h,l,u,c,f,m,d,v,M,p,g,b,x,w,E,R,A,T,y,I,L,N=i[0],P=i[1],O=i[2],S=Math.hypot(N,P,O);return S<r.EPSILON?null:(N*=S=1/S,P*=S,O*=S,a=Math.sin(n),o=1-(s=Math.cos(n)),h=e[0],l=e[1],u=e[2],c=e[3],f=e[4],m=e[5],d=e[6],v=e[7],M=e[8],p=e[9],g=e[10],b=e[11],x=N*N*o+s,w=P*N*o+O*a,E=O*N*o-P*a,R=N*P*o-O*a,A=P*P*o+s,T=O*P*o+N*a,y=N*O*o+P*a,I=P*O*o-N*a,L=O*O*o+s,t[0]=h*x+f*w+M*E,t[1]=l*x+m*w+p*E,t[2]=u*x+d*w+g*E,t[3]=c*x+v*w+b*E,t[4]=h*R+f*A+M*T,t[5]=l*R+m*A+p*T,t[6]=u*R+d*A+g*T,t[7]=c*R+v*A+b*T,t[8]=h*y+f*I+M*L,t[9]=l*y+m*I+p*L,t[10]=u*y+d*I+g*L,t[11]=c*y+v*I+b*L,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function g(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[4],s=e[5],o=e[6],h=e[7],l=e[8],u=e[9],c=e[10],f=e[11];return 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]),t[4]=a*i+l*r,t[5]=s*i+u*r,t[6]=o*i+c*r,t[7]=h*i+f*r,t[8]=l*i-a*r,t[9]=u*i-s*r,t[10]=c*i-o*r,t[11]=f*i-h*r,t}function b(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[0],s=e[1],o=e[2],h=e[3],l=e[8],u=e[9],c=e[10],f=e[11];return 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]),t[0]=a*i-l*r,t[1]=s*i-u*r,t[2]=o*i-c*r,t[3]=h*i-f*r,t[8]=a*r+l*i,t[9]=s*r+u*i,t[10]=o*r+c*i,t[11]=h*r+f*i,t}function x(t,e,n){var r=Math.sin(n),i=Math.cos(n),a=e[0],s=e[1],o=e[2],h=e[3],l=e[4],u=e[5],c=e[6],f=e[7];return 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]),t[0]=a*i+l*r,t[1]=s*i+u*r,t[2]=o*i+c*r,t[3]=h*i+f*r,t[4]=l*i-a*r,t[5]=u*i-s*r,t[6]=c*i-o*r,t[7]=f*i-h*r,t}function w(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}function E(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}function R(t,e,n){var i,a,s,o=n[0],h=n[1],l=n[2],u=Math.hypot(o,h,l);return u<r.EPSILON?null:(o*=u=1/u,h*=u,l*=u,i=Math.sin(e),s=1-(a=Math.cos(e)),t[0]=o*o*s+a,t[1]=h*o*s+l*i,t[2]=l*o*s-h*i,t[3]=0,t[4]=o*h*s-l*i,t[5]=h*h*s+a,t[6]=l*h*s+o*i,t[7]=0,t[8]=o*l*s+h*i,t[9]=h*l*s-o*i,t[10]=l*l*s+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function A(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function T(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function y(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,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}function I(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=r+r,h=i+i,l=a+a,u=r*o,c=r*h,f=r*l,m=i*h,d=i*l,v=a*l,M=s*o,p=s*h,g=s*l;return t[0]=1-(m+v),t[1]=c+g,t[2]=f-p,t[3]=0,t[4]=c-g,t[5]=1-(u+v),t[6]=d+M,t[7]=0,t[8]=f+p,t[9]=d-M,t[10]=1-(u+m),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function L(t,e){var n=new r.ARRAY_TYPE(3),i=-e[0],a=-e[1],s=-e[2],o=e[3],h=e[4],l=e[5],u=e[6],c=e[7],f=i*i+a*a+s*s+o*o;return f>0?(n[0]=2*(h*o+c*i+l*s-u*a)/f,n[1]=2*(l*o+c*a+u*i-h*s)/f,n[2]=2*(u*o+c*s+h*a-l*i)/f):(n[0]=2*(h*o+c*i+l*s-u*a),n[1]=2*(l*o+c*a+u*i-h*s),n[2]=2*(u*o+c*s+h*a-l*i)),I(t,e,n),t}function N(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function P(t,e){var n=e[0],r=e[1],i=e[2],a=e[4],s=e[5],o=e[6],h=e[8],l=e[9],u=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(a,s,o),t[2]=Math.hypot(h,l,u),t}function O(t,e){var n=new r.ARRAY_TYPE(3);P(n,e);var i=1/n[0],a=1/n[1],s=1/n[2],o=e[0]*i,h=e[1]*a,l=e[2]*s,u=e[4]*i,c=e[5]*a,f=e[6]*s,m=e[8]*i,d=e[9]*a,v=e[10]*s,M=o+c+v,p=0;return M>0?(p=2*Math.sqrt(M+1),t[3]=.25*p,t[0]=(f-d)/p,t[1]=(m-l)/p,t[2]=(h-u)/p):o>c&&o>v?(p=2*Math.sqrt(1+o-c-v),t[3]=(f-d)/p,t[0]=.25*p,t[1]=(h+u)/p,t[2]=(m+l)/p):c>v?(p=2*Math.sqrt(1+c-o-v),t[3]=(m-l)/p,t[0]=(h+u)/p,t[1]=.25*p,t[2]=(f+d)/p):(p=2*Math.sqrt(1+v-o-c),t[3]=(h-u)/p,t[0]=(m+l)/p,t[1]=(f+d)/p,t[2]=.25*p),t}function S(t,e,n,r){var i=e[0],a=e[1],s=e[2],o=e[3],h=i+i,l=a+a,u=s+s,c=i*h,f=i*l,m=i*u,d=a*l,v=a*u,M=s*u,p=o*h,g=o*l,b=o*u,x=r[0],w=r[1],E=r[2];return t[0]=(1-(d+M))*x,t[1]=(f+b)*x,t[2]=(m-g)*x,t[3]=0,t[4]=(f-b)*w,t[5]=(1-(c+M))*w,t[6]=(v+p)*w,t[7]=0,t[8]=(m+g)*E,t[9]=(v-p)*E,t[10]=(1-(c+d))*E,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function _(t,e,n,r,i){var a=e[0],s=e[1],o=e[2],h=e[3],l=a+a,u=s+s,c=o+o,f=a*l,m=a*u,d=a*c,v=s*u,M=s*c,p=o*c,g=h*l,b=h*u,x=h*c,w=r[0],E=r[1],R=r[2],A=i[0],T=i[1],y=i[2],I=(1-(v+p))*w,L=(m+x)*w,N=(d-b)*w,P=(m-x)*E,O=(1-(f+p))*E,S=(M+g)*E,_=(d+b)*R,V=(M-g)*R,U=(1-(f+v))*R;return t[0]=I,t[1]=L,t[2]=N,t[3]=0,t[4]=P,t[5]=O,t[6]=S,t[7]=0,t[8]=_,t[9]=V,t[10]=U,t[11]=0,t[12]=n[0]+A-(I*A+P*T+_*y),t[13]=n[1]+T-(L*A+O*T+V*y),t[14]=n[2]+y-(N*A+S*T+U*y),t[15]=1,t}function V(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=n+n,o=r+r,h=i+i,l=n*s,u=r*s,c=r*o,f=i*s,m=i*o,d=i*h,v=a*s,M=a*o,p=a*h;return t[0]=1-c-d,t[1]=u+p,t[2]=f-M,t[3]=0,t[4]=u-p,t[5]=1-l-d,t[6]=m+v,t[7]=0,t[8]=f+M,t[9]=m-v,t[10]=1-l-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function U(t,e,n,r,i,a,s){var o=1/(n-e),h=1/(i-r),l=1/(a-s);return t[0]=2*a*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*h,t[6]=0,t[7]=0,t[8]=(n+e)*o,t[9]=(i+r)*h,t[10]=(s+a)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*a*2*l,t[15]=0,t}function Y(t,e,n,r,i){var a,s=1/Math.tan(e/2);return t[0]=s/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(a=1/(r-i),t[10]=(i+r)*a,t[14]=2*i*r*a):(t[10]=-1,t[14]=-2*r),t}var D=Y;function B(t,e,n,r,i){var a,s=1/Math.tan(e/2);return t[0]=s/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(a=1/(r-i),t[10]=i*a,t[14]=i*r*a):(t[10]=-1,t[14]=-r),t}function q(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),h=2/(s+o),l=2/(i+a);return t[0]=h,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-(s-o)*h*.5,t[9]=(i-a)*l*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t}function F(t,e,n,r,i,a,s){var o=1/(e-n),h=1/(r-i),l=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+n)*o,t[13]=(i+r)*h,t[14]=(s+a)*l,t[15]=1,t}var z=F;function C(t,e,n,r,i,a,s){var o=1/(e-n),h=1/(r-i),l=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+n)*o,t[13]=(i+r)*h,t[14]=a*l,t[15]=1,t}function X(t,e,n,i){var a,s,o,h,u,c,f,m,d,v,M=e[0],p=e[1],g=e[2],b=i[0],x=i[1],w=i[2],E=n[0],R=n[1],A=n[2];return Math.abs(M-E)<r.EPSILON&&Math.abs(p-R)<r.EPSILON&&Math.abs(g-A)<r.EPSILON?l(t):(f=M-E,m=p-R,d=g-A,a=x*(d*=v=1/Math.hypot(f,m,d))-w*(m*=v),s=w*(f*=v)-b*d,o=b*m-x*f,(v=Math.hypot(a,s,o))?(a*=v=1/v,s*=v,o*=v):(a=0,s=0,o=0),h=m*o-d*s,u=d*a-f*o,c=f*s-m*a,(v=Math.hypot(h,u,c))?(h*=v=1/v,u*=v,c*=v):(h=0,u=0,c=0),t[0]=a,t[1]=h,t[2]=f,t[3]=0,t[4]=s,t[5]=u,t[6]=m,t[7]=0,t[8]=o,t[9]=c,t[10]=d,t[11]=0,t[12]=-(a*M+s*p+o*g),t[13]=-(h*M+u*p+c*g),t[14]=-(f*M+m*p+d*g),t[15]=1,t)}function G(t,e,n,r){var i=e[0],a=e[1],s=e[2],o=r[0],h=r[1],l=r[2],u=i-n[0],c=a-n[1],f=s-n[2],m=u*u+c*c+f*f;m>0&&(u*=m=1/Math.sqrt(m),c*=m,f*=m);var d=h*f-l*c,v=l*u-o*f,M=o*c-h*u;return(m=d*d+v*v+M*M)>0&&(d*=m=1/Math.sqrt(m),v*=m,M*=m),t[0]=d,t[1]=v,t[2]=M,t[3]=0,t[4]=c*M-f*v,t[5]=f*d-u*M,t[6]=u*v-c*d,t[7]=0,t[8]=u,t[9]=c,t[10]=f,t[11]=0,t[12]=i,t[13]=a,t[14]=s,t[15]=1,t}function H(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]+")"}function W(t){return Math.hypot(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])}function k(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t}function j(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}function $(t,e,n){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]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t}function Z(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t}function Q(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]}function K(t,e){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],h=t[5],l=t[6],u=t[7],c=t[8],f=t[9],m=t[10],d=t[11],v=t[12],M=t[13],p=t[14],g=t[15],b=e[0],x=e[1],w=e[2],E=e[3],R=e[4],A=e[5],T=e[6],y=e[7],I=e[8],L=e[9],N=e[10],P=e[11],O=e[12],S=e[13],_=e[14],V=e[15];return Math.abs(n-b)<=r.EPSILON*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-x)<=r.EPSILON*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(a-w)<=r.EPSILON*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-E)<=r.EPSILON*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(o-R)<=r.EPSILON*Math.max(1,Math.abs(o),Math.abs(R))&&Math.abs(h-A)<=r.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(l-T)<=r.EPSILON*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-y)<=r.EPSILON*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(c-I)<=r.EPSILON*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(f-L)<=r.EPSILON*Math.max(1,Math.abs(f),Math.abs(L))&&Math.abs(m-N)<=r.EPSILON*Math.max(1,Math.abs(m),Math.abs(N))&&Math.abs(d-P)<=r.EPSILON*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(v-O)<=r.EPSILON*Math.max(1,Math.abs(v),Math.abs(O))&&Math.abs(M-S)<=r.EPSILON*Math.max(1,Math.abs(M),Math.abs(S))&&Math.abs(p-_)<=r.EPSILON*Math.max(1,Math.abs(p),Math.abs(_))&&Math.abs(g-V)<=r.EPSILON*Math.max(1,Math.abs(g),Math.abs(V))}var J=d,tt=j},796(t,e,n){n.r(e),n.d(e,{add:()=>l,ceil:()=>m,clone:()=>a,copy:()=>o,create:()=>i,cross:()=>L,dist:()=>z,distance:()=>x,div:()=>F,divide:()=>f,dot:()=>I,equals:()=>Y,exactEquals:()=>U,floor:()=>d,forEach:()=>H,fromValues:()=>s,inverse:()=>T,len:()=>X,length:()=>E,lerp:()=>N,max:()=>M,min:()=>v,mul:()=>q,multiply:()=>c,negate:()=>A,normalize:()=>y,random:()=>P,round:()=>p,scale:()=>g,scaleAndAdd:()=>b,set:()=>h,sqrDist:()=>C,sqrLen:()=>G,squaredDistance:()=>w,squaredLength:()=>R,str:()=>V,sub:()=>B,subtract:()=>u,transformMat4:()=>O,transformQuat:()=>S,zero:()=>_});var r=n(823);function i(){var t=new r.ARRAY_TYPE(4);return r.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function a(t){var e=new r.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function s(t,e,n,i){var a=new r.ARRAY_TYPE(4);return a[0]=t,a[1]=e,a[2]=n,a[3]=i,a}function o(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function h(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function l(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t}function u(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t}function c(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t}function f(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t}function m(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function d(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function v(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t[3]=Math.min(e[3],n[3]),t}function M(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t}function p(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t}function g(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function b(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t}function x(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.hypot(n,r,i,a)}function w(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return n*n+r*r+i*i+a*a}function E(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.hypot(e,n,r,i)}function R(t){var e=t[0],n=t[1],r=t[2],i=t[3];return e*e+n*n+r*r+i*i}function A(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function T(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function y(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=n*n+r*r+i*i+a*a;return s>0&&(s=1/Math.sqrt(s)),t[0]=n*s,t[1]=r*s,t[2]=i*s,t[3]=a*s,t}function I(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function L(t,e,n,r){var i=n[0]*r[1]-n[1]*r[0],a=n[0]*r[2]-n[2]*r[0],s=n[0]*r[3]-n[3]*r[0],o=n[1]*r[2]-n[2]*r[1],h=n[1]*r[3]-n[3]*r[1],l=n[2]*r[3]-n[3]*r[2],u=e[0],c=e[1],f=e[2],m=e[3];return t[0]=c*l-f*h+m*o,t[1]=-u*l+f*s-m*a,t[2]=u*h-c*s+m*i,t[3]=-u*o+c*a-f*i,t}function N(t,e,n,r){var i=e[0],a=e[1],s=e[2],o=e[3];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=s+r*(n[2]-s),t[3]=o+r*(n[3]-o),t}function P(t,e){var n,i,a,s,o,h;e=e||1;do{o=(n=2*r.RANDOM()-1)*n+(i=2*r.RANDOM()-1)*i}while(o>=1);do{h=(a=2*r.RANDOM()-1)*a+(s=2*r.RANDOM()-1)*s}while(h>=1);var l=Math.sqrt((1-o)/h);return t[0]=e*n,t[1]=e*i,t[2]=e*a*l,t[3]=e*s*l,t}function O(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*s,t[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*s,t[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*s,t[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*s,t}function S(t,e,n){var r=e[0],i=e[1],a=e[2],s=n[0],o=n[1],h=n[2],l=n[3],u=l*r+o*a-h*i,c=l*i+h*r-s*a,f=l*a+s*i-o*r,m=-s*r-o*i-h*a;return t[0]=u*l+m*-s+c*-h-f*-o,t[1]=c*l+m*-o+f*-s-u*-h,t[2]=f*l+m*-h+u*-o-c*-s,t[3]=e[3],t}function _(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function V(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function U(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function Y(t,e){var n=t[0],i=t[1],a=t[2],s=t[3],o=e[0],h=e[1],l=e[2],u=e[3];return Math.abs(n-o)<=r.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-h)<=r.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(a-l)<=r.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))&&Math.abs(s-u)<=r.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))}var D,B=u,q=c,F=f,z=x,C=w,X=E,G=R,H=(D=i(),function(t,e,n,r,i,a){var s,o;for(e||(e=4),n||(n=0),o=r?Math.min(r*e+n,t.length):t.length,s=n;s<o;s+=e)D[0]=t[s],D[1]=t[s+1],D[2]=t[s+2],D[3]=t[s+3],i(D,D,a),t[s]=D[0],t[s+1]=D[1],t[s+2]=D[2],t[s+3]=D[3];return t})}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,n),a.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t=n(684),e=n(409),r=n(796);const i={canvasWidth:0,canvasHeight:0,absolute:!1,minBound:[0,0,0],maxBound:[0,0,0],orthographic:!1,angleOfView:0,initialZoom:0,viewportShift:[0,0],viewportMargin:[0,0],background:[],zoomFactor:0,zoomPinchFactor:0,zoomPinchCap:0,zoomStep:0,shiftHoldDistance:0,shiftWaitTime:0,vibrateTime:0,ibl:!1,webgl2:!1,autoplay:!0,imageURL:"",image:"",Transform:[],Centers:[],canvasWidth0:0,canvasHeight0:0,zoom0:0,embedded:!1,canvas:null};globalThis.document.asy=i;const a=i;let s,o,h,l,u,c,f,m=[],d=[],v=[],M=0,p=2;const g=1/3,b=Math.acos(-1),x=b/180,w=Math.ceil(1-Math.log2(Number.EPSILON));let E,R,A,T,y,I,L,N,P,O,S,_,V,U,Y,D,B,q,F,z,C=t.create(),X=t.create(),G=t.create(),H=t.create(),W=e.create(),k=e.create(),j=t.create(),$=t.create(),Z={x:0,y:0,z:0},Q={x:0,y:0},K={xmin:0,xmax:0,ymin:0,ymax:0,zmin:0,zmax:0},J=!0,tt=0,et=!1,nt=null,rt=null,it=[],at=[],st=[],ot=[],ht=null,lt=null,ut=null,ct=Math.min,ft=Math.max;class mt{constructor(t,e,n,r,i,a,s=!0){this.diffuse=t,this.emissive=e,this.specular=n,this.shininess=r,this.metallic=i,this.fresnel0=a,this.lightOn=s}setUniform(t,e){let n=n=>s.getUniformLocation(t,"Materials["+e+"]."+n);s.uniform4fv(n("diffuse"),new Float32Array(this.diffuse)),s.uniform4fv(n("emissive"),new Float32Array(this.emissive)),s.uniform4fv(n("specular"),new Float32Array(this.specular)),s.uniform4f(n("parameters"),this.shininess,this.metallic,this.fresnel0,this.lightOn)}}class dt{constructor(t,e){this.direction=t,this.color=e}setUniform(t,e){const n=n=>s.getUniformLocation(t,"Lights["+e+"]."+n);s.uniform3fv(n("direction"),new Float32Array(this.direction)),s.uniform3fv(n("color"),new Float32Array(this.color))}}function vt(t=!1){const e=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS);u=Math.floor((e-14)/4),p=ct(ft(p,v.length),u);const n=["NORMAL"],r=["NORMAL","COLOR","GENERAL"];t&&(n.push("USE_IBL"),r.push("USE_IBL")),_e=Gt(["WIDTH"]),Ve=Gt(n),Ue=Gt(["NORMAL","COLOR"]),Ye=Gt(r)}function Mt(){s.deleteProgram(Ye),s.deleteProgram(Ue),s.deleteProgram(Ve),s.deleteProgram(_e)}function pt(){const t=window.top.document,e=a.webgl2?t.asygl2[o]:t.asygl[o],n={gl:s,nlights:d.length,Nmaterials:p,maxMaterials:u,pixelShader:_e,materialShader:Ve,colorShader:Ue,transparentShader:Ye};Object.assign(e,n)}function gt(t,e){let n;return a.webgl2&&(n=t.getContext("webgl2",{alpha:e}),a.embedded&&!n)?(a.webgl2=!1,a.ibl=!1,bt(!1),null):(n||(a.webgl2=!1,a.ibl=!1,n=t.getContext("webgl",{alpha:e})),n||alert("Could not initialize WebGL"),n)}function bt(t=!0){if(a.ibl&&(a.webgl2=!0),o=a.background[3]<1,a.embedded){const e=window.top.document;t&&(l=a.canvas.getContext("2d")),h=a.webgl2?e.offscreen2:e.offscreen,h||(h=e.createElement("canvas"),a.webgl2?e.offscreen2=h:e.offscreen=h),a.webgl2?e.asygl2||(e.asygl2=Array(2)):e.asygl||(e.asygl=Array(2)),function(){let t=window.top.document;const e=a.webgl2?t.asygl2:t.asygl;if(e[o]&&e[o].gl)!function(){const t=window.top.document;let e=a.webgl2?t.asygl2[o]:t.asygl[o];s=e.gl,M=e.nlights,p=e.Nmaterials,u=e.maxMaterials,_e=e.pixelShader,Ve=e.materialShader,Ue=e.colorShader,Ye=e.transparentShader}(),(d.length!=M||ct(v.length,u)>p)&&(vt(),pt());else{const e=gt(h,o);if(!e)return;s=e,vt(),a.webgl2?t.asygl2[o]={}:t.asygl[o]={},pt()}}()}else s=gt(a.canvas,o),vt();_=s.getExtension("OES_element_index_uint"),V=s.TRIANGLES,U=new Rt(s.POINTS),Y=new Rt(s.LINES),D=new Rt,B=new Rt,q=new Rt,F=new Rt}function xt(t,e,n,r=[]){let i=a.webgl2?"300 es":"100",s=Array(...r),o=[["nlights",0==tt?d.length:0],["Nmaterials",p]],h=[["int","Nlights",ft(d.length,1)]];a.webgl2&&s.push("WEBGL2"),a.ibl&&o.push(["ROUGHNESS_STEP_COUNT",8..toFixed(2)]);const l=o.map(t=>`#define ${t[0]} ${t[1]}`).join("\n"),u=s.map(t=>`#define ${t}`).join("\n"),c=h.map(t=>`const ${t[0]} ${t[1]}=${t[2]};`).join("\n"),f=`#version ${i}\n${[].map(t=>`#extension ${t}: enable`).join("\n")}\n${u}\n${c}\n${l}\n\n\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n  \n${e}\n  `;let m=t.createShader(n);return t.shaderSource(m,f),t.compileShader(m),t.getShaderParameter(m,t.COMPILE_STATUS)?m:(alert(t.getShaderInfoLog(m)),null)}function wt(t,e,n,r=s.ARRAY_BUFFER){return t.length>0&&(0==e&&(e=s.createBuffer(),n=!0),s.bindBuffer(r,e),n&&s.bufferData(r,t,s.STATIC_DRAW)),e}function Et(t,e,n=t.indices){if(0==t.indices.length)return;let r=e!=_e;!function(t,e){let n=e==_e;s.useProgram(e),s.enableVertexAttribArray(qt),n&&s.enableVertexAttribArray(Xt);let r=!n&&d.length>0;if(r&&s.enableVertexAttribArray(Ft),s.enableVertexAttribArray(zt),e.projViewMatUniform=s.getUniformLocation(e,"projViewMat"),e.viewMatUniform=s.getUniformLocation(e,"viewMat"),e.normMatUniform=s.getUniformLocation(e,"normMat"),e.orthographicUniform=s.getUniformLocation(e,"orthographic"),(e==Ue||e==Ye)&&s.enableVertexAttribArray(Ct),r)for(let t=0;t<d.length;++t)d[t].setUniform(e,t);for(let n=0;n<t.materials.length;++n)t.materials[n].setUniform(e,n);s.uniformMatrix4fv(e.projViewMatUniform,!1,H),s.uniformMatrix4fv(e.viewMatUniform,!1,G),s.uniformMatrix3fv(e.normMatUniform,!1,W),s.uniform1i(e.orthographicUniform,1,a.orthographic)}(t,e),null!=lt&&(s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,ut),s.uniform1i(s.getUniformLocation(e,"reflBRDFSampler"),0),s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,lt),s.uniform1i(s.getUniformLocation(e,"diffuseSampler"),1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,ht),s.uniform1i(s.getUniformLocation(e,"reflImgSampler"),2));let i=J||t.partial||!t.rendered;t.verticesBuffer=wt(new Float32Array(t.vertices),t.verticesBuffer,i),s.vertexAttribPointer(qt,3,s.FLOAT,!1,r?24:16,0),r?d.length>0&&s.vertexAttribPointer(Ft,3,s.FLOAT,!1,24,12):s.vertexAttribPointer(Xt,1,s.FLOAT,!1,16,12),t.materialsBuffer=wt(new Int16Array(t.materialIndices),t.materialsBuffer,i),s.vertexAttribPointer(zt,1,s.SHORT,!1,2,0),e!=Ue&&e!=Ye||(t.colorsBuffer=wt(new Float32Array(t.colors),t.colorsBuffer,i),s.vertexAttribPointer(Ct,4,s.FLOAT,!0,0,0)),t.indicesBuffer=wt(_?new Uint32Array(n):new Uint16Array(n),t.indicesBuffer,i,s.ELEMENT_ARRAY_BUFFER),t.rendered=!0,s.drawElements(r?tt?s.LINES:t.type:s.POINTS,n.length,_?s.UNSIGNED_INT:s.UNSIGNED_SHORT,0)}class Rt{constructor(t=V){this.type=t,this.verticesBuffer=0,this.materialsBuffer=0,this.colorsBuffer=0,this.indicesBuffer=0,this.rendered=!1,this.partial=!1,this.vertices=[],this.materialIndices=[],this.colors=[],this.indices=[],this.materials=[],this.materialTable=[],this.nvertices=0,this.clear()}clear(){this.vertices.length=0,this.materialIndices=[],this.colors=[],this.indices=[],this.nvertices=0,this.materials=[],this.materialTable=[]}vertex(t,e){return this.vertices.push(t[0]),this.vertices.push(t[1]),this.vertices.push(t[2]),this.vertices.push(e[0]),this.vertices.push(e[1]),this.vertices.push(e[2]),this.materialIndices.push(z),this.nvertices++}Vertex(t,e,n=[0,0,0,0]){return this.vertices.push(t[0]),this.vertices.push(t[1]),this.vertices.push(t[2]),this.vertices.push(e[0]),this.vertices.push(e[1]),this.vertices.push(e[2]),this.materialIndices.push(z),this.colors.push(n[0]),this.colors.push(n[1]),this.colors.push(n[2]),this.colors.push(n[3]),this.nvertices++}vertex0(t,e){return this.vertices.push(t[0]),this.vertices.push(t[1]),this.vertices.push(t[2]),this.vertices.push(e),this.materialIndices.push(z),this.nvertices++}iVertex(t,e,n,r,i=[0,0,0,0]){let a=6*t;this.vertices[a]=e[0],this.vertices[a+1]=e[1],this.vertices[a+2]=e[2],this.vertices[a+3]=n[0],this.vertices[a+4]=n[1],this.vertices[a+5]=n[2],this.materialIndices[t]=z;let s=4*t;this.colors[s]=i[0],this.colors[s+1]=i[1],this.colors[s+2]=i[2],this.colors[s+3]=i[3],r&&this.indices.push(t)}append(t){At(this.vertices,t.vertices),At(this.materialIndices,t.materialIndices),At(this.colors,t.colors),function(t,e,n){let r=t.length,i=e.length;t.length+=e.length;for(let a=0;a<i;++a)t[r+a]=e[a]+n}(this.indices,t.indices,this.nvertices),this.nvertices+=t.nvertices}}function At(t,e){let n=t.length,r=e.length;t.length+=r;for(let i=0;i<r;++i)t[n+i]=e[i]}class Tt{constructor(){this.data=new Rt,this.Onscreen=!1,this.m=[]}offscreen(t){let e=H,n=t[0],r=n[0],i=n[1],a=n[2],s=1/(e[3]*r+e[7]*i+e[11]*a+e[15]);this.x=this.X=(e[0]*r+e[4]*i+e[8]*a+e[12])*s,this.y=this.Y=(e[1]*r+e[5]*i+e[9]*a+e[13])*s;for(let n=1,r=t.length;n<r;++n){let r=t[n],i=r[0],a=r[1],s=r[2],o=1/(e[3]*i+e[7]*a+e[11]*s+e[15]),h=(e[0]*i+e[4]*a+e[8]*s+e[12])*o,l=(e[1]*i+e[5]*a+e[9]*s+e[13])*o;h<this.x?this.x=h:h>this.X&&(this.X=h),l<this.y?this.y=l:l>this.Y&&(this.Y=l)}return(this.X<-1.01||this.x>1.01||this.Y<-1.01||this.y>1.01)&&(this.Onscreen=!1,!0)}T(t){let e=this.transform?this.transform([this.c])[0]:this.c,n=t[0]-this.c[0],r=t[1]-this.c[1],i=t[2]-this.c[2];return[n*W[0]+r*W[3]+i*W[6]+e[0],n*W[1]+r*W[4]+i*W[7]+e[1],n*W[2]+r*W[5]+i*W[8]+e[2]]}Tcorners(t,e){return[this.T(t),this.T([t[0],t[1],e[2]]),this.T([t[0],e[1],t[2]]),this.T([t[0],e[1],e[2]]),this.T([e[0],t[1],t[2]]),this.T([e[0],t[1],e[2]]),this.T([e[0],e[1],t[2]]),this.T(e)]}setMaterial(t,e){null==t.materialTable[this.MaterialIndex]&&(t.materials.length>=p&&(t.partial=!0,e()),t.materialTable[this.MaterialIndex]=t.materials.length,t.materials.push(v[this.MaterialIndex])),z=t.materialTable[this.MaterialIndex]}render(){let t,e;if(this.setMaterialIndex(),this.transform){t=this.transform(this.controlpoints);let e=It(t);this.epsilon=e*Number.EPSILON;let n=Math.sqrt(1e3*Number.EPSILON*e);[this.Min,this.Max]=this.Bounds(t,n)}else t=this.controlpoints;var n,r;if(0==this.CenterIndex?(n=this.Min,r=this.Max,e=[n,[n[0],n[1],r[2]],[n[0],r[1],n[2]],[n[0],r[1],r[2]],[r[0],n[1],n[2]],[r[0],n[1],r[2]],[r[0],r[1],n[2]],r]):(this.c=a.Centers[this.CenterIndex-1],e=this.transform?t:this.Tcorners(this.Min,this.Max)),this.offscreen(e))return this.data.clear(),void this.notRendered();let i;if(0==this.CenterIndex){if(!J&&this.Onscreen)return void this.append();i=t}else{let t=this.controlpoints.length;i=Array(t);for(let e=0;e<t;++e)i[e]=this.T(this.controlpoints[e])}let s=a.orthographic?1:this.Min[2]/a.maxBound[2],o=.75*Math.hypot(s*(K.xmax-K.xmin),s*(K.ymax-K.ymin))/O;this.res2=o*o,this.Epsilon=.1*o,this.data.clear(),this.notRendered(),this.Onscreen=!0,this.process(i)}}function yt(t,e){let n=t[0],r=t.length;for(let i=1;i<r;++i)n=e(n,t[i]);return n}function It(t){let e=t[0],n=0,r=t.length;for(let i=1;i<r;++i)n=ft(n,$t([t[i][0]-e[0],t[i][1]-e[1],t[i][2]-e[2]]));return n}class Lt extends Tt{constructor(t,e,n,r=null,i=nn(),a=function(){if(0==en.length)return;let t=en.filter(t=>null!=t.colorTransform);return function(e,n){let r=Ze([n[0],n[12],n[15],n[3]]);for(let n=t.length-1;n>=0;n--){const{colorTransform:i,durationInv:a}=t[n],s=ct(hn*a,1);e=Ke([[r[0],e[0]],[r[1],e[1]],[r[2],e[2]],[r[3],e[3]]],s,i)}return e}}()){super(),this.controlpoints=t,this.CenterIndex=e,this.MaterialIndex=n,this.Color=r,this.geometryTransform=i,this.colorTransform=a;const s=t.length;if(r){let t=r[0][3]+r[1][3]+r[2][3];this.transparent=16==s||4==s?t+r[3][3]<4:t<3}else this.transparent=v[n].diffuse[3]<1;if(r&&(this.color=[...r]),this.vertex=this.transparent?this.data.Vertex.bind(this.data):this.data.vertex.bind(this.data),this.transform=i,null==i){let e=It(t),n=Math.sqrt(1e3*Number.EPSILON*e);this.epsilon=e*Number.EPSILON,[this.Min,this.Max]=this.Bounds(t,n)}}setMaterialIndex(){this.transparent?this.setMaterial(q,Xe):this.color?this.setMaterial(B,ze):this.setMaterial(D,Fe)}cornerbound(t,e){let n=e(t[0],t[3]);return n=e(n,t[12]),e(n,t[15])}controlbound(t,e){let n=e(t[1],t[2]);return n=e(n,t[4]),n=e(n,t[5]),n=e(n,t[6]),n=e(n,t[7]),n=e(n,t[8]),n=e(n,t[9]),n=e(n,t[10]),n=e(n,t[11]),n=e(n,t[13]),e(n,t[14])}bound(t,e,n,r,i){if(n=e(n,this.cornerbound(t,e)),e(-1,1)*(n-this.controlbound(t,e))>=-r||0==i)return n;--i,r*=2;const a=new Ht(t[0],t[1],t[2],t[3]),s=new Ht(t[4],t[5],t[6],t[7]),o=new Ht(t[8],t[9],t[10],t[11]),h=new Ht(t[12],t[13],t[14],t[15]),l=new Ht(t[0],t[4],t[8],t[12]),u=new Ht(a.m0,s.m0,o.m0,h.m0),c=new Ht(a.m3,s.m3,o.m3,h.m3),f=new Ht(a.m5,s.m5,o.m5,h.m5),m=new Ht(a.m4,s.m4,o.m4,h.m4),d=new Ht(a.m2,s.m2,o.m2,h.m2),v=new Ht(t[3],t[7],t[11],t[15]),M=[t[0],a.m0,a.m3,a.m5,l.m0,u.m0,c.m0,f.m0,l.m3,u.m3,c.m3,f.m3,l.m5,u.m5,c.m5,f.m5];n=this.bound(M,e,n,r,i);const p=[l.m5,u.m5,c.m5,f.m5,l.m4,u.m4,c.m4,f.m4,l.m2,u.m2,c.m2,f.m2,t[12],h.m0,h.m3,h.m5];n=this.bound(p,e,n,r,i);const g=[f.m5,m.m5,d.m5,v.m5,f.m4,m.m4,d.m4,v.m4,f.m2,m.m2,d.m2,v.m2,h.m5,h.m4,h.m2,t[15]];n=this.bound(g,e,n,r,i);const b=[a.m5,a.m4,a.m2,t[3],f.m0,m.m0,d.m0,v.m0,f.m3,m.m3,d.m3,v.m3,f.m5,m.m5,d.m5,v.m5];return this.bound(b,e,n,r,i)}cornerboundtri(t,e){let n=e(t[0],t[6]);return e(n,t[9])}controlboundtri(t,e){let n=e(t[1],t[2]);return n=e(n,t[3]),n=e(n,t[4]),n=e(n,t[5]),n=e(n,t[7]),e(n,t[8])}boundtri(t,e,n,r,i){if(n=e(n,this.cornerboundtri(t,e)),e(-1,1)*(n-this.controlboundtri(t,e))>=-r||0==i)return n;--i,r*=2;let a=new kt(t),s=[a.l003,a.l102,a.l012,a.l201,a.l111,a.l021,a.l300,a.l210,a.l120,a.l030];n=this.boundtri(s,e,n,r,i);let o=[a.l300,a.r102,a.r012,a.r201,a.r111,a.r021,a.r300,a.r210,a.r120,a.r030];n=this.boundtri(o,e,n,r,i);let h=[a.l030,a.u102,a.u012,a.u201,a.u111,a.u021,a.r030,a.u210,a.u120,a.u030];n=this.boundtri(h,e,n,r,i);let l=[a.r030,a.u201,a.r021,a.u102,a.c111,a.r012,a.l030,a.l120,a.l210,a.l300];return this.boundtri(l,e,n,r,i)}Bound(t,e,n){let r=Array(3),i=t.length,a=Array(i);for(let s=0;s<3;++s){for(let e=0;e<i;++e)a[e]=t[e][s];r[s]=16==i?this.bound(a,e,a[0],n,w):10==i?this.boundtri(a,e,a[0],n,w):yt(a,e)}return[r[0],r[1],r[2]]}Bounds(t,e){return[this.Bound(t,ct,e),this.Bound(t,ft,e)]}processTriangle(t){let e=t[0],n=t[1],r=t[2],i=jt(Qt([n[0]-e[0],n[1]-e[1],n[2]-e[2]],[r[0]-e[0],r[1]-e[1],r[2]-e[2]]));if(!this.offscreen([e,n,r])){let t,a,s;this.color?(t=this.data.Vertex(e,i,this.color[0]),a=this.data.Vertex(n,i,this.color[1]),s=this.data.Vertex(r,i,this.color[2])):(t=this.vertex(e,i),a=this.vertex(n,i),s=this.vertex(r,i)),0==tt?(this.data.indices.push(t),this.data.indices.push(a),this.data.indices.push(s)):(this.data.indices.push(t),this.data.indices.push(a),this.data.indices.push(a),this.data.indices.push(s),this.data.indices.push(s),this.data.indices.push(t)),this.append()}}processQuad(t){let e=t[0],n=t[1],r=t[2],i=t[3],a=Qt([n[0]-e[0],n[1]-e[1],n[2]-e[2]],[r[0]-n[0],r[1]-n[1],r[2]-n[2]]),s=Qt([r[0]-i[0],r[1]-i[1],r[2]-i[2]],[i[0]-e[0],i[1]-e[1],i[2]-e[2]]),o=jt([a[0]+s[0],a[1]+s[1],a[2]+s[2]]);if(!this.offscreen([e,n,r,i])){let t,a,s,h;this.color?(t=this.data.Vertex(e,o,this.color[0]),a=this.data.Vertex(n,o,this.color[1]),s=this.data.Vertex(r,o,this.color[2]),h=this.data.Vertex(i,o,this.color[3])):(t=this.vertex(e,o),a=this.vertex(n,o),s=this.vertex(r,o),h=this.vertex(i,o)),0==tt?(this.data.indices.push(t),this.data.indices.push(a),this.data.indices.push(s),this.data.indices.push(t),this.data.indices.push(s),this.data.indices.push(h)):(this.data.indices.push(t),this.data.indices.push(a),this.data.indices.push(a),this.data.indices.push(s),this.data.indices.push(s),this.data.indices.push(h),this.data.indices.push(h),this.data.indices.push(t)),this.append()}}curve(t,e,n,r,i){new St([t[e],t[n],t[r],t[i]],0,z,this.Min,this.Max).render()}process(t){if(this.transparent&&1!=tt&&(z=this.color?-1-z:1+z),10==t.length)return this.process3(t);if(3==t.length)return this.processTriangle(t);if(4==t.length)return this.processQuad(t);if(this.color&&this.colorTransform&&(this.color=this.colorTransform(this.Color,t)),1==tt)return this.curve(t,0,4,8,12),this.curve(t,12,13,14,15),this.curve(t,15,11,7,3),void this.curve(t,3,2,1,0);let e=t[0],n=t[3],r=t[12],i=t[15],a=this.normal(n,t[2],t[1],e,t[4],t[8],r);$t(a)<this.epsilon&&(a=this.normal(n,t[2],t[1],e,t[13],t[14],i),$t(a)<this.epsilon&&(a=this.normal(i,t[11],t[7],n,t[4],t[8],r)));let s=this.normal(e,t[4],t[8],r,t[13],t[14],i);$t(s)<this.epsilon&&(s=this.normal(e,t[4],t[8],r,t[11],t[7],n),$t(s)<this.epsilon&&(s=this.normal(n,t[2],t[1],e,t[13],t[14],i)));let o=this.normal(r,t[13],t[14],i,t[11],t[7],n);$t(o)<this.epsilon&&(o=this.normal(r,t[13],t[14],i,t[2],t[1],e),$t(o)<this.epsilon&&(o=this.normal(e,t[4],t[8],r,t[11],t[7],n)));let h=this.normal(i,t[11],t[7],n,t[2],t[1],e);if($t(h)<this.epsilon&&(h=this.normal(i,t[11],t[7],n,t[4],t[8],r),$t(h)<this.epsilon&&(h=this.normal(r,t[13],t[14],i,t[2],t[1],e))),this.color){let l=this.color[0],u=this.color[1],c=this.color[2],f=this.color[3],m=this.data.Vertex(e,a,l),d=this.data.Vertex(r,s,u),v=this.data.Vertex(i,o,c),M=this.data.Vertex(n,h,f);this.Render(t,m,d,v,M,e,r,i,n,!1,!1,!1,!1,l,u,c,f)}else{let l=this.vertex(e,a),u=this.vertex(r,s),c=this.vertex(i,o),f=this.vertex(n,h);this.Render(t,l,u,c,f,e,r,i,n,!1,!1,!1,!1)}this.data.indices.length>0&&this.append()}append(){this.transparent?q.append(this.data):this.color?B.append(this.data):D.append(this.data)}notRendered(){this.transparent?q.rendered=!1:this.color?B.rendered=!1:D.rendered=!1}Render(t,e,n,r,i,a,s,o,h,l,u,c,f,m=null,d=null,v=null,M=null){let p=this.Distance(t);if(p[0]<this.res2&&p[1]<this.res2)this.offscreen([a,s,o])||(0==tt?(this.data.indices.push(e),this.data.indices.push(n),this.data.indices.push(r)):(this.data.indices.push(e),this.data.indices.push(n),this.data.indices.push(n),this.data.indices.push(r))),this.offscreen([a,o,h])||(0==tt?(this.data.indices.push(e),this.data.indices.push(r),this.data.indices.push(i)):(this.data.indices.push(r),this.data.indices.push(i),this.data.indices.push(i),this.data.indices.push(e)));else{if(this.offscreen(t))return;let g=t[0],b=t[3],x=t[12],w=t[15];if(p[0]<this.res2){let p=new Wt(g,t[1],t[2],b),E=new Wt(t[4],t[5],t[6],t[7]),R=new Wt(t[8],t[9],t[10],t[11]),A=new Wt(x,t[13],t[14],w),T=[g,p.m0,p.m3,p.m5,t[4],E.m0,E.m3,E.m5,t[8],R.m0,R.m3,R.m5,x,A.m0,A.m3,A.m5],y=[p.m5,p.m4,p.m2,b,E.m5,E.m4,E.m2,t[7],R.m5,R.m4,R.m2,t[11],A.m5,A.m4,A.m2,w],I=this.normal(T[12],T[13],T[14],T[15],T[11],T[7],T[3]);$t(I)<=this.epsilon&&(I=this.normal(T[12],T[13],T[14],T[15],T[2],T[1],T[0]),$t(I)<=this.epsilon&&(I=this.normal(T[0],T[4],T[8],T[12],T[11],T[7],T[3])));let L=this.normal(y[3],y[2],y[1],y[0],y[4],y[8],y[12]);$t(L)<=this.epsilon&&(L=this.normal(y[3],y[2],y[1],y[0],y[13],y[14],y[15]),$t(L)<=this.epsilon&&(L=this.normal(y[15],y[11],y[7],y[3],y[4],y[8],y[12])));let N=this.Epsilon,P=[.5*(s[0]+o[0]),.5*(s[1]+o[1]),.5*(s[2]+o[2])];if(!u)if(u=ne(x,t[13],t[14],w)<this.res2){let t=jt(this.differential(y[12],y[8],y[4],y[0]));P=[P[0]-N*t[0],P[1]-N*t[1],P[2]-N*t[2]]}else P=T[15];let O=[.5*(h[0]+a[0]),.5*(h[1]+a[1]),.5*(h[2]+a[2])];if(!f)if(f=ne(g,t[1],t[2],b)<this.res2){let t=jt(this.differential(T[3],T[7],T[11],T[15]));O=[O[0]-N*t[0],O[1]-N*t[1],O[2]-N*t[2]]}else O=y[0];if(m){let t=Array(4),p=Array(4);for(let e=0;e<4;++e)t[e]=.5*(d[e]+v[e]),p[e]=.5*(M[e]+m[e]);let g=this.data.Vertex(P,I,t),b=this.data.Vertex(O,L,p);this.Render(T,e,n,g,b,a,s,P,O,l,u,!1,f,m,d,t,p),this.Render(y,b,g,r,i,O,P,o,h,!1,u,c,f,p,t,v,M)}else{let t=this.vertex(P,I),m=this.vertex(O,L);this.Render(T,e,n,t,m,a,s,P,O,l,u,!1,f),this.Render(y,m,t,r,i,O,P,o,h,!1,u,c,f)}return}if(p[1]<this.res2){let p=new Wt(g,t[4],t[8],x),E=new Wt(t[1],t[5],t[9],t[13]),R=new Wt(t[2],t[6],t[10],t[14]),A=new Wt(b,t[7],t[11],w),T=[g,t[1],t[2],b,p.m0,E.m0,R.m0,A.m0,p.m3,E.m3,R.m3,A.m3,p.m5,E.m5,R.m5,A.m5],y=[p.m5,E.m5,R.m5,A.m5,p.m4,E.m4,R.m4,A.m4,p.m2,E.m2,R.m2,A.m2,x,t[13],t[14],w],I=this.normal(T[0],T[4],T[8],T[12],T[13],T[14],T[15]);$t(I)<=this.epsilon&&(I=this.normal(T[0],T[4],T[8],T[12],T[11],T[7],T[3]),$t(I)<=this.epsilon&&(I=this.normal(T[3],T[2],T[1],T[0],T[13],T[14],T[15])));let L=this.normal(y[15],y[11],y[7],y[3],y[2],y[1],y[0]);$t(L)<=this.epsilon&&(L=this.normal(y[15],y[11],y[7],y[3],y[4],y[8],y[12]),$t(L)<=this.epsilon&&(L=this.normal(y[12],y[13],y[14],y[15],y[2],y[1],y[0])));let N=this.Epsilon,P=[.5*(a[0]+s[0]),.5*(a[1]+s[1]),.5*(a[2]+s[2])];if(!l)if(l=ne(g,t[4],t[8],x)<this.res2){let t=jt(this.differential(y[0],y[1],y[2],y[3]));P=[P[0]-N*t[0],P[1]-N*t[1],P[2]-N*t[2]]}else P=T[12];let O=[.5*(o[0]+h[0]),.5*(o[1]+h[1]),.5*(o[2]+h[2])];if(!c)if(c=ne(w,t[11],t[7],b)<this.res2){let t=jt(this.differential(T[15],T[14],T[13],T[12]));O=[O[0]-N*t[0],O[1]-N*t[1],O[2]-N*t[2]]}else O=y[3];if(m){let t=Array(4),p=Array(4);for(let e=0;e<4;++e)t[e]=.5*(m[e]+d[e]),p[e]=.5*(v[e]+M[e]);let g=this.data.Vertex(P,I,t),b=this.data.Vertex(O,L,p);this.Render(T,e,g,b,i,a,P,O,h,l,!1,c,f,m,t,p,M),this.Render(y,g,n,r,b,P,s,o,O,l,u,c,!1,t,d,v,p)}else{let t=this.vertex(P,I),m=this.vertex(O,L);this.Render(T,e,t,m,i,a,P,O,h,l,!1,c,f),this.Render(y,t,n,r,m,P,s,o,O,l,u,c,!1)}return}let E=new Wt(g,t[1],t[2],b),R=new Wt(t[4],t[5],t[6],t[7]),A=new Wt(t[8],t[9],t[10],t[11]),T=new Wt(x,t[13],t[14],w),y=new Wt(g,t[4],t[8],x),I=new Wt(E.m0,R.m0,A.m0,T.m0),L=new Wt(E.m3,R.m3,A.m3,T.m3),N=new Wt(E.m5,R.m5,A.m5,T.m5),P=new Wt(E.m4,R.m4,A.m4,T.m4),O=new Wt(E.m2,R.m2,A.m2,T.m2),S=new Wt(b,t[7],t[11],w),_=[g,E.m0,E.m3,E.m5,y.m0,I.m0,L.m0,N.m0,y.m3,I.m3,L.m3,N.m3,y.m5,I.m5,L.m5,N.m5],V=[y.m5,I.m5,L.m5,N.m5,y.m4,I.m4,L.m4,N.m4,y.m2,I.m2,L.m2,N.m2,x,T.m0,T.m3,T.m5],U=[N.m5,P.m5,O.m5,S.m5,N.m4,P.m4,O.m4,S.m4,N.m2,P.m2,O.m2,S.m2,T.m5,T.m4,T.m2,w],Y=[E.m5,E.m4,E.m2,b,N.m0,P.m0,O.m0,S.m0,N.m3,P.m3,O.m3,S.m3,N.m5,P.m5,O.m5,S.m5],D=_[15],B=this.normal(_[0],_[4],_[8],_[12],_[13],_[14],_[15]);$t(B)<this.epsilon&&(B=this.normal(_[0],_[4],_[8],_[12],_[11],_[7],_[3]),$t(B)<this.epsilon&&(B=this.normal(_[3],_[2],_[1],_[0],_[13],_[14],_[15])));let q=this.normal(V[12],V[13],V[14],V[15],V[11],V[7],V[3]);$t(q)<this.epsilon&&(q=this.normal(V[12],V[13],V[14],V[15],V[2],V[1],V[0]),$t(q)<this.epsilon&&(q=this.normal(V[0],V[4],V[8],V[12],V[11],V[7],V[3])));let F=this.normal(U[15],U[11],U[7],U[3],U[2],U[1],U[0]);$t(F)<this.epsilon&&(F=this.normal(U[15],U[11],U[7],U[3],U[4],U[8],U[12]),$t(F)<this.epsilon&&(F=this.normal(U[12],U[13],U[14],U[15],U[2],U[1],U[0])));let z=this.normal(Y[3],Y[2],Y[1],Y[0],Y[4],Y[8],Y[12]);$t(z)<this.epsilon&&(z=this.normal(Y[3],Y[2],Y[1],Y[0],Y[13],Y[14],Y[15]),$t(z)<this.epsilon&&(z=this.normal(Y[15],Y[11],Y[7],Y[3],Y[4],Y[8],Y[12])));let C=this.normal(U[3],U[2],U[1],D,U[4],U[8],U[12]),X=this.Epsilon,G=[.5*(a[0]+s[0]),.5*(a[1]+s[1]),.5*(a[2]+s[2])];if(!l)if(l=ne(g,t[4],t[8],x)<this.res2){let t=jt(this.differential(V[0],V[1],V[2],V[3]));G=[G[0]-X*t[0],G[1]-X*t[1],G[2]-X*t[2]]}else G=_[12];let H=[.5*(s[0]+o[0]),.5*(s[1]+o[1]),.5*(s[2]+o[2])];if(!u)if(u=ne(x,t[13],t[14],w)<this.res2){let t=jt(this.differential(U[12],U[8],U[4],U[0]));H=[H[0]-X*t[0],H[1]-X*t[1],H[2]-X*t[2]]}else H=V[15];let W=[.5*(o[0]+h[0]),.5*(o[1]+h[1]),.5*(o[2]+h[2])];if(!c)if(c=ne(w,t[11],t[7],b)<this.res2){let t=jt(this.differential(Y[15],Y[14],Y[13],Y[12]));W=[W[0]-X*t[0],W[1]-X*t[1],W[2]-X*t[2]]}else W=U[3];let k=[.5*(h[0]+a[0]),.5*(h[1]+a[1]),.5*(h[2]+a[2])];if(!f)if(f=ne(g,t[1],t[2],b)<this.res2){let t=jt(this.differential(_[3],_[7],_[11],_[15]));k=[k[0]-X*t[0],k[1]-X*t[1],k[2]-X*t[2]]}else k=Y[0];if(m){let t=Array(4),p=Array(4),g=Array(4),b=Array(4),x=Array(4);for(let e=0;e<4;++e)t[e]=.5*(m[e]+d[e]),p[e]=.5*(d[e]+v[e]),g[e]=.5*(v[e]+M[e]),b[e]=.5*(M[e]+m[e]),x[e]=.5*(t[e]+g[e]);let w=this.data.Vertex(G,B,t),E=this.data.Vertex(H,q,p),R=this.data.Vertex(W,F,g),A=this.data.Vertex(k,z,b),T=this.data.Vertex(D,C,x);this.Render(_,e,w,T,A,a,G,D,k,l,!1,!1,f,m,t,x,b),this.Render(V,w,n,E,T,G,s,H,D,l,u,!1,!1,t,d,p,x),this.Render(U,T,E,r,R,D,H,o,W,!1,u,c,!1,x,p,v,g),this.Render(Y,A,T,R,i,k,D,W,h,!1,!1,c,f,b,x,g,M)}else{let t=this.vertex(G,B),m=this.vertex(H,q),d=this.vertex(W,F),v=this.vertex(k,z),M=this.vertex(D,C);this.Render(_,e,t,M,v,a,G,D,k,l,!1,!1,f),this.Render(V,t,n,m,M,G,s,H,D,l,u,!1,!1),this.Render(U,M,m,r,d,D,H,o,W,!1,u,c,!1),this.Render(Y,v,M,d,i,k,D,W,h,!1,!1,c,f)}}}process3(t){if(1==tt)return this.curve(t,0,1,3,6),this.curve(t,6,7,8,9),void this.curve(t,9,5,2,0);let e=t[0],n=t[6],r=t[9],i=this.normal(r,t[5],t[2],e,t[1],t[3],n),a=this.normal(e,t[1],t[3],n,t[7],t[8],r),s=this.normal(n,t[7],t[8],r,t[5],t[2],e);if(this.color){let o=this.color[0],h=this.color[1],l=this.color[2],u=this.data.Vertex(e,i,o),c=this.data.Vertex(n,a,h),f=this.data.Vertex(r,s,l);this.Render3(t,u,c,f,e,n,r,!1,!1,!1,o,h,l)}else{let o=this.vertex(e,i),h=this.vertex(n,a),l=this.vertex(r,s);this.Render3(t,o,h,l,e,n,r,!1,!1,!1)}this.data.indices.length>0&&this.append()}Render3(t,e,n,r,i,a,s,o,h,l,u=null,c=null,f=null){if(this.Distance3(t)<this.res2)this.offscreen([i,a,s])||(0==tt?(this.data.indices.push(e),this.data.indices.push(n),this.data.indices.push(r)):(this.data.indices.push(e),this.data.indices.push(n),this.data.indices.push(n),this.data.indices.push(r),this.data.indices.push(r),this.data.indices.push(e)));else{if(this.offscreen(t))return;let m=t[0],d=t[1],v=t[2],M=t[3],p=t[4],g=t[5],b=t[6],x=t[7],w=t[8],E=t[9],R=[.5*(E[0]+g[0]),.5*(E[1]+g[1]),.5*(E[2]+g[2])],A=[.5*(E[0]+w[0]),.5*(E[1]+w[1]),.5*(E[2]+w[2])],T=[.5*(g[0]+v[0]),.5*(g[1]+v[1]),.5*(g[2]+v[2])],y=[.5*(w[0]+p[0]),.5*(w[1]+p[1]),.5*(w[2]+p[2])],I=[.5*(w[0]+x[0]),.5*(w[1]+x[1]),.5*(w[2]+x[2])],L=[.5*(v[0]+p[0]),.5*(v[1]+p[1]),.5*(v[2]+p[2])],N=[.5*(v[0]+m[0]),.5*(v[1]+m[1]),.5*(v[2]+m[2])],P=[.5*(p[0]+M[0]),.5*(p[1]+M[1]),.5*(p[2]+M[2])],O=[.5*(x[0]+b[0]),.5*(x[1]+b[1]),.5*(x[2]+b[2])],S=[.5*(m[0]+d[0]),.5*(m[1]+d[1]),.5*(m[2]+d[2])],_=[.5*(d[0]+M[0]),.5*(d[1]+M[1]),.5*(d[2]+M[2])],V=[.5*(M[0]+b[0]),.5*(M[1]+b[1]),.5*(M[2]+b[2])],U=[.5*(R[0]+T[0]),.5*(R[1]+T[1]),.5*(R[2]+T[2])],Y=[.5*(A[0]+I[0]),.5*(A[1]+I[1]),.5*(A[2]+I[2])],D=[.5*(T[0]+N[0]),.5*(T[1]+N[1]),.5*(T[2]+N[2])],B=[.5*y[0]+.25*(p[0]+d[0]),.5*y[1]+.25*(p[1]+d[1]),.5*y[2]+.25*(p[2]+d[2])],q=[.5*(I[0]+O[0]),.5*(I[1]+O[1]),.5*(I[2]+O[2])],F=[.5*L[0]+.25*(p[0]+x[0]),.5*L[1]+.25*(p[1]+x[1]),.5*L[2]+.25*(p[2]+x[2])],z=[.25*(g[0]+p[0])+.5*P[0],.25*(g[1]+p[1])+.5*P[1],.25*(g[2]+p[2])+.5*P[2]],C=[.5*(S[0]+_[0]),.5*(S[1]+_[1]),.5*(S[2]+_[2])],X=[.5*(_[0]+V[0]),.5*(_[1]+V[1]),.5*(_[2]+V[2])],G=[.5*(F[0]+C[0]),.5*(F[1]+C[1]),.5*(F[2]+C[2])],H=[.5*(F[0]+X[0]),.5*(F[1]+X[1]),.5*(F[2]+X[2])],W=[.5*(C[0]+X[0]),.5*(C[1]+X[1]),.5*(C[2]+X[2])],k=[.5*(z[0]+q[0]),.5*(z[1]+q[1]),.5*(z[2]+q[2])],j=[.5*(Y[0]+z[0]),.5*(Y[1]+z[1]),.5*(Y[2]+z[2])],$=[.5*(Y[0]+q[0]),.5*(Y[1]+q[1]),.5*(Y[2]+q[2])],Z=[.5*(U[0]+B[0]),.5*(U[1]+B[1]),.5*(U[2]+B[2])],Q=[.5*(D[0]+B[0]),.5*(D[1]+B[1]),.5*(D[2]+B[2])],K=[.5*(U[0]+D[0]),.5*(U[1]+D[1]),.5*(U[2]+D[2])],J=[m,S,N,C,[.5*(L[0]+S[0]),.5*(L[1]+S[1]),.5*(L[2]+S[2])],D,W,G,Q,K],tt=[W,X,H,V,[.5*(P[0]+O[0]),.5*(P[1]+O[1]),.5*(P[2]+O[2])],k,b,O,q,$],et=[K,Z,U,j,[.5*(R[0]+y[0]),.5*(R[1]+y[1]),.5*(R[2]+y[2])],R,$,Y,A,E],nt=[$,j,k,Z,[.25*(T[0]+I[0]+_[0]+p[0]),.25*(T[1]+I[1]+_[1]+p[1]),.25*(T[2]+I[2]+_[2]+p[2])],H,K,Q,G,W],rt=this.normal(W,H,k,$,j,Z,K),it=this.normal($,j,Z,K,Q,G,W),at=this.normal(K,Q,G,W,H,k,$),st=this.Epsilon,ot=[.5*(a[0]+s[0]),.5*(a[1]+s[1]),.5*(a[2]+s[2])];if(!o)if(o=ne(b,x,w,E)<this.res2){let t=jt(this.sumdifferential(nt[0],nt[2],nt[5],nt[9],nt[1],nt[3],nt[6]));ot=[ot[0]-st*t[0],ot[1]-st*t[1],ot[2]-st*t[2]]}else ot=$;let ht=[.5*(s[0]+i[0]),.5*(s[1]+i[1]),.5*(s[2]+i[2])];if(!h)if(h=ne(m,v,g,E)<this.res2){let t=jt(this.sumdifferential(nt[6],nt[3],nt[1],nt[0],nt[7],nt[8],nt[9]));ht=[ht[0]-st*t[0],ht[1]-st*t[1],ht[2]-st*t[2]]}else ht=K;let lt=[.5*(i[0]+a[0]),.5*(i[1]+a[1]),.5*(i[2]+a[2])];if(!l)if(l=ne(m,d,M,b)<this.res2){let t=jt(this.sumdifferential(nt[9],nt[8],nt[7],nt[6],nt[5],nt[2],nt[0]));lt=[lt[0]-st*t[0],lt[1]-st*t[1],lt[2]-st*t[2]]}else lt=W;if(u){let t=Array(4),m=Array(4),d=Array(4);for(let e=0;e<4;++e)t[e]=.5*(c[e]+f[e]),m[e]=.5*(f[e]+u[e]),d[e]=.5*(u[e]+c[e]);let v=this.data.Vertex(ot,rt,t),M=this.data.Vertex(ht,it,m),p=this.data.Vertex(lt,at,d);this.Render3(J,e,p,M,i,lt,ht,!1,h,l,u,d,m),this.Render3(tt,p,n,v,lt,a,ot,o,!1,l,d,c,t),this.Render3(et,M,v,r,ht,ot,s,o,h,!1,m,t,f),this.Render3(nt,v,M,p,ot,ht,lt,!1,!1,!1,t,m,d)}else{let t=this.vertex(ot,rt),u=this.vertex(ht,it),c=this.vertex(lt,at);this.Render3(J,e,c,u,i,lt,ht,!1,h,l),this.Render3(tt,c,n,t,lt,a,ot,o,!1,l),this.Render3(et,u,t,r,ht,ot,s,o,h,!1),this.Render3(nt,t,u,c,ot,ht,lt,!1,!1,!1)}}}Distance(t){let e=t[0],n=t[3],r=t[12],i=t[15],a=re(e,r,n,i);a=ft(a,ne(e,t[4],t[8],r)),a=ft(a,ne(t[1],t[5],t[9],t[13])),a=ft(a,ne(n,t[7],t[11],i)),a=ft(a,ne(t[2],t[6],t[10],t[14]));let s=re(e,n,r,i);return s=ft(s,ne(e,t[1],t[2],n)),s=ft(s,ne(t[4],t[5],t[6],t[7])),s=ft(s,ne(t[8],t[9],t[10],t[11])),s=ft(s,ne(r,t[13],t[14],i)),[a,s]}Distance3(t){let e=t[0],n=t[4],r=t[6],i=t[9],a=$t([(e[0]+r[0]+i[0])*g-n[0],(e[1]+r[1]+i[1])*g-n[1],(e[2]+r[2]+i[2])*g-n[2]]);return a=ft(a,ne(e,t[1],t[3],r)),a=ft(a,ne(e,t[2],t[5],i)),ft(a,ne(r,t[7],t[8],i))}differential(t,e,n,r){let i=[3*(e[0]-t[0]),3*(e[1]-t[1]),3*(e[2]-t[2])];return $t(i)>this.epsilon?i:(i=te(t,e,n),$t(i)>this.epsilon?i:ee(t,e,n,r))}sumdifferential(t,e,n,r,i,a,s){let o=this.differential(t,e,n,r),h=this.differential(t,i,a,s);return[o[0]+h[0],o[1]+h[1],o[2]+h[2]]}normal(t,e,n,r,i,a,s){let o=3*(i[0]-r[0]),h=3*(i[1]-r[1]),l=3*(i[2]-r[2]),u=3*(n[0]-r[0]),c=3*(n[1]-r[1]),f=3*(n[2]-r[2]),m=[h*f-l*c,l*u-o*f,o*c-h*u];if($t(m)>this.epsilon)return m;let d=[u,c,f],v=[o,h,l],M=te(r,n,e),p=te(r,i,a),g=Qt(p,d),b=Qt(v,M);if(m=[g[0]+b[0],g[1]+b[1],g[2]+b[2]],$t(m)>this.epsilon)return m;let x=ee(r,n,e,t),w=ee(r,i,a,s);g=Qt(v,x),b=Qt(w,d);let E=Qt(p,M);return m=[g[0]+b[0]+E[0],g[1]+b[1]+E[1],g[2]+b[2]+E[2]],$t(m)>this.epsilon?m:(g=Qt(w,M),b=Qt(p,x),m=[g[0]+b[0],g[1]+b[1],g[2]+b[2]],$t(m)>this.epsilon?m:Qt(w,x))}}function Nt(t,e,n,r){return[r-t+3*(e-n),2*(t+n)-4*e,e-t]}function Pt(t){return 0<=t&&t<=1}class Ot{constructor(t,e,n){const r=1e3*Number.EPSILON,i=r*r;if(Math.abs(t)<=r*Math.abs(e)+i*Math.abs(n))Math.abs(e)>r*Math.abs(n)?(this.roots=1,this.t1=-n/e):0==n?(this.roots=1,this.t1=0):this.roots=0;else{let i=.5*e/t,a=e*i;if(Math.abs(a)<=r*Math.abs(n)){let e=-n/t;e>=0?(this.roots=2,this.t2=Math.sqrt(e),this.t1=-this.t2):this.roots=0}else{let t=-2*n/a;if(t>-1){this.roots=2;let e=i*function(t){return t/(Math.sqrt(1+t)+1)}(t),n=-e-2*i;n<=e?(this.t1=n,this.t2=e):(this.t1=e,this.t2=n)}else-1==t?(this.roots=1,this.t1=this.t2=-i):this.roots=0}}}}class St extends Tt{constructor(t,e,n,r=null,i=null,a=nn()){super(),this.controlpoints=t,this.CenterIndex=e,this.MaterialIndex=n,this.transform=a,null==a&&([this.Min,this.Max]=this.Bounds(t,0))}Bounds(t,e){let n=Array(3),r=Array(3),i=t.length,a=Array(i);for(let e=0;e<3;++e){for(let n=0;n<i;++n)a[n]=t[n][e];let s,o;if(s=o=a[0],4==i){s=ct(s,a[3]),o=ft(o,a[3]);let t=Nt(a[0],a[1],a[2],a[3]),e=new Ot(t[0],t[1],t[2]);if(0!=e.roots&&Pt(e.t1)){let t=Kt(a[0],a[1],a[2],a[3],e.t1);s=ct(s,t),o=ft(o,t)}if(2==e.roots&&Pt(e.t2)){let t=Kt(a[0],a[1],a[2],a[3],e.t2);s=ct(s,t),o=ft(o,t)}}else{let t=a[1];s=ct(s,t),o=ft(o,t)}n[e]=s,r[e]=o}return[[n[0],n[1],n[2]],[r[0],r[1],r[2]]]}setMaterialIndex(){this.setMaterial(Y,qe)}processLine(t){let e=t[0],n=t[1];if(!this.offscreen([e,n])){let t=[0,0,1];this.data.indices.push(this.data.vertex(e,t)),this.data.indices.push(this.data.vertex(n,t)),this.append()}}process(t){if(2==t.length)return this.processLine(t);let e=t[0],n=t[1],r=t[2],i=t[3],a=this.normal(Jt(e,n),te(e,n,r)),s=this.normal(Jt(r,i),te(i,r,n)),o=this.data.vertex(e,a),h=this.data.vertex(i,s);this.Render(t,o,h),this.data.indices.length>0&&this.append()}append(){Y.append(this.data)}notRendered(){Y.rendered=!1}Render(t,e,n){let r=t[0],i=t[1],a=t[2],s=t[3];if(ne(r,i,a,s)<this.res2)this.offscreen([r,s])||(this.data.indices.push(e),this.data.indices.push(n));else{if(this.offscreen(t))return;let o=[.5*(r[0]+i[0]),.5*(r[1]+i[1]),.5*(r[2]+i[2])],h=[.5*(i[0]+a[0]),.5*(i[1]+a[1]),.5*(i[2]+a[2])],l=[.5*(a[0]+s[0]),.5*(a[1]+s[1]),.5*(a[2]+s[2])],u=[.5*(o[0]+h[0]),.5*(o[1]+h[1]),.5*(o[2]+h[2])],c=[.5*(h[0]+l[0]),.5*(h[1]+l[1]),.5*(h[2]+l[2])],f=[.5*(u[0]+c[0]),.5*(u[1]+c[1]),.5*(u[2]+c[2])],m=[r,o,u,f],d=[f,c,l,s],v=this.normal(function(t,e,n,r){return[n[0]+r[0]-t[0]-e[0],n[1]+r[1]-t[1]-e[1],n[2]+r[2]-t[2]-e[2]]}(r,i,a,s),function(t,e,n,r){return[3*t[0]-5*e[0]+n[0]+r[0],3*t[1]-5*e[1]+n[1]+r[1],3*t[2]-5*e[2]+n[2]+r[2]]}(r,i,a,s)),M=this.data.vertex(f,v);this.Render(m,e,M),this.Render(d,M,n)}}normal(t,e){let n=Zt(t,t),r=Zt(t,e);return[n*e[0]-r*t[0],n*e[1]-r*t[1],n*e[2]-r*t[2]]}}class _t extends Tt{constructor(t,e,n,r=nn()){super(),this.controlpoint=t,this.width=e,this.MaterialIndex=n,this.CenterIndex=0,this.Min=t,this.Max=t,this.transform=r,this.controlpoints=[t]}setMaterialIndex(){this.setMaterial(U,Be)}Bounds(t,e){return[this.controlpoints[0],this.controlpoints[0]]}process(t){this.data.indices.push(this.data.vertex0(t[0],this.width)),this.append()}append(){U.append(this.data)}notRendered(){U.rendered=!1}}class Vt extends Tt{constructor(t,e,n=null){super(),this.CenterIndex=t,this.MaterialIndex=e,this.transparent=!1;const r=window;this.controlpoints=r.Positions,this.Normals=r.Normals,this.Colors=r.Colors,this.Indices=r.Indices,this.transparent=v[this.MaterialIndex].diffuse[3]<1}Bound(t,e){let n=Array(3),r=t.length,i=Array(r);for(let a=0;a<3;++a){for(let e=0;e<r;++e)i[e]=t[e][a];n[a]=yt(i,e)}return[n[0],n[1],n[2]]}Bounds(t,e){return[this.Bounds(t,ct),this.Bounds(t,ft)]}setMaterialIndex(){this.transparent?this.setMaterial(q,Xe):this.setMaterial(F,Ce)}process(t){this.data.vertices.length=6*t.length,z=this.Colors.length>0?-1-z:1+z;for(let e=0,n=this.Indices.length;e<n;++e){let n=this.Indices[e],r=n[0],i=t[r[0]],a=t[r[1]],s=t[r[2]],o=!this.offscreen([i,a,s]),h=n.length>1?n[1]:r;if(h&&0!=h.length||(h=r),this.Colors.length>0){let t=n.length>2?n[2]:r;t&&0!=t.length||(t=r);let e=this.Colors[t[0]],l=this.Colors[t[1]],u=this.Colors[t[2]];this.transparent=this.transparent||e[3]+l[3]+u[3]<3,0==tt?(this.data.iVertex(r[0],i,this.Normals[h[0]],o,e),this.data.iVertex(r[1],a,this.Normals[h[1]],o,l),this.data.iVertex(r[2],s,this.Normals[h[2]],o,u)):(this.data.iVertex(r[0],i,this.Normals[h[0]],o,e),this.data.iVertex(r[1],a,this.Normals[h[1]],o,l),this.data.iVertex(r[1],a,this.Normals[h[1]],o,l),this.data.iVertex(r[2],s,this.Normals[h[2]],o,u),this.data.iVertex(r[2],s,this.Normals[h[2]],o,u),this.data.iVertex(r[0],i,this.Normals[h[0]],o,e))}else 0==tt?(this.data.iVertex(r[0],i,this.Normals[h[0]],o),this.data.iVertex(r[1],a,this.Normals[h[1]],o),this.data.iVertex(r[2],s,this.Normals[h[2]],o)):(this.data.iVertex(r[0],i,this.Normals[h[0]],o),this.data.iVertex(r[1],a,this.Normals[h[1]],o),this.data.iVertex(r[1],a,this.Normals[h[1]],o),this.data.iVertex(r[2],s,this.Normals[h[2]],o),this.data.iVertex(r[2],s,this.Normals[h[2]],o),this.data.iVertex(r[0],i,this.Normals[h[0]],o))}this.data.nvertices=t.length,this.data.indices.length>0&&this.append()}append(){this.transparent?q.append(this.data):F.append(this.data)}notRendered(){this.transparent?q.rendered=!1:F.rendered=!1}}function Ut(){L=-Math.tan(.5*a.angleOfView)*a.maxBound[2],Z.x=Z.y=0,Z.z=.5*(a.minBound[2]+a.maxBound[2]),R=E=a.zoom0,K.zmin=a.minBound[2],K.zmax=a.maxBound[2],Q.x=Q.y=0,We(),J=!0,He()}function Yt(){return window.top.asyWebApplication}function Dt(t){window.parent.asyProjection=t}function Bt(){var e;t.identity(C),Ut(),null===(e=Yt())||void 0===e||e.setProjection(""),Dt(!1)}let qt=0,Ft=1,zt=2,Ct=3,Xt=4;function Gt(t=[]){let e=xt(s,"#ifdef WEBGL2\n#define IN in\n#define OUT out\n#else\n#define IN attribute\n#define OUT varying\n#endif\n\nIN vec3 position;\n#ifdef WIDTH\nIN float width;\n#endif\n#ifdef NORMAL\nIN vec3 normal;\n#endif\n\nIN float materialIndex;\n\n#ifdef WEBGL2\nflat out int MaterialIndex;\n#ifdef COLOR\nOUT vec4 Color;\n#endif\n#ifdef NORMAL\nOUT vec4 diffuse;\nOUT vec3 specular;\nOUT float roughness,metallic,fresnel0;\nOUT vec4 emissive;\n\nstruct Material {\n  vec4 diffuse,emissive,specular;\n  vec4 parameters;\n};\n\nuniform Material Materials[Nmaterials];\n#endif\n\n#else\nOUT vec4 diffuse;\nOUT vec3 specular;\nOUT float roughness,metallic,fresnel0;\nOUT vec4 emissive;\n\nstruct Material {\n  vec4 diffuse,emissive,specular;\n  vec4 parameters;\n};\n\nuniform Material Materials[Nmaterials];\n#endif\n\n#ifdef COLOR\nIN vec4 color;\n#endif\n\nuniform bool orthographic;\nuniform mat3 normMat;\nuniform mat4 viewMat;\nuniform mat4 projViewMat;\n\n#ifdef NORMAL\nOUT vec3 ViewPosition;\nOUT vec3 Normal;\n#endif\n\nvoid main(void)\n{\n  vec4 v=vec4(position,1.0);\n  gl_Position=projViewMat*v;\n\n#ifdef NORMAL\n  ViewPosition=orthographic ? vec3(0.0,0.0,-1.0) : (viewMat*v).xyz;\n  Normal=normalize(normal*normMat);\n#endif\n\n#ifdef WEBGL2\n  MaterialIndex=int(materialIndex);\n#ifdef NORMAL\n  Material m;\n#ifdef GENERAL\n  m=Materials[abs(int(materialIndex))-1];\n  emissive=m.emissive;\n  if(materialIndex >= 0.0)\n    diffuse=m.diffuse;\n  else {\n    if (m.parameters[3] != 0.0) {\n      diffuse=color;\n#if nlights == 0\n      emissive += color;\n#endif\n    } else {\n      emissive += color;\n      diffuse = m.diffuse;\n    }\n  }\n#else\n  m=Materials[int(materialIndex)];\n  emissive=m.emissive;\n#ifdef COLOR\n  if (m.parameters[3] != 0.0) {\n    diffuse=color;\n#if nlights == 0\n      emissive += color;\n#endif\n  } else {\n    emissive += color;\n    diffuse = m.diffuse;\n  }\n#else\n  diffuse=m.diffuse;\n#endif // COLOR\n#endif // GENERAL\n  specular=m.specular.rgb;\n  vec4 parameters=m.parameters;\n  roughness=1.0-parameters[0];\n  metallic=parameters[1];\n  fresnel0=parameters[2];\n#else\n  emissive=Materials[int(materialIndex)].emissive;\n#endif // NORMAL\n#ifdef COLOR\n  Color=color;\n#endif\n#else\n#ifdef NORMAL\n  Material m;\n#ifdef GENERAL\n  m=Materials[int(abs(materialIndex))-1];\n  emissive=m.emissive;\n  if(materialIndex >= 0.0)\n    diffuse=m.diffuse;\n  else {\n    if (m.parameters[3] != 0.0) {\n      diffuse=color;\n#if nlights == 0\n      emissive += color;\n#endif\n    } else {\n      emissive += color;\n      diffuse = m.diffuse;\n    }\n  }\n#else\n  m=Materials[int(materialIndex)];\n  emissive=m.emissive;\n#ifdef COLOR\n  if (m.parameters[3] != 0.0) {\n    diffuse=color;\n#if nlights == 0\n      emissive += color;\n#endif\n  } else {\n    emissive += color;\n    diffuse = m.diffuse;\n  }\n#else\n  diffuse=m.diffuse;\n#endif // COLOR\n#endif // GENERAL\n  specular=m.specular.rgb;\n  vec4 parameters=m.parameters;\n  roughness=1.0-parameters[0];\n  metallic=parameters[1];\n  fresnel0=parameters[2];\n#else\n  emissive=Materials[int(materialIndex)].emissive;\n#endif // NORMAL\n#endif // WEBGL2\n\n#ifdef WIDTH\n  gl_PointSize=width;\n#endif\n}\n",s.VERTEX_SHADER,t),n=xt(s,"#ifdef WEBGL2\n#define IN in\nout vec4 outValue;\n#define OUTVALUE outValue\n#else\n#define IN varying\n#define OUTVALUE gl_FragColor\n#endif\n\n#ifdef WEBGL2\nflat in int MaterialIndex;\n\n#ifdef NORMAL\nIN vec4 diffuse;\nIN vec3 specular;\nIN float roughness,metallic,fresnel0;\nIN vec4 emissive;\n#else\n\nstruct Material {\n  vec4 diffuse,emissive,specular;\n  vec4 parameters;\n};\n\nuniform Material Materials[Nmaterials];\n\nvec4 emissive;\n#endif\n\n#else\nIN vec4 diffuse;\nIN vec3 specular;\nIN float roughness,metallic,fresnel0;\nIN vec4 emissive;\n#endif\n\n#ifdef NORMAL\n\nIN vec3 ViewPosition;\nIN vec3 Normal;\n\nvec3 normal;\n\nstruct Light {\n  vec3 direction;\n  vec3 color;\n};\n\nuniform Light Lights[Nlights];\n\n#ifdef USE_IBL\nuniform sampler2D reflBRDFSampler;\nuniform sampler2D diffuseSampler;\nuniform sampler2D reflImgSampler;\n\nconst float pi=acos(-1.0);\nconst float piInv=1.0/pi;\nconst float twopi=2.0*pi;\nconst float twopiInv=1.0/twopi;\n\n// (x,y,z) -> (r,theta,phi);\n// theta -> [0,pi]: colatitude\n// phi -> [-pi,pi]: longitude\nvec3 cart2sphere(vec3 cart)\n{\n  float x=cart.x;\n  float y=cart.z;\n  float z=cart.y;\n\n  float r=length(cart);\n  float theta=r > 0.0 ? acos(z/r) : 0.0;\n  float phi=atan(y,x);\n\n  return vec3(r,theta,phi);\n}\n\nvec2 normalizedAngle(vec3 cartVec)\n{\n  vec3 sphericalVec=cart2sphere(cartVec);\n  sphericalVec.y=sphericalVec.y*piInv;\n  sphericalVec.z=0.75-sphericalVec.z*twopiInv;\n  return sphericalVec.zy;\n}\n\nvec3 IBLColor(vec3 viewDir)\n{\n  vec3 IBLDiffuse=diffuse.rgb*texture(diffuseSampler,normalizedAngle(normal)).rgb;\n  vec3 reflectVec=normalize(reflect(-viewDir,normal));\n  vec2 reflCoord=normalizedAngle(reflectVec);\n  vec3 IBLRefl=textureLod(reflImgSampler,reflCoord,roughness*ROUGHNESS_STEP_COUNT).rgb;\n  vec2 IBLbrdf=texture(reflBRDFSampler,vec2(dot(normal,viewDir),roughness)).rg;\n  float specularMultiplier=fresnel0*IBLbrdf.x+IBLbrdf.y;\n  vec3 dielectric=IBLDiffuse+specularMultiplier*IBLRefl;\n  vec3 metal=diffuse.rgb*IBLRefl;\n  return mix(dielectric,metal,metallic);\n}\n#else\nfloat Roughness2;\nfloat NDF_TRG(vec3 h)\n{\n  float ndoth=max(dot(normal,h),0.0);\n  float alpha2=Roughness2*Roughness2;\n  float denom=ndoth*ndoth*(alpha2-1.0)+1.0;\n  return denom != 0.0 ? alpha2/(denom*denom) : 0.0;\n}\n\nfloat GGX_Geom(vec3 v)\n{\n  float ndotv=max(dot(v,normal),0.0);\n  float ap=1.0+Roughness2;\n  float k=0.125*ap*ap;\n  return ndotv/((ndotv*(1.0-k))+k);\n}\n\nfloat Geom(vec3 v, vec3 l)\n{\n  return GGX_Geom(v)*GGX_Geom(l);\n}\n\nfloat Fresnel(vec3 h, vec3 v, float fresnel0)\n{\n  float a=1.0-max(dot(h,v),0.0);\n  float b=a*a;\n  return fresnel0+(1.0-fresnel0)*b*b*a;\n}\n\n// physical based shading using UE4 model.\nvec3 BRDF(vec3 viewDirection, vec3 lightDirection)\n{\n  vec3 lambertian=diffuse.rgb;\n  vec3 h=normalize(lightDirection+viewDirection);\n\n  float omegain=max(dot(viewDirection,normal),0.0);\n  float omegaln=max(dot(lightDirection,normal),0.0);\n\n  float D=NDF_TRG(h);\n  float G=Geom(viewDirection,lightDirection);\n  float F=Fresnel(h,viewDirection,fresnel0);\n\n  float denom=4.0*omegain*omegaln;\n  float rawReflectance=denom > 0.0 ? (D*G)/denom : 0.0;\n\n  vec3 dielectric=mix(lambertian,rawReflectance*specular,F);\n  vec3 metal=rawReflectance*diffuse.rgb;\n\n  return mix(dielectric,metal,metallic);\n}\n#endif\n\n#endif\n\nvoid main(void)\n{\n#if defined(NORMAL) && nlights > 0\n  normal=normalize(Normal);\n  normal=gl_FrontFacing ? normal : -normal;\n  vec3 viewDir=-normalize(ViewPosition);\n\nvec3 color;\n#ifdef USE_IBL\n  color=IBLColor(viewDir);\n#else\n  Roughness2=roughness*roughness;\n  color=emissive.rgb;\n  for(int i=0; i < nlights; ++i) {\n    Light Li=Lights[i];\n    vec3 L=Li.direction;\n    float cosTheta=max(dot(normal,L),0.0);\n    vec3 radiance=cosTheta*Li.color;\n    color += BRDF(viewDir,L)*radiance;\n  }\n#endif\n  OUTVALUE=vec4(color,diffuse.a);\n#else\n#ifdef WEBGL2\n#ifndef NORMAL\n  emissive=Materials[MaterialIndex].emissive;\n#endif\n#endif\n  OUTVALUE=emissive;\n#endif\n}\n",s.FRAGMENT_SHADER,t),r=s.createProgram();return s.attachShader(r,e),s.attachShader(r,n),s.bindAttribLocation(r,qt,"position"),s.bindAttribLocation(r,Ft,"normal"),s.bindAttribLocation(r,zt,"materialIndex"),s.bindAttribLocation(r,Ct,"color"),s.bindAttribLocation(r,Xt,"width"),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||alert("Could not initialize shaders"),r}class Ht{constructor(t,e,n,r){this.m0=.5*(t+e);const i=.5*(e+n);this.m2=.5*(n+r),this.m3=.5*(this.m0+i),this.m4=.5*(i+this.m2),this.m5=.5*(this.m3+this.m4)}}class Wt{constructor(t,e,n,r){this.m0=[.5*(t[0]+e[0]),.5*(t[1]+e[1]),.5*(t[2]+e[2])];const i=.5*(e[0]+n[0]),a=.5*(e[1]+n[1]),s=.5*(e[2]+n[2]);this.m2=[.5*(n[0]+r[0]),.5*(n[1]+r[1]),.5*(n[2]+r[2])],this.m3=[.5*(this.m0[0]+i),.5*(this.m0[1]+a),.5*(this.m0[2]+s)],this.m4=[.5*(i+this.m2[0]),.5*(a+this.m2[1]),.5*(s+this.m2[2])],this.m5=[.5*(this.m3[0]+this.m4[0]),.5*(this.m3[1]+this.m4[1]),.5*(this.m3[2]+this.m4[2])]}}class kt{constructor(t){this.l003=t[0];const e=t[1],n=t[2],r=t[3],i=t[4],a=t[5];this.r300=t[6];const s=t[7],o=t[8];this.u030=t[9],this.u021=.5*(this.u030+a),this.u120=.5*(this.u030+o);const h=.5*(a+n),l=.5*(o+i),u=.5*(o+s),c=.5*(n+i);this.l012=.5*(n+this.l003);const f=.5*(i+r);this.r210=.5*(s+this.r300),this.l102=.5*(this.l003+e);const m=.5*(e+r);this.r201=.5*(r+this.r300),this.u012=.5*(this.u021+h),this.u210=.5*(this.u120+u),this.l021=.5*(h+this.l012);const d=.5*l+.25*(i+e);this.r120=.5*(u+this.r210);const v=.5*c+.25*(i+s),M=.25*(a+i)+.5*f;this.l201=.5*(this.l102+m),this.r102=.5*(m+this.r201),this.l210=.5*(v+this.l201),this.r012=.5*(v+this.r102),this.l300=.5*(this.l201+this.r102),this.r021=.5*(M+this.r120),this.u201=.5*(this.u210+M),this.r030=.5*(this.u210+this.r120),this.u102=.5*(this.u012+d),this.l120=.5*(this.l021+d),this.l030=.5*(this.u012+this.l021),this.l111=.5*(c+this.l102),this.r111=.5*(f+this.r210),this.u111=.5*(this.u021+l),this.c111=.25*(h+u+m+i)}}function jt(t){const e=1/(Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])||1);return[t[0]*e,t[1]*e,t[2]*e]}function $t(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Zt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Qt(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Kt(t,e,n,r,i){let a=1-i,s=a*a;return s*a*t+i*(3*(s*e+i*a*n)+i*i*r)}function Jt(t,e){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function te(t,e,n){return[3*(t[0]+n[0])-6*e[0],3*(t[1]+n[1])-6*e[1],3*(t[2]+n[2])-6*e[2]]}function ee(t,e,n,r){return[r[0]-t[0]+3*(e[0]-n[0]),r[1]-t[1]+3*(e[1]-n[1]),r[2]-t[2]+3*(e[2]-n[2])]}function ne(t,e,n,r){let i=[g*(r[0]-t[0]),g*(r[1]-t[1]),g*(r[2]-t[2])];return ft($t([e[0]-i[0]-t[0],e[1]-i[1]-t[1],e[2]-i[2]-t[2]]),$t([r[0]-i[0]-n[0],r[1]-i[1]-n[1],r[2]-i[2]-n[2]]))}function re(t,e,n,r){const i=[e[0]-t[0],e[1]-t[1],e[2]-t[2]],a=[r[0]-n[0],r[1]-n[1],r[2]-n[2]];return ft($t(Qt(i,jt(a))),$t(Qt(a,jt(i))))/9}function ie(t){we||Ee(),et=!0,nt=t.clientX,rt=t.clientY}let ae,se,oe=!1;function he(t){return Math.hypot(t[0].pageX-t[1].pageX,t[0].pageY-t[1].pageY)}let le=null;function ue(t){t.preventDefault(),we||Ee();let e=t.targetTouches;Pe=Oe=oe=!1,Ne||(1!=e.length||et||(se=(new Date).getTime(),le=e[0].identifier,nt=e[0].pageX,rt=e[0].pageY),2!=e.length||et||(le=e[0].identifier,ae=he(e),oe=!0))}function ce(t){et=!1}function fe(e,n,r,i,a){if(e==r&&n==i)return;const{angle:s,axis:o}=function(t,e){const n=ge(t),r=ge(e),i=Zt(n,r);return{angle:i>1?0:i<-1?b:Math.acos(i),axis:jt(Qt(n,r))}}([e,-n],[r,-i]);t.fromRotation($,2*a*S*s/E,o),t.multiply(C,$,C)}function me(t,e,n,r){let i=1/E;Q.x+=(n-t)*i*c,Q.y-=(r-e)*i*f}function de(t,e,n,r){a.orthographic?me(t,e,n,r):(Z.x+=(n-t)*(K.xmax-K.xmin),Z.y-=(r-e)*(K.ymax-K.ymin))}function ve(){var n,r;n=G,r=C,t.fromTranslation($,[Z.x,Z.y,Z.z]),t.invert(j,$),t.multiply(n,r,j),t.multiply(n,$,n),t.translate(G,G,[Z.x,Z.y,0]),e.fromMat4(k,G),e.invert(W,k),t.multiply(H,X,G)}function Me(){let t=Math.sqrt(Number.MAX_VALUE),e=1/t;E<=e&&(E=e),E>=t&&(E=t),(1.5*E<R||E>1.5*R)&&(J=!0,R=E)}function pe(t){let e=a.zoomStep*f*t;const n=Math.log(.1*Number.MAX_VALUE)/Math.log(a.zoomFactor);Math.abs(e)<n&&(E*=a.zoomFactor**e,Me())}function ge(t){let e=t[0],n=t[1],r=Math.hypot(e,n);if(r>1){const t=1/r;e*=t,n*=t}return[e,n,Math.sqrt(ft(1-n*n-e*e,0))]}function be(t,e,n,r){pe(e-r)}function xe(t,e,n,r=1){let i;switch(n){case 1:i=fe;break;case 2:i=me;break;case 3:i=be;break;case 4:i=de;break;default:i=(t,e,n,r)=>{}}i((nt-c)/c,(rt-f)/f,(t-c)/c,(e-f)/f,r),nt=t,rt=e,We(),He()}let we=0;function Ee(){we=1,a.canvas.addEventListener("wheel",Ie,!1)}function Re(){let t,e,n;[t,e,n]=function(){let t=Array(3),e=Array(3),n=Array(3),r=Z.x,i=Z.y,s=.5*(K.zmin+K.zmax),o=[0,0,0,0];for(let h=0;h<3;++h){let l=0,u=0,c=0,f=4*h;o[3]=a.Transform[f+2]*s;for(let t=0;t<4;++t){let e=4*t,n=C[e],h=C[e+1],m=C[e+2],d=C[e+3],v=a.Transform[f+t]+o[t];l+=v*(d-r*n-i*h-s*m),c+=v*h,u+=v*(d-r*n-i*h)}t[h]=l,e[h]=c,n[h]=u}return[t,e,n]}();let r=a.orthographic?"  orthographic(":"  perspective(",i="".padStart(r.length),s="currentprojection=\n"+r+"camera=("+t+"),\n"+i+"up=("+e+"),\n"+i+"target=("+n+"),\n"+i+"zoom="+E*a.initialZoom/a.zoom0;return a.orthographic||(s+=",\n"+i+"angle="+2*Math.atan(Math.tan(.5*a.angleOfView)/E)/x),0==A&&0==T||(s+=",\n"+i+"viewportshift=("+A+","+T+")"),a.orthographic||(s+=",\n"+i+"autoadjust=false"),s+=");\n",Dt(!0),s}function Ae(e){if(we||Ee(),a.embedded&&we&&27==e.keyCode)return we=0,void a.canvas.removeEventListener("wheel",Ie,!1);let n=e.key,r=null;switch(n){case"x":r=[1,0,0];break;case"y":r=[0,1,0];break;case"z":r=[0,0,1];break;case"h":Bt();break;case"m":++tt,3==tt&&(tt=0),2!=tt&&(a.embedded||Mt(),vt(a.ibl)),J=!0,He();break;case"+":case"=":case">":E*=a.zoomFactor,ye();break;case"-":case"_":case"<":E/=a.zoomFactor,ye();break;case"c":Yt()||prompt("Ctrl+c Enter to copy currentprojection to clipboard; then append to asy file:",Re());break;case"b":dn?(sn.remove(),on=null,dn=!1,cn=!1,fn=!1):function(){dn=!0,on=null;const t=document;sn=t.createElement("input"),an=1/tn,sn.type="range",sn.min="0",sn.max="1",sn.step="0.001",sn.value=(hn*an).toString(),sn.className="slider",sn.style.position="fixed",sn.onkeydown=()=>!1,sn.oninput=()=>{const t=parseFloat(sn.value);hn=tn*t,document.asy.autoplay=!1,on=null,fn=!0,cn=!1,un=null,requestAnimationFrame(mn)},sn.onchange=()=>{fn=!1,cn=!1,on=document.asy.autoplay&&hn<tn?"forward":null,un=null},t.body.prepend(sn)}()}"ArrowRight"==n&&"forward"!=on?(document.asy.autoplay=!1,on="forward",cn=!0,fn=!1,un=null,requestAnimationFrame(mn)):"ArrowLeft"==n&&"backward"!=on&&(document.asy.autoplay=!1,on="backward",cn=!0,fn=!1,un=null,requestAnimationFrame(mn)),null!==r&&(t.rotate(C,C,.1,r),ve(),He())}function Te(t){cn=!1,on=null}function ye(){Me(),We(),He()}function Ie(t){t.preventDefault(),t.deltaY<0?E*=a.zoomFactor:E/=a.zoomFactor,ye()}function Le(t){if(!et)return;let e,n=t.clientX,r=t.clientY;e=t.getModifierState("Control")?2:t.getModifierState("Shift")?3:t.getModifierState("Alt")?4:1,xe(n,r,e)}let Ne=!1,Pe=!1,Oe=!1;function Se(t){if(t.preventDefault(),Ne)return;let e=t.targetTouches;if(!oe&&1==e.length&&le==e[0].identifier){let t=e[0].pageX,n=e[0].pageY,r=t-nt,i=n-rt,s=r*r+i*i<=a.shiftHoldDistance*a.shiftHoldDistance;s&&!Pe&&!Oe&&(new Date).getTime()-se>a.shiftWaitTime&&(navigator.vibrate&&window.navigator.vibrate(a.vibrateTime),Pe=!0),Pe?xe(t,n,2):s||(Oe=!0,xe(e[0].pageX,e[0].pageY,1,.5))}if(oe&&!Pe&&2==e.length&&le==e[0].identifier){let t=he(e),n=t-ae;Ne=!0,n*=a.zoomPinchFactor,n>a.zoomPinchCap&&(n=a.zoomPinchCap),n<-a.zoomPinchCap&&(n=-a.zoomPinchCap),pe(n/O),ae=t,Pe=Oe=Ne=!1,We(),He()}}let _e,Ve,Ue,Ye,De=[];function Be(){Et(U,_e),U.clear()}function qe(){Et(Y,Ve),Y.clear()}function Fe(){Et(D,Ve),D.clear()}function ze(){Et(B,Ue),B.clear()}function Ce(){Et(F,Ye),F.rendered=!1,F.clear()}function Xe(){let t=q.indices;if(tt>0)return Et(q,Ye,t),void q.clear();if(t.length>0){!function(t){let e=G[2],n=G[6],r=G[10];De.length=t.length;for(let i=0;i<t.length;++i){let a=6*i;De[i]=e*t[a]+n*t[a+1]+r*t[a+2]}}(q.vertices);const e=t.length/3,n=[...Array(e).keys()];n.sort(function(e,n){let r=3*e;const i=t[r],a=t[r+1],s=t[r+2];let o=3*n;const h=t[o],l=t[o+1],u=t[o+2];return De[i]+De[a]+De[s]<De[h]+De[l]+De[u]?-1:1});const r=Array(t.length);for(let i=0;i<e;++i){const e=3*n[i];r[3*i]=t[e],r[3*i+1]=t[e+1],r[3*i+2]=t[e+2]}s.depthMask(!1),Et(q,Ye,r),q.rendered=!1,s.depthMask(!0)}q.clear()}function Ge(){Be(),qe(),Fe(),ze(),Ce(),Xe(),requestAnimationFrame(Ge)}function He(){a.embedded&&(h.width=a.canvasWidth,h.height=a.canvasHeight,ke()),s.clearColor(a.background[0],a.background[1],a.background[2],a.background[3]),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),Je=performance.now();for(const t of m)t.render();Ge(),a.embedded&&(l.clearRect(0,0,a.canvasWidth,a.canvasHeight),l.drawImage(h,0,0)),0==tt&&(J=!1)}function We(){var e;!function(t,e,n,r){let i=t/e;A=(n/t+a.viewportShift[0])*E,T=(r/e+a.viewportShift[1])*E;let s=1/E;if(a.orthographic){let t=a.maxBound[0]-a.minBound[0],e=a.maxBound[1]-a.minBound[1];if(t<e*i){let t=.5*e*i*s,n=2*t*A,r=e*s*T;K.xmin=-t-n,K.xmax=t-n,K.ymin=a.minBound[1]*s-r,K.ymax=a.maxBound[1]*s-r}else{let e=.5*t*s/i,n=t*s*A,r=2*e*T;K.xmin=a.minBound[0]*s-n,K.xmax=a.maxBound[0]*s-n,K.ymin=-e-r,K.ymax=e-r}}else{let t=L*s,e=t*i,n=2*e*A,r=2*t*T;K.xmin=-e-n,K.xmax=e-n,K.ymin=-t-r,K.ymax=t-r}}(a.canvasWidth,a.canvasHeight,Q.x,Q.y),(a.orthographic?t.ortho:t.frustum)(X,K.xmin,K.xmax,K.ymin,K.ymax,-K.zmax,-K.zmin),ve(),null===(e=Yt())||void 0===e||e.setProjection(Re())}function ke(){s.viewportWidth=a.canvasWidth,s.viewportHeight=a.canvasHeight,s.viewport(.5*(a.canvas.width-a.canvasWidth),.5*(a.canvas.height-a.canvasHeight),a.canvasWidth,a.canvasHeight),s.scissor(0,0,a.canvas.width,a.canvas.height)}function je(){var t;if(a.zoom0=a.initialZoom,""===(null===(t=Yt())||void 0===t?void 0:t.getProjection())&&Dt(!1),a.absolute&&!a.embedded)a.canvasWidth=a.canvasWidth0*window.devicePixelRatio,a.canvasHeight=a.canvasHeight0*window.devicePixelRatio;else{let t=a.canvasWidth0/a.canvasHeight0;a.canvasWidth=ft(window.innerWidth-10,10),a.canvasHeight=ft(window.innerHeight-10,10),!a.orthographic&&!window.parent.asyProjection&&a.canvasWidth<a.canvasHeight*t&&(a.zoom0*=a.canvasWidth/(a.canvasHeight*t))}a.canvas.width=a.canvasWidth,a.canvas.height=a.canvasHeight,window.innerWidth,window.innerHeight;let e=1/a.zoom0;var n,r;a.viewportShift[0]*=e,a.viewportShift[1]*=e,n=a.canvasWidth,r=a.canvasHeight,n>y&&(n=y),r>I&&(r=I),Q.x*=n/a.canvasWidth,Q.y*=r/a.canvasHeight,a.canvasWidth=n,a.canvasHeight=r,a.embedded&&(a.canvas.width=h.width=a.canvasWidth,a.canvas.height=h.height=a.canvasHeight),O=Math.hypot(a.canvasWidth,a.canvasHeight),c=.5*a.canvas.width,f=.5*a.canvas.height,S=1+8*Math.hypot(a.viewportMargin[0],a.viewportMargin[1])/O,ke(),We(),J=!0,Ut()}class $e{constructor(t,e=null){if(this.center=t,e){const t=e[0],n=e[1];this.ct=Math.cos(t),this.st=Math.sin(t),this.cp=Math.cos(n),this.sp=Math.sin(n)}}T0(t){return[t[0]+this.center[0],t[1]+this.center[1],t[2]+this.center[2]]}T(t){let e=t[0],n=t[1],r=t[2],i=e*this.ct+r*this.st;return[i*this.cp-n*this.sp+this.center[0],i*this.sp+n*this.cp+this.center[1],-e*this.st+r*this.ct+this.center[2]]}}function Ze(t){return t.map(function(t){let e=[t[0],t[1],t[2],1],n=r.create();return r.transformMat4(n,e,N),[n[0],n[1],n[2]]})}function Qe(t,e,n){return t.map(function(t){return n(t,e)})}function Ke(t,e,n){return t.map(function(t){return n(t[0],t[1],e)})}let Je,tn=0,en=[];function nn(){if(0==en.length)return;let t=en.filter(t=>null!=t.geometryTransform);return function(e){let n=Ze(e);for(let e=t.length-1;e>=0;e--){const{geometryTransform:r,durationInv:i}=t[e];n=Qe(n,ct(hn*i,1),r)}return function(t){return t.map(function(t){let e=[t[0],t[1],t[2],1],n=r.create();return r.transformMat4(n,e,P),[n[0],n[1],n[2]]})}(n)}}let rn,an,sn,on=null,hn=0,ln=1,un=null,cn=!1,fn=!1;function mn(t){rn=t,un||(un=t);const e=t-un;un=t,null==on&&document.asy.autoplay&&(on="forward"),"forward"==on?(hn+=e*ln,hn>tn&&(hn=tn,on=null,cn=!1,fn=!0)):"backward"==on&&(hn-=e*ln,hn<=0&&(hn=0,on=null,cn=!1,fn=!0)),sn&&!fn&&null!=on&&(sn.value=(hn*an).toString()),J=!0,He(),document.asy.autoplay&&hn<tn&&!fn||cn?requestAnimationFrame(mn):(un=null,cn||(fn=!1))}let dn=!1,vn=4/3*(Math.sqrt(2)-1);async function Mn(t){return(await fetch(t)).arrayBuffer()}function pn(t){return t.getBytes().filter((t,e)=>e%4!=3)}function gn(t,e,n=s.RGB16F){let r=t.width(),i=t.height(),a=s.createTexture();return s.activeTexture(s.TEXTURE0+e),s.bindTexture(s.TEXTURE_2D,a),s.pixelStorei(s.UNPACK_ALIGNMENT,1),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,n,r,i,0,s.RGB,s.FLOAT,pn(t)),a}globalThis.window.webGLStart=function(){a.canvas=document.getElementById("Asymptote"),a.embedded=window.top.document!=document,bt(),s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.enable(s.DEPTH_TEST),s.enable(s.SCISSOR_TEST),a.canvas.onmousedown=ie,document.onmouseup=ce,document.onmousemove=Le,a.canvas.onkeydown=Ae,a.embedded||Ee(),a.canvas.addEventListener("touchstart",ue,!1),a.canvas.addEventListener("touchend",ce,!1),a.canvas.addEventListener("touchcancel",ce,!1),a.canvas.addEventListener("touchleave",ce,!1),a.canvas.addEventListener("touchmove",Se,!1),document.addEventListener("keydown",Ae,!1),document.addEventListener("keyup",Te,!1),a.canvasWidth0=a.canvasWidth,a.canvasHeight0=a.canvasHeight,t.identity(C),0!=window.innerWidth&&0!=window.innerHeight&&je(),window.addEventListener("resize",je,!1),a.ibl&&(Module.onRuntimeInitialized=async()=>{await async function(){const t=a.imageURL+a.image+"/",e=[Mn(a.imageURL+"refl.exr").then(t=>{let e=new Module.EXRLoader(t);ut=gn(e,0)}),Mn(t+"diffuse.exr").then(t=>{let e=new Module.EXRLoader(t);lt=gn(e,1)})],n=[Mn(t+"refl0.exr")];for(let e=1;e<=8;++e)n.push(Mn(t+"refl"+e+"w.exr"));const r=Promise.all(n).then(t=>{let e=s.createTexture();s.activeTexture(s.TEXTURE0+2),s.pixelStorei(s.UNPACK_ALIGNMENT,1),s.bindTexture(s.TEXTURE_2D,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAX_LEVEL,t.length-1),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameterf(s.TEXTURE_2D,s.TEXTURE_MIN_LOD,0),s.texParameterf(s.TEXTURE_2D,s.TEXTURE_MAX_LOD,8);for(let e=0;e<t.length;++e){let n=new Module.EXRLoader(t[e]);s.texImage2D(s.TEXTURE_2D,e,s.RGB16F,n.width(),n.height(),0,s.RGB,s.FLOAT,pn(n))}ht=e});e.push(r),await Promise.all(e)}(),a.embedded||Mt(),vt(a.ibl),Ut()}),Bt(),requestAnimationFrame(mn)},globalThis.window.light=function(t,e){d.push(new dt(t,e))},globalThis.window.material=function(t,e,n,r,i,a,s){v.push(new mt(t,e,n,r,i,a,s))},globalThis.window.patch=function(t,e,n,r){m.push(new Lt(t,e,n,r))},globalThis.window.curve=function(t,e,n){m.push(new St(t,e,n))},globalThis.window.pixel=function(t,e,n){m.push(new _t(t,e,n))},globalThis.window.triangles=function(t,e){m.push(new Vt(t,e)),it.length=0,at.length=0,st.length=0,ot.length=0},globalThis.window.sphere=function(t,e,n,r,i){let a,s,o,h,l,u,c=.524670512339254,f=.595936986722291,d=.954967051233925,v=.0820155480083437,M=.996685028842544,p=.0549670512339254,g=.998880711874577,b=.0405017186586849,x=[[[1,0,0],[1,0,c],[f,0,d],[v,0,M],[1,vn,0],[1,vn,c],[f,vn*f,d],[v,vn*v,M],[vn,1,0],[vn,1,c],[vn*f,f,d],[vn*v,v,M],[0,1,0],[0,1,c],[0,f,d],[0,v,M]],[[v,0,M],[v,vn*v,M],[p,0,g],[vn*v,v,M],[b,b,1],[.05*vn,0,1],[0,v,M],[0,p,g],[0,.05*vn,1],[0,0,1]]],w=new $e(t,i);function E(t){let e=Array(t.length);for(let n=0;n<t.length;++n){let r=t[n];e[n]=l([a*r[0],s*r[1],o*r[2]])}return e}i?(h=1,u=0,l=w.T.bind(w)):(h=-1,u=-e,l=w.T0.bind(w));for(let t=-1;t<=1;t+=2){a=t*e;for(let t=-1;t<=1;t+=2){s=t*e;for(let t=h;t<=1;t+=2){o=t*e;for(let t=0;t<2;++t)m.push(new Lt(E(x[t]),n,r))}}}},globalThis.window.disk=function(t,e,n,r,i){let a=1-2*vn/3,s=[[1,0,0],[1,-vn,0],[vn,-1,0],[0,-1,0],[1,vn,0],[a,0,0],[0,-a,0],[-vn,-1,0],[vn,1,0],[0,a,0],[-a,0,0],[-1,-vn,0],[0,1,0],[-vn,1,0],[-1,vn,0],[-1,0,0]],o=new $e(t,i);m.push(new Lt(function(t){let n=Array(t.length);for(let r=0;r<t.length;++r){let i=t[r];n[r]=o.T([e*i[0],e*i[1],0])}return n}(s),n,r))},globalThis.window.cylinder=function(t,e,n,r,i,a,s){let o,h,l=[[1,0,0],[1,0,1/3],[1,0,2/3],[1,0,1],[1,vn,0],[1,vn,1/3],[1,vn,2/3],[1,vn,1],[vn,1,0],[vn,1,1/3],[vn,1,2/3],[vn,1,1],[0,1,0],[0,1,1/3],[0,1,2/3],[0,1,1]],u=new $e(t,a);function c(t){let e=Array(t.length);for(let r=0;r<t.length;++r){let i=t[r];e[r]=u.T([o*i[0],h*i[1],n*i[2]])}return e}for(let t=-1;t<=1;t+=2){o=t*e;for(let t=-1;t<=1;t+=2)h=t*e,m.push(new Lt(c(l),r,i))}if(s){let e=u.T([0,0,n]);m.push(new St([t,e],r,i))}},globalThis.window.tube=function(t,e,n,r,i){let a=function(t,e,n,r,i){class a{constructor(t,e,n){this.p=t,this.r=e,this.t=n,this.s=Qt(this.t,this.r)}}let s=Number.EPSILON*ft($t(t),$t(e),$t(n),$t(r));function o(i){if(1==i){let i=[r[0]-n[0],r[1]-n[1],r[2]-n[2]];return $t(i)>s?jt(i):(i=[2*n[0]-e[0]-r[0],2*n[1]-e[1]-r[1],2*n[2]-e[2]-r[2]],$t(i)>s?jt(i):[r[0]-t[0]+3*(e[0]-n[0]),r[1]-t[1]+3*(e[1]-n[1]),r[2]-t[2]+3*(e[2]-n[2])])}let a=[r[0]-t[0]+3*(e[0]-n[0]),r[1]-t[1]+3*(e[1]-n[1]),r[2]-t[2]+3*(e[2]-n[2])],o=[2*(t[0]+n[0])-4*e[0],2*(t[1]+n[1])-4*e[1],2*(t[2]+n[2])-4*e[2]],h=[e[0]-t[0],e[1]-t[1],e[2]-t[2]],l=i*i,u=[a[0]*l+o[0]*i+h[0],a[1]*l+o[1]*i+h[1],a[2]*l+o[2]*i+h[2]];return $t(u)>s?jt(u):(l=2*i,u=[a[0]*l+o[0],a[1]*l+o[1],a[2]*l+o[2]],$t(u)>s?jt(u):jt(a))}let h=Array(i.length),l=[e[0]-t[0],e[1]-t[1],e[2]-t[2]];$t(l)<s&&(l=[t[0]-2*e[0]+n[0],t[1]-2*e[1]+n[1],t[2]-2*e[2]+n[2]],$t(l)<s&&(l=[r[0]-t[0]+3*(e[0]-n[0]),r[1]-t[1]+3*(e[1]-n[1]),r[2]-t[2]+3*(e[2]-n[2])])),l=jt(l);let u=function(t){let e=Qt(t,[0,1,0]),n=Number.EPSILON*$t(t);return $t(e)>n?jt(e):(e=Qt(t,[0,0,1]),$t(e)>n?jt(e):[1,0,0])}(l);h[0]=new a(t,u,l);for(let s=1;s<i.length;++s){let l=h[s-1],u=i[s],c=1-u,f=c*c,m=f*c,d=3*u;f*=d,c*=d*u;let v=u*u*u,M=[m*t[0]+f*e[0]+c*n[0]+v*r[0],m*t[1]+f*e[1]+c*n[1]+v*r[1],m*t[2]+f*e[2]+c*n[2]+v*r[2]],p=[M[0]-l.p[0],M[1]-l.p[1],M[2]-l.p[2]];if(0!=p[0]||0!=p[1]||0!=p[2]){let t=l.r,e=jt(p),n=l.t,r=Zt(e,n),i=[n[0]-2*r*e[0],n[1]-2*r*e[1],n[2]-2*r*e[2]];n=o(u);let c=2*Zt(e,t),f=[t[0]-c*e[0],t[1]-c*e[1],t[2]-c*e[2]],m=jt([n[0]-i[0],n[1]-i[1],n[2]-i[2]]),d=2*Zt(m,f);f=[f[0]-d*m[0],f[1]-d*m[1],f[2]-d*m[2]],h[s]=new a(M,jt(f),jt(n))}else h[s]=h[s-1]}return h}(t[0],t[1],t[2],t[3],[0,1/3,2/3,1]),s=vn*e,o=[[e,0],[e,s],[s,e],[0,e]];function h(e,i,s,h){let l=Array(16);for(let n=0;n<4;++n){let r=a[n],u=r.r[0],c=r.s[0],f=u*e+c*i,m=u*s+c*h;u=r.r[1],c=r.s[1];let d=u*e+c*i,v=u*s+c*h;u=r.r[2],c=r.s[2];let M=u*e+c*i,p=u*s+c*h,g=t[n],b=g[0];const x=g[1],w=g[2];for(let t=0;t<4;++t){let e=o[t],r=e[0],i=e[1];l[4*n+t]=[f*r+m*i+b,d*r+v*i+x,M*r+p*i+w]}}m.push(new Lt(l,n,r))}h(1,0,0,1),h(0,-1,1,0),h(-1,0,0,-1),h(0,1,-1,0),i&&m.push(new St(t,n,r))},globalThis.window.Positions=it,globalThis.window.Normals=at,globalThis.window.Colors=st,globalThis.window.Indices=ot,globalThis.window.initTransform=function(){N=t.create(),t.transpose(N,document.asy.Transform),P=t.create(),t.invert(P,N)},globalThis.window.beginTransform=function(t,e,n){const r=1e3*n;n>tn&&(tn=r),en.push({geometryTransform:t,colorTransform:e,durationInv:r>0?1/r:0})},globalThis.window.endTransform=function(){en.pop()},globalThis.window.interp=function(t,e,n){return[t[0]*(1-n)+e[0]*n,t[1]*(1-n)+e[1]*n,t[2]*(1-n)+e[2]*n,t[3]*(1-n)+e[3]*n]},globalThis.window.updateScene=function(){J=!0,He()}})(),(()=>{var t={};n.r(t),n.d(t,{LDU:()=>y,add:()=>I,adjoint:()=>p,clone:()=>u,copy:()=>c,create:()=>l,determinant:()=>g,equals:()=>P,exactEquals:()=>N,frob:()=>T,fromRotation:()=>E,fromScaling:()=>R,fromValues:()=>m,identity:()=>f,invert:()=>M,mul:()=>_,multiply:()=>b,multiplyScalar:()=>O,multiplyScalarAndAdd:()=>S,rotate:()=>x,scale:()=>w,set:()=>d,str:()=>A,sub:()=>V,subtract:()=>L,transpose:()=>v});var e={};n.r(e),n.d(e,{add:()=>K,clone:()=>Y,copy:()=>D,create:()=>U,determinant:()=>C,equals:()=>rt,exactEquals:()=>nt,frob:()=>Q,fromRotation:()=>k,fromScaling:()=>j,fromTranslation:()=>$,fromValues:()=>q,identity:()=>B,invert:()=>z,mul:()=>it,multiply:()=>X,multiplyScalar:()=>tt,multiplyScalarAndAdd:()=>et,rotate:()=>G,scale:()=>H,set:()=>F,str:()=>Z,sub:()=>at,subtract:()=>J,translate:()=>W});var r={};n.r(r),n.d(r,{add:()=>dt,angle:()=>Xt,bezier:()=>Ut,ceil:()=>gt,clone:()=>lt,copy:()=>ft,create:()=>ht,cross:()=>St,dist:()=>Kt,distance:()=>Tt,div:()=>Qt,divide:()=>pt,dot:()=>Ot,equals:()=>kt,exactEquals:()=>Wt,floor:()=>bt,forEach:()=>ne,fromValues:()=>ct,hermite:()=>Vt,inverse:()=>Nt,len:()=>te,length:()=>ut,lerp:()=>_t,max:()=>wt,min:()=>xt,mul:()=>Zt,multiply:()=>Mt,negate:()=>Lt,normalize:()=>Pt,random:()=>Yt,rotateX:()=>Ft,rotateY:()=>zt,rotateZ:()=>Ct,round:()=>Et,scale:()=>Rt,scaleAndAdd:()=>At,set:()=>mt,sqrDist:()=>Jt,sqrLen:()=>ee,squaredDistance:()=>yt,squaredLength:()=>It,str:()=>Ht,sub:()=>$t,subtract:()=>vt,transformMat3:()=>Bt,transformMat4:()=>Dt,transformQuat:()=>qt,zero:()=>Gt});var i={};n.r(i),n.d(i,{add:()=>Ve,calculateW:()=>me,clone:()=>Pe,conjugate:()=>xe,copy:()=>Se,create:()=>ie,dot:()=>De,equals:()=>He,exactEquals:()=>Ge,exp:()=>de,fromEuler:()=>Ee,fromMat3:()=>we,fromValues:()=>Oe,getAngle:()=>he,getAxisAngle:()=>oe,identity:()=>ae,invert:()=>be,len:()=>Fe,length:()=>qe,lerp:()=>Be,ln:()=>ve,mul:()=>Ue,multiply:()=>le,normalize:()=>Xe,pow:()=>Me,random:()=>ge,rotateX:()=>ue,rotateY:()=>ce,rotateZ:()=>fe,rotationTo:()=>We,scale:()=>Ye,set:()=>_e,setAxes:()=>je,setAxisAngle:()=>se,slerp:()=>pe,sqlerp:()=>ke,sqrLen:()=>Ce,squaredLength:()=>ze,str:()=>Re});var a={};n.r(a),n.d(a,{add:()=>bn,clone:()=>Ze,conjugate:()=>yn,copy:()=>rn,create:()=>$e,dot:()=>Rn,equals:()=>Vn,exactEquals:()=>_n,fromMat4:()=>nn,fromRotation:()=>en,fromRotationTranslation:()=>Je,fromRotationTranslationValues:()=>Ke,fromTranslation:()=>tn,fromValues:()=>Qe,getDual:()=>hn,getReal:()=>on,getTranslation:()=>cn,identity:()=>an,invert:()=>Tn,len:()=>Ln,length:()=>In,lerp:()=>An,mul:()=>wn,multiply:()=>xn,normalize:()=>On,rotateAroundAxis:()=>gn,rotateByQuatAppend:()=>Mn,rotateByQuatPrepend:()=>pn,rotateX:()=>mn,rotateY:()=>dn,rotateZ:()=>vn,scale:()=>En,set:()=>sn,setDual:()=>un,setReal:()=>ln,sqrLen:()=>Pn,squaredLength:()=>Nn,str:()=>Sn,translate:()=>fn});var s={};n.r(s),n.d(s,{add:()=>Fn,angle:()=>mr,ceil:()=>Gn,clone:()=>Yn,copy:()=>Bn,create:()=>Un,cross:()=>ar,dist:()=>Er,distance:()=>Qn,div:()=>wr,divide:()=>Xn,dot:()=>ir,equals:()=>pr,exactEquals:()=>Mr,floor:()=>Hn,forEach:()=>Tr,fromValues:()=>Dn,inverse:()=>nr,len:()=>gr,length:()=>Jn,lerp:()=>sr,max:()=>kn,min:()=>Wn,mul:()=>xr,multiply:()=>Cn,negate:()=>er,normalize:()=>rr,random:()=>or,rotate:()=>fr,round:()=>jn,scale:()=>$n,scaleAndAdd:()=>Zn,set:()=>qn,sqrDist:()=>Rr,sqrLen:()=>Ar,squaredDistance:()=>Kn,squaredLength:()=>tr,str:()=>vr,sub:()=>br,subtract:()=>zn,transformMat2:()=>hr,transformMat2d:()=>lr,transformMat3:()=>ur,transformMat4:()=>cr,zero:()=>dr});var o={};n.r(o),n.d(o,{glMatrix:()=>h,mat2:()=>t,mat2d:()=>e,mat3:()=>st,mat4:()=>ot,quat:()=>i,quat2:()=>a,vec2:()=>s,vec3:()=>r,vec4:()=>re});var h=n(823);function l(){var t=new h.ARRAY_TYPE(4);return h.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function u(t){var e=new h.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function c(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function f(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function m(t,e,n,r){var i=new h.ARRAY_TYPE(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i}function d(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function v(t,e){if(t===e){var n=e[1];t[1]=e[2],t[2]=n}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function M(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=n*a-i*r;return s?(s=1/s,t[0]=a*s,t[1]=-r*s,t[2]=-i*s,t[3]=n*s,t):null}function p(t,e){var n=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=n,t}function g(t){return t[0]*t[3]-t[2]*t[1]}function b(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=n[0],h=n[1],l=n[2],u=n[3];return t[0]=r*o+a*h,t[1]=i*o+s*h,t[2]=r*l+a*u,t[3]=i*l+s*u,t}function x(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(n),h=Math.cos(n);return t[0]=r*h+a*o,t[1]=i*h+s*o,t[2]=r*-o+a*h,t[3]=i*-o+s*h,t}function w(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=n[0],h=n[1];return t[0]=r*o,t[1]=i*o,t[2]=a*h,t[3]=s*h,t}function E(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=-n,t[3]=r,t}function R(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function A(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function T(t){return Math.hypot(t[0],t[1],t[2],t[3])}function y(t,e,n,r){return t[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-t[2]*n[1],[t,e,n]}function I(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t}function L(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t}function N(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function P(t,e){var n=t[0],r=t[1],i=t[2],a=t[3],s=e[0],o=e[1],l=e[2],u=e[3];return Math.abs(n-s)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-o)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-l)<=h.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(a-u)<=h.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))}function O(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function S(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t}var _=b,V=L;function U(){var t=new h.ARRAY_TYPE(6);return h.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}function Y(t){var e=new h.ARRAY_TYPE(6);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}function D(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}function B(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function q(t,e,n,r,i,a){var s=new h.ARRAY_TYPE(6);return s[0]=t,s[1]=e,s[2]=n,s[3]=r,s[4]=i,s[5]=a,s}function F(t,e,n,r,i,a,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t}function z(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],h=n*a-r*i;return h?(h=1/h,t[0]=a*h,t[1]=-r*h,t[2]=-i*h,t[3]=n*h,t[4]=(i*o-a*s)*h,t[5]=(r*s-n*o)*h,t):null}function C(t){return t[0]*t[3]-t[1]*t[2]}function X(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=n[0],u=n[1],c=n[2],f=n[3],m=n[4],d=n[5];return t[0]=r*l+a*u,t[1]=i*l+s*u,t[2]=r*c+a*f,t[3]=i*c+s*f,t[4]=r*m+a*d+o,t[5]=i*m+s*d+h,t}function G(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=Math.sin(n),u=Math.cos(n);return t[0]=r*u+a*l,t[1]=i*u+s*l,t[2]=r*-l+a*u,t[3]=i*-l+s*u,t[4]=o,t[5]=h,t}function H(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=n[0],u=n[1];return t[0]=r*l,t[1]=i*l,t[2]=a*u,t[3]=s*u,t[4]=o,t[5]=h,t}function W(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=e[4],h=e[5],l=n[0],u=n[1];return t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=r*l+a*u+o,t[5]=i*l+s*u+h,t}function k(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=-n,t[3]=r,t[4]=0,t[5]=0,t}function j(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t}function $(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t}function Z(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}function Q(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)}function K(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t}function J(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t}function tt(t,e,n){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]*n,t[5]=e[5]*n,t}function et(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t}function nt(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]}function rt(t,e){var n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],o=t[5],l=e[0],u=e[1],c=e[2],f=e[3],m=e[4],d=e[5];return Math.abs(n-l)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(r-u)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-c)<=h.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(a-f)<=h.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(s-m)<=h.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(o-d)<=h.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))}var it=X,at=J,st=n(409),ot=n(684);function ht(){var t=new h.ARRAY_TYPE(3);return h.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function lt(t){var e=new h.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ut(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function ct(t,e,n){var r=new h.ARRAY_TYPE(3);return r[0]=t,r[1]=e,r[2]=n,r}function ft(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function mt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function dt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function vt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Mt(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function pt(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t}function gt(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function bt(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function xt(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}function wt(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}function Et(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function Rt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function At(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t}function Tt(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)}function yt(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}function It(t){var e=t[0],n=t[1],r=t[2];return e*e+n*n+r*r}function Lt(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Nt(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Pt(t,e){var n=e[0],r=e[1],i=e[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function Ot(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function St(t,e,n){var r=e[0],i=e[1],a=e[2],s=n[0],o=n[1],h=n[2];return t[0]=i*h-a*o,t[1]=a*s-r*h,t[2]=r*o-i*s,t}function _t(t,e,n,r){var i=e[0],a=e[1],s=e[2];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=s+r*(n[2]-s),t}function Vt(t,e,n,r,i,a){var s=a*a,o=s*(2*a-3)+1,h=s*(a-2)+a,l=s*(a-1),u=s*(3-2*a);return t[0]=e[0]*o+n[0]*h+r[0]*l+i[0]*u,t[1]=e[1]*o+n[1]*h+r[1]*l+i[1]*u,t[2]=e[2]*o+n[2]*h+r[2]*l+i[2]*u,t}function Ut(t,e,n,r,i,a){var s=1-a,o=s*s,h=a*a,l=o*s,u=3*a*o,c=3*h*s,f=h*a;return t[0]=e[0]*l+n[0]*u+r[0]*c+i[0]*f,t[1]=e[1]*l+n[1]*u+r[1]*c+i[1]*f,t[2]=e[2]*l+n[2]*u+r[2]*c+i[2]*f,t}function Yt(t,e){e=e||1;var n=2*h.RANDOM()*Math.PI,r=2*h.RANDOM()-1,i=Math.sqrt(1-r*r)*e;return t[0]=Math.cos(n)*i,t[1]=Math.sin(n)*i,t[2]=r*e,t}function Dt(t,e,n){var r=e[0],i=e[1],a=e[2],s=n[3]*r+n[7]*i+n[11]*a+n[15];return s=s||1,t[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/s,t[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/s,t[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/s,t}function Bt(t,e,n){var r=e[0],i=e[1],a=e[2];return t[0]=r*n[0]+i*n[3]+a*n[6],t[1]=r*n[1]+i*n[4]+a*n[7],t[2]=r*n[2]+i*n[5]+a*n[8],t}function qt(t,e,n){var r=n[0],i=n[1],a=n[2],s=n[3],o=e[0],h=e[1],l=e[2],u=i*l-a*h,c=a*o-r*l,f=r*h-i*o,m=i*f-a*c,d=a*u-r*f,v=r*c-i*u,M=2*s;return u*=M,c*=M,f*=M,m*=2,d*=2,v*=2,t[0]=o+u+m,t[1]=h+c+d,t[2]=l+f+v,t}function Ft(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t}function zt(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t}function Ct(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t}function Xt(t,e){var n=t[0],r=t[1],i=t[2],a=e[0],s=e[1],o=e[2],h=Math.sqrt(n*n+r*r+i*i)*Math.sqrt(a*a+s*s+o*o),l=h&&Ot(t,e)/h;return Math.acos(Math.min(Math.max(l,-1),1))}function Gt(t){return t[0]=0,t[1]=0,t[2]=0,t}function Ht(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function Wt(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function kt(t,e){var n=t[0],r=t[1],i=t[2],a=e[0],s=e[1],o=e[2];return Math.abs(n-a)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-o)<=h.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))}var jt,$t=vt,Zt=Mt,Qt=pt,Kt=Tt,Jt=yt,te=ut,ee=It,ne=(jt=ht(),function(t,e,n,r,i,a){var s,o;for(e||(e=3),n||(n=0),o=r?Math.min(r*e+n,t.length):t.length,s=n;s<o;s+=e)jt[0]=t[s],jt[1]=t[s+1],jt[2]=t[s+2],i(jt,jt,a),t[s]=jt[0],t[s+1]=jt[1],t[s+2]=jt[2];return t}),re=n(796);function ie(){var t=new h.ARRAY_TYPE(4);return h.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ae(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function se(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function oe(t,e){var n=2*Math.acos(e[3]),r=Math.sin(n/2);return r>h.EPSILON?(t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r):(t[0]=1,t[1]=0,t[2]=0),n}function he(t,e){var n=De(t,e);return Math.acos(2*n*n-1)}function le(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=n[0],h=n[1],l=n[2],u=n[3];return t[0]=r*u+s*o+i*l-a*h,t[1]=i*u+s*h+a*o-r*l,t[2]=a*u+s*l+r*h-i*o,t[3]=s*u-r*o-i*h-a*l,t}function ue(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(n),h=Math.cos(n);return t[0]=r*h+s*o,t[1]=i*h+a*o,t[2]=a*h-i*o,t[3]=s*h-r*o,t}function ce(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(n),h=Math.cos(n);return t[0]=r*h-a*o,t[1]=i*h+s*o,t[2]=a*h+r*o,t[3]=s*h-i*o,t}function fe(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(n),h=Math.cos(n);return t[0]=r*h+i*o,t[1]=i*h-r*o,t[2]=a*h+s*o,t[3]=s*h-a*o,t}function me(t,e){var n=e[0],r=e[1],i=e[2];return t[0]=n,t[1]=r,t[2]=i,t[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),t}function de(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=Math.sqrt(n*n+r*r+i*i),o=Math.exp(a),h=s>0?o*Math.sin(s)/s:0;return t[0]=n*h,t[1]=r*h,t[2]=i*h,t[3]=o*Math.cos(s),t}function ve(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=Math.sqrt(n*n+r*r+i*i),o=s>0?Math.atan2(s,a)/s:0;return t[0]=n*o,t[1]=r*o,t[2]=i*o,t[3]=.5*Math.log(n*n+r*r+i*i+a*a),t}function Me(t,e,n){return ve(t,e),Ye(t,t,n),de(t,t),t}function pe(t,e,n,r){var i,a,s,o,l,u=e[0],c=e[1],f=e[2],m=e[3],d=n[0],v=n[1],M=n[2],p=n[3];return(a=u*d+c*v+f*M+m*p)<0&&(a=-a,d=-d,v=-v,M=-M,p=-p),1-a>h.EPSILON?(i=Math.acos(a),s=Math.sin(i),o=Math.sin((1-r)*i)/s,l=Math.sin(r*i)/s):(o=1-r,l=r),t[0]=o*u+l*d,t[1]=o*c+l*v,t[2]=o*f+l*M,t[3]=o*m+l*p,t}function ge(t){var e=h.RANDOM(),n=h.RANDOM(),r=h.RANDOM(),i=Math.sqrt(1-e),a=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*n),t[1]=i*Math.cos(2*Math.PI*n),t[2]=a*Math.sin(2*Math.PI*r),t[3]=a*Math.cos(2*Math.PI*r),t}function be(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],s=n*n+r*r+i*i+a*a,o=s?1/s:0;return t[0]=-n*o,t[1]=-r*o,t[2]=-i*o,t[3]=a*o,t}function xe(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function we(t,e){var n,r=e[0]+e[4]+e[8];if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,s=(i+2)%3;n=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*s+s]+1),t[i]=.5*n,n=.5/n,t[3]=(e[3*a+s]-e[3*s+a])*n,t[a]=(e[3*a+i]+e[3*i+a])*n,t[s]=(e[3*s+i]+e[3*i+s])*n}return t}function Ee(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var a=Math.sin(e),s=Math.cos(e),o=Math.sin(n),h=Math.cos(n),l=Math.sin(r),u=Math.cos(r);return t[0]=a*h*u-s*o*l,t[1]=s*o*u+a*h*l,t[2]=s*h*l-a*o*u,t[3]=s*h*u+a*o*l,t}function Re(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var Ae,Te,ye,Ie,Le,Ne,Pe=re.clone,Oe=re.fromValues,Se=re.copy,_e=re.set,Ve=re.add,Ue=le,Ye=re.scale,De=re.dot,Be=re.lerp,qe=re.length,Fe=qe,ze=re.squaredLength,Ce=ze,Xe=re.normalize,Ge=re.exactEquals,He=re.equals,We=(Ae=ht(),Te=ct(1,0,0),ye=ct(0,1,0),function(t,e,n){var r=Ot(e,n);return r<-.999999?(St(Ae,Te,e),te(Ae)<1e-6&&St(Ae,ye,e),Pt(Ae,Ae),se(t,Ae,Math.PI),t):r>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(St(Ae,e,n),t[0]=Ae[0],t[1]=Ae[1],t[2]=Ae[2],t[3]=1+r,Xe(t,t))}),ke=(Ie=ie(),Le=ie(),function(t,e,n,r,i,a){return pe(Ie,e,i,a),pe(Le,n,r,a),pe(t,Ie,Le,2*a*(1-a)),t}),je=(Ne=st.create(),function(t,e,n,r){return Ne[0]=n[0],Ne[3]=n[1],Ne[6]=n[2],Ne[1]=r[0],Ne[4]=r[1],Ne[7]=r[2],Ne[2]=-e[0],Ne[5]=-e[1],Ne[8]=-e[2],Xe(t,we(t,Ne))});function $e(){var t=new h.ARRAY_TYPE(8);return h.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t}function Ze(t){var e=new h.ARRAY_TYPE(8);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}function Qe(t,e,n,r,i,a,s,o){var l=new h.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=n,l[3]=r,l[4]=i,l[5]=a,l[6]=s,l[7]=o,l}function Ke(t,e,n,r,i,a,s){var o=new h.ARRAY_TYPE(8);o[0]=t,o[1]=e,o[2]=n,o[3]=r;var l=.5*i,u=.5*a,c=.5*s;return o[4]=l*r+u*n-c*e,o[5]=u*r+c*t-l*n,o[6]=c*r+l*e-u*t,o[7]=-l*t-u*e-c*n,o}function Je(t,e,n){var r=.5*n[0],i=.5*n[1],a=.5*n[2],s=e[0],o=e[1],h=e[2],l=e[3];return t[0]=s,t[1]=o,t[2]=h,t[3]=l,t[4]=r*l+i*h-a*o,t[5]=i*l+a*s-r*h,t[6]=a*l+r*o-i*s,t[7]=-r*s-i*o-a*h,t}function tn(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t}function en(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function nn(t,e){var n=ie();ot.getRotation(n,e);var r=new h.ARRAY_TYPE(3);return ot.getTranslation(r,e),Je(t,n,r),t}function rn(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}function an(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function sn(t,e,n,r,i,a,s,o,h){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=h,t}var on=Se;function hn(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t}var ln=Se;function un(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t}function cn(t,e){var n=e[4],r=e[5],i=e[6],a=e[7],s=-e[0],o=-e[1],h=-e[2],l=e[3];return t[0]=2*(n*l+a*s+r*h-i*o),t[1]=2*(r*l+a*o+i*s-n*h),t[2]=2*(i*l+a*h+n*o-r*s),t}function fn(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=.5*n[0],h=.5*n[1],l=.5*n[2],u=e[4],c=e[5],f=e[6],m=e[7];return t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=s*o+i*l-a*h+u,t[5]=s*h+a*o-r*l+c,t[6]=s*l+r*h-i*o+f,t[7]=-r*o-i*h-a*l+m,t}function mn(t,e,n){var r=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=o*s+u*r+h*a-l*i,f=h*s+u*i+l*r-o*a,m=l*s+u*a+o*i-h*r,d=u*s-o*r-h*i-l*a;return ue(t,e,n),r=t[0],i=t[1],a=t[2],s=t[3],t[4]=c*s+d*r+f*a-m*i,t[5]=f*s+d*i+m*r-c*a,t[6]=m*s+d*a+c*i-f*r,t[7]=d*s-c*r-f*i-m*a,t}function dn(t,e,n){var r=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=o*s+u*r+h*a-l*i,f=h*s+u*i+l*r-o*a,m=l*s+u*a+o*i-h*r,d=u*s-o*r-h*i-l*a;return ce(t,e,n),r=t[0],i=t[1],a=t[2],s=t[3],t[4]=c*s+d*r+f*a-m*i,t[5]=f*s+d*i+m*r-c*a,t[6]=m*s+d*a+c*i-f*r,t[7]=d*s-c*r-f*i-m*a,t}function vn(t,e,n){var r=-e[0],i=-e[1],a=-e[2],s=e[3],o=e[4],h=e[5],l=e[6],u=e[7],c=o*s+u*r+h*a-l*i,f=h*s+u*i+l*r-o*a,m=l*s+u*a+o*i-h*r,d=u*s-o*r-h*i-l*a;return fe(t,e,n),r=t[0],i=t[1],a=t[2],s=t[3],t[4]=c*s+d*r+f*a-m*i,t[5]=f*s+d*i+m*r-c*a,t[6]=m*s+d*a+c*i-f*r,t[7]=d*s-c*r-f*i-m*a,t}function Mn(t,e,n){var r=n[0],i=n[1],a=n[2],s=n[3],o=e[0],h=e[1],l=e[2],u=e[3];return t[0]=o*s+u*r+h*a-l*i,t[1]=h*s+u*i+l*r-o*a,t[2]=l*s+u*a+o*i-h*r,t[3]=u*s-o*r-h*i-l*a,o=e[4],h=e[5],l=e[6],u=e[7],t[4]=o*s+u*r+h*a-l*i,t[5]=h*s+u*i+l*r-o*a,t[6]=l*s+u*a+o*i-h*r,t[7]=u*s-o*r-h*i-l*a,t}function pn(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=n[0],h=n[1],l=n[2],u=n[3];return t[0]=r*u+s*o+i*l-a*h,t[1]=i*u+s*h+a*o-r*l,t[2]=a*u+s*l+r*h-i*o,t[3]=s*u-r*o-i*h-a*l,o=n[4],h=n[5],l=n[6],u=n[7],t[4]=r*u+s*o+i*l-a*h,t[5]=i*u+s*h+a*o-r*l,t[6]=a*u+s*l+r*h-i*o,t[7]=s*u-r*o-i*h-a*l,t}function gn(t,e,n,r){if(Math.abs(r)<h.EPSILON)return rn(t,e);var i=Math.hypot(n[0],n[1],n[2]);r*=.5;var a=Math.sin(r),s=a*n[0]/i,o=a*n[1]/i,l=a*n[2]/i,u=Math.cos(r),c=e[0],f=e[1],m=e[2],d=e[3];t[0]=c*u+d*s+f*l-m*o,t[1]=f*u+d*o+m*s-c*l,t[2]=m*u+d*l+c*o-f*s,t[3]=d*u-c*s-f*o-m*l;var v=e[4],M=e[5],p=e[6],g=e[7];return t[4]=v*u+g*s+M*l-p*o,t[5]=M*u+g*o+p*s-v*l,t[6]=p*u+g*l+v*o-M*s,t[7]=g*u-v*s-M*o-p*l,t}function bn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t}function xn(t,e,n){var r=e[0],i=e[1],a=e[2],s=e[3],o=n[4],h=n[5],l=n[6],u=n[7],c=e[4],f=e[5],m=e[6],d=e[7],v=n[0],M=n[1],p=n[2],g=n[3];return t[0]=r*g+s*v+i*p-a*M,t[1]=i*g+s*M+a*v-r*p,t[2]=a*g+s*p+r*M-i*v,t[3]=s*g-r*v-i*M-a*p,t[4]=r*u+s*o+i*l-a*h+c*g+d*v+f*p-m*M,t[5]=i*u+s*h+a*o-r*l+f*g+d*M+m*v-c*p,t[6]=a*u+s*l+r*h-i*o+m*g+d*p+c*M-f*v,t[7]=s*u-r*o-i*h-a*l+d*g-c*v-f*M-m*p,t}var wn=xn;function En(t,e,n){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]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t}var Rn=De;function An(t,e,n,r){var i=1-r;return Rn(e,n)<0&&(r=-r),t[0]=e[0]*i+n[0]*r,t[1]=e[1]*i+n[1]*r,t[2]=e[2]*i+n[2]*r,t[3]=e[3]*i+n[3]*r,t[4]=e[4]*i+n[4]*r,t[5]=e[5]*i+n[5]*r,t[6]=e[6]*i+n[6]*r,t[7]=e[7]*i+n[7]*r,t}function Tn(t,e){var n=Nn(e);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]/n,t[5]=-e[5]/n,t[6]=-e[6]/n,t[7]=e[7]/n,t}function yn(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}var In=qe,Ln=In,Nn=ze,Pn=Nn;function On(t,e){var n=Nn(e);if(n>0){n=Math.sqrt(n);var r=e[0]/n,i=e[1]/n,a=e[2]/n,s=e[3]/n,o=e[4],h=e[5],l=e[6],u=e[7],c=r*o+i*h+a*l+s*u;t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=(o-r*c)/n,t[5]=(h-i*c)/n,t[6]=(l-a*c)/n,t[7]=(u-s*c)/n}return t}function Sn(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"}function _n(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]}function Vn(t,e){var n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],o=t[5],l=t[6],u=t[7],c=e[0],f=e[1],m=e[2],d=e[3],v=e[4],M=e[5],p=e[6],g=e[7];return Math.abs(n-c)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(r-f)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(f))&&Math.abs(i-m)<=h.EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(a-d)<=h.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(s-v)<=h.EPSILON*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(o-M)<=h.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(l-p)<=h.EPSILON*Math.max(1,Math.abs(l),Math.abs(p))&&Math.abs(u-g)<=h.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))}function Un(){var t=new h.ARRAY_TYPE(2);return h.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function Yn(t){var e=new h.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e}function Dn(t,e){var n=new h.ARRAY_TYPE(2);return n[0]=t,n[1]=e,n}function Bn(t,e){return t[0]=e[0],t[1]=e[1],t}function qn(t,e,n){return t[0]=e,t[1]=n,t}function Fn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function zn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t}function Cn(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t}function Xn(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t}function Gn(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function Hn(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function Wn(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t}function kn(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t}function jn(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function $n(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t}function Zn(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t}function Qn(t,e){var n=e[0]-t[0],r=e[1]-t[1];return Math.hypot(n,r)}function Kn(t,e){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function Jn(t){var e=t[0],n=t[1];return Math.hypot(e,n)}function tr(t){var e=t[0],n=t[1];return e*e+n*n}function er(t,e){return t[0]=-e[0],t[1]=-e[1],t}function nr(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function rr(t,e){var n=e[0],r=e[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function ir(t,e){return t[0]*e[0]+t[1]*e[1]}function ar(t,e,n){var r=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=r,t}function sr(t,e,n,r){var i=e[0],a=e[1];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t}function or(t,e){e=e||1;var n=2*h.RANDOM()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t}function hr(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i,t[1]=n[1]*r+n[3]*i,t}function lr(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i+n[4],t[1]=n[1]*r+n[3]*i+n[5],t}function ur(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[3]*i+n[6],t[1]=n[1]*r+n[4]*i+n[7],t}function cr(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t}function fr(t,e,n,r){var i=e[0]-n[0],a=e[1]-n[1],s=Math.sin(r),o=Math.cos(r);return t[0]=i*o-a*s+n[0],t[1]=i*s+a*o+n[1],t}function mr(t,e){var n=t[0],r=t[1],i=e[0],a=e[1],s=Math.sqrt(n*n+r*r)*Math.sqrt(i*i+a*a),o=s&&(n*i+r*a)/s;return Math.acos(Math.min(Math.max(o,-1),1))}function dr(t){return t[0]=0,t[1]=0,t}function vr(t){return"vec2("+t[0]+", "+t[1]+")"}function Mr(t,e){return t[0]===e[0]&&t[1]===e[1]}function pr(t,e){var n=t[0],r=t[1],i=e[0],a=e[1];return Math.abs(n-i)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-a)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))}var gr=Jn,br=zn,xr=Cn,wr=Xn,Er=Qn,Rr=Kn,Ar=tr,Tr=function(){var t=Un();return function(e,n,r,i,a,s){var o,h;for(n||(n=2),r||(r=0),h=i?Math.min(i*n+r,e.length):e.length,o=r;o<h;o+=n)t[0]=e[o],t[1]=e[o+1],a(t,t,s),e[o]=t[0],e[o+1]=t[1];return e}}();globalThis.glmat=o})()})();