@splinetool/loader 0.9.72 → 0.9.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,542 +1,607 @@
1
- var Xm=Object.create;var va=Object.defineProperty;var Km=Object.getOwnPropertyDescriptor;var Ym=Object.getOwnPropertyNames;var Jm=Object.getPrototypeOf,Qm=Object.prototype.hasOwnProperty;var Zm=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),ef=(i,t)=>{for(var e in t)va(i,e,{get:t[e],enumerable:!0})},tf=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ym(t))!Qm.call(i,o)&&o!==e&&va(i,o,{get:()=>t[o],enumerable:!(r=Km(t,o))||r.enumerable});return i};var rf=(i,t,e)=>(e=i!=null?Xm(Jm(i)):{},tf(t||!i||!i.__esModule?va(e,"default",{value:i,enumerable:!0}):e,i));var wm=Zm((ya,Sm)=>{(function(i,t){typeof ya=="object"&&typeof Sm<"u"?t(ya):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(ya,function(i){"use strict";i.SVD=function(t,e,r,o,n){if(e=e===void 0||e,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var s,a,l,c,h,p,u,d,m,g,x,y,v=t[0].length,P=t.length;if(P<v)throw new TypeError("Invalid matrix: m < n");for(var S=[],b=[],B=[],w=e==="f"?P:v,f=g=u=0;f<P;f++)b[f]=new Array(w).fill(0);for(f=0;f<v;f++)B[f]=new Array(v).fill(0);var D,C=new Array(v).fill(0);for(f=0;f<P;f++)for(s=0;s<v;s++)b[f][s]=t[f][s];for(f=0;f<v;f++){for(S[f]=u,m=0,l=f+1,s=f;s<P;s++)m+=Math.pow(b[s][f],2);if(m<n)u=0;else for(d=(p=b[f][f])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,b[f][f]=p-u,s=l;s<v;s++){for(m=0,a=f;a<P;a++)m+=b[a][f]*b[a][s];for(p=m/d,a=f;a<P;a++)b[a][s]=b[a][s]+p*b[a][f]}for(C[f]=u,m=0,s=l;s<v;s++)m+=Math.pow(b[f][s],2);if(m<n)u=0;else{for(d=(p=b[f][f+1])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,b[f][f+1]=p-u,s=l;s<v;s++)S[s]=b[f][s]/d;for(s=l;s<P;s++){for(m=0,a=l;a<v;a++)m+=b[s][a]*b[f][a];for(a=l;a<v;a++)b[s][a]=b[s][a]+m*S[a]}}g<(x=Math.abs(C[f])+Math.abs(S[f]))&&(g=x)}if(r)for(f=v-1;0<=f;f--){if(u!==0){for(d=b[f][f+1]*u,s=l;s<v;s++)B[s][f]=b[f][s]/d;for(s=l;s<v;s++){for(m=0,a=l;a<v;a++)m+=b[f][a]*B[a][s];for(a=l;a<v;a++)B[a][s]=B[a][s]+m*B[a][f]}}for(s=l;s<v;s++)B[f][s]=0,B[s][f]=0;B[f][f]=1,u=S[f],l=f}if(e){if(e==="f")for(f=v;f<P;f++){for(s=v;s<P;s++)b[f][s]=0;b[f][f]=1}for(f=v-1;0<=f;f--){for(l=f+1,u=C[f],s=l;s<w;s++)b[f][s]=0;if(u!==0){for(d=b[f][f]*u,s=l;s<w;s++){for(m=0,a=l;a<P;a++)m+=b[a][f]*b[a][s];for(p=m/d,a=f;a<P;a++)b[a][s]=b[a][s]+p*b[a][f]}for(s=f;s<P;s++)b[s][f]=b[s][f]/u}else for(s=f;s<P;s++)b[s][f]=0;b[f][f]=b[f][f]+1}}for(o*=g,a=v-1;0<=a;a--)for(var I=0;I<50;I++){for(D=!1,l=a;0<=l;l--){if(Math.abs(S[l])<=o){D=!0;break}if(Math.abs(C[l-1])<=o)break}if(!D){for(h=0,c=l-(m=1),f=l;f<a+1&&(p=m*S[f],S[f]=h*S[f],!(Math.abs(p)<=o));f++)if(u=C[f],C[f]=Math.sqrt(p*p+u*u),h=u/(d=C[f]),m=-p/d,e)for(s=0;s<P;s++)x=b[s][c],y=b[s][f],b[s][c]=x*h+y*m,b[s][f]=-x*m+y*h}if(y=C[a],l===a){if(y<0&&(C[a]=-y,r))for(s=0;s<v;s++)B[s][a]=-B[s][a];break}for(g=C[l],p=(((x=C[a-1])-y)*(x+y)+((u=S[a-1])-(d=S[a]))*(u+d))/(2*d*x),u=Math.sqrt(p*p+1),p=((g-y)*(g+y)+d*(x/(p<0?p-u:p+u)-d))/g,f=l+(m=h=1);f<a+1;f++){if(u=S[f],x=C[f],d=m*u,u*=h,y=Math.sqrt(p*p+d*d),p=g*(h=p/(S[f-1]=y))+u*(m=d/y),u=-g*m+u*h,d=x*m,x*=h,r)for(s=0;s<v;s++)g=B[s][f-1],y=B[s][f],B[s][f-1]=g*h+y*m,B[s][f]=-g*m+y*h;if(y=Math.sqrt(p*p+d*d),p=(h=p/(C[f-1]=y))*u+(m=d/y)*x,g=-m*u+h*x,e)for(s=0;s<P;s++)x=b[s][f-1],y=b[s][f],b[s][f-1]=x*h+y*m,b[s][f]=-x*m+y*h}S[l]=0,S[a]=p,C[a]=g}for(f=0;f<v;f++)C[f]<o&&(C[f]=0);return{u:b,q:C,v:B}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as z1,Loader as V1}from"three";function gc(i){return Array.isArray(i)?i:[i]}var of=typeof global=="object"&&global&&global.Object===Object&&global,bi=of;var nf=typeof self=="object"&&self&&self.Object===Object&&self,sf=bi||nf||Function("return this")(),Ve=sf;var af=Ve.Symbol,it=af;var yc=Object.prototype,lf=yc.hasOwnProperty,cf=yc.toString,Sn=it?it.toStringTag:void 0;function hf(i){var t=lf.call(i,Sn),e=i[Sn];try{i[Sn]=void 0;var r=!0}catch{}var o=cf.call(i);return r&&(t?i[Sn]=e:delete i[Sn]),o}var xc=hf;var pf=Object.prototype,uf=pf.toString;function df(i){return uf.call(i)}var vc=df;var mf="[object Null]",ff="[object Undefined]",bc=it?it.toStringTag:void 0;function gf(i){return i==null?i===void 0?ff:mf:bc&&bc in Object(i)?xc(i):vc(i)}var gt=gf;function yf(i){return i!=null&&typeof i=="object"}var Ze=yf;var xf="[object Symbol]";function vf(i){return typeof i=="symbol"||Ze(i)&&gt(i)==xf}var lo=vf;function bf(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var Si=bf;var Sf=Array.isArray,Fe=Sf;var wf=1/0,Sc=it?it.prototype:void 0,wc=Sc?Sc.toString:void 0;function Nc(i){if(typeof i=="string")return i;if(Fe(i))return Si(i,Nc)+"";if(lo(i))return wc?wc.call(i):"";var t=i+"";return t=="0"&&1/i==-wf?"-0":t}var Cc=Nc;function Nf(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var et=Nf;function Cf(i){return i}var wi=Cf;var Tf="[object AsyncFunction]",Lf="[object Function]",If="[object GeneratorFunction]",Pf="[object Proxy]";function Mf(i){if(!et(i))return!1;var t=gt(i);return t==Lf||t==If||t==Tf||t==Pf}var co=Mf;var Af=Ve["__core-js_shared__"],Ni=Af;var Tc=function(){var i=/[^.]+$/.exec(Ni&&Ni.keys&&Ni.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Of(i){return!!Tc&&Tc in i}var Lc=Of;var Df=Function.prototype,_f=Df.toString;function Bf(i){if(i!=null){try{return _f.call(i)}catch{}try{return i+""}catch{}}return""}var ur=Bf;var Ef=/[\\^$.*+?()[\]{}|]/g,Gf=/^\[object .+?Constructor\]$/,Rf=Function.prototype,zf=Object.prototype,Vf=Rf.toString,Ff=zf.hasOwnProperty,Uf=RegExp("^"+Vf.call(Ff).replace(Ef,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function jf(i){if(!et(i)||Lc(i))return!1;var t=co(i)?Uf:Gf;return t.test(ur(i))}var Ic=jf;function kf(i,t){return i?.[t]}var Pc=kf;function Hf(i,t){var e=Pc(i,t);return Ic(e)?e:void 0}var ht=Hf;var Wf=ht(Ve,"WeakMap"),Ci=Wf;var Mc=Object.create,qf=function(){function i(){}return function(t){if(!et(t))return{};if(Mc)return Mc(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Ac=qf;function $f(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Oc=$f;function Xf(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Ti=Xf;var Kf=800,Yf=16,Jf=Date.now;function Qf(i){var t=0,e=0;return function(){var r=Jf(),o=Yf-(r-e);if(e=r,o>0){if(++t>=Kf)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Dc=Qf;function Zf(i){return function(){return i}}var _c=Zf;var eg=function(){try{var i=ht(Object,"defineProperty");return i({},"",{}),i}catch{}}(),ho=eg;var tg=ho?function(i,t){return ho(i,"toString",{configurable:!0,enumerable:!1,value:_c(t),writable:!0})}:wi,Bc=tg;var rg=Dc(Bc),Li=rg;function og(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Ec=og;var ng=9007199254740991,ig=/^(?:0|[1-9]\d*)$/;function sg(i,t){var e=typeof i;return t=t??ng,!!t&&(e=="number"||e!="symbol"&&ig.test(i))&&i>-1&&i%1==0&&i<t}var Ii=sg;function ag(i,t,e){t=="__proto__"&&ho?ho(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var po=ag;function lg(i,t){return i===t||i!==i&&t!==t}var Lr=lg;var cg=Object.prototype,hg=cg.hasOwnProperty;function pg(i,t,e){var r=i[t];(!(hg.call(i,t)&&Lr(r,e))||e===void 0&&!(t in i))&&po(i,t,e)}var Pi=pg;function ug(i,t,e,r){var o=!e;e||(e={});for(var n=-1,s=t.length;++n<s;){var a=t[n],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),o?po(e,a,l):Pi(e,a,l)}return e}var Ct=ug;var Gc=Math.max;function dg(i,t,e){return t=Gc(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Gc(r.length-t,0),s=Array(n);++o<n;)s[o]=r[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=r[o];return a[t]=e(s),Oc(i,this,a)}}var Mi=dg;function mg(i,t){return Li(Mi(i,t,wi),i+"")}var Rc=mg;var fg=9007199254740991;function gg(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=fg}var Ai=gg;function yg(i){return i!=null&&Ai(i.length)&&!co(i)}var Ir=yg;function xg(i,t,e){if(!et(e))return!1;var r=typeof t;return(r=="number"?Ir(e)&&Ii(t,e.length):r=="string"&&t in e)?Lr(e[t],i):!1}var zc=xg;function vg(i){return Rc(function(t,e){var r=-1,o=e.length,n=o>1?e[o-1]:void 0,s=o>2?e[2]:void 0;for(n=i.length>3&&typeof n=="function"?(o--,n):void 0,s&&zc(e[0],e[1],s)&&(n=o<3?void 0:n,o=1),t=Object(t);++r<o;){var a=e[r];a&&i(t,a,r,n)}return t})}var Vc=vg;var bg=Object.prototype;function Sg(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||bg;return i===e}var uo=Sg;function wg(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Fc=wg;var Ng="[object Arguments]";function Cg(i){return Ze(i)&&gt(i)==Ng}var ba=Cg;var Uc=Object.prototype,Tg=Uc.hasOwnProperty,Lg=Uc.propertyIsEnumerable,Ig=ba(function(){return arguments}())?ba:function(i){return Ze(i)&&Tg.call(i,"callee")&&!Lg.call(i,"callee")},Wr=Ig;function Pg(){return!1}var jc=Pg;var Wc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,kc=Wc&&typeof module=="object"&&module&&!module.nodeType&&module,Mg=kc&&kc.exports===Wc,Hc=Mg?Ve.Buffer:void 0,Ag=Hc?Hc.isBuffer:void 0,Og=Ag||jc,mo=Og;var Dg="[object Arguments]",_g="[object Array]",Bg="[object Boolean]",Eg="[object Date]",Gg="[object Error]",Rg="[object Function]",zg="[object Map]",Vg="[object Number]",Fg="[object Object]",Ug="[object RegExp]",jg="[object Set]",kg="[object String]",Hg="[object WeakMap]",Wg="[object ArrayBuffer]",qg="[object DataView]",$g="[object Float32Array]",Xg="[object Float64Array]",Kg="[object Int8Array]",Yg="[object Int16Array]",Jg="[object Int32Array]",Qg="[object Uint8Array]",Zg="[object Uint8ClampedArray]",ey="[object Uint16Array]",ty="[object Uint32Array]",Pe={};Pe[$g]=Pe[Xg]=Pe[Kg]=Pe[Yg]=Pe[Jg]=Pe[Qg]=Pe[Zg]=Pe[ey]=Pe[ty]=!0;Pe[Dg]=Pe[_g]=Pe[Wg]=Pe[Bg]=Pe[qg]=Pe[Eg]=Pe[Gg]=Pe[Rg]=Pe[zg]=Pe[Vg]=Pe[Fg]=Pe[Ug]=Pe[jg]=Pe[kg]=Pe[Hg]=!1;function ry(i){return Ze(i)&&Ai(i.length)&&!!Pe[gt(i)]}var qc=ry;function oy(i){return function(t){return i(t)}}var fo=oy;var $c=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wn=$c&&typeof module=="object"&&module&&!module.nodeType&&module,ny=wn&&wn.exports===$c,Sa=ny&&bi.process,iy=function(){try{var i=wn&&wn.require&&wn.require("util").types;return i||Sa&&Sa.binding&&Sa.binding("util")}catch{}}(),dr=iy;var Xc=dr&&dr.isTypedArray,sy=Xc?fo(Xc):qc,Oi=sy;var ay=Object.prototype,ly=ay.hasOwnProperty;function cy(i,t){var e=Fe(i),r=!e&&Wr(i),o=!e&&!r&&mo(i),n=!e&&!r&&!o&&Oi(i),s=e||r||o||n,a=s?Fc(i.length,String):[],l=a.length;for(var c in i)(t||ly.call(i,c))&&!(s&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ii(c,l)))&&a.push(c);return a}var Di=cy;function hy(i,t){return function(e){return i(t(e))}}var _i=hy;var py=_i(Object.keys,Object),Kc=py;var uy=Object.prototype,dy=uy.hasOwnProperty;function my(i){if(!uo(i))return Kc(i);var t=[];for(var e in Object(i))dy.call(i,e)&&e!="constructor"&&t.push(e);return t}var Yc=my;function fy(i){return Ir(i)?Di(i):Yc(i)}var go=fy;function gy(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Jc=gy;var yy=Object.prototype,xy=yy.hasOwnProperty;function vy(i){if(!et(i))return Jc(i);var t=uo(i),e=[];for(var r in i)r=="constructor"&&(t||!xy.call(i,r))||e.push(r);return e}var Qc=vy;function by(i){return Ir(i)?Di(i,!0):Qc(i)}var qt=by;var Sy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,wy=/^\w*$/;function Ny(i,t){if(Fe(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||lo(i)?!0:wy.test(i)||!Sy.test(i)||t!=null&&i in Object(t)}var Zc=Ny;var Cy=ht(Object,"create"),mr=Cy;function Ty(){this.__data__=mr?mr(null):{},this.size=0}var eh=Ty;function Ly(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var th=Ly;var Iy="__lodash_hash_undefined__",Py=Object.prototype,My=Py.hasOwnProperty;function Ay(i){var t=this.__data__;if(mr){var e=t[i];return e===Iy?void 0:e}return My.call(t,i)?t[i]:void 0}var rh=Ay;var Oy=Object.prototype,Dy=Oy.hasOwnProperty;function _y(i){var t=this.__data__;return mr?t[i]!==void 0:Dy.call(t,i)}var oh=_y;var By="__lodash_hash_undefined__";function Ey(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=mr&&t===void 0?By:t,this}var nh=Ey;function yo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}yo.prototype.clear=eh;yo.prototype.delete=th;yo.prototype.get=rh;yo.prototype.has=oh;yo.prototype.set=nh;var wa=yo;function Gy(){this.__data__=[],this.size=0}var ih=Gy;function Ry(i,t){for(var e=i.length;e--;)if(Lr(i[e][0],t))return e;return-1}var Pr=Ry;var zy=Array.prototype,Vy=zy.splice;function Fy(i){var t=this.__data__,e=Pr(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Vy.call(t,e,1),--this.size,!0}var sh=Fy;function Uy(i){var t=this.__data__,e=Pr(t,i);return e<0?void 0:t[e][1]}var ah=Uy;function jy(i){return Pr(this.__data__,i)>-1}var lh=jy;function ky(i,t){var e=this.__data__,r=Pr(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var ch=ky;function xo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}xo.prototype.clear=ih;xo.prototype.delete=sh;xo.prototype.get=ah;xo.prototype.has=lh;xo.prototype.set=ch;var Mr=xo;var Hy=ht(Ve,"Map"),Ar=Hy;function Wy(){this.size=0,this.__data__={hash:new wa,map:new(Ar||Mr),string:new wa}}var hh=Wy;function qy(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var ph=qy;function $y(i,t){var e=i.__data__;return ph(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Or=$y;function Xy(i){var t=Or(this,i).delete(i);return this.size-=t?1:0,t}var uh=Xy;function Ky(i){return Or(this,i).get(i)}var dh=Ky;function Yy(i){return Or(this,i).has(i)}var mh=Yy;function Jy(i,t){var e=Or(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var fh=Jy;function vo(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}vo.prototype.clear=hh;vo.prototype.delete=uh;vo.prototype.get=dh;vo.prototype.has=mh;vo.prototype.set=fh;var Nn=vo;var Qy="Expected a function";function Na(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(Qy);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var s=i.apply(this,r);return e.cache=n.set(o,s)||n,s};return e.cache=new(Na.Cache||Nn),e}Na.Cache=Nn;var gh=Na;var Zy=500;function ex(i){var t=gh(i,function(r){return e.size===Zy&&e.clear(),r}),e=t.cache;return t}var yh=ex;var tx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rx=/\\(\\)?/g,ox=yh(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(tx,function(e,r,o,n){t.push(o?n.replace(rx,"$1"):r||e)}),t}),xh=ox;function nx(i){return i==null?"":Cc(i)}var vh=nx;function ix(i,t){return Fe(i)?i:Zc(i,t)?[i]:xh(vh(i))}var bo=ix;var sx=1/0;function ax(i){if(typeof i=="string"||lo(i))return i;var t=i+"";return t=="0"&&1/i==-sx?"-0":t}var Bi=ax;function lx(i,t){t=bo(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Bi(t[e++])];return e&&e==r?i:void 0}var bh=lx;function cx(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var So=cx;var Sh=it?it.isConcatSpreadable:void 0;function hx(i){return Fe(i)||Wr(i)||!!(Sh&&i&&i[Sh])}var wh=hx;function Nh(i,t,e,r,o){var n=-1,s=i.length;for(e||(e=wh),o||(o=[]);++n<s;){var a=i[n];t>0&&e(a)?t>1?Nh(a,t-1,e,r,o):So(o,a):r||(o[o.length]=a)}return o}var Ch=Nh;function px(i){var t=i==null?0:i.length;return t?Ch(i,1):[]}var Th=px;function ux(i){return Li(Mi(i,void 0,Th),i+"")}var Lh=ux;var dx=_i(Object.getPrototypeOf,Object),wo=dx;var mx="[object Object]",fx=Function.prototype,gx=Object.prototype,Ih=fx.toString,yx=gx.hasOwnProperty,xx=Ih.call(Object);function vx(i){if(!Ze(i)||gt(i)!=mx)return!1;var t=wo(i);if(t===null)return!0;var e=yx.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ih.call(e)==xx}var Ei=vx;function bx(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var Ph=bx;function Sx(){this.__data__=new Mr,this.size=0}var Mh=Sx;function wx(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var Ah=wx;function Nx(i){return this.__data__.get(i)}var Oh=Nx;function Cx(i){return this.__data__.has(i)}var Dh=Cx;var Tx=200;function Lx(i,t){var e=this.__data__;if(e instanceof Mr){var r=e.__data__;if(!Ar||r.length<Tx-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Nn(r)}return e.set(i,t),this.size=e.size,this}var _h=Lx;function No(i){var t=this.__data__=new Mr(i);this.size=t.size}No.prototype.clear=Mh;No.prototype.delete=Ah;No.prototype.get=Oh;No.prototype.has=Dh;No.prototype.set=_h;var Gi=No;function Ix(i,t){return i&&Ct(t,go(t),i)}var Bh=Ix;function Px(i,t){return i&&Ct(t,qt(t),i)}var Eh=Px;var Vh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gh=Vh&&typeof module=="object"&&module&&!module.nodeType&&module,Mx=Gh&&Gh.exports===Vh,Rh=Mx?Ve.Buffer:void 0,zh=Rh?Rh.allocUnsafe:void 0;function Ax(i,t){if(t)return i.slice();var e=i.length,r=zh?zh(e):new i.constructor(e);return i.copy(r),r}var Ri=Ax;function Ox(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var s=i[e];t(s,e,i)&&(n[o++]=s)}return n}var Fh=Ox;function Dx(){return[]}var zi=Dx;var _x=Object.prototype,Bx=_x.propertyIsEnumerable,Uh=Object.getOwnPropertySymbols,Ex=Uh?function(i){return i==null?[]:(i=Object(i),Fh(Uh(i),function(t){return Bx.call(i,t)}))}:zi,Co=Ex;function Gx(i,t){return Ct(i,Co(i),t)}var jh=Gx;var Rx=Object.getOwnPropertySymbols,zx=Rx?function(i){for(var t=[];i;)So(t,Co(i)),i=wo(i);return t}:zi,Vi=zx;function Vx(i,t){return Ct(i,Vi(i),t)}var kh=Vx;function Fx(i,t,e){var r=t(i);return Fe(i)?r:So(r,e(i))}var Fi=Fx;function Ux(i){return Fi(i,go,Co)}var Hh=Ux;function jx(i){return Fi(i,qt,Vi)}var Ui=jx;var kx=ht(Ve,"DataView"),ji=kx;var Hx=ht(Ve,"Promise"),ki=Hx;var Wx=ht(Ve,"Set"),Hi=Wx;var Wh="[object Map]",qx="[object Object]",qh="[object Promise]",$h="[object Set]",Xh="[object WeakMap]",Kh="[object DataView]",$x=ur(ji),Xx=ur(Ar),Kx=ur(ki),Yx=ur(Hi),Jx=ur(Ci),qr=gt;(ji&&qr(new ji(new ArrayBuffer(1)))!=Kh||Ar&&qr(new Ar)!=Wh||ki&&qr(ki.resolve())!=qh||Hi&&qr(new Hi)!=$h||Ci&&qr(new Ci)!=Xh)&&(qr=function(i){var t=gt(i),e=t==qx?i.constructor:void 0,r=e?ur(e):"";if(r)switch(r){case $x:return Kh;case Xx:return Wh;case Kx:return qh;case Yx:return $h;case Jx:return Xh}return t});var To=qr;var Qx=Object.prototype,Zx=Qx.hasOwnProperty;function e0(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&Zx.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Yh=e0;var t0=Ve.Uint8Array,Ca=t0;function r0(i){var t=new i.constructor(i.byteLength);return new Ca(t).set(new Ca(i)),t}var Lo=r0;function o0(i,t){var e=t?Lo(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Jh=o0;var n0=/\w*$/;function i0(i){var t=new i.constructor(i.source,n0.exec(i));return t.lastIndex=i.lastIndex,t}var Qh=i0;var Zh=it?it.prototype:void 0,ep=Zh?Zh.valueOf:void 0;function s0(i){return ep?Object(ep.call(i)):{}}var tp=s0;function a0(i,t){var e=t?Lo(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Wi=a0;var l0="[object Boolean]",c0="[object Date]",h0="[object Map]",p0="[object Number]",u0="[object RegExp]",d0="[object Set]",m0="[object String]",f0="[object Symbol]",g0="[object ArrayBuffer]",y0="[object DataView]",x0="[object Float32Array]",v0="[object Float64Array]",b0="[object Int8Array]",S0="[object Int16Array]",w0="[object Int32Array]",N0="[object Uint8Array]",C0="[object Uint8ClampedArray]",T0="[object Uint16Array]",L0="[object Uint32Array]";function I0(i,t,e){var r=i.constructor;switch(t){case g0:return Lo(i);case l0:case c0:return new r(+i);case y0:return Jh(i,e);case x0:case v0:case b0:case S0:case w0:case N0:case C0:case T0:case L0:return Wi(i,e);case h0:return new r;case p0:case m0:return new r(i);case u0:return Qh(i);case d0:return new r;case f0:return tp(i)}}var rp=I0;function P0(i){return typeof i.constructor=="function"&&!uo(i)?Ac(wo(i)):{}}var qi=P0;var M0="[object Map]";function A0(i){return Ze(i)&&To(i)==M0}var op=A0;var np=dr&&dr.isMap,O0=np?fo(np):op,ip=O0;var D0="[object Set]";function _0(i){return Ze(i)&&To(i)==D0}var sp=_0;var ap=dr&&dr.isSet,B0=ap?fo(ap):sp,lp=B0;var E0=1,G0=2,R0=4,cp="[object Arguments]",z0="[object Array]",V0="[object Boolean]",F0="[object Date]",U0="[object Error]",hp="[object Function]",j0="[object GeneratorFunction]",k0="[object Map]",H0="[object Number]",pp="[object Object]",W0="[object RegExp]",q0="[object Set]",$0="[object String]",X0="[object Symbol]",K0="[object WeakMap]",Y0="[object ArrayBuffer]",J0="[object DataView]",Q0="[object Float32Array]",Z0="[object Float64Array]",ev="[object Int8Array]",tv="[object Int16Array]",rv="[object Int32Array]",ov="[object Uint8Array]",nv="[object Uint8ClampedArray]",iv="[object Uint16Array]",sv="[object Uint32Array]",Le={};Le[cp]=Le[z0]=Le[Y0]=Le[J0]=Le[V0]=Le[F0]=Le[Q0]=Le[Z0]=Le[ev]=Le[tv]=Le[rv]=Le[k0]=Le[H0]=Le[pp]=Le[W0]=Le[q0]=Le[$0]=Le[X0]=Le[ov]=Le[nv]=Le[iv]=Le[sv]=!0;Le[U0]=Le[hp]=Le[K0]=!1;function $i(i,t,e,r,o,n){var s,a=t&E0,l=t&G0,c=t&R0;if(e&&(s=o?e(i,r,o,n):e(i)),s!==void 0)return s;if(!et(i))return i;var h=Fe(i);if(h){if(s=Yh(i),!a)return Ti(i,s)}else{var p=To(i),u=p==hp||p==j0;if(mo(i))return Ri(i,a);if(p==pp||p==cp||u&&!o){if(s=l||u?{}:qi(i),!a)return l?kh(i,Eh(s,i)):jh(i,Bh(s,i))}else{if(!Le[p])return o?i:{};s=rp(i,p,a)}}n||(n=new Gi);var d=n.get(i);if(d)return d;n.set(i,s),lp(i)?i.forEach(function(x){s.add($i(x,t,e,x,i,n))}):ip(i)&&i.forEach(function(x,y){s.set(y,$i(x,t,e,y,i,n))});var m=c?l?Ui:Hh:l?qt:go,g=h?void 0:m(i);return Ec(g||i,function(x,y){g&&(y=x,x=i[y]),Pi(s,y,$i(x,t,e,y,i,n))}),s}var Xi=$i;var av=1,lv=4;function cv(i){return Xi(i,av|lv)}var Cn=cv;function hv(i){return function(t,e,r){for(var o=-1,n=Object(t),s=r(t),a=s.length;a--;){var l=s[i?a:++o];if(e(n[l],l,n)===!1)break}return t}}var up=hv;var pv=up(),dp=pv;function uv(i,t,e){(e!==void 0&&!Lr(i[t],e)||e===void 0&&!(t in i))&&po(i,t,e)}var Tn=uv;function dv(i){return Ze(i)&&Ir(i)}var mp=dv;function mv(i,t){if(!(t==="constructor"&&typeof i[t]=="function")&&t!="__proto__")return i[t]}var Ln=mv;function fv(i){return Ct(i,qt(i))}var fp=fv;function gv(i,t,e,r,o,n,s){var a=Ln(i,e),l=Ln(t,e),c=s.get(l);if(c){Tn(i,e,c);return}var h=n?n(a,l,e+"",i,t,s):void 0,p=h===void 0;if(p){var u=Fe(l),d=!u&&mo(l),m=!u&&!d&&Oi(l);h=l,u||d||m?Fe(a)?h=a:mp(a)?h=Ti(a):d?(p=!1,h=Ri(l,!0)):m?(p=!1,h=Wi(l,!0)):h=[]:Ei(l)||Wr(l)?(h=a,Wr(a)?h=fp(a):(!et(a)||co(a))&&(h=qi(l))):p=!1}p&&(s.set(l,h),o(h,l,r,n,s),s.delete(l)),Tn(i,e,h)}var gp=gv;function yp(i,t,e,r,o){i!==t&&dp(t,function(n,s){if(o||(o=new Gi),et(n))gp(i,t,s,e,yp,r,o);else{var a=r?r(Ln(i,s),n,s+"",i,t,o):void 0;a===void 0&&(a=n),Tn(i,s,a)}},qt)}var xp=yp;function yv(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var vp=yv;function xv(i,t){return t.length<2?i:bh(i,Ph(t,0,-1))}var bp=xv;var vv=Vc(function(i,t,e){xp(i,t,e)}),$r=vv;function bv(i,t){return t=bo(t,i),i=bp(i,t),i==null||delete i[Bi(vp(t))]}var Sp=bv;function Sv(i){return Ei(i)?void 0:i}var wp=Sv;var wv=1,Nv=2,Cv=4,Tv=Lh(function(i,t){var e={};if(i==null)return e;var r=!1;t=Si(t,function(n){return n=bo(n,i),r||(r=n.length>1),n}),Ct(i,Ui(i),e),r&&(e=Xi(e,wv|Nv|Cv,wp));for(var o=t.length;o--;)Sp(e,t[o]);return e}),Io=Tv;var Po;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Po||(Po={}));var Xr;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective.zoom:n.orthographic.zoom}o.getZoom=r})(Xr||(Xr={}));var Np;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n]}e.lerp=t})(Np||(Np={}));var Mo;(o=>{function i(n,s){return n[0]===s[0]&&n[1]===s[1]&&n[2]===s[2]}o.isEqual=i;function t(n,s){return[n[0]+s[0],n[1]+s[1],n[2]+s[2]]}o.add=t;function e(n,s){return[n[0]-s[0],n[1]-s[1],n[2]-s[2]]}o.sub=e;function r(n,s,a){return[n[0]+(s[0]-n[0])*a,n[1]+(s[1]-n[1])*a,n[2]+(s[2]-n[2])*a]}o.lerp=r})(Mo||(Mo={}));var Cp;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(Cp||(Cp={}));var Dr;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,s){for(let a=0;a<16;a++)if(n[a]!==s[a])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(n,s){let a=s.slice(0);for(var l=0,c=s.length;l<c;l+=3){let h=n[3]*s[l]+n[7]*s[l+1]+n[11]*s[l+2]+n[15];a[l]=(n[0]*s[l]+n[4]*s[l+1]+n[8]*s[l+2]+n[12])/h,a[l+1]=(n[1]*s[l]+n[5]*s[l+1]+n[9]*s[l+2]+n[13])/h,a[l+2]=(n[2]*s[l]+n[6]*s[l+1]+n[10]*s[l+2]+n[14])/h}return a}o.applyMatrix4=r})(Dr||(Dr={}));var yt;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function n(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=n;function s(c,h){return c.r===h.r&&c.g===h.g&&c.b===h.b}l.equals=s;function a(c,h,p){return{r:c.r+(h.r-c.r)*p,g:c.g+(h.g-c.g)*p,b:c.b+(h.b-c.b)*p}}l.lerp=a})(yt||(yt={}));var xt;(s=>{s.white={...yt.white,a:1};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}s.from0to1=t;function e(a,l){return{...yt.fromHex(a),a:l}}s.fromHexAndA=e;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}s.toRgb255a1=r;function o(a,l){return yt.equals(a,l)&&a.a===l.a}s.equals=o;function n(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}s.lerp=n})(xt||(xt={}));var Ki;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Ki||(Ki={}));var Tp;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Tp||(Tp={}));var Lp;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(Lp||(Lp={}));var Yi;(t=>{function i(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(o=>o*(1+r)),useCenter:!0}}}t.defaultData=i})(Yi||(Yi={}));var Tt=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,Tt.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:s}=t,a={...e,[n]:s};return Object.setPrototypeOf(a,Tt.prototype),{data:a,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,Tt.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}throw new Error("illegal arg")}};function In(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&In(r)}return Object.freeze(i)}function Ip(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Ji=class extends Error{};function $t(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let s=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(s)}return r}function Qi(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Pp(){return typeof process<"u"}function Mp(i,t){for(let e of i)t(e.id,e.data),Mp(e.children,t)}function Ap(i,t){t(i.id,i.data);for(let e of i.children)Ap(e,t)}var Lt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Lt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)In(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Ap(o,r)}}traverse(e){Mp(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),s=this.childrenArray(n),a=s.findIndex(h=>h.id===e);if(a<0)throw new Error("not expected");let l=s[a];return s=[...s],s[a]={...l,data:r},this.modifyArrayBy(n,s)}}modifyArrayBy(e,r){let o=e,n=r;for(;o!==null;){let a=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(h=>h.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:a}}Object.setPrototypeOf(n,Lt.prototype);let s=n;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:s,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),h={fi:o,id:n,data:s,children:a};return c=[...c,h],c.sort((u,d)=>u.fi-d.fi),e.localIndex=c.indexOf(h),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),s=n.findIndex(c=>c.id===r);e.localIndex=s,n=[...n];let a=n.splice(s,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...a,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let d=r;for(;d!==null;){if(d===void 0)throw new Error;if(d===n)throw new Ji("cyclic tree");d=this.parent(d)}}let s=this.parent(n);if(s===void 0)return null;let a=s,l=this.childrenArray(s),c=l.findIndex(d=>d.id===n);l=[...l];let h=l.splice(c,1)[0],p=this.modifyArrayBy(s,l);s=r,l=p.childrenArray(s);let u=h.fi;return h={...h,fi:o},l=[...l,h],l.sort((d,m)=>d.fi-m.fi),e.localIndex=l.indexOf(h),p=p.modifyArrayBy(s,l),{data:p,actual:e,reverse:{type:9,parent:a,fi:u,id:n}}}previous(e,r){if(r===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(s=>s.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(s=>s.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Ip(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),s=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...s,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return $t(0,o,o);{let s=n[0].fi;return $t(s-o,s,o)}}else{let s=this.get(r);if(s===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=n.find(l=>l.fi>s.fi);if(a===void 0){let l=n[n.length-1].fi;return $t(l,l+o,o)}else return $t(s.fi,a.fi,o)}}};var Zi;(t=>{function i(e,r){if(Array.isArray(e)){let o=r.props,n={},s=[...e],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=s[c],s[c]=o[l],a=!0}return a?{data:s,actual:r,reverse:{type:0,props:n}}:null}else{let o=r.props,n={},s={...e},a=!1;if(o)for(let l of Object.keys(o)){n[l]=s[l];let c=o[l];c===void 0?delete s[l]:s[l]=c,a=!0}return a?{data:s,actual:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(Zi||(Zi={}));var De=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,De.prototype)}deepFreeze(){let e=0;for(;e<this.length;)In(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,s=n.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=n[s];return n=[...n],n[s]={...a,data:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,De.prototype);let r=e;return Pp()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:o,data:n}=e,s=this,a={fi:r,id:o,data:n};return s=[...s,a],s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,n=o.findIndex(l=>l.id===r);if(n===-1)return null;e.localIndex=n,o=[...o];let s=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:r,id:o}=e,n=this;n=[...n];let s=n.findIndex(h=>h.id===o);if(s===-1)return null;let a=n[s].fi,l={...n[s],fi:r};return n[s]=l,n.sort((h,p)=>h.fi-p.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),actual:e,reverse:{type:6,fi:a,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return $t(0,r,r);{let n=o[0].fi;return $t(n-r,n,r)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let s=o.find(a=>a.fi>n.fi);if(s===void 0){let a=o[o.length-1].fi;return $t(a,a+r,r)}else return $t(n.fi,s.fi,r)}}};var Op=Symbol(),ts=Symbol(),Ao=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let o=[];for(;!(r instanceof es);){let n=r._path,s=r._current;if(n!==""&&o.splice(0,0,n),r=r._parent,r===null)return;r.update(n,s)}r.push(o,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[ts];r&&r(),delete this._children[t]}}}},La=class extends Ao{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Zi.runOp(this._current,t))}},Ia=class extends Ao{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Tt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Dp={get(i,t){if(t===ts)return()=>{i._parent=null};if(t===Op)return i._current;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],s=rs(i,t,n);return s!==n?(r===void 0&&(r={},i._children=r),r[t]=s,s):n},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},Lv={...Dp,set(i,t,e){let r={type:0,props:{[t]:Aa(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},Iv={...Dp,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Oo=class extends Ao{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[ts]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,s=rs(this,t,n);return s!==n?(r===void 0&&(r={},this._children=r),r[t]=s,s):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(t,o[n],s.id,s.data,s.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(t,o[n],s.id,s.data,s.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(t,o[n],s)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(t,o[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Do=class extends Ao{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[ts]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;t(this.data(this._current[r].id),o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,s=rs(this,t,n);return s!==n?(r===void 0&&(r={},this._children=r),r[t]=s,s):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ta(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&os.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var es=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Ta(this.ts,e,t),Ta(this.actual,r,t),Ta(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function rs(i,t,e){return e instanceof Lt?new Oo(i,t,e):e instanceof De?new Do(i,t,e):e instanceof Tt?new Proxy(new Ia(i,t,e),Iv):e!==null&&typeof e=="object"?Qi(e)?e:new Proxy(new La(i,t,e),Lv):e}function Pa(i){let t=new es(i);return[rs(t,"",i),t]}function Ma(i,t){let[e,r]=Pa(i);return t(e),r.result()}function Aa(i){return i instanceof Oo||i instanceof Do?i._current:i!==null&&typeof i=="object"?i[Op]:i}var os;(r=>{function i(o,n){if(n.length===o.length)for(var s=0;s<o.length;){if(o[s]!==n[s])return!1;s+=1}else return!1;return!0}r.equal=i;function t(o,n,s){let a=e(s,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...n};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return n}r.removeOverridden=t;function e(o,n,s=0){if(n.length<=s)return o;if((o instanceof Lt||o instanceof Oo)&&typeof n[s]=="string")return e(o.data(n[s]),n,s+1);if((o instanceof De||o instanceof Do)&&typeof n[s]=="string")return e(o.data(n[s]),n,s+1);if(typeof n[s]=="number"&&Array.isArray(o))return e(o[n[s]],n,s+1);if(typeof n[s]=="string"&&typeof o=="object")return e(o[n[s]],n,s+1)}r.zoom=e})(os||(os={}));var ns=class{},Pn=class extends ns{constructor(e){super();this.id=e}},Mn=class extends ns{constructor(e){super();this.data=e}};var Da;try{Da=new TextDecoder}catch{}var te,Br,N=0;var Fp=[],_a=Fp,Ba=0,pt={},be,_r,It=0,Xt=0,vt,fr,st=[],we,_p={useRecords:!1,mapsAsObjects:!0},An=class{},Ga=new An;Ga.name="MessagePack 0xC1";var _o=!1,Kt=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(te)return Wp(()=>(ss(),this?this.unpack(t,e):Kt.prototype.unpack.call(_p,t,e)));Br=e>-1?e:t.length,N=0,Ba=0,Xt=0,_r=null,_a=Fp,vt=null,te=t;try{we=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw te=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Kt){if(pt=this,this.structures)return be=this.structures,is();(!be||be.length>0)&&(be=[])}else pt=_p,(!be||be.length>0)&&(be=[]);return is()}unpackMultiple(t,e){let r,o=0;try{_o=!0;let n=t.length,s=this?this.unpack(t,n):cs.unpack(t,n);if(e){for(e(s);N<n;)if(o=N,e(is())===!1)return}else{for(r=[s];N<n;)o=N,r.push(is());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{_o=!1,ss()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function is(){try{if(!pt.trusted&&!_o){let t=be.sharedLength||0;t<be.length&&(be.length=t)}let i=Be();if(N==Br)be.restoreStructures&&Bp(),be=null,te=null,fr&&(fr=null);else if(N>Br){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!_o)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw be.restoreStructures&&Bp(),ss(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Bp(){for(let i in be.restoreStructures)be[i]=be.restoreStructures[i];be.restoreStructures=null}function Be(){let i=te[N++];if(i<160)if(i<128){if(i<64)return i;{let t=be[i&63]||pt.getStructures&&Up()[i&63];return t?(t.read||(t.read=Ra(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,pt.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[kp()]=Be();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Be(),Be());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Be();return t}else if(i<192){let t=i-160;if(Xt>=N)return _r.slice(N-It,(N+=t)-It);if(Xt==0&&Br<140){let e=t<16?za(t):jp(t);if(e!=null)return e}return Ea(t)}else{let t;switch(i){case 192:return null;case 193:return vt?(t=Be(),t>0?vt[1].slice(vt.position1,vt.position1+=t):vt[0].slice(vt.position0,vt.position0-=t)):Ga;case 194:return!1;case 195:return!0;case 196:return Oa(te[N++]);case 197:return t=we.getUint16(N),N+=2,Oa(t);case 198:return t=we.getUint32(N),N+=4,Oa(t);case 199:return Kr(te[N++]);case 200:return t=we.getUint16(N),N+=2,Kr(t);case 201:return t=we.getUint32(N),N+=4,Kr(t);case 202:if(t=we.getFloat32(N),pt.useFloat32>2){let e=ls[(te[N]&127)<<1|te[N+1]>>7];return N+=4,(e*t+(t>0?.5:-.5)>>0)/e}return N+=4,t;case 203:return t=we.getFloat64(N),N+=8,t;case 204:return te[N++];case 205:return t=we.getUint16(N),N+=2,t;case 206:return t=we.getUint32(N),N+=4,t;case 207:return pt.int64AsNumber?(t=we.getUint32(N)*4294967296,t+=we.getUint32(N+4)):t=we.getBigUint64(N),N+=8,t;case 208:return we.getInt8(N++);case 209:return t=we.getInt16(N),N+=2,t;case 210:return t=we.getInt32(N),N+=4,t;case 211:return pt.int64AsNumber?(t=we.getInt32(N)*4294967296,t+=we.getUint32(N+4)):t=we.getBigInt64(N),N+=8,t;case 212:if(t=te[N++],t==114)return Vp(te[N++]&63);{let e=st[t];if(e)return e.read?(N++,e.read(Be())):e.noBuffer?(N++,e()):e(te.subarray(N,++N));throw new Error("Unknown extension "+t)}case 213:return t=te[N],t==114?(N++,Vp(te[N++]&63,te[N++])):Kr(2);case 214:return Kr(4);case 215:return Kr(8);case 216:return Kr(16);case 217:return t=te[N++],Xt>=N?_r.slice(N-It,(N+=t)-It):Mv(t);case 218:return t=we.getUint16(N),N+=2,Xt>=N?_r.slice(N-It,(N+=t)-It):Av(t);case 219:return t=we.getUint32(N),N+=4,Xt>=N?_r.slice(N-It,(N+=t)-It):Ov(t);case 220:return t=we.getUint16(N),N+=2,Gp(t);case 221:return t=we.getUint32(N),N+=4,Gp(t);case 222:return t=we.getUint16(N),N+=2,Rp(t);case 223:return t=we.getUint32(N),N+=4,Rp(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var Pv=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ra(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>Pv.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Be);return i.highByte===0&&(i.read=Ep(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let s=i[o];r[s]=Be()}return r}return e.count=0,i.highByte===0?Ep(t,e):e}var Ep=(i,t)=>function(){let e=te[N++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=be[r]||Up()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Ra(o,i)),o.read()};function Up(){let i=Wp(()=>(te=null,pt.getStructures()));return be=pt._mergeStructures(i,be)}var Ea=as,Mv=as,Av=as,Ov=as;function as(i){let t;if(i<16&&(t=za(i)))return t;if(i>64&&Da)return Da.decode(te.subarray(N,N+=i));let e=N+i,r=[];for(t="";N<e;){let o=te[N++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=te[N++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=te[N++]&63,s=te[N++]&63;r.push((o&31)<<12|n<<6|s)}else if((o&248)===240){let n=te[N++]&63,s=te[N++]&63,a=te[N++]&63,l=(o&7)<<18|n<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=We.apply(String,r),r.length=0)}return r.length>0&&(t+=We.apply(String,r)),t}function Gp(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Be();return t}function Rp(i){if(pt.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[kp()]=Be();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Be(),Be());return t}}var We=String.fromCharCode;function jp(i){let t=N,e=new Array(i);for(let r=0;r<i;r++){let o=te[N++];if((o&128)>0){N=t;return}e[r]=o}return We.apply(String,e)}function za(i){if(i<4)if(i<2){if(i===0)return"";{let t=te[N++];if((t&128)>1){N-=1;return}return We(t)}}else{let t=te[N++],e=te[N++];if((t&128)>0||(e&128)>0){N-=2;return}if(i<3)return We(t,e);let r=te[N++];if((r&128)>0){N-=3;return}return We(t,e,r)}else{let t=te[N++],e=te[N++],r=te[N++],o=te[N++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){N-=4;return}if(i<6){if(i===4)return We(t,e,r,o);{let n=te[N++];if((n&128)>0){N-=5;return}return We(t,e,r,o,n)}}else if(i<8){let n=te[N++],s=te[N++];if((n&128)>0||(s&128)>0){N-=6;return}if(i<7)return We(t,e,r,o,n,s);let a=te[N++];if((a&128)>0){N-=7;return}return We(t,e,r,o,n,s,a)}else{let n=te[N++],s=te[N++],a=te[N++],l=te[N++];if((n&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){N-=8;return}if(i<10){if(i===8)return We(t,e,r,o,n,s,a,l);{let c=te[N++];if((c&128)>0){N-=9;return}return We(t,e,r,o,n,s,a,l,c)}}else if(i<12){let c=te[N++],h=te[N++];if((c&128)>0||(h&128)>0){N-=10;return}if(i<11)return We(t,e,r,o,n,s,a,l,c,h);let p=te[N++];if((p&128)>0){N-=11;return}return We(t,e,r,o,n,s,a,l,c,h,p)}else{let c=te[N++],h=te[N++],p=te[N++],u=te[N++];if((c&128)>0||(h&128)>0||(p&128)>0||(u&128)>0){N-=12;return}if(i<14){if(i===12)return We(t,e,r,o,n,s,a,l,c,h,p,u);{let d=te[N++];if((d&128)>0){N-=13;return}return We(t,e,r,o,n,s,a,l,c,h,p,u,d)}}else{let d=te[N++],m=te[N++];if((d&128)>0||(m&128)>0){N-=14;return}if(i<15)return We(t,e,r,o,n,s,a,l,c,h,p,u,d,m);let g=te[N++];if((g&128)>0){N-=15;return}return We(t,e,r,o,n,s,a,l,c,h,p,u,d,m,g)}}}}}function Oa(i){return pt.copyBuffers?Uint8Array.prototype.slice.call(te,N,N+=i):te.subarray(N,N+=i)}function Kr(i){let t=te[N++];if(st[t])return st[t](te.subarray(N,N+=i));throw new Error("Unknown extension type "+t)}var zp=new Array(4096);function kp(){let i=te[N++];if(i>=160&&i<192){if(i=i-160,Xt>=N)return _r.slice(N-It,(N+=i)-It);if(!(Xt==0&&Br<180))return Ea(i)}else return N--,Be();let t=(i<<5^(i>1?we.getUint16(N):i>0?te[N]:0))&4095,e=zp[t],r=N,o=N+i-3,n,s=0;if(e&&e.bytes==i){for(;r<o;){if(n=we.getUint32(r),n!=e[s++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=te[r++],n!=e[s++]){r=1879048192;break}if(r===o)return N=r,e.string;o-=3,r=N}for(e=[],zp[t]=e,e.bytes=i;r<o;)n=we.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=te[r++],e.push(n);let a=i<16?za(i):jp(i);return a!=null?e.string=a:e.string=Ea(i)}var Vp=(i,t)=>{var e=Be();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=be[i];return o&&o.isShared&&((be.restoreStructures||(be.restoreStructures=[]))[i]=o),be[i]=e,e.read=Ra(e,r),e.read()},Hp=typeof self=="object"?self:global;st[0]=()=>{};st[0].noBuffer=!0;st[101]=()=>{let i=Be();return(Hp[i[0]]||Error)(i[1])};st[105]=i=>{let t=we.getUint32(N-4);fr||(fr=new Map);let e=te[N],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};fr.set(t,o);let n=Be();return o.used?Object.assign(r,n):(o.target=n,n)};st[112]=i=>{let t=we.getUint32(N-4),e=fr.get(t);return e.used=!0,e.target};st[115]=()=>new Set(Be());var Va=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");st[116]=i=>{let t=i[0],e=Va[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Hp[e](Uint8Array.prototype.slice.call(i,1).buffer)};st[120]=()=>{let i=Be();return new RegExp(i[0],i[1])};st[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=N;N+=t-4,vt=[Be(),Be()],vt.position0=0,vt.position1=0;let r=N;N=e;try{return Be()}finally{N=r}};st[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function Wp(i){let t=Br,e=N,r=Ba,o=It,n=Xt,s=_r,a=_a,l=fr,c=vt,h=new Uint8Array(te.slice(0,Br)),p=be,u=be.slice(0,be.length),d=pt,m=_o,g=i();return Br=t,N=e,Ba=r,It=o,Xt=n,_r=s,_a=a,fr=l,vt=c,te=h,_o=m,be=p,be.splice(0,be.length,...u),pt=d,we=new DataView(te.buffer,te.byteOffset,te.byteLength),g}function ss(){te=null,fr=null,be=null}function qp(i){i.unpack?st[i.type]=i.unpack:st[i.type]=i}var ls=new Array(147);for(let i=0;i<256;i++)ls[i]=+("1e"+Math.floor(45.15-i*.30103));var cs=new Kt({useRecords:!1}),Dv=cs.unpack,_v=cs.unpackMultiple,Bv=cs.unpack,hs={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Ev=new Float32Array(1),fO=new Uint8Array(Ev.buffer,0,4);var ps;try{ps=new TextEncoder}catch{}var us,Ua,ds=typeof Buffer<"u",Fa=ds?Buffer.allocUnsafeSlow:Uint8Array,Yp=ds?Buffer:Uint8Array,$p=ds?4294967296:2144337920,R,Ge,T=0,Yt,Jt=null,Gv=/[\u0080-\uFFFF]/,On=Symbol("record-id"),Yr=class extends Kt{constructor(t){super(t),this.offset=0;let e,r,o,n,s,a,l=0,c=Yp.prototype.utf8Write?function(f,D,C){return R.utf8Write(f,D,C)}:ps&&ps.encodeInto?function(f,D){return ps.encodeInto(f,R.subarray(D)).written}:!1,h=this;t||(t={});let p=t&&t.sequential,u=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=t.maxOwnStructures;m==null&&(m=u?32:64),p&&!t.saveStructures&&(this.structures=[]);let g=d>32||m+d>64,x=d+64,y=d+m+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],P=0,S=0;this.pack=this.encode=function(f,D){if(R||(R=new Fa(8192),Ge=new DataView(R.buffer,0,8192),T=0),Yt=R.length-10,Yt-T<2048?(R=new Fa(R.length),Ge=new DataView(R.buffer,0,R.length),Yt=R.length-10,T=0):T=T+7&2147483640,r=T,a=h.structuredClone?new Map:null,h.bundleStrings?(Jt=["",""],R[T++]=214,R[T++]=98,Jt.position=T-r,T+=4):Jt=null,o=h.structures,o){o.uninitialized&&(o=h._mergeStructures(h.getStructures()));let C=o.sharedLength||0;if(C>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let I=0;I<C;I++){let L=o[I];if(!L)continue;let M,k=o.transitions;for(let W=0,oe=L.length;W<oe;W++){let he=L[W];M=k[he],M||(M=k[he]=Object.create(null)),k=M}k[On]=I+64}l=C}p||(o.nextId=C+64)}n&&(n=!1),s=o||[];try{if(b(f),Jt){Ge.setUint32(Jt.position+r,T-Jt.position-r);let C=Jt;Jt=null,b(C[0]),b(C[1])}if(h.offset=T,a&&a.idsToInsert){T+=a.idsToInsert.length*6,T>Yt&&w(T),h.offset=T;let C=zv(R.subarray(r,T),a.idsToInsert);return a=null,C}return D&Qp?(R.start=r,R.end=T,R):R.subarray(r,T)}finally{if(o){if(S<10&&S++,P>1e4)o.transitions=null,S=0,P=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let C=0,I=v.length;C<I;C++)v[C][On]=0;v=[]}if(n&&h.saveStructures){let C=o.sharedLength||d;o.length>C&&(o=o.slice(0,C));let I=R.subarray(r,T);return h.saveStructures(o,l)===!1?(h._mergeStructures(h.getStructures()),h.pack(f)):(l=C,I)}}D&Wv&&(T=r)}};let b=f=>{T>Yt&&(R=w(T));var D=typeof f,C;if(D==="string"){let I=f.length;if(Jt&&I>=8&&I<4096){let k=Gv.test(f);Jt[k?0:1]+=f,R[T++]=193,b(k?-I:I);return}let L;I<32?L=1:I<256?L=2:I<65536?L=3:L=5;let M=I*3;if(T+M>Yt&&(R=w(T+M)),I<64||!c){let k,W,oe,he=T+L;for(k=0;k<I;k++)W=f.charCodeAt(k),W<128?R[he++]=W:W<2048?(R[he++]=W>>6|192,R[he++]=W&63|128):(W&64512)===55296&&((oe=f.charCodeAt(k+1))&64512)===56320?(W=65536+((W&1023)<<10)+(oe&1023),k++,R[he++]=W>>18|240,R[he++]=W>>12&63|128,R[he++]=W>>6&63|128,R[he++]=W&63|128):(R[he++]=W>>12|224,R[he++]=W>>6&63|128,R[he++]=W&63|128);C=he-T-L}else C=c(f,T+L,M);C<32?R[T++]=160|C:C<256?(L<2&&R.copyWithin(T+2,T+1,T+1+C),R[T++]=217,R[T++]=C):C<65536?(L<3&&R.copyWithin(T+3,T+2,T+2+C),R[T++]=218,R[T++]=C>>8,R[T++]=C&255):(L<5&&R.copyWithin(T+5,T+3,T+3+C),R[T++]=219,Ge.setUint32(T,C),T+=4),T+=C}else if(D==="number")if(f>>>0===f)f<64?R[T++]=f:f<256?(R[T++]=204,R[T++]=f):f<65536?(R[T++]=205,R[T++]=f>>8,R[T++]=f&255):(R[T++]=206,Ge.setUint32(T,f),T+=4);else if(f>>0===f)f>=-32?R[T++]=256+f:f>=-128?(R[T++]=208,R[T++]=f+256):f>=-32768?(R[T++]=209,Ge.setInt16(T,f),T+=2):(R[T++]=210,Ge.setInt32(T,f),T+=4);else{let I;if((I=this.useFloat32)>0&&f<4294967296&&f>=-2147483648){R[T++]=202,Ge.setFloat32(T,f);let L;if(I<4||(L=f*ls[(R[T]&127)<<1|R[T+1]>>7])>>0===L){T+=4;return}else T--}R[T++]=203,Ge.setFloat64(T,f),T+=8}else if(D==="object")if(!f)R[T++]=192;else{if(a){let L=a.get(f);if(L){if(!L.id){let M=a.idsToInsert||(a.idsToInsert=[]);L.id=M.push(L)}R[T++]=214,R[T++]=112,Ge.setUint32(T,L.id),T+=4;return}else a.set(f,{offset:T-r})}let I=f.constructor;if(I===Object)B(f,!0);else if(I===Array){C=f.length,C<16?R[T++]=144|C:C<65536?(R[T++]=220,R[T++]=C>>8,R[T++]=C&255):(R[T++]=221,Ge.setUint32(T,C),T+=4);for(let L=0;L<C;L++)b(f[L])}else if(I===Map){C=f.size,C<16?R[T++]=128|C:C<65536?(R[T++]=222,R[T++]=C>>8,R[T++]=C&255):(R[T++]=223,Ge.setUint32(T,C),T+=4);for(let[L,M]of f)b(L),b(M)}else{for(let L=0,M=us.length;L<M;L++){let k=Ua[L];if(f instanceof k){let W=us[L];if(W.write){W.type&&(R[T++]=212,R[T++]=W.type,R[T++]=0),b(W.write.call(this,f));return}let oe=R,he=Ge,ie=T;R=null;let Y;try{Y=W.pack.call(this,f,U=>(R=oe,oe=null,T+=U,T>Yt&&w(T),{target:R,targetView:Ge,position:T-U}),b)}finally{oe&&(R=oe,Ge=he,T=ie,Yt=R.length-10)}Y&&(Y.length+T>Yt&&w(Y.length+T),T=Rv(Y,R,T,W.type));return}}B(f,!f.hasOwnProperty)}}else if(D==="boolean")R[T++]=f?195:194;else if(D==="bigint"){if(f<BigInt(1)<<BigInt(63)&&f>=-(BigInt(1)<<BigInt(63)))R[T++]=211,Ge.setBigInt64(T,f);else if(f<BigInt(1)<<BigInt(64)&&f>0)R[T++]=207,Ge.setBigUint64(T,f);else if(this.largeBigIntToFloat)R[T++]=203,Ge.setFloat64(T,Number(f));else throw new RangeError(f+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");T+=8}else if(D==="undefined")this.encodeUndefinedAsNil?R[T++]=192:(R[T++]=212,R[T++]=0,R[T++]=0);else if(D==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},B=this.useRecords===!1?this.variableMapSize?f=>{let D=Object.keys(f),C=D.length;C<16?R[T++]=128|C:C<65536?(R[T++]=222,R[T++]=C>>8,R[T++]=C&255):(R[T++]=223,Ge.setUint32(T,C),T+=4);let I;for(let L=0;L<C;L++)b(I=D[L]),b(f[I])}:(f,D)=>{R[T++]=222;let C=T-r;T+=2;let I=0;for(let L in f)(D||f.hasOwnProperty(L))&&(b(L),b(f[L]),I++);R[C+++r]=I>>8,R[C+r]=I&255}:f=>{let D=Object.keys(f),C,I=s.transitions||(s.transitions=Object.create(null)),L=0;for(let k=0,W=D.length;k<W;k++){let oe=D[k];C=I[oe],C||(C=I[oe]=Object.create(null),L++),I=C}let M=I[On];if(M)M>=96&&g?(R[T++]=((M-=96)&31)+96,R[T++]=M>>5):R[T++]=M;else{M=s.nextId,M||(M=64),M<x&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(M=s.nextOwnId,M<y||(M=x),s.nextOwnId=M+1):(M>=y&&(M=x),s.nextId=M+1);let k=D.highByte=M>=96&&g?M-96>>5:-1;I[On]=M,s[M-64]=D,M<x?(D.isShared=!0,s.sharedLength=M-63,n=!0,k>=0?(R[T++]=(M&31)+96,R[T++]=k):R[T++]=M):(k>=0?(R[T++]=213,R[T++]=114,R[T++]=(M&31)+96,R[T++]=k):(R[T++]=212,R[T++]=114,R[T++]=M),L&&(P+=S*L),v.length>=m&&(v.shift()[On]=0),v.push(I),b(D))}for(let k=0,W=D.length;k<W;k++)b(f[D[k]])},w=f=>{let D;if(f>16777216){if(f-r>$p)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min($p,Math.round(Math.max((f-r)*(f>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(f-r<<2,R.length-1)>>12)+1<<12;let C=new Fa(D);return Ge=new DataView(C.buffer,0,D),R.copy?R.copy(C,0,r,f):C.set(R.slice(r,f)),T-=r,r=0,Yt=C.length-10,R=C}}useBuffer(t){R=t,Ge=new DataView(R.buffer,R.byteOffset,R.byteLength),T=0}};Ua=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,An];us=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:s}=t(6);o[s++]=214,o[s++]=255,n.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:s}=t(10);o[s++]=215,o[s++]=255,n.setUint32(s,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:s}=t(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:n,position:s}=t(15);o[s++]=199,o[s++]=12,o[s++]=255,n.setUint32(s,i.getMilliseconds()*1e6),n.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?Xp(i,16,t):Kp(ds?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==Yp&&this.structuredClone?Xp(i,Va.indexOf(e.name),t):Kp(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function Xp(i,t,e,r){let o=i.byteLength;if(o+1<256){var{target:n,position:s}=e(4+o);n[s++]=199,n[s++]=o+1}else if(o+1<65536){var{target:n,position:s}=e(5+o);n[s++]=200,n[s++]=o+1>>8,n[s++]=o+1&255}else{var{target:n,position:s,targetView:a}=e(7+o);n[s++]=201,a.setUint32(s,o+1),s+=4}n[s++]=116,n[s++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),s)}function Kp(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function Rv(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function zv(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,s)=>n.offset>s.offset?1:-1);e=t.pop();){let n=e.offset,s=e.id;i.copyWithin(n+r,n,o),r-=6;let a=n+r;i[a++]=214,i[a++]=105,i[a++]=s>>24,i[a++]=s>>16&255,i[a++]=s>>8&255,i[a++]=s&255,o=n}return i}function Jr(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ua.unshift(i.Class),us.unshift(i)}qp(i)}var Jp=new Yr({useRecords:!1}),Vv=Jp.pack,Fv=Jp.pack;var{NEVER:Uv,ALWAYS:jv,DECIMAL_ROUND:kv,DECIMAL_FIT:Hv}=hs,Qp=512,Wv=1024;var Zp=new Yr({structuredClone:!0});Jr({Class:Tt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Tt.prototype),i}});Jr({Class:De.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,De.prototype),i}});Jr({Class:Lt.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Lt.prototype),i}});Jr({Class:Pn.prototype.constructor,type:4,write(i){return i.id},read(i){return new Pn(i)}});Jr({Class:Mn.prototype.constructor,type:5,write(i){return i.data},read(i){return new Mn(i)}});function qv(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function ja(i){if(Qi(i))return i;if(Array.isArray(i))return i.map(ja);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=ja(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var ms;(r=>{function i(o){return Zp.pack(o)}r.serialize=i;function t(o){return Zp.unpack(o)}r.deserialize=t;function e(o){return qv(i(ja(o))).toString()}r.checksum=e})(ms||(ms={}));var fs;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(fs||(fs={}));var gs;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:xt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(r==="SpotLight")return{type:r,color:xt.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:xt.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(gs||(gs={}));var ka;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(ka||(ka={}));var Ha;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(Ha||(Ha={}));var ys;(t=>t.defaultData={...Ha.defaultData,...ka.defaultData,cloner:null,booleanExclude:null})(ys||(ys={}));var Wa=(o=>(o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify",o))(Wa||{}),qa=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(qa||{}),$a=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))($a||{}),xs;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:xt.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(xs||(xs={}));var Bo;(r=>{function i(o,n){return o==="light"&&n?t(n):e(o)}r.defaultData=i;function t(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function e(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:yt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...yt.fromHex(6710886),a:1},colorB:{...yt.fromHex(6710886),a:1},colorC:{...yt.fromHex(16777215),a:1},colorD:{...yt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:xt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:xt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:xt.fromHexAndA(0,1),contourColor:xt.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Bo||(Bo={}));var Qr;(a=>{function i(l){return!l.layers.some(h=>{if(h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")return!0})&&!e(l)}a.isMergable=i;function t(l){let c="";return l.layers.forEach(h=>{Object.entries(h.data).forEach(([p,u])=>{c+=`${p}${u}`,Array.isArray(u)?u.forEach(d=>c+=`${d}`):typeof u=="object"?Object.values(u).forEach(d=>{typeof d=="number"?c+=`${d.toFixed(4)}`:c+=`${d}`}):c+=`${u}`})}),c}a.getHash=t;function e(l){let c=0;for(let h of l.layers)"alpha"in h.data&&h.data.type!=="light"&&h.data.type!=="fresnel"&&(c+=(1-c)*h.data.alpha);return c<1}a.isTransparent=e;function r(){return{layers:new De}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return n("phong",l,c)}a.defaultData=o;function n(l,c="layer1",h="layer2"){let p=new De;return p.push({fi:0,data:Bo.defaultData("light",l),id:c}),p.push({fi:1,data:Bo.defaultData("color"),id:h}),{layers:p}}a.defaultTwoLayerData=n;function s(l,c="basic",h="layer1",p="layer2"){let u=Bo.defaultData("texture");Object.assign(u.texture,{image:l});let d=new De;return d.push({fi:0,data:u,id:h}),d.push({fi:1,data:Bo.defaultData("light",c),id:p}),{layers:d}}a.defaultTwoLayerTextureData=s})(Qr||(Qr={}));var Eo;(t=>{function i(){return{points:new De,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Eo||(Eo={}));var vs;(t=>{function i(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=i})(vs||(vs={}));var Dn;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Eo.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}t.defaultData=i})(Dn||(Dn={}));var _n;(o=>{o.identity={...Ki.identity,hiddenMatrix:Dr.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,s){return{position:s?.position||n.position,rotation:s?.rotation||n.rotation,scale:s?.scale||n.scale,hiddenMatrix:s?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,s){return{position:Mo.isEqual(n.position,s.position)?null:s.position,rotation:Mo.isEqual(n.rotation,s.rotation)?null:s.rotation,scale:Mo.isEqual(n.scale,s.scale)?null:s.scale,hiddenMatrix:Dr.isEqual(n.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=r})(_n||(_n={}));var gr;(t=>t.defaultData={states:new De,events:new De,visible:!0,raycastLock:!1,..._n.identity})(gr||(gr={}));var eu;(t=>t.defaultData={type:"Empty",...gr.defaultData})(eu||(eu={}));var bs;(t=>t.defaultData={type:"Mesh",...gr.defaultData,...ys.defaultData})(bs||(bs={}));var tu;(t=>t.defaultData={type:"TextFrame",...gr.defaultData,...xs.defaultData})(tu||(tu={}));var Ss;(t=>t.defaultData={...gr.defaultData,..._n.identity,...Xr.defaultData})(Ss||(Ss={}));var ru;(t=>{function i(e){return{...gr.defaultData,...gs.defaultData(e)}}t.defaultData=i})(ru||(ru={}));var ou;(r=>(r.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Dr.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new De,events:new De,...Xr.defaultData},r.defaultMeshObject={name:"Rectangle",...gr.defaultData,...bs.defaultData,geometry:Dn.defaultData("RectangleGeometry"),material:Qr.defaultTwoLayerData("basic","layer1","layer2")},r.defaultBooleanObject={name:"Boolean",...gr.defaultData,...bs.defaultData,geometry:Dn.defaultData("BooleanGeometry"),material:Qr.defaultTwoLayerData("phong","layer1","layer2")}))(ou||(ou={}));var nu;(e=>{function i(r,o){if(o===void 0)return r;let n={...r};return"material"in n&&"material"in o&&o.material&&(n.material=Ma(n.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=s.layers.data(a);c&&$r(c,l)}}).data),n.materials&&o.materials&&(n.materials=Ma(n.materials,s=>{for(let a=0;a<n.materials.length;a++){let l=o.materials[a];if(typeof l!="string")for(let[c,h]of Object.entries(l.layers)){let p=s[a]?.layers?.data(c);p&&$r(p,h)}}}).data),n}e.patchMaterialState=i;function t(r,o){if(o===void 0)return r;let n={...r};if(Object.assign(n,_n.merge(n,o)),Po.is(r.type)){n.orthographic={...n.orthographic},n.perspective={...n.perspective};let s=o;s.orthographic?.zoom!==void 0&&(n.orthographic.zoom=s.orthographic.zoom),s.perspective?.zoom!==void 0&&(n.perspective.zoom=s.perspective.zoom),s.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=s.isUpVectorFlipped),s.targetOffset!==void 0&&(n.targetOffset=s.targetOffset)}else if(r.type==="Mesh")n.geometry={...n.geometry},Object.assign(n.geometry,o.geometry),n=i(n,o);else if(fs.is(r.type)){let s=o;n.intensity!==void 0&&(n.intensity=s.intensity),s.color!==void 0&&(typeof s.color=="string"?n.color=s.color:n.color=yt.clone(s.color))}return n}e.patch=t})(nu||(nu={}));import{ConeBufferGeometry as Kv}from"three";import{BufferGeometry as $v,CylinderBufferGeometry as Xv,Float32BufferAttribute as Xa,Vector2 as Et,Vector3 as ws}from"three";var su=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=e.width/2,o=e.radiusTop??r,n=e.radiusBottom??r;return o===n?(o=r,n=r):o>n?(o=r,n=n*r/o):(o=o*r/n,n=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:n})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:h,cornerRadius:p,cornerSegments:u,hollow:d}=i.parameters,m;return p||d?m=new Bn(c,h,r,o,n,s,a,l*Math.PI/180,p,p,u,d):m=new Xv(c,h,r,o,n,s,a,l*Math.PI/180),m.scale(1,1,e/t),Object.assign(m,{userData:{...i,type:"CylinderGeometry"}})}};function Er(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function iu(i){return new Et(i.y,-i.x)}var Bn=class extends $v{constructor(t,e,r,o,n,s,a,l,c,h,p,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,h=0);let m=[],g=[],x=[],y=[],v=0,P=r/2,S=new ws,b=new ws;d&&t==0&&(t=c),d&&e==0&&(e=h);let B=new Et(t,P),w=new Et(e,-P),f=null,D=null,C=null,I=null,L=B.clone().sub(w),M=0,k=0,W=0;u>0&&(M=Math.min(t,e)*(1-u),k=t-M,W=e-M);let oe=B.clone();oe.x-=M;let he=Math.PI-L.angle(),ie=L.angle(),Y=Math.tan(ie/2),U=Math.tan(he/2),z=Y+U,E=u?z:U,_=u?z:Y;if(c=Math.min(c,(t-k)/E,L.length()/z),h=Math.min(h,(e-W)/_,L.length()/z),c>0){let F=c/Y;f=B.clone().sub(new Et(F,c)),u&&(C=f.clone(),C.x-=M-z*c),B.sub(L.clone().setLength(F))}if(h>0){let F=h/U;D=w.clone().sub(new Et(F,-h)),w.add(L.clone().setLength(F)),u&&(I=D.clone(),I.x-=M-z*h,oe.sub(L.clone().setLength(F)))}L=B.clone().sub(w);let A=L.length()<.5,G=[];for(let F=0;F<=o;F++){let O=[],q=F/o,Z=q*l+a,ee=new Et(Math.sin(Z),Math.cos(Z));I&&D?(J(O,q,ee,he,h,I,-1,!0),J(O,q,ee,ie,h,D,-1,!1)):D?(j(O,ee,D.x,0,-1),J(O,q,ee,ie,h,D,-1,!1)):s||j(O,ee,e,W,-1);let H=iu(L).normalize();if(Er(H,ee,S),!A)for(let Q=0;Q<=n;Q++){let $=Q/n,re=L.clone().multiplyScalar($).add(w);Er(re,ee,b),g.push(b.x,b.y,b.z),x.push(S.x,S.y,S.z),y.push(q,.5+b.y/r),O.push(v++)}if(C&&f?(J(O,q,ee,he,c,f,1,!1),J(O,q,ee,ie,c,C,1,!0)):f?(J(O,q,ee,he,c,f,1,!1),j(O,ee,f.x,0,1)):s||j(O,ee,t,k,1),u&&!A){let Q=iu(L).multiplyScalar(-1).normalize();Er(Q,ee,S);for(let $=0;$<=n;$++){let re=$/n,le=L.clone().multiplyScalar(-re).add(oe);Er(le,ee,b),g.push(b.x,b.y,b.z),x.push(S.x,S.y,S.z),y.push(q,.5+b.y/r),O.push(v++)}}u&&!s&&O.push(O[0]),G.push(O)}for(let F=0;F<G.length-1;F++)for(let O=0;O<G[0].length-1;O++){if(s&&u&&O==n)continue;let q=G[F][O],Z=G[F+1][O],ee=G[F+1][O+1],H=G[F][O+1],Q=g[ee*3+0],$=g[ee*3+2];m.push(q,Z,H),(Q!=0||$!=0)&&m.push(Z,ee,H)}l<Math.PI*2&&(V(-1,G[0],a),V(1,G[G.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Xa(g,3)),this.setAttribute("normal",new Xa(x,3)),this.setAttribute("uv",new Xa(y,2));function J(F,O,q,Z,ee,H,Q,$){for(let re=0;re<p+1;re++){let le=re/p,ne=Q<0?le:1-le;$&&(ne-=1),ne*=Z;let me=new Et(Math.sin(ne),Math.cos(ne)*Q),_e=me.clone().multiplyScalar(ee).add(H);Er(_e,q,b),g.push(b.x,b.y,b.z),Er(me,q,S),x.push(S.x,S.y,S.z),y.push(O,.5+b.y/r),F.push(v++)}}function j(F,O,q,Z,ee){let H=new ws,Q=new Et,$=[q,Z];ee<0&&$.reverse();for(let re of $)Q.set(re,P*ee),Er(Q,O,H),g.push(H.x,H.y,H.z),x.push(0,ee,0),y.push(.5,.5),F.push(v++)}function V(F,O,q){let Z=new Et(Math.sin(q),Math.cos(q)),ee=new Et(-Math.cos(q),Math.sin(q)),H=new ws,Q=F<0?(le,ne,me)=>m.push(le,ne,me):(le,ne,me)=>m.push(le,me,ne),$=new Et((t+e+k+W)/4,0);Er($,Z,H),g.push(H.x,H.y,H.z),x.push(ee.x,0,ee.y),y.push(.5,.5);let re=v++;for(let le of O){let ne=g.slice(le*3,le*3+3);g.push(...ne),x.push(ee.x,0,ee.y);let me=y.slice(le*2,le*2+2);y.push(...me),v++}for(let le=re+1;le<v-1;le++)Q(re,le,le+1);Q(re,v-1,re+1)}}};var au=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:h,cornerSegments:p}=i.parameters,u;return c>0||h>0||l<360?u=new Bn(0,t/2,r,o,n,s,a,l*Math.PI/180,c,h,p,0,!0):u=new Kv(t/2,r,o,n,s),u.scale(1,1,e/t),Object.assign(u,{userData:{...i,type:"ConeGeometry"}})}};import{BoxBufferGeometry as Yv,BufferGeometry as Jv,Float32BufferAttribute as Ka,Vector3 as En}from"three";var lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:s,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new Yv(t,e,r,o,n,s):c=new Ja(t,e,r,o,n,s,a,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},Ya=Math.PI/2,Ja=class extends Jv{constructor(t=1,e=1,r=1,o=1,n=1,s=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let h=[],p=[],u=[],d=[],m=0,g=0;x("z","y","x",-1,-1,r,e,t,s,n,0),x("z","y","x",1,-1,r,e,-t,s,n,1),x("x","z","y",1,1,t,r,e,o,s,2),x("x","z","y",1,-1,t,r,-e,o,s,3),x("x","y","z",1,-1,t,e,r,o,n,4),x("x","y","z",-1,-1,t,e,-r,o,n,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,s,0),y("z","y","x",1,-1,-1,r,e,t,s,1),y("z","y","x",-1,1,-1,r,e,t,s,1),y("z","y","x",1,1,1,r,e,t,s,0),y("x","y","z",-1,-1,-1,t,e,r,o,0),y("x","y","z",1,-1,1,t,e,r,o,1),y("x","y","z",-1,1,1,t,e,r,o,0),y("x","y","z",1,1,-1,t,e,r,o,1),y("y","x","z",-1,-1,1,e,t,r,n,0),y("y","x","z",1,-1,-1,e,t,r,n,1),y("y","x","z",1,1,1,e,t,r,n,1),y("y","x","z",-1,1,-1,e,t,r,n,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Ka(p,3)),this.setAttribute("normal",new Ka(u,3)),this.setAttribute("uv",new Ka(d,2));function x(P,S,b,B,w,f,D,C,I,L,M){let k=(f-2*a)/I,W=(D-2*a)/L,oe=f/2-a,he=D/2-a,ie=C/2,Y=I+1,U=L+1,z=0,E=0,_=new En;for(let A=0;A<U;A++){let G=A*W-he;for(let J=0;J<Y;J++){let j=J*k-oe;_[P]=j*B,_[S]=G*w,_[b]=ie,p.push(_.x,_.y,_.z),_[P]=0,_[S]=0,_[b]=C>0?1:-1,u.push(_.x,_.y,_.z),d.push(J/I),d.push(1-A/L),z+=1}}for(let A=0;A<L;A++)for(let G=0;G<I;G++){let J=m+G+Y*A,j=m+G+Y*(A+1),V=m+(G+1)+Y*(A+1),F=m+(G+1)+Y*A;h.push(J,j,F),h.push(j,V,F),E+=6}c.addGroup(g,E,M),g+=E,m+=z}function y(P,S,b,B,w,f,D,C,I,L,M){let k=(D-2*a)/L,W=D/2-a,oe=C/2-a,he=I/2,ie=L+1,Y=0,U=0,z=new En,E=new En;for(let _=0;_<l+1;_++){let A=_/l*Ya,G=Math.sin(A)*a,J=(1-Math.cos(A))*a,j=Math.sin(A),V=Math.cos(A);z[S]=(oe+G)*w,z[b]=(he-J)*f,E[P]=0,E[S]=j*Math.sign(z[S]),E[b]=V*Math.sign(z[b]);for(let F=0;F<ie;F++){let O=F*k-W;z[P]=O*B,p.push(z.x,z.y,z.z),u.push(E.x,E.y,E.z),d.push(F/L),d.push(0),Y+=1}}for(let _=0;_<l;_++)for(let A=0;A<L;A++){let G=m+A+ie*_,J=m+A+ie*(_+1),j=m+(A+1)+ie*(_+1),V=m+(A+1)+ie*_;h.push(G,J,V),h.push(J,j,V),U+=6}c.addGroup(g,U,M),g+=U,m+=Y}function v(P,S,b){let B=new En,w=new En(t/2,e/2,r/2);w.subScalar(a);let f=[],D=P*S*b>0?(I,L,M)=>h.push(I,L,M):(I,L,M)=>h.push(I,M,L);for(let I=0;I<=l;I++){let L=[],M=Ya*(1-I/l),k=Math.cos(M),W=Math.sin(M),oe=0;for(let he=0;he<=I;he++){let ie=Math.cos(oe),Y=Math.sin(oe);B.x=k*ie,B.y=W,B.z=k*Y;let U=w.clone().addScaledVector(B,a);p.push(P*U.x,S*U.y,b*U.z),u.push(P*B.x,S*B.y,b*B.z),d.push(0,0),L.push(m++),oe+=Ya/I}f.push(L)}let C=f.length-1;for(let I=0;I<C;I++){let L=f[I],M=f[I+1],k=L.length-1;D(L[0],M[1],M[0]);for(let W=1;W<=k;W++)D(L[W-1],L[W],M[W]),D(L[W],M[W+1],M[W])}}}};import{BufferGeometry as Qv,Float32BufferAttribute as Qa,Triangle as Zv,Vector3 as yr,Vector2 as Za}from"three";var Gr=class extends Qv{constructor(t=[],e=[],r="",o=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];h(),p(),this.setAttribute("position",new Qa(a,3)),this.setAttribute("normal",new Qa(c,3)),this.setAttribute("uv",new Qa(l,2));return;function h(){n=Math.min(1-1e-5,n),n==0&&(s=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new yr,g=m.clone(),x=new Zv,y=n*o,v=o-y,P=s+1,S=new yr,b=(Y,U)=>S.subVectors(Y,U).normalize(),B=(Y,U)=>Array(Y).fill(void 0).map(U),w=B(t.length/3,(Y,U)=>new yr().fromArray(t,U*3).setLength(o)),f=[],D=1e6;for(let Y=0;Y<w.length;Y++){let U=w[Y],z=[],E,_,A,G=1e10,J=-1;for(;(J=e.indexOf(Y,J+1))!=-1;){let O=J-J%3;E=e[O+(J+1)%3],_=e[O+(J+2)%3],A=U.distanceToSquared(w[E]),G=Math.min(G,A),z.push([E,_,A])}G+=1e-6;let j=[],V=0,F=z.length;for(let O=0;O<F;O++){[E,_,A]=z[V];let q=f[E]?.includes(Y)==!0;A<=G&&j.push(E+ +q*D),V=z.findIndex(Z=>Z[0]==_)}f.push(j)}let C=[];{let Y=0,U=0,z,E,_=d==3;for(let A=0;A<=s;A++){z=A*(A+1)/2,E=(A+1)*(A+2)/2;for(let G=0;G<s-A;G++)[Y,U]=[z+G+A+2,E+G+A+3],C.push(z,E,..._?[U,z]:[Y,E],U,Y),[z,E]=[Y,U];C.push(z,E,z+s+2)}}let I=m.clone(),L=m.clone(),M=m.clone(),k=m.clone(),W=m.clone(),oe=[],he=B(w.length,()=>B(d,()=>m.clone()));for(let Y=0;Y<w.length;Y++){m.copy(w[Y]).normalize(),I.copy(m).multiplyScalar(v);let U=f[Y];for(let j=0;j<U.length;j++){let V=U[j],F=U[(j+1)%d];x.setFromPointsAndIndices(w,Y,V%D,F%D),x.b.sub(x.a).setLength(1e10).add(x.a),x.c.sub(x.a).setLength(1e10).add(x.a),x.closestPointToPoint(I,he[Y][j])}let z=[],E=[],_=[],A=new yr;s==0&&[...he[Y]].reduce((j,V)=>j.add(V),A).multiplyScalar(1/d);for(let j=0;j<d;j++){let V=[],F=(j-1+d)%d,O=he[Y][F],q=he[Y][j];m.copy(O).sub(I),g.copy(q).sub(I);let Z=I.angleTo(m),ee=m.angleTo(g),H=Math.cos(Z)*y;s==0?L.copy(A):L.copy(I).setLength(v+H),E.push(H);let Q=[L,O,q];for(let $=0;$<2;$++){let re=Q[$],le=Q[$+1];k.subVectors(re,I),W.subVectors(le,I),M.crossVectors(k,W).normalize();for(let ne=0;ne<P;ne++){let me=[Z,ee][$]*ne/P;m.copy(k).applyAxisAngle(M,me).add(I),z.push(m.clone()),$&&(b(m,I),V.push([ne==0?re:m.clone(),S.clone()]))}$&&(b(le,I),V.push([le,S.clone()]))}_.push(V)}oe.push(_);let G=2*P,J=2;for(let j=0;j<d;j++){let V=G*j,F=G*((j+1)%d),O=[z[V]];for(let Z=1;Z<P;Z++){k=z[V+Z],W=z[F+Z],O.push(k);for(let ee=1,H=Z-J+1;ee<=H;ee++)m.lerpVectors(k,W,ee/(H+1)),m.sub(I).setLength(E[j]).add(I),O.push(m.clone());O.push(W)}for(let Z=0;Z<P;Z++)O.push(z[Z+P+V]);O.push(z[F+P]);let q=C.map(Z=>O[Z]);a.push(...q.map(Z=>[Z.x,Z.y,Z.z]).flat()),c.push(...q.map(Z=>(b(Z,I),[S.x,S.y,S.z])).flat())}}let ie=[];for(let Y=0;Y<f.length;Y++)for(let U=0;U<d;U++){let z=f[Y][U];if(z<D){let E=f[z].findIndex(G=>G%D==Y),_=oe[Y][U],A=oe[z][E];for(let G=0;G<P;G++){let J=_[G],j=A[P-G],V=_[G+1],F=A[P-(G+1)];[J,j,V,V,j,F].forEach(O=>{a.push(O[0].x,O[0].y,O[0].z),c.push(O[1].x,O[1].y,O[1].z)})}ie.push(_[0][0],A[P][0],_[P][0],A[0][0])}}for(;ie.length;){let Y,U,z,E;[Y,U]=ie.splice(0,2);let _=[Y];for(;Y!=U;)_.push(U),z=ie.indexOf(U),E=z%2,U=ie.splice(z-E,2)[1-E];S.subVectors(_[0],_[1]).cross(m.subVectors(_[0],_[2])).normalize();let A=S.dot(_[0])<0;A&&S.negate();for(let G=1;G<=_.length-2;G++)[_[G+ +A],_[G+1-+A],_[0]].forEach(J=>{a.push(J.x,J.y,J.z),c.push(S.x,S.y,S.z)})}}function p(){let u=new yr;for(let w=0;w<a.length;w+=3){u.x=a[w+0],u.y=a[w+1],u.z=a[w+2];let f=b(u)/2/Math.PI+.5,D=B(u)/Math.PI+.5;l.push(f,1-D)}let d=new yr,m=new yr,g=new yr,x=new yr,y=new Za,v=new Za,P=new Za,S=(w,f,D,C)=>{C<0&&w.x===1&&(l[f]=w.x-1),D.x===0&&D.z===0&&(l[f]=C/2/Math.PI+.5)};for(let w=0,f=0;w<a.length;w+=9,f+=6){d.set(a[w+0],a[w+1],a[w+2]),m.set(a[w+3],a[w+4],a[w+5]),g.set(a[w+6],a[w+7],a[w+8]),y.set(l[f+0],l[f+1]),v.set(l[f+2],l[f+3]),P.set(l[f+4],l[f+5]),x.copy(d).add(m).add(g).divideScalar(3);let D=b(x);S(y,f+0,d,D),S(v,f+2,m,D),S(P,f+4,g,D)}for(let w=0;w<l.length;w+=6){let f=l[w+0],D=l[w+2],C=l[w+4],I=Math.max(f,D,C),L=Math.min(f,D,C);I>.9&&L<.1&&(f<.2&&(l[w+0]+=1),D<.2&&(l[w+2]+=1),C<.2&&(l[w+4]+=1))}function b(w){return Math.atan2(w.z,-w.x)}function B(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}}static fromJSON(t){return new Gr(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as eb}from"three";var cu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new Gn(t*.5,n,s):new eb(t*.5,o);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Gn=class extends Gr{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(s,a,l,t,e,r),this.type=l}static fromJSON(t){return new Gn(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as pb,Plane as ub,Shape as Cu,Vector2 as xr,Vector3 as db,MathUtils as sl,LineCurve as al,QuadraticBezierCurve as Tu,CubicBezierCurve as Ls}from"three";import{CubicBezierCurve as Ns,EllipseCurve as tb,LineCurve as Cs,LineCurve3 as rb,MathUtils as ob,QuadraticBezierCurve as tl,SplineCurve as nb,Vector2 as tt,Vector3 as uu}from"three";var Rn=1e-12,Go=class{constructor(t){this.position=new tt;this.startPosition=new tt;this.uuid=ob.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Go(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ro=class extends Go{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ro(this.parent).copy(this)}},Gt=class extends Go{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ro(this),new Ro(this))}static create(e,r){let o=new Gt(e,new tt(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let s=this.controls[o];this.position.distanceTo(s.position)<=r?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Gt(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new tt,r=new tt){let[o,n]=this.computeTangents();return o&&n&&(hu(o,e),hu(n,r)),[e,r]}computeTangent(e=new tt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new tt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function hu(i,t=new tt){let e=i.length();return t.set(-i.y/e,i.x/e)}var rl=i=>i,zo=new tt,Ts=new tt,ib=new tt,sb=new tt,ab=new tt,lb=new tt,du=new uu,mu=new uu;function fu(i){let t=new tt;t.addVectors(i.v0,zo.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new tt;return e.addVectors(i.v2,Ts.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ns(i.v0,t,e,i.v2)}function zn(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function cb(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function hb(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function ol(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function gu(i,t,e){return pu(i,t)&&pu(t,e)&&el(i.position,t.position,e.position)}function el(i,t,e){return zo.copy(t).sub(i).cross(Ts.copy(e).sub(i))===0}function yu(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(a+l,s+c),o.set(a-l,s-c),[r,o]}function xu(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function vu(i,t,e,r,o,n){let s=t.x-i.x,a=t.y-i.y,l=e.x-i.x,c=e.y-i.y,h=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),p;return ol(t,i,e)>Math.PI&&(h*=-1),zn(c,a)?p=(a+c)*(r/h-.5)*8/3/(s-l):p=(s+l)*(r/h-.5)*8/3/(c-a),o.set(t.x-p*a,t.y+p*s),n.set(e.x+p*c,e.y-p*l),[o,n]}function nl(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function pu(i,t){return el(i.position,i.controls[1].position,t.position)&&el(i.position,t.controls[0].position,t.position)}function bu(i,t,e,r,o=.5){let n=zo.subVectors(t,i).multiplyScalar(o).add(i),s=Ts.subVectors(e,t).multiplyScalar(o).add(t),a=ib.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=sb.subVectors(s,n).multiplyScalar(o).add(n),h=ab.subVectors(a,s).multiplyScalar(o).add(s),p=a,u=lb.subVectors(h,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,u.x,u.y,h.x,h.y,p.x,p.y,r.x,r.y]}function Su(i,t,e=12,r=!0){let o=mu.set(0,0,0),n,s=0,a=[];for(let l=0;l<t.length;l++){let c=rl(t[l]),h=zo,p=Rr(c,e);a.push(p);for(let u=0;u<=p;u++)if(c instanceof Ns||c instanceof tl||c instanceof Cs){if(c.getPoint(u/p,h),o.set(h.x,h.y,0),n!==void 0&&hb(n,o))continue;n===void 0&&(n=du),n.copy(o),i.setXYZ(s,o.x,o.y,o.z),s++}}return r&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),i}function wu(i,t,e,r=12,o=!0){let n=mu.set(0,0,0),s=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,h=rl(t[l]),p=zo,u=Rr(h,r);a.push(u);for(let d=0;d<=u;d++)if(h instanceof Ns||h instanceof tl||h instanceof Cs){if(h.getPoint(d/u,p),n.set(p.x,p.y,0),c?.equals(n))continue;c===void 0?c=du:(i.setXYZ(s,c.x,c.y,c.z),s++,i.setXYZ(s,n.x,n.y,n.z),s++),c.copy(n)}}return o&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),a}function il(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let s=i[o],a=0;if(e&&s.roundedCurveCorner!==void 0){let l=Rr(s.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=Rr(s.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Rr(i[0].roundedCurveCorner,t)*.5),r}function Rr(i,t=12){return i&&i instanceof tb?t*2:i&&(i instanceof Cs||i instanceof rb)?1:i&&i instanceof nb?t*i.points.length:t}function Nu(i,t,e=12,r=!0){let o,n=0;for(let s=0;s<t.length;s++){let a=rl(t[s]),l=Rr(a,e),c=zo;for(let h=0;h<=l;h++)if(a instanceof Ns||a instanceof tl||a instanceof Cs){if(a.getPoint(h/l,c),o!==void 0&&cb(o,c,Rn))continue;o===void 0&&(o=Ts),o.copy(c),i.push(c.x,c.y),n++}}return zn(i[0],i[i.length-2],Rn)&&zn(i[1],i[i.length-1],Rn)&&(i.pop(),i.pop()),r&&n>1&&!(zn(i[n-1],i[1],Rn)&&zn(i[n-2],i[0],Rn))&&(i.push(i[0],i[1]),n++),i}var ll=new xr,mb=new xr,fb=new xr,gb=new xr,yb=new xr,xb=new xr,ve=class extends Cu{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new pb;this.plane=new ub(new db(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=sl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new ve;return n.isClosed=e.isClosed,n.points=e.points.map(s=>Gt.create(s.id,s.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(s=>ve.createFromState(s)),r!==void 0&&o!==void 0&&n.applySize(r,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;for(let s=0,a=this.shapeHoles.length;s<a;s++){let l=this.shapeHoles[s],c=l.points.length-1,h=l.getPointIndexById(e);if(h<0)n+=c;else return h+n}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let r=0,o=this.shapeHoles.length;r<o;r++){let n=this.shapeHoles[r],s=e-this.points.length;if(s<=n.points.length-1)return n.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let s=this.shapeHoles[o],a=s.points.indexOf(e);if(a>=0)return r+a;r+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=ll.set(e,r);for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n];a.position.multiply(o),a.controls[0].position.multiply(o),a.controls[1].position.multiply(o)}for(let n=0,s=this.shapeHoles.length;n<s;n++)this.shapeHoles[n].applyScale(e,r);this._update(!1)}createPoint(e,r=0,o=sl.generateUUID()){let n;e instanceof xr?n=e:n=new xr(e,r);let s=new Gt(o,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let s=this.shapeHoles[r].getPointByUuid(e);if(s)return s}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,o=this.shapeHoles.length;r<o;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return Su(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=il(this.points,e,!1),this.roundedCurveDivisions=il(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return wu(e,this.curves,r,o,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),Nu(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,s=0;r&&this.points[0].roundedCurveCorner!==void 0&&(s=Rr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let h=n[l];if(a<o+h)return[l,(a-o+1)/h];o+=h}return[0,1]}getCurveT(e,r,o){let n=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(nl(n,s)){let p=n.position.distanceTo(s.position);return n.position.distanceTo(ll.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=a[p];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){nl(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(e=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];if(o===0)this.moveTo(s.position.x,s.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(s,a)}}let r=this.getLastPoint();if(r?.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(o,n)}if(this.points.length>2){let o=0;for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n],l=this.points[n-1]??this.points[this.points.length-1],c=this.points[n+1]??this.points[0],h=a.roundness,p=l&&c&&gu(l,a,c);if(!a.controlsMoved()&&h>0&&!p){let u=a.curveBefore,d=a.curveAfter;if(u===void 0||d===void 0)continue;let m=a.roundedCurveBefore,g=a.roundedCurveAfter,x=u.getLength(),y=d.getLength(),v=Math.min(h,x*.499),P=Math.min(h,y*.499),S=Math.min(v,P),b=1-S/x,B=S/y,w=u.getPointAt(b,ll),f=d.getPointAt(B,mb);this._subSplitCurve(u,m,b,w,void 0),this._subSplitCurve(d,g,B,void 0,f);let D;if(this.useCubicForRoundedCorners){let C=ol(w,a.position,f)/2,I=Math.tan(C)*w.distanceTo(a.position),[L,M]=yu(w,f,I,fb,gb),k=xu(L,M,a.position),[W,oe]=vu(k,w,f,I,yb,xb);D=new Ls(w.clone(),W.clone(),oe.clone(),f.clone())}else D=new Tu(w.clone(),a.position.clone(),f.clone());a.roundedCurveCorner=D,this.roundedCurves.splice(n+o,0,D),o++}}}e&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(e,r,o,n,s){if(e instanceof al)n!==void 0&&r.v2.copy(n),s!==void 0&&r.v1.copy(s);else{let a=e,l=r,c=a.getUtoTmapping(o,0),h=bu(a.v0,a.v1,a.v2,a.v3,c);return n!==void 0&&(l.v0.set(h[0],h[1]),l.v1.set(h[2],h[3]),l.v2.set(h[4],h[5]),l.v3.set(h[6],h[7])),s!==void 0&&(l.v0.set(h[6],h[7]),l.v1.set(h[8],h[9]),l.v2.set(h[10],h[11]),l.v3.set(h[12],h[13])),l}return r}clone(){let e=new ve(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let n=o*7,s=e.points[n+0],a=e.points[n+1],l=e.points[n+2],c=e.points[n+3],h=e.points[n+4],p=e.points[n+5],u=e.points[n+6],d=new Gt(sl.generateUUID(),new xr(s,a));d.controls[0].position.set(l,c),d.controls[1].position.set(h,p),d.roundness=u,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new ve;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(n,s)=>{s instanceof Ls&&s.v3.equals(n.position)&&n.controls[0].position.copy(s.v2)},o=n=>{let s=[],a,l;for(a=0,l=n.length;a<l;a++)n[a]instanceof Tu&&(n[a]=fu(n[a]));for(a=0,l=n.length;a<l;a++){let p=n[a],u=a>0?n[a-1]:null,d;p instanceof Ls?(d=this.createPoint(p.v0),d.controls[1].position.copy(p.v1)):p instanceof al&&(d=this.createPoint(p.v1)),d!==void 0&&(u!==null&&r(d,u),s.push(d))}let c=n[n.length-1],h=!1;return c instanceof Ls?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),h=!0):c instanceof al&&c.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=o(e.curves),e instanceof Cu&&(this.shapeHoles=e.holes.map(n=>{let s=new ve;return s.fromShape(n),s})),this.update(),this}};var hl=Math.PI*2;function cl({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function vb(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),s=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+s*e,y:s-n*e},{x:n,y:s}]}function Lu(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function bb(i,t,e,r,o,n,s,a,l,c){let h=Math.pow(o,2),p=Math.pow(n,2),u=Math.pow(s,2),d=Math.pow(a,2),m=h*p-h*d-p*u;m<0&&(m=0),m/=h*d+p*u,m=Math.sqrt(m)*(l===c?-1:1);let g=m*o/n*a,x=m*-n/o*s,y=g+(i+e)/2,v=x+(t+r)/2,P=(s-g)/o,S=(a-x)/n,b=(-s-g)/o,B=(-a-x)/n,w=Lu(1,0,P,S),f=Lu(P,S,b,B);return!c&&f>0&&(f-=hl),c&&f<0&&(f+=hl),{centerx:y,centery:v,ang1:w,ang2:f}}function Iu({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:s,sweepFlag:a}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,h=(t-r)/2;if(c===0&&h===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(h,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let u=bb(i,t,e,r,o,n,c,h,s,a),{ang1:d,ang2:m}=u,{centerx:g,centery:x}=u,y=Math.abs(m)/(hl/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);m/=v;for(let P=0;P<v;P++)l.push(vb(d,m)),d+=m;return l.map(P=>{let{x:S,y:b}=cl(P[0],o,n,g,x),{x:B,y:w}=cl(P[1],o,n,g,x),{x:f,y:D}=cl(P[2],o,n,g,x);return{x1:S,y1:b,x2:B,y2:w,x:f,y:D}})}import{BufferAttribute as Ps,BufferGeometry as Tb}from"three";var Me;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Me||(Me={}));var Ue;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Ue||(Ue={}));function pe(i,t){if(!i)throw t||"Assertion Failed!"}var se=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){pe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){pe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var s,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(s=i.edgeEval(t,r,e),a=i.edgeEval(r,e,o),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,e.s)):(s=i.edgeSign(t,r,e),a=-i.edgeSign(t,o,e),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(s=i.transEval(t,r,e),a=i.transEval(r,e,o),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,e.t)):(s=i.transSign(t,r,e),a=-i.transSign(t,o,e),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,o.t)):n.t=(r.t+e.t)/2},i}(),Vn=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Is=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Vo=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),Pu=function(){function i(){var t=new Vo,e=new Vn,r=new Is(0),o=new Is(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Is(0),r=new Is(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;pe(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;pe(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var s=e;do s.Lface=o,s=s.Lnext;while(s!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,s=t.next;s.prev=n,n.next=s},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,s=t.next;s.prev=n,n.next=s},i.prototype.makeEdge=function(){var t=new Vo,e=new Vo,r=new Vn,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Vo;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var s=new Vn;this.makeFace_(s,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new Vn;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Vo;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var s=new Vn;this.makeFace_(s,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,s,a;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);s=t.prev,a=t.next,a.prev=s,s.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,s,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,s=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),a+l-2<=t&&se.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&se.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===s);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,s,a,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){pe(o.prev===n),l=o.anEdge;do pe(l.Sym!==l),pe(l.Sym.Sym===l),pe(l.Lnext.Onext.Sym===l),pe(l.Onext.Sym.Lnext===l),pe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(pe(o.prev===n&&o.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){pe(s.prev===a),l=s.anEdge;do pe(l.Sym!==l),pe(l.Sym.Sym===l),pe(l.Lnext.Onext.Sym===l),pe(l.Onext.Sym.Lnext===l),pe(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(pe(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)pe(l.Sym.next===c.Sym),pe(l.Sym!==l),pe(l.Sym.Sym===l),pe(l.Org!==null),pe(l.Dst!==null),pe(l.Lnext.Onext.Sym===l),pe(l.Onext.Sym.Lnext===l);pe(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Mu=function(){function i(){this.handle=null}return i}(),Au=function(){function i(){this.key=null,this.node=0}return i}(),Sb=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Mu,this.handles[r]=new Au;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,s;for(o=e[t].handle;;){if(s=t<<1,s<this.size&&this.leq(r[e[s+1].handle].key,r[e[s].handle].key)&&++s,pe(s<=this.max),n=e[s].handle,s>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=s}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,s;for(o=e[t].handle;;){if(s=t>>1,n=e[s].handle,s===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=s}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Mu;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new Au}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;pe(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),pl=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Ou=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),wb=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Ou,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new Ou;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),Nb=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,s=r.eUp;if(n.Dst===o)return s.Dst===o?se.vertLeq(n.Org,s.Org)?se.edgeSign(s.Dst,n.Org,s.Org)<=0:se.edgeSign(n.Dst,s.Org,n.Org)>=0:se.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return se.edgeSign(n.Dst,o,n.Org)>=0;var a=se.edgeEval(n.Dst,o,n.Org),l=se.edgeEval(s.Dst,o,s.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&pe(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){pe(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new pl;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case Me.ODD:return(e&1)!==0;case Me.NONZERO:return e!==0;case Me.POSITIVE:return e>0;case Me.NEGATIVE:return e<0;case Me.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,s=e,a=e.eUp;s!==r;){if(s.fixUpperEdge=!1,n=i.regionBelow(s),o=n.eUp,o.Org!=a.Org){if(!n.fixUpperEdge){i.finishRegion(t,s);break}o=t.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}a.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(a,o)),i.finishRegion(t,s),a=n.eUp,s=n}return a},i.addRightEdges=function(t,e,r,o,n,s){var a,l,c,h,p=!0;c=r;do pe(se.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,h=n;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===h.Org;)c.Onext!==h&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(t,l)&&(i.addWinding(c,h),i.deleteRegion(t,l),t.mesh.delete(h)),p=!1,l=a,h=c;l.dirty=!0,pe(l.windingNumber-c.winding===a.windingNumber),s&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=se.vertL1dist(e,t),n=se.vertL1dist(r,t),s=.5*n/(o+n),a=.5*o/(o+n);t.coords[0]+=s*e.coords[0]+a*r.coords[0],t.coords[1]+=s*e.coords[1]+a*r.coords[1],t.coords[2]+=s*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,s)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp;if(se.vertLeq(o.Org,n.Org)){if(se.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;se.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(se.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,s;if(pe(!se.vertEq(o.Dst,n.Dst)),se.vertLeq(o.Dst,n.Dst)){if(se.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,s=t.mesh.splitEdge(o),t.mesh.splice(n.Sym,s),s.Lface.inside=e.inside}else{if(se.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=r.dirty=!0,s=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),s.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,s=o.Org,a=n.Org,l=o.Dst,c=n.Dst,h,p,u=new Vo,d,m;if(pe(!se.vertEq(c,l)),pe(se.edgeSign(l,t.event,s)<=0),pe(se.edgeSign(c,t.event,a)>=0),pe(s!==t.event&&a!==t.event),pe(!e.fixUpperEdge&&!r.fixUpperEdge),s===a||(h=Math.min(s.t,l.t),p=Math.max(a.t,c.t),h>p))return!1;if(se.vertLeq(s,a)){if(se.edgeSign(c,s,a)>0)return!1}else if(se.edgeSign(l,a,s)<0)return!1;return i.debugEvent(t),se.intersect(l,s,c,a,u),pe(Math.min(s.t,l.t)<=u.t),pe(u.t<=Math.max(a.t,c.t)),pe(Math.min(c.s,l.s)<=u.s),pe(u.s<=Math.max(a.s,s.s)),se.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),d=se.vertLeq(s,a)?s:a,se.vertLeq(d,u)&&(u.s=d.s,u.t=d.t),se.vertEq(u,s)||se.vertEq(u,a)?(i.checkForRightSplice(t,e),!1):!se.vertEq(l,t.event)&&se.edgeSign(l,t.event,u)>=0||!se.vertEq(c,t.event)&&se.edgeSign(c,t.event,u)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),m=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,m,!0),!0):(se.edgeSign(l,t.event,u)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),se.edgeSign(c,t.event,u)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=u.s,o.Org.t=u.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,s,l,a,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,s=i.regionBelow(e),a=e.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),se.vertEq(a.Org,t.event)&&(t.mesh.splice(n.Oprev,a),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),s),c=!0),se.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,s,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}se.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,s,a,l;if(o=e.eUp,se.vertEq(o.Org,r)){pe(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!se.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}pe(!1),e=i.topRightRegion(e),l=i.regionBelow(e),s=l.eUp.Sym,n=a=s.Onext,l.fixUpperEdge&&(pe(n!==s),i.deleteRegion(t,l),t.mesh.delete(s),s=n.Oprev),t.mesh.splice(r.anEdge,s),se.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,s.Onext,a,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,s,a,l,c=new pl;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(s=r.eUp,a=o.eUp,se.edgeSign(s.Dst,e,s.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=se.vertLeq(a.Dst,s.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,s.Lnext);else{var h=t.mesh.connect(a.Dnext,e.anEdge);l=h.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);pe(o!==null);var n=i.regionBelow(o),s=n.eUp,a=i.finishLeftRegions(t,n,null);a.Onext===s?i.connectRightVertex(t,o,a):i.addRightEdges(t,o,a.Onext,s,s,!0)},i.addSentinel=function(t,e,r,o){var n=new pl,s=t.mesh.makeEdge();s.Org.s=r,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,t.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new wb(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,s=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,o,n,s),i.addSentinel(t,o,n,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(pe(e.fixUpperEdge),pe(++r===1)),pe(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,se.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new Sb(n,se.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,pe(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!se.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),Cb=function(){function i(){this.mesh=new Pu,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Me.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,s,a,l=[0,0,0],c=[0,0,0],h=[0,0,0],p=[0,0,0],u=[0,0,0],d=[null,null,null],m=[null,null,null],g=this.mesh.vHead;e=g.next;for(var x=0;x<3;++x)n=e.coords[x],c[x]=n,m[x]=e,l[x]=n,d[x]=e;for(e=g.next;e!==g;e=e.next)for(var y=0;y<3;++y)n=e.coords[y],n<c[y]&&(c[y]=n,m[y]=e),n>l[y]&&(l[y]=n,d[y]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=m[v],o=d[v],h[0]=r.coords[0]-o.coords[0],h[1]=r.coords[1]-o.coords[1],h[2]=r.coords[2]-o.coords[2],e=g.next;e!==g;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],u[0]=h[1]*p[2]-h[2]*p[1],u[1]=h[2]*p[0]-h[0]*p[2],u[2]=h[0]*p[1]-h[1]*p[0],s=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],s>a&&(a=s,t[0]=u[0],t[1]=u[1],t[2]=u[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(h)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,s=t.next;s!==t;s=s.next)if(o=s.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(n<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,n=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),n=!0),r=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;se.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;se.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(se.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(se.edgeGoesLeft(o.Lnext)||se.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(se.edgeGoesRight(r.Lprev)||se.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,s=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var h=t.fHead.next;h!==t.fHead;h=h.next)if(h.n=-1,!!h.inside){n=h.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=a,a++),l++,n=n.Lnext}while(n!==h.anEdge);if(l>r)throw"Face vertex greater that support polygon";h.n=s,++s}this.elementCount=s,e===Ue.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var u=0,h=t.fHead.next;h!==t.fHead;h=h.next)if(!!h.inside){n=h.anEdge,l=0;do{var c=n.Org;this.elements[u++]=c.n,l++,n=n.Lnext}while(n!==h.anEdge);for(var d=l;d<r;++d)this.elements[u++]=-1;if(e===Ue.CONNECTED_POLYGONS){n=h.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==h.anEdge);for(var m=l;m<r;++m)this.elements[u++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,h=0;n=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){s=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==o);this.elements[h++]=n,this.elements[h++]=s,n+=s}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new Pu),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,o,n,s){if(t===void 0&&(t=Me.ODD),e===void 0&&(e=Ue.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),Nb.computeInterior(this,s);var a=this.mesh;return e===Ue.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===Ue.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,e,r,o),!0},i}();function Zr(i){var t=i.windingRule,e=t===void 0?Me.ODD:t,r=i.elementType,o=r===void 0?Ue.POLYGONS:r,n=i.polySize,s=n===void 0?3:n,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,h=c===void 0?[0,0,1]:c,p=i.contours,u=p===void 0?[]:p,d=i.strict,m=d===void 0?!0:d,g=i.debug,x=g===void 0?!1:g;if(!u&&m)throw new Error("Contours can't be empty");if(!!u){var y=new Cb;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<u.length;v++)y.addContour(l||2,u[v]);return y.tesselate(e,o,s,l,h,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:x?y.mesh:void 0}}}var o3=Me.ODD,n3=Me.NONZERO,i3=Me.POSITIVE,s3=Me.NEGATIVE,a3=Me.ABS_GEQ_TWO,l3=Ue.POLYGONS,c3=Ue.CONNECTED_POLYGONS,h3=Ue.BOUNDARY_CONTOURS;var Fo=class extends Tb{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Me.ODD;this.elementType=Ue.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Me.ODD,elementType:Ue.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,h,p;for(let m=0,g=n.length/2;m<g;m++){let x=m*2,y=n[x+0],v=n[x+1];if(h!==void 0&&y!==h&&(l=!1),p!==void 0&&v!==p&&(c=!1),h=y,p=v,!l&&!c)break}!l&&!c&&(a=Zr({contours:[n,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let u=a?.vertexCount??1,d=a?.elementCount??1;if(this._positionAttribute=new Ps(new Float32Array(u*3),3),this._normalAttribute=new Ps(new Float32Array(u*3),3),this._uvAttribute=new Ps(new Float32Array(u*2),2),this._indexAttribute=new Ps(new Uint32Array(d*3),1),a){let m=1/0,g=-1/0,x=1/0,y=-1/0;for(let S=0,b=u;S<b;S++){let B=S*2,w=a.vertices[B+0],f=a.vertices[B+1];w<m&&(m=w),w>g&&(g=w),f<x&&(x=f),f>y&&(y=f)}let v=g-m,P=y-x;for(let S=0,b=u;S<b;S++){let B=S*2,w=a.vertices[B+0],f=a.vertices[B+1],D=(w-m)/v,C=(f-x)/P;this._positionAttribute.setXYZ(S,w,f,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,D,C)}for(let S=0,b=d;S<b;S++){let B=S*3,w=a.elements[B+0],f=a.elements[B+1],D=a.elements[B+2];this._indexAttribute.setX(B+0,w),this._indexAttribute.setX(B+1,f),this._indexAttribute.setX(B+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Fo(this._shape,this._curveSegments);return e.userData=Cn(this.userData),e}};import{BufferAttribute as As,BufferGeometry as Lb}from"three";var Ms=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Ms.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Ms.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*n,3*t);s+=3*t;let l=new Float32Array(o,s*n,3*t);s+=3*t;let c=new Float32Array(o,s*n,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Fn=Ms;Fn.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var ul=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Uo=class extends Lb{constructor(e,r,o=0,n=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=o,this._curveSegments=n,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,r/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],n),l=this._shape.shapeHoles.map(w=>{let f=w.extractShapePointsToFlatArray([],n),D=[];for(let C=f.length-1;C>=1;C-=2){let I=f[C-1],L=f[C-0];D.push(I,L)}return D}),c=Zr({windingRule:Me.ODD,elementType:Ue.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=Zr({windingRule:Me.ODD,elementType:Ue.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let p=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let w=0;w<h.elements.length;w++){let f=h.elements[w],D=w%2===0?c.vertexCount:0;c.elements.push(f+D)}for(let w=0;w<h.vertexIndices.length;w++){let f=h.vertexIndices[w],D=c.vertexCount;c.vertexIndices.push(f+D)}for(let w=0;w<h.vertices.length;w++){let f=h.vertices[w];c.vertices.push(f)}}let u=1/0,d=-1/0,m=1/0,g=-1/0;for(let w=0,f=c.vertexCount;w<f;w++){let D=w*2,C=c.vertices[D+0],I=c.vertices[D+1];C<u&&(u=C),C>d&&(d=C),I<m&&(m=I),I>g&&(g=I)}this._minX=u,this._minY=m,this._width=d-u,this._height=g-m;let x=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Fn(x);let y=[],v=[];for(let w=c.elementCount-1;w>=0;w--){let f=w>=p,D=w*2,C=c.elements[D+0],I=c.elements[D+1],L=C+I,M={start:C,count:I,normals:[],continuous:[],concave:[]},k=C,W=L-1,oe=C+1,he=this._shape.roundedCurves.length;do{let z=k-C,E=c.vertices[W*2+0],_=c.vertices[W*2+1],A=c.vertices[k*2+0],G=c.vertices[k*2+1],J=c.vertices[oe*2+0],j=c.vertices[oe*2+1],V=A-E,F=G-_,O=Math.sqrt(V*V+F*F);V/=O,F/=O;let q=A-J,Z=G-j,ee=Math.sqrt(q*q+Z*Z);q/=ee,Z/=ee,M.normals[z*2+0]=-Z,M.normals[z*2+1]=q,M.concave[z]=V*Z-F*q>0;let H=c.vertexIndices[k];if(Array.isArray(H))M.continuous[z]=!1;else{let[Q,$]=this._shape.getCurveIndexFromVertexId(H-1,!0);if($>0&&$<1)M.continuous[z]=!0;else{let re=$===1?Q+1:Q-1;re=(re+he)%he;let le=$===1?0:1,ne=this._shape.roundedCurves[Q].getTangent($),me=this._shape.roundedCurves[re].getTangent(le);M.continuous[z]=ne.dot(me)>.95}}f&&(M.normals[z*2+0]*=-1,M.normals[z*2+1]*=-1),[W,k,oe]=[k,oe,oe+1],oe>=L&&(oe-=I)}while(oe!==C+1);let ie=[];ie.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(C*2,L*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((z,E)=>[E,E]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,L*2)});for(let z=1;z<=this._bevelSegments;z++){let E=z/this._bevelSegments*Math.PI/2,_=(1-Math.cos(E))*this._bevelSize,A=[],G=[],J=[],j=[],V=0;for(let O=0;O<I;O++){let q=O*2,Z=(O-1+I)%I*2,ee=c.vertices[M.start*2+q+0],H=c.vertices[M.start*2+q+1],Q=-M.normals[Z+0]*_,$=-M.normals[Z+1]*_,re=-M.normals[q+0]*_,le=-M.normals[q+1]*_;if(M.concave[O]||!M.concave[O]&&f){let ne=Math.atan2($,Q),me=Math.atan2(le,re);me>ne&&(me-=Math.PI*2);let _e=me-ne;if(M.continuous[O]||f){let ge=ne+_e/2,ze=Math.cos(ge)*_,Se=Math.sin(ge)*_;A[2*V+0]=ee+ze*(f?-1:1),A[2*V+1]=H+Se*(f?-1:1),j[V]=O,V++}else{let ge=Math.max(1,Math.floor(n/4*Math.abs(_e)/Math.PI));for(let ze=0;ze<=ge;ze++){let Se=ne+_e*(ze/ge),lt=Math.cos(Se)*_,Nt=Math.sin(Se)*_;A[2*V+0]=ee+lt,A[2*V+1]=H+Nt,j[V]=O,V++}}}else A[2*V+0]=ee+Q,A[2*V+1]=H+$,j[V]=O,G[O]=V,V++,A[2*V+0]=ee,A[2*V+1]=H,j[V]=O,V++,A[2*V+0]=ee+re,A[2*V+1]=H+le,j[V]=O,J[O]=V,V++}let F=Zr({windingRule:Me.POSITIVE,elementType:Ue.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[A],edgeCreateCallback:O=>{let Z=O.Org.idx,ee=j[Z],H=j[(Z+1)%j.length];O.idx=[ee,H],O.Sym.idx=[H,ee]},vertexIdCallback:O=>{let q=O.Lprev.idx;return[q?q[1]:0,O.idx[0]]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!F.vertexCount)break;for(let O=0;O<F.vertexIndices.length;O++){let[q,Z]=F.vertexIndices[O];if(q===Z)continue;let ee=Z;Z<q&&(ee+=I);for(let H=q;H<ee;H++){let Q=H%I,$=(H+1)%I;if(!M.continuous[Q]||!M.continuous[$]){F.vertexIndices[O]=[q,Q],F.vertexIndices.splice(O+1,0,[$,Z]),F.vertices.splice((O+1)*2,0,F.vertices[O*2],F.vertices[O*2+1]);break}}}ie.push({bevelI:z,angle:E,size:_,boundary:F,reverseMap:j,insetPoints:A})}let Y=(z,E,_)=>{let A=0,G=z.boundary.vertexIndices.length;for(;A<G&&_(z.boundary.vertexIndices[E]);)E=(E+1)%G,A++;return A},U=y.length;for(let z=1;z<ie.length;z++){let E=ie[z-1],_=ie[z],A=E.boundary.vertexIndices.length,G=_.boundary.vertexIndices.length;if(!A||!G)break;let J=M.concave.length,j=0,V=ul(j,I);for(;!E.boundary.vertexIndices.filter(V).length||!_.boundary.vertexIndices.filter(V).length;)j++,V=ul(j,I);let F=E.boundary.vertexIndices.findIndex(V),O=_.boundary.vertexIndices.findIndex(V);do F=(F+1)%A;while(V(E.boundary.vertexIndices[F]));do O=(O+1)%G;while(V(_.boundary.vertexIndices[O]));j=(j+1)%I;let q=j,Z=this.buildBevelVert(M,E,(F-1+A)%A),ee=this.buildBevelVert(M,_,(O-1+G)%G),H=Z,Q=ee,$,re,le=!1;do{V=ul(j,I);let ne=Y(E,F,V),me=Y(_,O,V),_e=le;if(le=!1,ne&&!me){for(let ge=0;ge<ne;ge++)$=this.buildBevelVert(M,E,(F+ge)%A,ge/(ne-1)),y.push(H.topN,$.topP,Q.topN),y.push($.bottomP,H.bottomN,Q.bottomN),H=$;le=!0}else if(!ne&&me)for(let ge=0;ge<me;ge++)re=this.buildBevelVert(M,_,(O+ge)%G,ge/(me-1)),y.push(Q.topN,H.topP,re.topP),y.push(H.bottomP,Q.bottomN,re.bottomP),Q=re;else if(ne&&me)if($=this.buildBevelVert(M,E,F,0),re=this.buildBevelVert(M,_,O,0),_e?(y.push(H.topN,re.topP,Q.topN),y.push(H.topN,$.topP,re.topP),y.push(re.bottomP,H.bottomN,Q.bottomN),y.push(re.bottomP,$.bottomP,H.bottomN)):(y.push(Q.topN,H.topN,$.topP),y.push(Q.topN,$.topP,re.topP),y.push($.bottomP,H.bottomN,Q.bottomN),y.push($.bottomP,Q.bottomN,re.bottomP)),H=$,Q=re,ne===me)for(let ge=1;ge<ne;ge++)$=this.buildBevelVert(M,E,(F+ge)%A,ge/(ne-1)),re=this.buildBevelVert(M,_,(O+ge)%G,ge/(me-1)),y.push(H.topN,$.topP,Q.topN),y.push(Q.topN,$.topP,re.topP),y.push($.bottomP,H.bottomN,Q.bottomN),y.push($.bottomP,Q.bottomN,re.bottomP),H=$,Q=re;else if(ne>me){let ge=ne/me,ze=0;for(let Se=1;Se<ne;Se++)$=this.buildBevelVert(M,E,(F+Se)%A,Se/(ne-1)),y.push(H.topN,$.topP,Q.topN),y.push($.bottomP,H.bottomN,Q.bottomN),H=$,Se>(ze+1)*ge&&(ze++,re=this.buildBevelVert(M,_,(O+ze)%G,ze/(me-1)),y.push(Q.topN,$.topP,re.topP),y.push($.bottomP,Q.bottomN,re.bottomP),Q=re)}else{let ge=me/ne,ze=0;for(let Se=1;Se<me;Se++)re=this.buildBevelVert(M,_,(O+Se)%G,Se/(me-1)),y.push(Q.topN,$.topP,re.topP),y.push($.bottomP,Q.bottomN,re.bottomP),Q=re,Se>(ze+1)*ge&&(ze++,$=this.buildBevelVert(M,E,(F+ze)%A,ze/(ne-1)),y.push(H.topN,$.topP,Q.topN),y.push($.bottomP,H.bottomN,Q.bottomN),H=$)}F=(F+ne)%A,O=(O+me)%G,j=(j+1)%J}while(j!==q)}{let z=ie[0];for(let E=0,_=z.boundary.vertexCount;E<_;E++){let A=this.buildBevelVert(M,z,E),G=this.buildBevelVert(M,z,(E+1)%_);y.push(G.topP,A.topN,A.bottomN),y.push(G.topP,A.bottomN,G.bottomP)}}if(f){let z=[];for(let E=y.length-1;E>=U+2;E-=3){let _=y[E-2],A=y[E-1],G=y[E-0];z.push(G,A,_)}y.splice(U,y.length-U,...z)}if(f){let z=[];for(let E=ie[ie.length-1].boundary.vertices.length-1;E>=1;E-=2){let _=ie[ie.length-1].boundary.vertices[E-1],A=ie[ie.length-1].boundary.vertices[E-0];z.push(_,A)}v.push(z)}if(!f){let z=ie[ie.length-1],E=Zr({windingRule:ie.length>1?Me.POSITIVE:Me.ODD,elementType:Ue.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...v]});if(!E)throw new Error("Error generating geometry for surface");l.length===0&&Object.assign(this,{capStartIndex:y.length});for(let _=0;_<E.elementCount*3;_+=3){let A=this.buildSurfaceVert(E,E.elements[_+0]),G=this.buildSurfaceVert(E,E.elements[_+1]),J=this.buildSurfaceVert(E,E.elements[_+2]);y.push(A.top,G.top,J.top),y.push(J.bottom,G.bottom,A.bottom)}}this.vertexCache={}}this._buffer.shrink();let P=new As(Uint32Array.from(y),1),S=new As(this._buffer.positions,3),b=new As(this._buffer.normals,3),B=new As(this._buffer.uvs,2);S.needsUpdate=!0,b.needsUpdate=!0,B.needsUpdate=!0,P.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",b),this.setAttribute("uv",B),this.setIndex(P)}buildSurfaceVert(e,r){let o=r.toString();if(o in this.vertexCache)return this.vertexCache[o];let n=e.vertices[r*2+0],s=e.vertices[r*2+1],a=(n-this._minX)/this._width,l=(s-this._minY)/this._height,c=this._buffer.get(2),h=c*3,p=c*2,u={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=n,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[p+0]=a,this._buffer.uvs[p+1]=l,this._buffer.positions[h+3]=n,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[p+2]=a,this._buffer.uvs[p+3]=l,this.vertexCache[o]=u,u}buildBevelVert(e,r,o,n=1){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[a,l]=r.boundary.vertexIndices[o],c,h,p,u;a!==l?(h=a,c=l,u=!1,p=e.continuous[h]&&e.continuous[c]):(c=a,h=(c-1+e.count)%e.count,u=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||u);let d=Math.cos(r.angle),m=Math.sin(r.angle),g=o*2,x=c*2,y=h*2,v=r.boundary.vertices[g+0],P=r.boundary.vertices[g+1],S=(1-m)*this._bevelSize,b=(v-this._minX)/this._width,B=(P-this._minY)/this._height,w=e.normals[x+0],f=e.normals[x+1],D=e.normals[y+0],C=e.normals[y+1];if(u){let W=D-w,oe=C-f;w=w+W*(1-n),f=f+oe*(1-n);let he=Math.sqrt(w*w+f*f);w/=he,f/=he}let I=this._buffer.get(p?2:4),L=I*3,M=I*2,k={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=P,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=w*d,this._buffer.normals[L+1]=f*d,this._buffer.normals[L+2]=m,this._buffer.uvs[M+0]=b,this._buffer.uvs[M+1]=B,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=P,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=w*d,this._buffer.normals[L+4]=f*d,this._buffer.normals[L+5]=-m,this._buffer.uvs[M+2]=B,this._buffer.uvs[M+3]=b,p||(I+=2,L+=6,M+=4,k.topP=I+0,k.bottomP=I+1,this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=P,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=D*d,this._buffer.normals[L+1]=C*d,this._buffer.normals[L+2]=m,this._buffer.uvs[M+0]=b,this._buffer.uvs[M+1]=B,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=P,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=D*d,this._buffer.normals[L+4]=C*d,this._buffer.normals[L+5]=-m,this._buffer.uvs[M+2]=B,this._buffer.uvs[M+3]=b),this.vertexCache[s]=k,k}clone(){let e=new Uo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Cn(this.userData),e}};var Ke=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),s=i.shape??t?.shape,a=s?.roundness??e.roundness;s!==void 0&&(s instanceof ve?(s.width!==r||s.height!==o)&&s.applySize(r,o):s=new ve(r,o).fromJSON(s),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&s.update(!1));let l=s??new ve(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:n,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:n}=i.parameters;i.shape.roundness=n;let s;return t<=0?s=new Fo(i.shape,o):s=new Uo(i.shape,t,e,o,r),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};import{MathUtils as _u,Vector2 as Bu}from"three";var Eu=Math.PI*2,Gu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof ve?i.shape:new ve,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:o,innerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c=i.shape,h=t*.5,p=e*.5,u=Ib(c,h,p,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let d=Ke.create({shape:c,parameters:{subdivisions:u,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:{...i,type:"EllipseGeometry"}})}};function Ib(i,t,e,r,o,n){if(r>=Eu)return o>30||o%4===0?(Mb(i,t,e,n),Math.round(o/4)):Du(i,r,o,t,e,n);let s={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=Iu({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?Pb(i,s.x,s.y,c,o,t,e,n):Du(i,r,o,t,e,n)}function Pb(i,t,e,r,o,n,s,a){let l=Math.round(o/r.length);i.addPoint(jo(t,e));for(let c=0,h=r.length;c<h;c++){let p=r[c],u=i.points[c],d=jo(p.x,p.y);u.controls[1].position.set(p.x1,p.y1),d.controls[0].position.set(p.x2,p.y2),i.addPoint(d)}return a>0?Ru(i,n,s,a):i.addPoint(jo(0,0)),l}function Du(i,t,e,r,o,n){let s=-t/e;for(let a=0;a<=e;a++){let l=s*a,c=Math.sin(l)*r,h=Math.cos(l)*o;i.addPoint(jo(c,h))}return t<Eu?n>0?Ru(i,r,o,n):i.addPoint(jo(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&zu(i,r,o,n)),1}function Mb(i,t,e,r=0,o=0,n=0){let s=.5522847498,a=t*s,l=e*s;i.addPoint(Os(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Os(o,n+e,o-a,n+e,o+a,n+e)),i.addPoint(Os(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Os(o,n-e,o+a,n-e,o-a,n-e)),r>0&&zu(i,t,e,r)}function jo(i,t){return new Gt(_u.generateUUID(),new Bu(i,t))}function Os(i,t,e,r,o,n){let s=jo(i,t);return s.controls[0].position.set(e,r),s.controls[1].position.set(o,n),s}function Ru(i,t,e,r){Vu(i,t,e,r).forEach(n=>i.addPoint(n))}function zu(i,t,e,r){let o=Vu(i,t,e,r),n=new ve;o.forEach(s=>n.addPoint(s)),n.isClosed=!0,i.shapeHoles.push(n)}function Vu(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),s=new Bu(o/t,n/e),a=i.points.map(l=>{let c=l.clone();return c.uuid=_u.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),h=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Ab,Float32BufferAttribute as dl,Vector3 as Fu}from"three";var Uu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),n=Math.abs(e.depth??r),s=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:n,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:o,revolutions:n,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:p}=i.parameters,u=new Un(!1,t,e,r,o,n,s,a,l,c,h,p);return Object.assign(u,{userData:{...i,type:"HelixGeometry"}})}},Un=class extends Ab{constructor(t=!0,e=1,r=1,o=1,n=1,s=1,a=1,l=1,c=1,h=1,p=1,u=1){super();let d=t&&s===1;d&&(u=0),p>100&&(p=100);let m=()=>new Fu,g=new Fu,x=m(),y=m(),v=m(),P,S,b,B,w,f,D,C,I=m(),L=m(),M=m(),k=m(),W=m(),oe=m(),he=m(),ie=m(),Y=r-2*l+.001,U=Y/s,z=Math.ceil(a*s),E=z+1,_=Y/z,A=-Y/2,G=h+1,J=2*Math.PI/h,j=Math.PI/2/u,V=.01,F=Math.min((1-p/100)*l,l-V),O=l-F,q=0,Z=2,ee=u*Z+Z,H=G*ee/Z,Q=H+G*E,$=G*(E+ee),[re,le,ne]=[3,3,2].map(Ee=>Array($*Ee).fill(0)),me=[],_e=n-l;function ge(Ee,ft){let Wt=Math.PI/2;f=ft*_,C=2*Math.PI*(f%U)/U+Wt,f+=A,D=Math.sin(C)*_e,w=Math.cos(C)*_e,t?Ee.set(w,D,f):Ee.set(w,f,D)}ge(g,-1e-10),ge(x,0),I.copy(g),ge(g,1);let ze=g.distanceTo(x),Se=O+F,lt=ze*z+2*Se,Nt=F,so=lt-Se;for(let Ee=0;Ee<=z;Ee++){ge(y,Ee),ie.subVectors(y,I).normalize(),I.copy(y),oe.copy(y).setComponent(+t+1,0).normalize(),he.crossVectors(ie,oe).normalize();let ft=Ee===0,Wt=Ee===z,Um=ft?3*Math.PI/2:j,jm=ft?Nt:so,km=ft?G:Q,Hm=ft?0:$-G,Wm=ie.clone().multiplyScalar(ft?-O:O).add(y),qm=ie.clone().multiplyScalar(ft?-1:1).normalize();for(let pr=0;pr<G;pr++){let fc=pr*J;if(L.addVectors(g.copy(oe).multiplyScalar(l*Math.cos(fc)),x.copy(he).multiplyScalar(l*Math.sin(fc))),M.copy(L).normalize(),ft||Wt){d||(q=Hm+pr,[0,1,2].forEach(ct=>{re[q*3+ct]=Wm.getComponent(ct),le[q*3+ct]=qm.getComponent(ct)}),ne[q*2]=+Wt,ne[q*2+1]=pr/h),x.copy(M).multiplyScalar(F),v.addVectors(y,x);for(let ct=0;ct<u;ct++){let xa=ct*j+Um;k.addVectors(g.copy(ie).multiplyScalar(O*Math.sin(xa)),x.copy(M).multiplyScalar(O*Math.cos(xa))),W.copy(k).normalize(),x.addVectors(v,k),k.normalize(),q=km+ct*G+pr,[0,1,2].forEach(vi=>{re[q*3+vi]=x.getComponent(vi),le[q*3+vi]=W.getComponent(vi)});let $m=+ft+Math.sin(xa);ne[q*2]=(jm+O*$m)/lt,ne[q*2+1]=pr/h}}x.addVectors(y,L),q=H+Ee*G+pr,[0,1,2].forEach(ct=>{re[q*3+ct]=x.getComponent(ct),le[q*3+ct]=M.getComponent(ct)}),ne[q*2]=(Se+Ee*ze)/lt,ne[q*2+1]=pr/h}}let mt=E+2*u+Z,ao=1,[yi,xi]=d?[ao,ao+E-1]:[0,mt-1];for(let Ee=yi;Ee<=xi-1;Ee++){let ft=d&&Ee===xi-1;for(let Wt=0;Wt<G-1;Wt++)P=Ee*G+Wt,S=P+1,b=(ft?Wt:P)+G,B=(ft?Wt+1:S)+G,Ee===0?me.push(S,B,b):Ee===mt-2?me.push(P,S,b):me.push(P,S,b,S,B,b)}this.setIndex(me),this.setAttribute("position",new dl(re,3)),this.setAttribute("normal",new dl(le,3)),this.setAttribute("uv",new dl(ne,2))}};import{IcosahedronBufferGeometry as Ob}from"three";var ju=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new jn(t*.5,n,s):new Ob(t*.5,o);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},jn=class extends Gr{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(n,s,a,t,e,r),this.type=a}static fromJSON(t){return new jn(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as Db,Shape as _b}from"three";var ku=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,o=new _b;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new Db(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};import{BufferGeometry as Ku,BufferGeometryLoader as kb,Vector3 as Hb,BoxBufferGeometry as Yu}from"three";import{BufferGeometry as Vb,Vector2 as gl,Vector3 as Xu}from"three";import{Box3 as Bb,BufferAttribute as kn,BufferGeometry as Hu,Color as qu,EventDispatcher as Eb,Float32BufferAttribute as ko,Matrix3 as Wu,Matrix4 as $u,MathUtils as Gb,Object3D as Rb,Sphere as zb,Vector2 as Pt,Vector3 as rt}from"three";var Qt=new $u,ml=new Rb,Ds=new rt,zr=class extends Eb{constructor(){super(),this.uuid=Gb.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new Wu().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];n.normal.applyMatrix3(e).normalize();for(let s=0,a=n.vertexNormals.length;s<a;s++)n.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Qt.makeRotationX(t),this.applyMatrix4(Qt),this}rotateY(t){return Qt.makeRotationY(t),this.applyMatrix4(Qt),this}rotateZ(t){return Qt.makeRotationZ(t),this.applyMatrix4(Qt),this}translate(t,e,r){return Qt.makeTranslation(t,e,r),this.applyMatrix4(Qt),this}scale(t,e,r){return Qt.makeScale(t,e,r),this.applyMatrix4(Qt),this}lookAt(t){return ml.lookAt(t),ml.updateMatrix(),this.applyMatrix4(ml.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let n=o.position,s=o.normal,a=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let u=0;u<n.count;u++)e.vertices.push(new rt().fromBufferAttribute(n,u)),a!==void 0&&e.colors.push(new qu().fromBufferAttribute(a,u));function h(u,d,m,g){let x=a===void 0?[]:[e.colors[u].clone(),e.colors[d].clone(),e.colors[m].clone()],y=s===void 0?[]:[new rt().fromBufferAttribute(s,u),new rt().fromBufferAttribute(s,d),new rt().fromBufferAttribute(s,m)],v=new Ho(u,d,m,y,x,g);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new Pt().fromBufferAttribute(l,u),new Pt().fromBufferAttribute(l,d),new Pt().fromBufferAttribute(l,m)]),c!==void 0&&e.faceVertexUvs[1].push([new Pt().fromBufferAttribute(c,u),new Pt().fromBufferAttribute(c,d),new Pt().fromBufferAttribute(c,m)])}let p=t.groups;if(p.length>0)for(let u=0;u<p.length;u++){let d=p[u],m=d.start,g=d.count;for(let x=m,y=m+g;x<y;x+=3)r!==void 0?h(r.getX(x),r.getX(x+1),r.getX(x+2),d.materialIndex):h(x,x+1,x+2,d.materialIndex)}else if(r!==void 0)for(let u=0;u<r.count;u+=3)h(r.getX(u),r.getX(u+1),r.getX(u+2));else for(let u=0;u<n.count;u+=3)h(u,u+1,u+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ds).negate(),this.translate(Ds.x,Ds.y,Ds.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new $u;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new rt,e=new rt;for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],s=this.vertices[n.a],a=this.vertices[n.b],l=this.vertices[n.c];t.subVectors(l,a),e.subVectors(s,a),t.cross(e),t.normalize(),n.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new rt;if(t){let r=new rt,o=new rt;for(let n=0,s=this.faces.length;n<s;n++){let a=this.faces[n],l=this.vertices[a.a],c=this.vertices[a.b],h=this.vertices[a.c];r.subVectors(h,c),o.subVectors(l,c),r.cross(o),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],s=n.vertexNormals;s.length===3?(s[0].copy(e[n.a]),s[1].copy(e[n.b]),s[2].copy(e[n.c])):(s[0]=e[n.a].clone(),s[1]=e[n.b].clone(),s[2]=e[n.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let n=0,s=o.vertexNormals.length;n<s;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let t=new zr;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let n=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new rt,h={a:new rt,b:new rt,c:new rt};n.push(c),s.push(h)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let n=0,s=this.faces.length;n<s;n++){let a=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bb),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zb),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,n=this.vertices.length,s=this.vertices,a=t.vertices,l=this.faces,c=t.faces,h=this.colors,p=t.colors;e!==void 0&&(o=new Wu().getNormalMatrix(e));for(let u=0,d=a.length;u<d;u++){let g=a[u].clone();e!==void 0&&g.applyMatrix4(e),s.push(g)}for(let u=0,d=p.length;u<d;u++)h.push(p[u].clone());for(let u=0,d=c.length;u<d;u++){let m=c[u],g,x,y=m.vertexNormals,v=m.vertexColors,P=new Ho(m.a+n,m.b+n,m.c+n);P.normal.copy(m.normal),o!==void 0&&P.normal.applyMatrix3(o).normalize();for(let S=0,b=y.length;S<b;S++)g=y[S].clone(),o!==void 0&&g.applyMatrix3(o).normalize(),P.vertexNormals.push(g);P.color.copy(m.color);for(let S=0,b=v.length;S<b;S++)x=v[S],P.vertexColors.push(x.clone());P.materialIndex=m.materialIndex+r,l.push(P)}for(let u=0,d=t.faceVertexUvs.length;u<d;u++){let m=t.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let g=0,x=m.length;g<x;g++){let y=m[g],v=[];for(let P=0,S=y.length;P<S;P++)v.push(y[P].clone());this.faceVertexUvs[u].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],n=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let h=this.vertices[l],p=Math.round(h.x*n)+"_"+Math.round(h.y*n)+"_"+Math.round(h.z*n);e[p]===void 0?(e[p]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[p]]}let s=[];for(let l=0,c=this.faces.length;l<c;l++){let h=this.faces[l];h.a=o[h.a],h.b=o[h.b],h.c=o[h.c];let p=[h.a,h.b,h.c];for(let u=0;u<3;u++)if(p[u]===p[(u+1)%3]){s.push(l);break}}for(let l=s.length-1;l>=0;l--){let c=s[l];this.faces.splice(c,1);for(let h=0,p=this.faceVertexUvs.length;h<p;h++)this.faceVertexUvs[h].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new rt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],n=this.faceVertexUvs[1],s,a;o&&o.length===e&&(s=[]),n&&n.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;s&&s.push(o[c]),a&&a.push(n[c])}s&&(this.faceVertexUvs[0]=s),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let g in m)m[g]!==void 0&&(t[g]=m[g]);return t}let e=[];for(let m=0;m<this.vertices.length;m++){let g=this.vertices[m];e.push(g.x,g.y,g.z)}let r=[],o=[],n={},s=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let g=this.faces[m],x=!0,y=!1,v=this.faceVertexUvs[0][m]!==void 0,P=g.normal.length()>0,S=g.vertexNormals.length>0,b=g.color.r!==1||g.color.g!==1||g.color.b!==1,B=g.vertexColors.length>0,w=0;if(w=h(w,0,0),w=h(w,1,x),w=h(w,2,y),w=h(w,3,v),w=h(w,4,P),w=h(w,5,S),w=h(w,6,b),w=h(w,7,B),r.push(w),r.push(g.a,g.b,g.c),r.push(g.materialIndex),v){let f=this.faceVertexUvs[0][m];r.push(d(f[0]),d(f[1]),d(f[2]))}if(P&&r.push(p(g.normal)),S){let f=g.vertexNormals;r.push(p(f[0]),p(f[1]),p(f[2]))}if(b&&r.push(u(g.color)),B){let f=g.vertexColors;r.push(u(f[0]),u(f[1]),u(f[2]))}}function h(m,g,x){return x?m|1<<g:m&~(1<<g)}function p(m){let g=m.x.toString()+m.y.toString()+m.z.toString();return n[g]!==void 0||(n[g]=o.length/3,o.push(m.x,m.y,m.z)),n[g]}function u(m){let g=m.r.toString()+m.g.toString()+m.b.toString();return a[g]!==void 0||(a[g]=s.length,s.push(m.getHex())),a[g]}function d(m){let g=m.x.toString()+m.y.toString();return c[g]!==void 0||(c[g]=l.length/2,l.push(m.x,m.y)),c[g]}return t.data={},t.data.vertices=e,t.data.normals=o,s.length>0&&(t.data.colors=s),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new zr().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let u=0,d=e.length;u<d;u++)this.vertices.push(e[u].clone());let r=t.colors;for(let u=0,d=r.length;u<d;u++)this.colors.push(r[u].clone());let o=t.faces;for(let u=0,d=o.length;u<d;u++)this.faces.push(o[u].clone());for(let u=0,d=t.faceVertexUvs.length;u<d;u++){let m=t.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let g=0,x=m.length;g<x;g++){let y=m[g],v=[];for(let P=0,S=y.length;P<S;P++){let b=y[P];v.push(b.clone())}this.faceVertexUvs[u].push(v)}}let n=t.morphTargets;for(let u=0,d=n.length;u<d;u++){let m={};if(m.name=n[u].name,n[u].vertices!==void 0){m.vertices=[];for(let g=0,x=n[u].vertices.length;g<x;g++)m.vertices.push(n[u].vertices[g].clone())}if(n[u].normals!==void 0){m.normals=[];for(let g=0,x=n[u].normals.length;g<x;g++)m.normals.push(n[u].normals[g].clone())}this.morphTargets.push(m)}let s=t.morphNormals;for(let u=0,d=s.length;u<d;u++){let m={};if(s[u].vertexNormals!==void 0){m.vertexNormals=[];for(let g=0,x=s[u].vertexNormals.length;g<x;g++){let y=s[u].vertexNormals[g],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),m.vertexNormals.push(v)}}if(s[u].faceNormals!==void 0){m.faceNormals=[];for(let g=0,x=s[u].faceNormals.length;g<x;g++)m.faceNormals.push(s[u].faceNormals[g].clone())}this.morphNormals.push(m)}let a=t.skinWeights;for(let u=0,d=a.length;u<d;u++)this.skinWeights.push(a[u].clone());let l=t.skinIndices;for(let u=0,d=l.length;u<d;u++)this.skinIndices.push(l[u].clone());let c=t.lineDistances;for(let u=0,d=c.length;u<d;u++)this.lineDistances.push(c[u]);let h=t.boundingBox;h!==null&&(this.boundingBox=h.clone());let p=t.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new fl().fromGeometry(this),e=new Hu,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",new kn(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",new kn(o,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",new kn(o,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",new kn(o,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",new kn(o,2).copyVector2sArray(t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let n=[],s=t.morphTargets[o];for(let a=0,l=s.length;a<l;a++){let c=s[a],h=new ko(c.data.length*3,3);h.name=c.name,n.push(h.copyVector3sArray(c.data))}e.morphAttributes[o]=n}if(t.skinIndices.length>0){let o=new ko(t.skinIndices.length*4,4);e.setAttribute("skinIndex",o.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let o=new ko(t.skinWeights.length*4,4);e.setAttribute("skinWeight",o.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Hu,r=t.geometry;if(t.isPoints||t.isLine){let o=new ko(r.vertices.length*3,3),n=new ko(r.colors.length*3,3);if(e.setAttribute("position",o.copyVector3sArray(r.vertices)),e.setAttribute("color",n.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let s=new ko(r.lineDistances.length,1);e.setAttribute("lineDistance",s.copyArray(r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};zr.prototype.isGeometry=!0;var fl=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,n,s=t.faces;for(o=0;o<s.length;o++){let a=s[o];a.materialIndex!==n&&(n=a.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:n})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,n=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let y=0;y<l;y++)c[y]={name:a[y].name,data:[]};this.morphTargets.position=c}let h=t.morphNormals,p=h.length,u;if(p>0){u=[];for(let y=0;y<p;y++)u[y]={name:h[y].name,data:[]};this.morphTargets.normal=u}let d=t.skinIndices,m=t.skinWeights,g=d.length===r.length,x=m.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let P=v.vertexNormals;if(P.length===3)this.normals.push(P[0],P[1],P[2]);else{let b=v.normal;this.normals.push(b,b,b)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let b=v.color;this.colors.push(b,b,b)}if(n===!0){let b=o[0][y];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new Pt,new Pt,new Pt))}if(s===!0){let b=o[1][y];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new Pt,new Pt,new Pt))}for(let b=0;b<l;b++){let B=a[b].vertices;c[b].data.push(B[v.a],B[v.b],B[v.c])}for(let b=0;b<p;b++){let B=h[b].vertexNormals[y];u[b].data.push(B.a,B.b,B.c)}g&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),x&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Ho=class{constructor(t,e,r,o,n,s=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new rt,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new qu,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};var Fb=["a","b","c"];function Ub(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function yl(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function xl(i,t,e,r,o,n){let s=Math.min(i,t),a=Math.max(i,t),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let h=e[s],p=e[a];c={a:h,b:p,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function jb(i,t,e,r){let o,n,s;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=t.length;o<n;o++)s=t[o],xl(s.a,s.b,i,r,s,e),xl(s.b,s.c,i,r,s,e),xl(s.c,s.a,i,r,s,e)}function _s(i,t,e,r,o){i.push(new Ho(t,e,r,void 0,void 0,o))}function Wo(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Bs(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Es=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Vb?t=new zr().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new Xu,r,o,n,s,a,l=t.vertices,c=t.faces,h=t.faceVertexUvs[0],p=h!==void 0&&h.length>0,u=[],d=new Map;jb(l,c,u,d);let m=[],g,x,y,v,P,S,b;for(let V of Array.from(d.keys())){for(x=d.get(V),y=new Xu,P=3/8,S=1/8,b=x.faces.length,b!=2&&(P=.5,S=0,b!=1),y.addVectors(x.a,x.b).multiplyScalar(P),e.set(0,0,0),s=0;s<b;s++){for(v=x.faces[s],a=0;a<3&&(g=l[Ub(v,Fb[a])],!(g!==x.a&&g!==x.b));a++);g&&e.add(g)}e.multiplyScalar(S),y.add(e),x.newEdge=m.length,m.push(y)}let B,w,f,D,C,I,L,M=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],C=u[o].edges,r=C.length,r==3?B=3/16:r>3&&(B=3/(8*r)),w=1-r*Number(B),f=B,r<=2&&(r==2?(w=3/4,f=1/8):r==1||r==0),L=I.clone().multiplyScalar(w),e.set(0,0,0),s=0;s<r;s++)D=C[s],g=D.a!==I?D.a:D.b,e.add(g);e.multiplyScalar(Number(f)),L.add(e),M.push(L)}let k=M.concat(m),W=M.length,oe,he,ie,Y=[],U=[],z,E,_,A,G=new gl,J=new gl,j=new gl;for(o=0,n=c.length;o<n;o++)v=c[o],oe=Number(yl(v.a,v.b,d).newEdge)+W,he=Number(yl(v.b,v.c,d).newEdge)+W,ie=Number(yl(v.c,v.a,d).newEdge)+W,_s(Y,oe,he,ie,v.materialIndex),_s(Y,v.a,oe,ie,v.materialIndex),_s(Y,v.b,he,oe,v.materialIndex),_s(Y,v.c,ie,he,v.materialIndex),p&&(z=h[o],E=z[0],_=z[1],A=z[2],G.set(Wo(E.x,_.x),Wo(E.y,_.y)),J.set(Wo(_.x,A.x),Wo(_.y,A.y)),j.set(Wo(E.x,A.x),Wo(E.y,A.y)),Bs(U,G,J,j),Bs(U,E,G,j),Bs(U,_,J,G),Bs(U,A,j,J));t.vertices=k,t.faces=Y,p&&(t.faceVertexUvs[0]=U)}};var je=new Hb,Ju=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ku().copy(new Yu(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(je),r={width:je.x,height:je.y,depth:je.z,subdivisions:0}):r=t.parameters;let o={...r,...i.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:o}=i.parameters,n=i.geometry??new Ku().copy(new Yu(100,100,100)),s=n.userData.parameters;s===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(je)):je.set(s.width,s.height,s.depth),(t!==je.x||e!==je.y||r!==je.z)&&n.scale(je.x===0?1:t/je.x,je.y===0?1:e/je.y,je.z===0?1:r/je.z);let a=n.originalGeometry;return o>0?(a===void 0||s?.subdivisions!==o)&&(a===void 0&&(a=n),n=new Es(o).modify(a).toBufferGeometry()):(a!==void 0&&(n=a),a=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),a!==void 0&&Object.assign(n,{originalGeometry:a}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new kb(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(je);let s=100/je.x;Object.assign(n.parameters,{width:100,height:je.y*s,depth:je.z*s}),t(this.build(n))})}};var Qu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof ve?i.shape:new ve,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}=i.parameters,l=i.shape,c=t*.5,h=e*.5,p=0,u=0,d=2*Math.PI/r;for(let g=0;g<r;g++){let x=d*g,y=p+Math.sin(x)*c,v=u+Math.cos(x)*h;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let g=0,x=l.points.length;g<x;g++)l.points[g].roundness=o;l.roundness=o,l.update();let m=Ke.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...i,type:"PolygonGeometry"}})}};import{BufferGeometry as Wb,Float32BufferAttribute as vl,Vector2 as Zt,Vector3 as qe}from"three";var Zu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:n,openEnded:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=new Sl(t*.5,e,o,n,s,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Hn(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function bl(i,t,e,r,o,n){let s=t.clone().sub(i),a=e.clone().sub(i),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===o){let c=s.add(a).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);n.copy(i),n.addScaledVector(s,o/Math.sin(c)),n.addScaledVector(a,r/Math.sin(c))}}function qb(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Sl=class extends Wb{constructor(t=.5,e=1,r=4,o=1,n=!1,s=0,a=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],h=[],p=[],u=0,d=e/2,m=Math.PI/r,g=t*Math.cos(Math.PI/r),x=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,P=new qe(0,-d,0),S=new qe(0,d,0),b=new Zt(t,-d),B=new Zt(g,-d),w=new Zt(0,S.y).sub(B),f=new Zt(0,S.y).sub(b),D=new Zt(w.y,-w.x).normalize(),C=new Zt(f.y,-f.x).normalize(),L=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-w.angle())/2)-1e-8;s=Math.min(s,L);let M;{let U=new qe(D.x,D.y,0),z=new qe(Math.cos(x)*U.x,U.y,Math.sin(x)*U.x);M=U.angleTo(z)}let k=s/Math.tan((Math.PI-w.angle())/2),W=s/Math.tan((Math.PI-M)/2),oe=new qe;if(!n){c.push(P.x,P.y,P.z),h.push(0,-1,0),p.push(0,0);let U=u++,z=[],E=b.clone(),_=k/Math.cos(Math.PI/r);E.x-=_;for(let A=0;A<r;A++){let G=A/r*Math.PI*2+m,J=new Zt(Math.sin(G),Math.cos(G));Hn(E,J,oe),c.push(oe.x,oe.y,oe.z),h.push(0,-1,0),p.push(0,0),z.push(u++)}for(let A=0;A<z.length;A++)l.push(z[A],U,z[(A+1)%z.length])}let he=[];{let U=new qe,z=new qe,E=new qe,_=new qe,A=new qe,G=new qe;for(let J=0;J<r;J++){let j=J/r*Math.PI*2+m,V=(J+.5)/r*Math.PI*2+m,F=(J+1)/r*Math.PI*2+m,O=new Zt(Math.sin(j),Math.cos(j)),q=new Zt(Math.sin(V),Math.cos(V)),Z=new Zt(Math.sin(F),Math.cos(F));Hn(b,O,z),Hn(b,Z,E),Hn(D,q,U),bl(S,z,E,W,W,_),c.push(_.x,_.y,_.z),bl(z,S,E,W,k,A),c.push(A.x,A.y,A.z),bl(E,z,S,k,W,G),c.push(G.x,G.y,G.z),h.push(U.x,U.y,U.z),h.push(U.x,U.y,U.z),h.push(U.x,U.y,U.z),p.push(0,0),p.push(0,0),p.push(0,0);let ee=u++,H=u++,Q=u++;if(l.push(ee,H,Q),s>0){{let le=z.clone().add(E).multiplyScalar(.5),ne=S.clone().sub(le).normalize(),_e=P.clone().sub(le).normalize().add(ne).normalize().multiplyScalar(-1),ge=G.clone().sub(A);ie(le,ge,_e,w.angle())}let $,re;{let le=new qe;Hn(C,Z,le);let ne=G.clone().add(_).multiplyScalar(.5);ne=qb(ne,E,S);let me=G.clone().sub(_);[$,re]=ie(ne,me,le,M,_.y)}{let le=$,ne=le.clone().setY(0).normalize(),me=new qe(0,-1,0),_e=ne.clone().cross(me);Y(le,ne,me,_e)}he.concat(re);{let le=w.angle(),ne=Math.PI-le,me=S.clone();me.y-=s/Math.sin(le-Math.PI/2);let _e=new qe,ge=[];for(let Se=0;Se<a;Se++){let lt=[],Nt=Math.PI/2-ne*Se/a,so=Math.cos(Nt),mt=Math.sin(Nt),ao=V;for(let yi=0;yi<=Se;yi++){let xi=Math.cos(ao),Ee=Math.sin(ao);U.x=so*Ee,U.y=mt,U.z=so*xi,_e.copy(me).addScaledVector(U,s),c.push(_e.x,_e.y,_e.z),h.push(U.x,U.y,U.z),p.push(0,0),lt.push(u++),ao+=Math.PI*2/Se/r}ge.push(lt)}re.reverse(),ge.push(re);let ze=ge.length-1;for(let Se=0;Se<ze;Se++){let lt=ge[Se],Nt=ge[Se+1],so=lt.length-1;l.push(Nt[1],lt[0],Nt[0]);for(let mt=1;mt<=so;mt++)l.push(lt[mt],lt[mt-1],Nt[mt]),l.push(Nt[mt+1],lt[mt],Nt[mt])}}}}}this.setIndex(l),this.setAttribute("position",new vl(c,3)),this.setAttribute("normal",new vl(h,3)),this.setAttribute("uv",new vl(p,2));function ie(U,z,E,_,A){let G=-_/2,J=(Math.PI-_)/2,j=z.clone().normalize().cross(E);U.addScaledVector(E,-s/Math.sin(J));let V=new qe,F=new qe,O=1,q=u,Z=[];for(let ee=0;ee<=a;ee++){let H=G+ee/a*_;F.set(0,0,0),F.addScaledVector(j,Math.sin(H)),F.addScaledVector(E,Math.cos(H));for(let Q=0;Q<=O;Q++){let $=Q/O-.5;if(V.copy(U),V.addScaledVector(z,$),V.addScaledVector(F,s),A!=null){let re=Math.max(0,V.y-A);V.addScaledVector(z,-re/z.y)}c.push(V.x,V.y,V.z),h.push(F.x,F.y,F.z),p.push(0,0),Q===0&&Z.push(u),u++}}for(let ee=0;ee<a;ee++)for(let H=0;H<O;H++){let Q=q+H+(O+1)*ee,$=Q+(O+1),re=$+1,le=Q+1;l.push(Q,$,le),l.push($,re,le)}return[U.clone().addScaledVector(z,.5),Z]}function Y(U,z,E,_){let A=Math.PI/2,G=f.angle()-A,J=[],j=new qe,V=new qe;for(let O=0;O<=a;O++){let q=[],Z=O/a;for(let ee=0;ee<=O;ee++){let Q=((O?ee/O:0)-.5)*v,$=Math.cos(Q),re=Math.sin(Q),le=Math.atan(Math.tan(G)*$),ne=(A+le)*Z,me=Math.cos(ne),_e=Math.sin(ne);j.set(0,0,0),j.addScaledVector(z,_e*$),j.addScaledVector(E,me),j.addScaledVector(_,_e*re),V.copy(U).addScaledVector(j,s),c.push(V.x,V.y,V.z),h.push(j.x,j.y,j.z),p.push(0,0),q.push(u++)}J.push(q)}let F=J.length-1;for(let O=0;O<F;O++){let q=J[O],Z=J[O+1],ee=q.length-1;l.push(q[0],Z[1],Z[0]);for(let H=1;H<=ee;H++)l.push(q[H-1],q[H],Z[H]),l.push(q[H],Z[H+1],Z[H])}}}};var ed=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof ve?i.shape:new ve,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:o,cornerType:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},h={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function u(S,b,B){return b>e&&B>r?Math.min(S*e/b,S*r/B):b>e?S*e/b:B>r?S*r/B:S}let d=[];d[0]=o[0]===0?0:u(o[0],o[0]+o[3],o[0]+o[1]),d[1]=o[1]===0?0:u(o[1],o[1]+o[2],o[1]+o[0]),d[2]=o[2]===0?0:u(o[2],o[2]+o[1],o[2]+o[3]),d[3]=o[3]===0?0:u(o[3],o[3]+o[0],o[3]+o[2]);let m=h.x,g=p.x,x=p.y,y=h.y;t.addPoint(t.createPoint(m,x)),t.addPoint(t.createPoint(g,x)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let v=!0;for(let S=0,b=t.points.length;S<b;S++)t.points[S].roundness=d[S],S>0&&d[S]!==d[S-1]&&(v=!1);v&&(t.roundness=d[0]),t.useCubicForRoundedCorners=n!==1,t.update();let P=Ke.create({shape:t,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(P,{userData:{...i,type:"RectangleGeometry"}})}};import{SphereBufferGeometry as $b}from"three";var td=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:n=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,h=new $b(.5*t,o,n,s,a,l,c);return h.scale(1,e/t,r/t),Object.assign(h,{userData:{...i,type:"SphereGeometry"}})}};import{PlaneBufferGeometry as Xb}from"three";var rd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Xb(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};import{BufferGeometry as Kb,Float32BufferAttribute as wl,Vector3 as Yb}from"three";var od=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:o,cornerRadius:n,cornerSegments:s}=i.parameters,a=new Nl(t,e,r,o,n,s);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},Nl=class extends Kb{constructor(t=1,e=1,r=1,o=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],h=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),o=Math.min(180-h,o),o*=Math.PI/180;let p=[],u=Math.PI/2,d=(V=0,F=0,O=0)=>new Yb(V,F,O),m=d(),g=d(),[x,y,v]=[e/2,t/2,r/2],P=-y,S=+y,[b,B,w]=[d(P,-x,+v),d(P,-x,-v),d(P,+x,-v)],f=(V,F=!1)=>Math.sin(V-Math.PI/(1+ +F)),D=(V,F=!1)=>Math.cos(V-Math.PI/(1+ +F));w.y=Math.sin(o)*e-x;let C=Math.cos(o)*e-v,I=b.z-h;o<=u?(w.z=Math.min(C,I),w.z==I&&(w.y-=(C-I)/Math.tan(u-o))):B.z=Math.min(B.z-C-v,b.z-h),m.subVectors(b,B),g.subVectors(w,B);let L=Math.min(m.length(),g.length())*n/100,M=L*Math.tan(o/2),k=L/Math.cos(o/2),W=m.clone().normalize().add(g.normalize()).setLength(k).add(B);m.set(0,f(o,!0),D(o,!0)),p.push([w,m.clone()]);let oe=(Math.PI-o)/s;for(let V=0;V<=s;V++){let F=u+o+V*oe;m.set(0,Math.sin(F)*M,Math.cos(F)*M),m.add(W),g.set(0,f(F),D(F)),p.push([m.clone(),g.clone()])}p.push([b,d(0,1,0)]);let he=Math.sin(oe/2)*M*2,ie=p.length-1,Y=p[0][0].distanceTo(p[1][0]),U=p[ie-1][0].distanceTo(p[ie][0]),z=Y+he*s+U;p[0].push(1);for(let V=0;V<=s;V++)p[V+1].push(1-(Y+V*he)/z);p[ie].push(0);let[E,_,A]=p[0],G,J,j;for(let V=1;V<p.length;V++)[G,J,j]=p[V],a.push(P,E.y,E.z,P,G.y,G.z,S,E.y,E.z,S,E.y,E.z,P,G.y,G.z,S,G.y,G.z),l.push(0,_.y,_.z,0,J.y,J.z,0,_.y,_.z,0,_.y,_.z,0,J.y,J.z,0,J.y,J.z),c.push(0,A,0,j,1,A,1,A,0,j,1,j),[E,_,A]=[G,J,j];this.setAttribute("position",new wl(a,3)),this.setAttribute("normal",new wl(l,3)),this.setAttribute("uv",new wl(c,2))}};var nd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof ve?i.shape:new ve,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,h=i.shape,p=t*.5,u=e*.5,d=0,m=0,g=s*Math.PI/360/o,x=Math.PI/2*3*-1,y=p*r/100,v=u*r/100;if(o===3&&r===50){g=2*Math.PI/o;for(let S=0;S<o;S++){let b=g*S,B=d+Math.sin(b)*p,w=m+Math.cos(b)*u;h.addPoint(h.createPoint(B,w))}}else for(let S=0;S<o;S++){let b=d+Math.cos(x)*p,B=m+Math.sin(x)*u;h.addPoint(h.createPoint(b,B)),x+=g,b=d+Math.cos(x)*y,B=m+Math.sin(x)*v,S<=o,h.addPoint(h.createPoint(b,B)),x+=g}h.isClosed=!0;for(let S=0,b=h.points.length;S<b;S++)h.points[S].roundness=n;h.roundness=n,h.update();let P=Ke.create({shape:h,parameters:{roundness:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(P,{userData:{...i,type:"StarGeometry"}})}};import{PlaneBufferGeometry as Jb}from"three";var Gs=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new Jb(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var id=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??e.width*.25);return{parameters:Object.assign(e,{width:r,height:o,depth:n})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:n,arc:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=Qb(t,e,r,t*.5,s,n,0,0,o,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function Qb(i,t,e,r,o,n,s,a,l,c,h){return[t,e]=[e,t],s=t/2,o/=2*Math.PI,o==1&&(c=0),new Un(!0,i,t,e,r,o,n,s,a,l,c,h)}import{TorusKnotBufferGeometry as Zb}from"three";var sd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:n,q:s}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new Zb(a,e,r,o,n,s);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var ad=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof ve?i.shape:new ve,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s,isRect:a}=i.parameters,l=i.shape,c=t*.5,h=e*.5;a?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let u=0,d=l.points.length;u<d;u++)l.points[u].roundness=r;l.roundness=r,l.update();let p=Ke.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};import{BufferGeometry as $d,BufferAttribute as Xd,Uint32BufferAttribute as Jl,Float32BufferAttribute as Ql,Matrix4 as vw,Vector3 as oa}from"three";var eS,Rs=new Promise(i=>{eS=i});import{BufferGeometryLoader as yw}from"three";import{EventDispatcher as mw,Matrix3 as fw,Vector3 as Yl}from"three";import{Mesh as uw,Matrix4 as dw}from"three";import{Matrix4 as fd}from"three";import{Box3 as dd,Line3 as nS,Matrix4 as Tl,Vector3 as Mt}from"three";import{HemisphereLight as ld}from"three";import{Color as tS}from"three";var ut=class extends tS{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Ae(i,t){let e;if(typeof i=="string"){let r=t?.getColor(i);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new ut(0,0,0,0))}else return"a"in i?new ut(i.r,i.g,i.b,i.a):new ut(i.r,i.g,i.b,1);return e}var Cl=i=>"isEntity"in i,er=i=>"isAbstractMesh"in i,tr=i=>i!==null&&i.isBooleanMesh,cd=i=>i.objectType==="CombinedCamera";var vr=i=>"objectHelper"in i;function rS(i,t){let e=!1;t.position&&(i.position.fromArray(t.position),e=!0),t.rotation&&(i.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,i.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(e=!0,i.hiddenMatrix.fromArray(t.hiddenMatrix??Dr.identity)),e&&(i.updateMatrix(),tr(i.parent)&&er(i)&&i.invalidateDownstreamBooleanData(!0).recomputeBoolean()),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=t.isUpVectorFlipped),i.updateUp())}function oS(i,t){rS(i,t),t.name!==void 0&&(i.name=t.name),t.visible!==void 0&&(i.isEntity?i.visibility=t.visible:i.visible=t.visible)}function hd(i,t,e){oS(i,t),t.color!==void 0&&(i.color=Ae(t.color,e)),t.intensity!==void 0&&(i.intensity=t.intensity),t.shadows!==void 0&&!(i instanceof ld)&&(i.castShadow=t.shadows),i.shadow&&!(i instanceof ld)&&t.depth!==void 0&&(i.shadow.camera.far=t.depth,i.shadow.needsUpdate=!0),t.helper!==void 0&&vr(i)&&(i.enableHelper=t.helper,i.gizmos.shadowmap.visible=t.helper)}function pd(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var qo=new dd,rr=new Mt,or=new Mt,$o=new Tl,md=[new Mt(-1,1,1),new Mt(-1,-1,1),new Mt(1,-1,1),new Mt(1,1,1),new Mt(-1,1,-1),new Mt(-1,-1,-1),new Mt(1,-1,-1),new Mt(1,1,-1)],iS=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],sS=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function aS(i,t,e=0,r=t.count){let o=1/0,n=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=e;h<r;h++){let p=t.getX(h),u=t.getY(h),d=t.getZ(h);p<o&&(o=p),u<n&&(n=u),d<s&&(s=d),p>a&&(a=p),u>l&&(l=u),d>c&&(c=d)}return i.min.set(o,n,s),i.max.set(a,l,c),i}var ud=(i,t,e,r)=>{if(er(i)){let o=i.geometry.userData.parameters,n=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?rr.copy(i.originalGeometry.boundingSphere.center):n!==void 0&&(aS(qo,n,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:n.count),qo.getCenter(rr)),i.forceComputeSize?qo.getSize(or).multiplyScalar(.5):or.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}else if(vr(i)&&r===!0){let o=i.geometryHelper.getAttribute("position");qo.setFromArray(o.array),qo.getCenter(rr),qo.getSize(or).multiplyScalar(.5)}else rr.setScalar(0),or.setScalar(0);$o.copy(t).multiply(i.matrixWorld),or.x===0&&or.y===0&&or.z===0?e.push(new Mt(rr.x,rr.y,rr.z).applyMatrix4($o)):md.forEach(o=>{e.push(o.clone().multiply(or).add(rr).applyMatrix4($o))})},Wn=class extends dd{constructor(){super(...arguments);this.matrix=new Tl;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Tl().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let n=[];return o===!0?e.traverseEntity(s=>{s.visible&&ud(s,r,n,e.enableHelper===!0)}):ud(e,r,n,e.enableHelper===!0),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($o.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(or).multiplyScalar(.5),this.getCenter(rr),$o.copy(this.matrix).setPosition(rr),this.vertices=md.map(e=>e.clone().multiply(or).applyMatrix4($o))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=iS.map(([e,r])=>new nS(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Mt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=sS.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};import{Object3D as lS,Matrix4 as cS}from"three";var zs=i=>class extends i{hasEntityChild(){return this.children.some(e=>Cl(e))}isDescendantOf(e){e instanceof lS&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let o=new cS().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),o.multiply(e.parent.matrixWorld)),Cl(e)?e.hiddenMatrix.premultiply(o):e.applyMatrix4(o),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let o=0;o<e.children.length;o++){let n=e.children[o];this.add(n.clone())}return this}};var At=i=>"isEntity"in i,gd=i=>"isAbstractMesh"in i,Ot=i=>class extends zs(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new fd;this._singleBBox=new Wn;this._recursiveBBox=new Wn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let o of this.children)At(o)&&o.traverseEntity(n=>{vr(n)&&n.visible&&(n.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{At(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let o of this.children)At(o)&&o.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,o=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),o===!0)for(let n of r.children)At(n)&&this.add(n.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,o=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),o===!0)for(let n of r.children)At(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let r=new fd,o=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(o);for(let n of this.children)At(n)&&n.hiddenMatrix.premultiply(r)}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Io(o,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Io(o,r)}fromState(r,o){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as pS,Vector3 as qn,Euler as yd,MathUtils as Vr}from"three";var Ll=i=>i.isCloner===!0,Il=i=>i.parent!==null&&Ll(i.parent),eo=class extends pS{constructor(e,r={}){super();this.isCloner=!0;this.originalMask=0;this.object=e,this.originalMask=e.layers.mask;let o=e.recursiveBBox.getSize(new qn),n=.1;this.parameters=Yi.defaultData(o.toArray(),n),$r(this.parameters,r),this.setHideBase(this.parameters.hideBase),this.update()}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}refreshClonerMasks(){for(let e of this.children)e.layers.mask=this.object.layers.mask;this.parameters.hideBase&&!this.object.layers.isEnabled(16)&&(this.originalMask=this.object.layers.mask,this.object.layers.set(16))}setHideBase(e){"material"in this.object&&(e||(this.object.layers.mask=this.originalMask),this.parameters.hideBase=e,this.refreshClonerMasks())}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let r=0,o=e-this.children.length;r<o;++r){let n=this.object.shallowClone(!1);n.material=this.object.material,n.visible=!0,n.layers.mask=this.originalMask,this.add(n)}else for(let r=0,o=this.children.length-e;r<o;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,o=r.start*Vr.DEG2RAD,n=r.end*Vr.DEG2RAD,s=o-n,a=new yd(r.rotation[0]*Vr.DEG2RAD,r.rotation[1]*Vr.DEG2RAD,r.rotation[2]*Vr.DEG2RAD),l;switch(r.axis){case"z":l=new qn(0,0,1);break;case"y":l=new qn(0,1,0);break;default:case"x":l=new qn(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=r.scale[0],h.scale.y=r.scale[1],h.scale.z=r.scale[2],h.position.setScalar(0);let p=s/e.count*c-o;switch(r.axis){case"x":h.rotation.set(0,p,0);break;case"y":h.rotation.set(0,0,p);break;case"z":h.rotation.set(p,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0],h.position.y+=r.position[1],h.position.z+=r.position[2],r.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new yd(r.rotation[0]*Vr.DEG2RAD,r.rotation[1]*Vr.DEG2RAD,r.rotation[2]*Vr.DEG2RAD);for(let[n,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(r.scale[0]-1)*n,s.scale.y=1+(r.scale[1]-1)*n,s.scale.z=1+(r.scale[2]-1)*n,s.rotation.x=o.x*n,s.rotation.y=o.y*n,s.rotation.z=o.z*n,s.position.x=r.position[0]*n,s.position.y=r.position[1]*n,s.position.z=r.position[2]*n}_updateGrid(e){let r=0,o=e.grid;if(o.useCenter===!0){let n={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},s=new qn(o.size[0]*(o.count[0]-n.x)*.5,o.size[1]*(o.count[1]-n.y)*.5,o.size[2]*(o.count[2]-n.z)*.5);for(let a=0;a<o.count[0];a++)for(let l=0;l<o.count[1];l++)for(let c=0;c<o.count[2];c++){let h=this.children[r++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=o.size[0]*a-s.x,h.position.y=o.size[1]*l-s.y,h.position.z=o.size[2]*c-s.z}}else for(let n=0;n<o.count[0];n++)for(let s=0;s<o.count[1];s++)for(let a=0;a<o.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=o.size[0]*n,l.position.y=-o.size[1]*s,l.position.z=-o.size[2]*a}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),$r(this.parameters,e),this.update(),this}onRemoved(){this.object.layers.mask=this.originalMask}};import{MathUtils as ql,BufferAttribute as sw,Mesh as Vd,Vector3 as $l,Float32BufferAttribute as Fd}from"three";import{MathUtils as Sr,Vector2 as wr,Vector3 as Rt,Vector4 as Zo}from"three";import{Texture as uS}from"three";var Oe=class{constructor(t,e,r,o){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=t,this.uuid=e,r){this.type=r.type;for(let n in r)n!=="type"&&n!=="calpha"&&(this.uniforms[`f${this.id}_${n}`]=r[n]);for(let n in o)this.defines[n]=o[n]}}copy(t){this.id=t.id,this.type=t.type,this.defines={...t.defines};for(let e in t.uniforms)this.getName(e)==="transmissionSamplerMap"||this.getName(e)==="transmissionDepthMap"||this.getName(e)==="normalMap"||this.getName(e)==="depthMap"||(this.uniforms[e]?this.uniforms[e].copy(t.uniforms[e]):this.uniforms[e]=t.uniforms[e].clone());return this}clone(){return new Oe(this.id).copy(this)}copyUniforms(t){for(let e in this.uniforms){let r=this.getName(e);r!==void 0&&t.uniforms[`f${t.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[e].copy(t.uniforms[`f${t.id}_${r}`])}return this}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getValues(){let t={type:this.type};for(let e in this.uniforms){let r=this.getName(e);if(r===void 0)continue;let n=this.uniforms[`f${this.id}_${r}`].value;n!==void 0&&(Array.isArray(n)?t[r]=n.map(s=>s.clone?s.clone():s):t[r]=n.clone?n.clone():n)}return t}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}isEqual(t){for(let e in t.uniforms){let r=t.getName(e);if(!r)return!1;let o=this.getValue(r),n=t.uniforms[e].value;if(n.value instanceof uS){if(o.image!==n.image)return!1}else if(Array.isArray(n)){let s=o;for(let a=0,l=s.length;a<l;++a)if(s[a]!==n[a])return!1}else{let s=o;if(s.equals){if(!s.equals(n))return!1}else if(o!==n)return!1}}return!0}dispose(){}};function xd(i){let t=i instanceof Oe?i.type:i;return t==="texture"||t==="displace_map"||t==="matcap"}import{MathUtils as dS}from"three";var ce=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=dS.generateUUID(),this.type=t,this.name="",this.userData={}}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,s){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof ce&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}copy(t){return this.name=t.name,t.type&&(this.type=t.type),t.frameId&&(this.frameId=t.frameId),t.hashProperties&&(this.hashProperties=t.hashProperties.map(e=>e)),this.userData=JSON.parse(JSON.stringify(t.userData)),this.shortcuts=JSON.parse(JSON.stringify(t.shortcuts)),this}clone(){return new this.constructor().copy(this)}};import{MathUtils as mS}from"three";var ae=class extends ce{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let s=this.getUnique(e,r);s&&this.uuid===void 0&&(this.uuid=mS.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,o)):super.build(e,r,o);if(s)return a.name=a.name||super.build(e,r,o),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,a.output,n);let h=this.generate(e,l,o);return e.addNodeCode(c+" = "+h+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,s){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),s,this.getLabel()).name}};var Ie=class extends ae{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,s,a){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,s,a,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,s,a,this.getLabel())),e.format(l.fragment.name,n,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var Ne=class extends Ie{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof ut?e:new ut(e||0,r,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,n,s,a){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return c?this.generateReadonly(e,r,o,n,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,s,a,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,s,a,this.getLabel())),e.format(l.fragment.name,n,r))}generateReadonly(e,r,o,n,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,r)}};var X=class extends Ie{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,n,s,a){return e.format(this.value+(this.value%1?"":".0"),n,r)}copy(e){return super.copy(e),this.value=e.value,this}};var fe=class extends Ie{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,n,s,a){return e.format(this.value.toString(),n,r)}copy(e){return super.copy(e),this.value=e.value,this}};var Fr=class extends Ie{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,n){return e.format(this.value?"true":"false",n,r)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector2 as vd}from"three";var Ye=class extends Ie{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof vd?e:new vd(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as bd}from"three";var ot=class extends Ie{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof bd?e:new bd(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var nr=class extends Ie{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof ut?e:new ut(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector4 as Sd}from"three";var br=class extends Ie{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Sd?new Array(e).fill(r):new Array(e).fill(new Sd(0))}copy(e){return super.copy(e),this.value=e.value.map(r=>r.clone()),this}};var ke=class extends Ie{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};var Pl=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},He=new Pl;var Xo=class extends ae{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}copy(e){return super.copy(e),this.index=e.index,this}};He.addKeyword("uv",function(){return new Xo});He.addKeyword("uv2",function(){return new Xo(1)});import{LinearEncoding as gS,sRGBEncoding as yS}from"three";var fS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,wd=/[a-z_0-9]+/gi,K=class extends ae{constructor(e,r,o,n,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,s){let a,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let h=[];for(;a=wd.exec(this.src);)h.push(a);for(let p=0;p<h.length;p++){let u=h[p],d=u[0],m=this.isMethod?!this.getInputByName(d):!0,g=d;if(this.keywords[d]||this.useKeywords&&m&&He.containsKeyword(d)){let x=this.keywords[d];if(!x){let y=He.getKeywordData(d);y.cache&&(x=e.keywords[d]),x=x||He.getKeyword(d,e),y.cache&&(e.keywords[d]=x)}g=x.build(e)}d!==g&&c[u.index+l-1]!=="."&&(c=c.substring(0,u.index+l)+g+c.substring(u.index+d.length+l),l+=g.length-d.length),this.getIncludeByName(g)===void 0&&He.contains(g)&&e.include(He.get(g))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let s=fS.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(wd);if(a){let l=0;for(;l<a.length;){let c=a[l++],h;c==="in"||c==="out"||c==="inout"?h=a[l++]:(h=c,c="");let p=a[l++];this.inputs.push({name:p,type:h,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}};var to=class extends ae{constructor(e=new ce,r){super("v4");this.nodeType="ColorSpace";this.factor=new ce;this.input=e,this.method=r??to.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case gS:return["Linear"];case yS:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),s=to.Nodes[this.method],a=e.include(s);if(a===to.LINEAR_TO_LINEAR)return e.format(o,n,r);if(s.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+o+", "+l+" )",n,r)}else return e.format(a+"( "+o+" )",n,r)}fromEncoding(e){let r=to.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=to.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},at=to;at.Nodes={LinearToLinear:new K(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
2
- `)),sRGBToLinear:new K(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
3
- `)),LinearTosRGB:new K(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
4
- `))},at.LINEAR_TO_LINEAR="LinearToLinear",at.SRGB_TO_LINEAR="sRGBToLinear",at.LINEAR_TO_SRGB="LinearTosRGB";var Ce=class extends K{constructor(e="",r,o,n,s){super(e,s,n,o,r);this.nodeType="Expression"}};import{Texture as xS}from"three";var Dt=class extends xS{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let o=this.image;if(Array.isArray(o)){t.images[o.uuid].url=[];for(let n=0;n<o.length;n++)t.images[o.uuid].url[n]=Nd(o[n])}else t.images[o.uuid].url=Nd(o)}return e}};function Nd(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?vS(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var Ko;function vS(i){if(/^data:/i.test(i.src))return i.src;let t;if(i instanceof HTMLCanvasElement)t=i;else{Ko===void 0&&(Ko=document.createElement("canvas")),Ko.width=i.width,Ko.height=i.height;let r=Ko.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),t=Ko}let e=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Je=class extends Ie{constructor(e=new Dt,r,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new Xo,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?l=a+"( "+o+", "+n+", "+s+" )":l=a+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},h=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new at(new Ce("",h)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,h),e.removeContext(),e.format(l,h,r)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};import{Matrix3 as bS}from"three";var Yo=class extends Ie{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new bS}generateReadonly(e,r,o,n,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",n,r)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Xn=class extends ae{constructor(e=new Je,r,o,n,s,a,l,c,h){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=o,this.projection=n,this.axis=s,this.side=a,this.size=l,this.mat=new Yo(this.texture.value.matrix),this.alpha=c,this.mode=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,n;switch(this.projection.value){case 3:n=e.include(Xn.Nodes.cylindrical);break;case 2:n=e.include(Xn.Nodes.spherical);break;case 1:let a=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=new K(`
5
- vec3 ${o}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
6
-
7
- vec2 uvs = ( mat * vec3( (${o}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
8
-
9
- vec4 tmp = texture2D( tex, uvs );
10
-
11
- vec3 col = tmp.rgb;
12
- float lalpha = alpha * tmp.a;
13
- ${this.side.value===0?"":`lalpha *= step(0.0, ${this.side.value===2?"-1.0 * ":""}dot(vObjectNormal, mat * ${a}));`}
14
-
15
- if ( crop > 0.5 ) {
16
- if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
17
- lalpha = 0.0;
18
- }
1
+ var Ff=Object.create;var ga=Object.defineProperty;var Uf=Object.getOwnPropertyDescriptor;var jf=Object.getOwnPropertyNames;var kf=Object.getPrototypeOf,Hf=Object.prototype.hasOwnProperty;var Wf=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),qf=(i,t)=>{for(var e in t)ga(i,e,{get:t[e],enumerable:!0})},$f=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jf(t))!Hf.call(i,o)&&o!==e&&ga(i,o,{get:()=>t[o],enumerable:!(r=Uf(t,o))||r.enumerable});return i};var Xf=(i,t,e)=>(e=i!=null?Ff(kf(i)):{},$f(t||!i||!i.__esModule?ga(e,"default",{value:i,enumerable:!0}):e,i));var ff=Wf((fa,df)=>{(function(i,t){typeof fa=="object"&&typeof df<"u"?t(fa):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(fa,function(i){"use strict";i.SVD=function(t,e,r,o,n){if(e=e===void 0||e,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var s,a,l,c,u,m,p,d,f,g,x,y,v=t[0].length,A=t.length;if(A<v)throw new TypeError("Invalid matrix: m < n");for(var S=[],b=[],B=[],w=e==="f"?A:v,h=g=p=0;h<A;h++)b[h]=new Array(w).fill(0);for(h=0;h<v;h++)B[h]=new Array(v).fill(0);var _,N=new Array(v).fill(0);for(h=0;h<A;h++)for(s=0;s<v;s++)b[h][s]=t[h][s];for(h=0;h<v;h++){for(S[h]=p,f=0,l=h+1,s=h;s<A;s++)f+=Math.pow(b[s][h],2);if(f<n)p=0;else for(d=(m=b[h][h])*(p=m<0?Math.sqrt(f):-Math.sqrt(f))-f,b[h][h]=m-p,s=l;s<v;s++){for(f=0,a=h;a<A;a++)f+=b[a][h]*b[a][s];for(m=f/d,a=h;a<A;a++)b[a][s]=b[a][s]+m*b[a][h]}for(N[h]=p,f=0,s=l;s<v;s++)f+=Math.pow(b[h][s],2);if(f<n)p=0;else{for(d=(m=b[h][h+1])*(p=m<0?Math.sqrt(f):-Math.sqrt(f))-f,b[h][h+1]=m-p,s=l;s<v;s++)S[s]=b[h][s]/d;for(s=l;s<A;s++){for(f=0,a=l;a<v;a++)f+=b[s][a]*b[h][a];for(a=l;a<v;a++)b[s][a]=b[s][a]+f*S[a]}}g<(x=Math.abs(N[h])+Math.abs(S[h]))&&(g=x)}if(r)for(h=v-1;0<=h;h--){if(p!==0){for(d=b[h][h+1]*p,s=l;s<v;s++)B[s][h]=b[h][s]/d;for(s=l;s<v;s++){for(f=0,a=l;a<v;a++)f+=b[h][a]*B[a][s];for(a=l;a<v;a++)B[a][s]=B[a][s]+f*B[a][h]}}for(s=l;s<v;s++)B[h][s]=0,B[s][h]=0;B[h][h]=1,p=S[h],l=h}if(e){if(e==="f")for(h=v;h<A;h++){for(s=v;s<A;s++)b[h][s]=0;b[h][h]=1}for(h=v-1;0<=h;h--){for(l=h+1,p=N[h],s=l;s<w;s++)b[h][s]=0;if(p!==0){for(d=b[h][h]*p,s=l;s<w;s++){for(f=0,a=l;a<A;a++)f+=b[a][h]*b[a][s];for(m=f/d,a=h;a<A;a++)b[a][s]=b[a][s]+m*b[a][h]}for(s=h;s<A;s++)b[s][h]=b[s][h]/p}else for(s=h;s<A;s++)b[s][h]=0;b[h][h]=b[h][h]+1}}for(o*=g,a=v-1;0<=a;a--)for(var I=0;I<50;I++){for(_=!1,l=a;0<=l;l--){if(Math.abs(S[l])<=o){_=!0;break}if(Math.abs(N[l-1])<=o)break}if(!_){for(u=0,c=l-(f=1),h=l;h<a+1&&(m=f*S[h],S[h]=u*S[h],!(Math.abs(m)<=o));h++)if(p=N[h],N[h]=Math.sqrt(m*m+p*p),u=p/(d=N[h]),f=-m/d,e)for(s=0;s<A;s++)x=b[s][c],y=b[s][h],b[s][c]=x*u+y*f,b[s][h]=-x*f+y*u}if(y=N[a],l===a){if(y<0&&(N[a]=-y,r))for(s=0;s<v;s++)B[s][a]=-B[s][a];break}for(g=N[l],m=(((x=N[a-1])-y)*(x+y)+((p=S[a-1])-(d=S[a]))*(p+d))/(2*d*x),p=Math.sqrt(m*m+1),m=((g-y)*(g+y)+d*(x/(m<0?m-p:m+p)-d))/g,h=l+(f=u=1);h<a+1;h++){if(p=S[h],x=N[h],d=f*p,p*=u,y=Math.sqrt(m*m+d*d),m=g*(u=m/(S[h-1]=y))+p*(f=d/y),p=-g*f+p*u,d=x*f,x*=u,r)for(s=0;s<v;s++)g=B[s][h-1],y=B[s][h],B[s][h-1]=g*u+y*f,B[s][h]=-g*f+y*u;if(y=Math.sqrt(m*m+d*d),m=(u=m/(N[h-1]=y))*p+(f=d/y)*x,g=-f*p+u*x,e)for(s=0;s<A;s++)x=b[s][h-1],y=b[s][h],b[s][h-1]=x*u+y*f,b[s][h]=-x*f+y*u}S[l]=0,S[a]=m,N[a]=g}for(h=0;h<v;h++)N[h]<o&&(N[h]=0);return{u:b,q:N,v:B}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as O1,Loader as _1}from"three";function ya(i,t){return Object.setPrototypeOf(i,t),i}function uc(i){return Array.isArray(i)?i:[i]}var Yf=typeof global=="object"&&global&&global.Object===Object&&global,Ni=Yf;var Kf=typeof self=="object"&&self&&self.Object===Object&&self,Qf=Ni||Kf||Function("return this")(),Ge=Qf;var Jf=Ge.Symbol,nt=Jf;var pc=Object.prototype,Zf=pc.hasOwnProperty,eh=pc.toString,Sn=nt?nt.toStringTag:void 0;function th(i){var t=Zf.call(i,Sn),e=i[Sn];try{i[Sn]=void 0;var r=!0}catch{}var o=eh.call(i);return r&&(t?i[Sn]=e:delete i[Sn]),o}var mc=th;var rh=Object.prototype,oh=rh.toString;function nh(i){return oh.call(i)}var dc=nh;var ih="[object Null]",sh="[object Undefined]",fc=nt?nt.toStringTag:void 0;function ah(i){return i==null?i===void 0?sh:ih:fc&&fc in Object(i)?mc(i):dc(i)}var yt=ah;function lh(i){return i!=null&&typeof i=="object"}var Ze=lh;var ch="[object Symbol]";function uh(i){return typeof i=="symbol"||Ze(i)&&yt(i)==ch}var ho=uh;function ph(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var Ci=ph;var mh=Array.isArray,Re=mh;var dh=1/0,hc=nt?nt.prototype:void 0,gc=hc?hc.toString:void 0;function yc(i){if(typeof i=="string")return i;if(Re(i))return Ci(i,yc)+"";if(ho(i))return gc?gc.call(i):"";var t=i+"";return t=="0"&&1/i==-dh?"-0":t}var xc=yc;function fh(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var et=fh;function hh(i){return i}var Li=hh;var gh="[object AsyncFunction]",yh="[object Function]",xh="[object GeneratorFunction]",vh="[object Proxy]";function bh(i){if(!et(i))return!1;var t=yt(i);return t==yh||t==xh||t==gh||t==vh}var go=bh;var Sh=Ge["__core-js_shared__"],Ii=Sh;var vc=function(){var i=/[^.]+$/.exec(Ii&&Ii.keys&&Ii.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function wh(i){return!!vc&&vc in i}var bc=wh;var Th=Function.prototype,Nh=Th.toString;function Ch(i){if(i!=null){try{return Nh.call(i)}catch{}try{return i+""}catch{}}return""}var mr=Ch;var Lh=/[\\^$.*+?()[\]{}|]/g,Ih=/^\[object .+?Constructor\]$/,Ah=Function.prototype,Ph=Object.prototype,Mh=Ah.toString,Oh=Ph.hasOwnProperty,_h=RegExp("^"+Mh.call(Oh).replace(Lh,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Dh(i){if(!et(i)||bc(i))return!1;var t=go(i)?_h:Ih;return t.test(mr(i))}var Sc=Dh;function Bh(i,t){return i?.[t]}var wc=Bh;function Eh(i,t){var e=wc(i,t);return Sc(e)?e:void 0}var ut=Eh;var Gh=ut(Ge,"WeakMap"),Ai=Gh;var Tc=Object.create,Rh=function(){function i(){}return function(t){if(!et(t))return{};if(Tc)return Tc(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Nc=Rh;function Vh(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Cc=Vh;function zh(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Pi=zh;var Fh=800,Uh=16,jh=Date.now;function kh(i){var t=0,e=0;return function(){var r=jh(),o=Uh-(r-e);if(e=r,o>0){if(++t>=Fh)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Lc=kh;function Hh(i){return function(){return i}}var Ic=Hh;var Wh=function(){try{var i=ut(Object,"defineProperty");return i({},"",{}),i}catch{}}(),yo=Wh;var qh=yo?function(i,t){return yo(i,"toString",{configurable:!0,enumerable:!1,value:Ic(t),writable:!0})}:Li,Ac=qh;var $h=Lc(Ac),Mi=$h;function Xh(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Pc=Xh;var Yh=9007199254740991,Kh=/^(?:0|[1-9]\d*)$/;function Qh(i,t){var e=typeof i;return t=t??Yh,!!t&&(e=="number"||e!="symbol"&&Kh.test(i))&&i>-1&&i%1==0&&i<t}var Oi=Qh;function Jh(i,t,e){t=="__proto__"&&yo?yo(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var xo=Jh;function Zh(i,t){return i===t||i!==i&&t!==t}var Lr=Zh;var eg=Object.prototype,tg=eg.hasOwnProperty;function rg(i,t,e){var r=i[t];(!(tg.call(i,t)&&Lr(r,e))||e===void 0&&!(t in i))&&xo(i,t,e)}var _i=rg;function og(i,t,e,r){var o=!e;e||(e={});for(var n=-1,s=t.length;++n<s;){var a=t[n],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),o?xo(e,a,l):_i(e,a,l)}return e}var wt=og;var Mc=Math.max;function ng(i,t,e){return t=Mc(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Mc(r.length-t,0),s=Array(n);++o<n;)s[o]=r[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=r[o];return a[t]=e(s),Cc(i,this,a)}}var Di=ng;function ig(i,t){return Mi(Di(i,t,Li),i+"")}var Oc=ig;var sg=9007199254740991;function ag(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=sg}var Bi=ag;function lg(i){return i!=null&&Bi(i.length)&&!go(i)}var Ir=lg;function cg(i,t,e){if(!et(e))return!1;var r=typeof t;return(r=="number"?Ir(e)&&Oi(t,e.length):r=="string"&&t in e)?Lr(e[t],i):!1}var _c=cg;function ug(i){return Oc(function(t,e){var r=-1,o=e.length,n=o>1?e[o-1]:void 0,s=o>2?e[2]:void 0;for(n=i.length>3&&typeof n=="function"?(o--,n):void 0,s&&_c(e[0],e[1],s)&&(n=o<3?void 0:n,o=1),t=Object(t);++r<o;){var a=e[r];a&&i(t,a,r,n)}return t})}var Dc=ug;var pg=Object.prototype;function mg(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||pg;return i===e}var vo=mg;function dg(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Bc=dg;var fg="[object Arguments]";function hg(i){return Ze(i)&&yt(i)==fg}var xa=hg;var Ec=Object.prototype,gg=Ec.hasOwnProperty,yg=Ec.propertyIsEnumerable,xg=xa(function(){return arguments}())?xa:function(i){return Ze(i)&&gg.call(i,"callee")&&!yg.call(i,"callee")},$r=xg;function vg(){return!1}var Gc=vg;var zc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Rc=zc&&typeof module=="object"&&module&&!module.nodeType&&module,bg=Rc&&Rc.exports===zc,Vc=bg?Ge.Buffer:void 0,Sg=Vc?Vc.isBuffer:void 0,wg=Sg||Gc,bo=wg;var Tg="[object Arguments]",Ng="[object Array]",Cg="[object Boolean]",Lg="[object Date]",Ig="[object Error]",Ag="[object Function]",Pg="[object Map]",Mg="[object Number]",Og="[object Object]",_g="[object RegExp]",Dg="[object Set]",Bg="[object String]",Eg="[object WeakMap]",Gg="[object ArrayBuffer]",Rg="[object DataView]",Vg="[object Float32Array]",zg="[object Float64Array]",Fg="[object Int8Array]",Ug="[object Int16Array]",jg="[object Int32Array]",kg="[object Uint8Array]",Hg="[object Uint8ClampedArray]",Wg="[object Uint16Array]",qg="[object Uint32Array]",Ie={};Ie[Vg]=Ie[zg]=Ie[Fg]=Ie[Ug]=Ie[jg]=Ie[kg]=Ie[Hg]=Ie[Wg]=Ie[qg]=!0;Ie[Tg]=Ie[Ng]=Ie[Gg]=Ie[Cg]=Ie[Rg]=Ie[Lg]=Ie[Ig]=Ie[Ag]=Ie[Pg]=Ie[Mg]=Ie[Og]=Ie[_g]=Ie[Dg]=Ie[Bg]=Ie[Eg]=!1;function $g(i){return Ze(i)&&Bi(i.length)&&!!Ie[yt(i)]}var Fc=$g;function Xg(i){return function(t){return i(t)}}var So=Xg;var Uc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wn=Uc&&typeof module=="object"&&module&&!module.nodeType&&module,Yg=wn&&wn.exports===Uc,va=Yg&&Ni.process,Kg=function(){try{var i=wn&&wn.require&&wn.require("util").types;return i||va&&va.binding&&va.binding("util")}catch{}}(),dr=Kg;var jc=dr&&dr.isTypedArray,Qg=jc?So(jc):Fc,Ei=Qg;var Jg=Object.prototype,Zg=Jg.hasOwnProperty;function ey(i,t){var e=Re(i),r=!e&&$r(i),o=!e&&!r&&bo(i),n=!e&&!r&&!o&&Ei(i),s=e||r||o||n,a=s?Bc(i.length,String):[],l=a.length;for(var c in i)(t||Zg.call(i,c))&&!(s&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Oi(c,l)))&&a.push(c);return a}var Gi=ey;function ty(i,t){return function(e){return i(t(e))}}var Ri=ty;var ry=Ri(Object.keys,Object),kc=ry;var oy=Object.prototype,ny=oy.hasOwnProperty;function iy(i){if(!vo(i))return kc(i);var t=[];for(var e in Object(i))ny.call(i,e)&&e!="constructor"&&t.push(e);return t}var Hc=iy;function sy(i){return Ir(i)?Gi(i):Hc(i)}var wo=sy;function ay(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Wc=ay;var ly=Object.prototype,cy=ly.hasOwnProperty;function uy(i){if(!et(i))return Wc(i);var t=vo(i),e=[];for(var r in i)r=="constructor"&&(t||!cy.call(i,r))||e.push(r);return e}var qc=uy;function py(i){return Ir(i)?Gi(i,!0):qc(i)}var kt=py;var my=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dy=/^\w*$/;function fy(i,t){if(Re(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ho(i)?!0:dy.test(i)||!my.test(i)||t!=null&&i in Object(t)}var $c=fy;var hy=ut(Object,"create"),fr=hy;function gy(){this.__data__=fr?fr(null):{},this.size=0}var Xc=gy;function yy(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Yc=yy;var xy="__lodash_hash_undefined__",vy=Object.prototype,by=vy.hasOwnProperty;function Sy(i){var t=this.__data__;if(fr){var e=t[i];return e===xy?void 0:e}return by.call(t,i)?t[i]:void 0}var Kc=Sy;var wy=Object.prototype,Ty=wy.hasOwnProperty;function Ny(i){var t=this.__data__;return fr?t[i]!==void 0:Ty.call(t,i)}var Qc=Ny;var Cy="__lodash_hash_undefined__";function Ly(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=fr&&t===void 0?Cy:t,this}var Jc=Ly;function To(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}To.prototype.clear=Xc;To.prototype.delete=Yc;To.prototype.get=Kc;To.prototype.has=Qc;To.prototype.set=Jc;var ba=To;function Iy(){this.__data__=[],this.size=0}var Zc=Iy;function Ay(i,t){for(var e=i.length;e--;)if(Lr(i[e][0],t))return e;return-1}var Ar=Ay;var Py=Array.prototype,My=Py.splice;function Oy(i){var t=this.__data__,e=Ar(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():My.call(t,e,1),--this.size,!0}var eu=Oy;function _y(i){var t=this.__data__,e=Ar(t,i);return e<0?void 0:t[e][1]}var tu=_y;function Dy(i){return Ar(this.__data__,i)>-1}var ru=Dy;function By(i,t){var e=this.__data__,r=Ar(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var ou=By;function No(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}No.prototype.clear=Zc;No.prototype.delete=eu;No.prototype.get=tu;No.prototype.has=ru;No.prototype.set=ou;var Pr=No;var Ey=ut(Ge,"Map"),Mr=Ey;function Gy(){this.size=0,this.__data__={hash:new ba,map:new(Mr||Pr),string:new ba}}var nu=Gy;function Ry(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var iu=Ry;function Vy(i,t){var e=i.__data__;return iu(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Or=Vy;function zy(i){var t=Or(this,i).delete(i);return this.size-=t?1:0,t}var su=zy;function Fy(i){return Or(this,i).get(i)}var au=Fy;function Uy(i){return Or(this,i).has(i)}var lu=Uy;function jy(i,t){var e=Or(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var cu=jy;function Co(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Co.prototype.clear=nu;Co.prototype.delete=su;Co.prototype.get=au;Co.prototype.has=lu;Co.prototype.set=cu;var Tn=Co;var ky="Expected a function";function Sa(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(ky);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var s=i.apply(this,r);return e.cache=n.set(o,s)||n,s};return e.cache=new(Sa.Cache||Tn),e}Sa.Cache=Tn;var uu=Sa;var Hy=500;function Wy(i){var t=uu(i,function(r){return e.size===Hy&&e.clear(),r}),e=t.cache;return t}var pu=Wy;var qy=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$y=/\\(\\)?/g,Xy=pu(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(qy,function(e,r,o,n){t.push(o?n.replace($y,"$1"):r||e)}),t}),mu=Xy;function Yy(i){return i==null?"":xc(i)}var du=Yy;function Ky(i,t){return Re(i)?i:$c(i,t)?[i]:mu(du(i))}var Lo=Ky;var Qy=1/0;function Jy(i){if(typeof i=="string"||ho(i))return i;var t=i+"";return t=="0"&&1/i==-Qy?"-0":t}var Vi=Jy;function Zy(i,t){t=Lo(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Vi(t[e++])];return e&&e==r?i:void 0}var fu=Zy;function ex(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var Io=ex;var hu=nt?nt.isConcatSpreadable:void 0;function tx(i){return Re(i)||$r(i)||!!(hu&&i&&i[hu])}var gu=tx;function yu(i,t,e,r,o){var n=-1,s=i.length;for(e||(e=gu),o||(o=[]);++n<s;){var a=i[n];t>0&&e(a)?t>1?yu(a,t-1,e,r,o):Io(o,a):r||(o[o.length]=a)}return o}var xu=yu;function rx(i){var t=i==null?0:i.length;return t?xu(i,1):[]}var vu=rx;function ox(i){return Mi(Di(i,void 0,vu),i+"")}var bu=ox;var nx=Ri(Object.getPrototypeOf,Object),Ao=nx;var ix="[object Object]",sx=Function.prototype,ax=Object.prototype,Su=sx.toString,lx=ax.hasOwnProperty,cx=Su.call(Object);function ux(i){if(!Ze(i)||yt(i)!=ix)return!1;var t=Ao(i);if(t===null)return!0;var e=lx.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Su.call(e)==cx}var zi=ux;function px(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var wu=px;function mx(){this.__data__=new Pr,this.size=0}var Tu=mx;function dx(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var Nu=dx;function fx(i){return this.__data__.get(i)}var Cu=fx;function hx(i){return this.__data__.has(i)}var Lu=hx;var gx=200;function yx(i,t){var e=this.__data__;if(e instanceof Pr){var r=e.__data__;if(!Mr||r.length<gx-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Tn(r)}return e.set(i,t),this.size=e.size,this}var Iu=yx;function Po(i){var t=this.__data__=new Pr(i);this.size=t.size}Po.prototype.clear=Tu;Po.prototype.delete=Nu;Po.prototype.get=Cu;Po.prototype.has=Lu;Po.prototype.set=Iu;var Fi=Po;function xx(i,t){return i&&wt(t,wo(t),i)}var Au=xx;function vx(i,t){return i&&wt(t,kt(t),i)}var Pu=vx;var Du=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mu=Du&&typeof module=="object"&&module&&!module.nodeType&&module,bx=Mu&&Mu.exports===Du,Ou=bx?Ge.Buffer:void 0,_u=Ou?Ou.allocUnsafe:void 0;function Sx(i,t){if(t)return i.slice();var e=i.length,r=_u?_u(e):new i.constructor(e);return i.copy(r),r}var Ui=Sx;function wx(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var s=i[e];t(s,e,i)&&(n[o++]=s)}return n}var Bu=wx;function Tx(){return[]}var ji=Tx;var Nx=Object.prototype,Cx=Nx.propertyIsEnumerable,Eu=Object.getOwnPropertySymbols,Lx=Eu?function(i){return i==null?[]:(i=Object(i),Bu(Eu(i),function(t){return Cx.call(i,t)}))}:ji,Mo=Lx;function Ix(i,t){return wt(i,Mo(i),t)}var Gu=Ix;var Ax=Object.getOwnPropertySymbols,Px=Ax?function(i){for(var t=[];i;)Io(t,Mo(i)),i=Ao(i);return t}:ji,ki=Px;function Mx(i,t){return wt(i,ki(i),t)}var Ru=Mx;function Ox(i,t,e){var r=t(i);return Re(i)?r:Io(r,e(i))}var Hi=Ox;function _x(i){return Hi(i,wo,Mo)}var Vu=_x;function Dx(i){return Hi(i,kt,ki)}var Wi=Dx;var Bx=ut(Ge,"DataView"),qi=Bx;var Ex=ut(Ge,"Promise"),$i=Ex;var Gx=ut(Ge,"Set"),Xi=Gx;var zu="[object Map]",Rx="[object Object]",Fu="[object Promise]",Uu="[object Set]",ju="[object WeakMap]",ku="[object DataView]",Vx=mr(qi),zx=mr(Mr),Fx=mr($i),Ux=mr(Xi),jx=mr(Ai),Xr=yt;(qi&&Xr(new qi(new ArrayBuffer(1)))!=ku||Mr&&Xr(new Mr)!=zu||$i&&Xr($i.resolve())!=Fu||Xi&&Xr(new Xi)!=Uu||Ai&&Xr(new Ai)!=ju)&&(Xr=function(i){var t=yt(i),e=t==Rx?i.constructor:void 0,r=e?mr(e):"";if(r)switch(r){case Vx:return ku;case zx:return zu;case Fx:return Fu;case Ux:return Uu;case jx:return ju}return t});var Oo=Xr;var kx=Object.prototype,Hx=kx.hasOwnProperty;function Wx(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&Hx.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Hu=Wx;var qx=Ge.Uint8Array,wa=qx;function $x(i){var t=new i.constructor(i.byteLength);return new wa(t).set(new wa(i)),t}var _o=$x;function Xx(i,t){var e=t?_o(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Wu=Xx;var Yx=/\w*$/;function Kx(i){var t=new i.constructor(i.source,Yx.exec(i));return t.lastIndex=i.lastIndex,t}var qu=Kx;var $u=nt?nt.prototype:void 0,Xu=$u?$u.valueOf:void 0;function Qx(i){return Xu?Object(Xu.call(i)):{}}var Yu=Qx;function Jx(i,t){var e=t?_o(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Yi=Jx;var Zx="[object Boolean]",e0="[object Date]",t0="[object Map]",r0="[object Number]",o0="[object RegExp]",n0="[object Set]",i0="[object String]",s0="[object Symbol]",a0="[object ArrayBuffer]",l0="[object DataView]",c0="[object Float32Array]",u0="[object Float64Array]",p0="[object Int8Array]",m0="[object Int16Array]",d0="[object Int32Array]",f0="[object Uint8Array]",h0="[object Uint8ClampedArray]",g0="[object Uint16Array]",y0="[object Uint32Array]";function x0(i,t,e){var r=i.constructor;switch(t){case a0:return _o(i);case Zx:case e0:return new r(+i);case l0:return Wu(i,e);case c0:case u0:case p0:case m0:case d0:case f0:case h0:case g0:case y0:return Yi(i,e);case t0:return new r;case r0:case i0:return new r(i);case o0:return qu(i);case n0:return new r;case s0:return Yu(i)}}var Ku=x0;function v0(i){return typeof i.constructor=="function"&&!vo(i)?Nc(Ao(i)):{}}var Ki=v0;var b0="[object Map]";function S0(i){return Ze(i)&&Oo(i)==b0}var Qu=S0;var Ju=dr&&dr.isMap,w0=Ju?So(Ju):Qu,Zu=w0;var T0="[object Set]";function N0(i){return Ze(i)&&Oo(i)==T0}var ep=N0;var tp=dr&&dr.isSet,C0=tp?So(tp):ep,rp=C0;var L0=1,I0=2,A0=4,op="[object Arguments]",P0="[object Array]",M0="[object Boolean]",O0="[object Date]",_0="[object Error]",np="[object Function]",D0="[object GeneratorFunction]",B0="[object Map]",E0="[object Number]",ip="[object Object]",G0="[object RegExp]",R0="[object Set]",V0="[object String]",z0="[object Symbol]",F0="[object WeakMap]",U0="[object ArrayBuffer]",j0="[object DataView]",k0="[object Float32Array]",H0="[object Float64Array]",W0="[object Int8Array]",q0="[object Int16Array]",$0="[object Int32Array]",X0="[object Uint8Array]",Y0="[object Uint8ClampedArray]",K0="[object Uint16Array]",Q0="[object Uint32Array]",Le={};Le[op]=Le[P0]=Le[U0]=Le[j0]=Le[M0]=Le[O0]=Le[k0]=Le[H0]=Le[W0]=Le[q0]=Le[$0]=Le[B0]=Le[E0]=Le[ip]=Le[G0]=Le[R0]=Le[V0]=Le[z0]=Le[X0]=Le[Y0]=Le[K0]=Le[Q0]=!0;Le[_0]=Le[np]=Le[F0]=!1;function Qi(i,t,e,r,o,n){var s,a=t&L0,l=t&I0,c=t&A0;if(e&&(s=o?e(i,r,o,n):e(i)),s!==void 0)return s;if(!et(i))return i;var u=Re(i);if(u){if(s=Hu(i),!a)return Pi(i,s)}else{var m=Oo(i),p=m==np||m==D0;if(bo(i))return Ui(i,a);if(m==ip||m==op||p&&!o){if(s=l||p?{}:Ki(i),!a)return l?Ru(i,Pu(s,i)):Gu(i,Au(s,i))}else{if(!Le[m])return o?i:{};s=Ku(i,m,a)}}n||(n=new Fi);var d=n.get(i);if(d)return d;n.set(i,s),rp(i)?i.forEach(function(x){s.add(Qi(x,t,e,x,i,n))}):Zu(i)&&i.forEach(function(x,y){s.set(y,Qi(x,t,e,y,i,n))});var f=c?l?Wi:Vu:l?kt:wo,g=u?void 0:f(i);return Pc(g||i,function(x,y){g&&(y=x,x=i[y]),_i(s,y,Qi(x,t,e,y,i,n))}),s}var Ji=Qi;var J0=1,Z0=4;function ev(i){return Ji(i,J0|Z0)}var Nn=ev;function tv(i){return function(t,e,r){for(var o=-1,n=Object(t),s=r(t),a=s.length;a--;){var l=s[i?a:++o];if(e(n[l],l,n)===!1)break}return t}}var sp=tv;var rv=sp(),ap=rv;function ov(i,t,e){(e!==void 0&&!Lr(i[t],e)||e===void 0&&!(t in i))&&xo(i,t,e)}var Cn=ov;function nv(i){return Ze(i)&&Ir(i)}var lp=nv;function iv(i,t){if(!(t==="constructor"&&typeof i[t]=="function")&&t!="__proto__")return i[t]}var Ln=iv;function sv(i){return wt(i,kt(i))}var cp=sv;function av(i,t,e,r,o,n,s){var a=Ln(i,e),l=Ln(t,e),c=s.get(l);if(c){Cn(i,e,c);return}var u=n?n(a,l,e+"",i,t,s):void 0,m=u===void 0;if(m){var p=Re(l),d=!p&&bo(l),f=!p&&!d&&Ei(l);u=l,p||d||f?Re(a)?u=a:lp(a)?u=Pi(a):d?(m=!1,u=Ui(l,!0)):f?(m=!1,u=Yi(l,!0)):u=[]:zi(l)||$r(l)?(u=a,$r(a)?u=cp(a):(!et(a)||go(a))&&(u=Ki(l))):m=!1}m&&(s.set(l,u),o(u,l,r,n,s),s.delete(l)),Cn(i,e,u)}var up=av;function pp(i,t,e,r,o){i!==t&&ap(t,function(n,s){if(o||(o=new Fi),et(n))up(i,t,s,e,pp,r,o);else{var a=r?r(Ln(i,s),n,s+"",i,t,o):void 0;a===void 0&&(a=n),Cn(i,s,a)}},kt)}var mp=pp;function lv(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var dp=lv;function cv(i,t){return t.length<2?i:fu(i,wu(t,0,-1))}var fp=cv;var uv=Dc(function(i,t,e){mp(i,t,e)}),Yr=uv;function pv(i,t){return t=Lo(t,i),i=fp(i,t),i==null||delete i[Vi(dp(t))]}var hp=pv;function mv(i){return zi(i)?void 0:i}var gp=mv;var dv=1,fv=2,hv=4,gv=bu(function(i,t){var e={};if(i==null)return e;var r=!1;t=Ci(t,function(n){return n=Lo(n,i),r||(r=n.length>1),n}),wt(i,Wi(i),e),r&&(e=Ji(e,dv|fv|hv,gp));for(var o=t.length;o--;)hp(e,t[o]);return e}),Do=gv;var Bo;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Bo||(Bo={}));var Kr;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective.zoom:n.orthographic.zoom}o.getZoom=r})(Kr||(Kr={}));var yp;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n]}e.lerp=t})(yp||(yp={}));var Eo;(o=>{function i(n,s){return n[0]===s[0]&&n[1]===s[1]&&n[2]===s[2]}o.isEqual=i;function t(n,s){return[n[0]+s[0],n[1]+s[1],n[2]+s[2]]}o.add=t;function e(n,s){return[n[0]-s[0],n[1]-s[1],n[2]-s[2]]}o.sub=e;function r(n,s,a){return[n[0]+(s[0]-n[0])*a,n[1]+(s[1]-n[1])*a,n[2]+(s[2]-n[2])*a]}o.lerp=r})(Eo||(Eo={}));var xp;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(xp||(xp={}));var _r;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,s){for(let a=0;a<16;a++)if(n[a]!==s[a])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(n,s){let a=s.slice(0);for(var l=0,c=s.length;l<c;l+=3){let u=n[3]*s[l]+n[7]*s[l+1]+n[11]*s[l+2]+n[15];a[l]=(n[0]*s[l]+n[4]*s[l+1]+n[8]*s[l+2]+n[12])/u,a[l+1]=(n[1]*s[l]+n[5]*s[l+1]+n[9]*s[l+2]+n[13])/u,a[l+2]=(n[2]*s[l]+n[6]*s[l+1]+n[10]*s[l+2]+n[14])/u}return a}o.applyMatrix4=r})(_r||(_r={}));var xt;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function n(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=n;function s(c,u){return c.r===u.r&&c.g===u.g&&c.b===u.b}l.equals=s;function a(c,u,m){return{r:c.r+(u.r-c.r)*m,g:c.g+(u.g-c.g)*m,b:c.b+(u.b-c.b)*m}}l.lerp=a})(xt||(xt={}));var vt;(s=>{s.white={...xt.white,a:1};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}s.from0to1=t;function e(a,l){return{...xt.fromHex(a),a:l}}s.fromHexAndA=e;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}s.toRgb255a1=r;function o(a,l){return xt.equals(a,l)&&a.a===l.a}s.equals=o;function n(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}s.lerp=n})(vt||(vt={}));var Zi;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Zi||(Zi={}));var vp;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(vp||(vp={}));var bp;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(bp||(bp={}));var es;(t=>{function i(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(o=>o*(1+r)),useCenter:!0}}}t.defaultData=i})(es||(es={}));var ze=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,ze.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:s}=t,a={...e,[n]:s};return Object.setPrototypeOf(a,ze.prototype),{data:a,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,ze.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}throw new Error("illegal arg")}};function In(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&In(r)}return Object.freeze(i)}function Sp(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ts=class extends Error{};function Ht(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let s=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(s)}return r}function rs(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function wp(){return typeof process<"u"}function Tp(i,t){for(let e of i)t(e.id,e.data),Tp(e.children,t)}function Np(i,t){t(i.id,i.data);for(let e of i.children)Np(e,t)}var Tt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Tt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)In(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Np(o,r)}}traverse(e){Tp(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),s=this.childrenArray(n),a=s.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=s[a];return s=[...s],s[a]={...l,data:r},this.modifyArrayBy(n,s)}}modifyArrayBy(e,r){let o=e,n=r;for(;o!==null;){let a=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(u=>u.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:a}}Object.setPrototypeOf(n,Tt.prototype);let s=n;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:s,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:o,id:n,data:s,children:a};return c=[...c,u],c.sort((p,d)=>p.fi-d.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),s=n.findIndex(c=>c.id===r);e.localIndex=s,n=[...n];let a=n.splice(s,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...a,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let d=r;for(;d!==null;){if(d===void 0)throw new Error;if(d===n)throw new ts("cyclic tree");d=this.parent(d)}}let s=this.parent(n);if(s===void 0)return null;let a=s,l=this.childrenArray(s),c=l.findIndex(d=>d.id===n);l=[...l];let u=l.splice(c,1)[0],m=this.modifyArrayBy(s,l);s=r,l=m.childrenArray(s);let p=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((d,f)=>d.fi-f.fi),e.localIndex=l.indexOf(u),m=m.modifyArrayBy(s,l),{data:m,actual:e,reverse:{type:9,parent:a,fi:p,id:n}}}previous(e,r){if(r===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(s=>s.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(s=>s.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Sp(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),s=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...s,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return Ht(0,o,o);{let s=n[0].fi;return Ht(s-o,s,o)}}else{let s=this.get(r);if(s===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=n.find(l=>l.fi>s.fi);if(a===void 0){let l=n[n.length-1].fi;return Ht(l,l+o,o)}else return Ht(s.fi,a.fi,o)}}};var os;(t=>{function i(e,r){if(Array.isArray(e)){let o=r.props,n={},s=[...e],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=s[c],s[c]=o[l],a=!0}return a?{data:s,actual:r,reverse:{type:0,props:n}}:null}else{let o=r.props,n={},s={...e},a=!1;if(o)for(let l of Object.keys(o)){n[l]=s[l];let c=o[l];c===void 0?delete s[l]:s[l]=c,a=!0}return a?{data:s,actual:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(os||(os={}));var Pe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Pe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)In(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,s=n.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=n[s];return n=[...n],n[s]={...a,data:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,Pe.prototype);let r=e;return wp()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:o,data:n}=e,s=this,a={fi:r,id:o,data:n};return s=[...s,a],s.sort((c,u)=>c.fi-u.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,n=o.findIndex(l=>l.id===r);if(n===-1)return null;e.localIndex=n,o=[...o];let s=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:r,id:o}=e,n=this;n=[...n];let s=n.findIndex(u=>u.id===o);if(s===-1)return null;let a=n[s].fi,l={...n[s],fi:r};return n[s]=l,n.sort((u,m)=>u.fi-m.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),actual:e,reverse:{type:6,fi:a,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return Ht(0,r,r);{let n=o[0].fi;return Ht(n-r,n,r)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let s=o.find(a=>a.fi>n.fi);if(s===void 0){let a=o[o.length-1].fi;return Ht(a,a+r,r)}else return Ht(n.fi,s.fi,r)}}};var Cp=Symbol(),is=Symbol(),Go=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let o=[];for(;!(r instanceof ns);){let n=r._path,s=r._current;if(n!==""&&o.splice(0,0,n),r=r._parent,r===null)return;r.update(n,s)}r.push(o,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[is];r&&r(),delete this._children[t]}}}},Na=class extends Go{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,os.runOp(this._current,t))}},Ca=class extends Go{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,ze.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Lp={get(i,t){if(t===is)return()=>{i._parent=null};if(t===Cp)return i._current;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],s=ss(i,t,n);return s!==n?(r===void 0&&(r={},i._children=r),r[t]=s,s):n},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},yv={...Lp,set(i,t,e){let r={type:0,props:{[t]:Aa(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},xv={...Lp,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Ro=class extends Go{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,s=ss(this,t,n);return s!==n?(r===void 0&&(r={},this._children=r),r[t]=s,s):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(t,o[n],s.id,s.data,s.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(t,o[n],s.id,s.data,s.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(t,o[n],s)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(t,o[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Vo=class extends Go{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;t(this.data(this._current[r].id),o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,s=ss(this,t,n);return s!==n?(r===void 0&&(r={},this._children=r),r[t]=s,s):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ta(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&as.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var ns=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Ta(this.ts,e,t),Ta(this.actual,r,t),Ta(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ss(i,t,e){return e instanceof Tt?new Ro(i,t,e):e instanceof Pe?new Vo(i,t,e):e instanceof ze?new Proxy(new Ca(i,t,e),xv):e!==null&&typeof e=="object"?rs(e)?e:new Proxy(new Na(i,t,e),yv):e}function La(i){let t=new ns(i);return[ss(t,"",i),t]}function Ia(i,t){let[e,r]=La(i);return t(e),r.result()}function Aa(i){return i instanceof Ro||i instanceof Vo?i._current:i!==null&&typeof i=="object"?i[Cp]:i}var as;(r=>{function i(o,n){if(n.length===o.length)for(var s=0;s<o.length;){if(o[s]!==n[s])return!1;s+=1}else return!1;return!0}r.equal=i;function t(o,n,s){let a=e(s,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...n};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return n}r.removeOverridden=t;function e(o,n,s=0){if(n.length<=s)return o;if((o instanceof Tt||o instanceof Ro)&&typeof n[s]=="string")return e(o.data(n[s]),n,s+1);if((o instanceof Pe||o instanceof Vo)&&typeof n[s]=="string")return e(o.data(n[s]),n,s+1);if(typeof n[s]=="number"&&Array.isArray(o))return e(o[n[s]],n,s+1);if(typeof n[s]=="string"&&typeof o=="object")return e(o[n[s]],n,s+1)}r.zoom=e})(as||(as={}));var ls=class{},An=class extends ls{constructor(e){super();this.id=e}},Pn=class extends ls{constructor(e){super();this.data=e}};var Ma;try{Ma=new TextDecoder}catch{}var te,Br,T=0;var Bp=[],Oa=Bp,_a=0,pt={},xe,Dr,Nt=0,Wt=0,bt,hr,it=[],Te,Ip={useRecords:!1,mapsAsObjects:!0},Mn=class{},Ba=new Mn;Ba.name="MessagePack 0xC1";var zo=!1,qt=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(te)return zp(()=>(us(),this?this.unpack(t,e):qt.prototype.unpack.call(Ip,t,e)));Br=e>-1?e:t.length,T=0,_a=0,Wt=0,Dr=null,Oa=Bp,bt=null,te=t;try{Te=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw te=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof qt){if(pt=this,this.structures)return xe=this.structures,cs();(!xe||xe.length>0)&&(xe=[])}else pt=Ip,(!xe||xe.length>0)&&(xe=[]);return cs()}unpackMultiple(t,e){let r,o=0;try{zo=!0;let n=t.length,s=this?this.unpack(t,n):ds.unpack(t,n);if(e){for(e(s);T<n;)if(o=T,e(cs())===!1)return}else{for(r=[s];T<n;)o=T,r.push(cs());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{zo=!1,us()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function cs(){try{if(!pt.trusted&&!zo){let t=xe.sharedLength||0;t<xe.length&&(xe.length=t)}let i=Oe();if(T==Br)xe.restoreStructures&&Ap(),xe=null,te=null,hr&&(hr=null);else if(T>Br){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!zo)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw xe.restoreStructures&&Ap(),us(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Ap(){for(let i in xe.restoreStructures)xe[i]=xe.restoreStructures[i];xe.restoreStructures=null}function Oe(){let i=te[T++];if(i<160)if(i<128){if(i<64)return i;{let t=xe[i&63]||pt.getStructures&&Ep()[i&63];return t?(t.read||(t.read=Ea(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,pt.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Rp()]=Oe();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Oe(),Oe());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Oe();return t}else if(i<192){let t=i-160;if(Wt>=T)return Dr.slice(T-Nt,(T+=t)-Nt);if(Wt==0&&Br<140){let e=t<16?Ga(t):Gp(t);if(e!=null)return e}return Da(t)}else{let t;switch(i){case 192:return null;case 193:return bt?(t=Oe(),t>0?bt[1].slice(bt.position1,bt.position1+=t):bt[0].slice(bt.position0,bt.position0-=t)):Ba;case 194:return!1;case 195:return!0;case 196:return Pa(te[T++]);case 197:return t=Te.getUint16(T),T+=2,Pa(t);case 198:return t=Te.getUint32(T),T+=4,Pa(t);case 199:return Qr(te[T++]);case 200:return t=Te.getUint16(T),T+=2,Qr(t);case 201:return t=Te.getUint32(T),T+=4,Qr(t);case 202:if(t=Te.getFloat32(T),pt.useFloat32>2){let e=ms[(te[T]&127)<<1|te[T+1]>>7];return T+=4,(e*t+(t>0?.5:-.5)>>0)/e}return T+=4,t;case 203:return t=Te.getFloat64(T),T+=8,t;case 204:return te[T++];case 205:return t=Te.getUint16(T),T+=2,t;case 206:return t=Te.getUint32(T),T+=4,t;case 207:return pt.int64AsNumber?(t=Te.getUint32(T)*4294967296,t+=Te.getUint32(T+4)):t=Te.getBigUint64(T),T+=8,t;case 208:return Te.getInt8(T++);case 209:return t=Te.getInt16(T),T+=2,t;case 210:return t=Te.getInt32(T),T+=4,t;case 211:return pt.int64AsNumber?(t=Te.getInt32(T)*4294967296,t+=Te.getUint32(T+4)):t=Te.getBigInt64(T),T+=8,t;case 212:if(t=te[T++],t==114)return Dp(te[T++]&63);{let e=it[t];if(e)return e.read?(T++,e.read(Oe())):e.noBuffer?(T++,e()):e(te.subarray(T,++T));throw new Error("Unknown extension "+t)}case 213:return t=te[T],t==114?(T++,Dp(te[T++]&63,te[T++])):Qr(2);case 214:return Qr(4);case 215:return Qr(8);case 216:return Qr(16);case 217:return t=te[T++],Wt>=T?Dr.slice(T-Nt,(T+=t)-Nt):bv(t);case 218:return t=Te.getUint16(T),T+=2,Wt>=T?Dr.slice(T-Nt,(T+=t)-Nt):Sv(t);case 219:return t=Te.getUint32(T),T+=4,Wt>=T?Dr.slice(T-Nt,(T+=t)-Nt):wv(t);case 220:return t=Te.getUint16(T),T+=2,Mp(t);case 221:return t=Te.getUint32(T),T+=4,Mp(t);case 222:return t=Te.getUint16(T),T+=2,Op(t);case 223:return t=Te.getUint32(T),T+=4,Op(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var vv=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ea(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>vv.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Oe);return i.highByte===0&&(i.read=Pp(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let s=i[o];r[s]=Oe()}return r}return e.count=0,i.highByte===0?Pp(t,e):e}var Pp=(i,t)=>function(){let e=te[T++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=xe[r]||Ep()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Ea(o,i)),o.read()};function Ep(){let i=zp(()=>(te=null,pt.getStructures()));return xe=pt._mergeStructures(i,xe)}var Da=ps,bv=ps,Sv=ps,wv=ps;function ps(i){let t;if(i<16&&(t=Ga(i)))return t;if(i>64&&Ma)return Ma.decode(te.subarray(T,T+=i));let e=T+i,r=[];for(t="";T<e;){let o=te[T++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=te[T++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=te[T++]&63,s=te[T++]&63;r.push((o&31)<<12|n<<6|s)}else if((o&248)===240){let n=te[T++]&63,s=te[T++]&63,a=te[T++]&63,l=(o&7)<<18|n<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=qe.apply(String,r),r.length=0)}return r.length>0&&(t+=qe.apply(String,r)),t}function Mp(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Oe();return t}function Op(i){if(pt.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[Rp()]=Oe();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Oe(),Oe());return t}}var qe=String.fromCharCode;function Gp(i){let t=T,e=new Array(i);for(let r=0;r<i;r++){let o=te[T++];if((o&128)>0){T=t;return}e[r]=o}return qe.apply(String,e)}function Ga(i){if(i<4)if(i<2){if(i===0)return"";{let t=te[T++];if((t&128)>1){T-=1;return}return qe(t)}}else{let t=te[T++],e=te[T++];if((t&128)>0||(e&128)>0){T-=2;return}if(i<3)return qe(t,e);let r=te[T++];if((r&128)>0){T-=3;return}return qe(t,e,r)}else{let t=te[T++],e=te[T++],r=te[T++],o=te[T++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){T-=4;return}if(i<6){if(i===4)return qe(t,e,r,o);{let n=te[T++];if((n&128)>0){T-=5;return}return qe(t,e,r,o,n)}}else if(i<8){let n=te[T++],s=te[T++];if((n&128)>0||(s&128)>0){T-=6;return}if(i<7)return qe(t,e,r,o,n,s);let a=te[T++];if((a&128)>0){T-=7;return}return qe(t,e,r,o,n,s,a)}else{let n=te[T++],s=te[T++],a=te[T++],l=te[T++];if((n&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){T-=8;return}if(i<10){if(i===8)return qe(t,e,r,o,n,s,a,l);{let c=te[T++];if((c&128)>0){T-=9;return}return qe(t,e,r,o,n,s,a,l,c)}}else if(i<12){let c=te[T++],u=te[T++];if((c&128)>0||(u&128)>0){T-=10;return}if(i<11)return qe(t,e,r,o,n,s,a,l,c,u);let m=te[T++];if((m&128)>0){T-=11;return}return qe(t,e,r,o,n,s,a,l,c,u,m)}else{let c=te[T++],u=te[T++],m=te[T++],p=te[T++];if((c&128)>0||(u&128)>0||(m&128)>0||(p&128)>0){T-=12;return}if(i<14){if(i===12)return qe(t,e,r,o,n,s,a,l,c,u,m,p);{let d=te[T++];if((d&128)>0){T-=13;return}return qe(t,e,r,o,n,s,a,l,c,u,m,p,d)}}else{let d=te[T++],f=te[T++];if((d&128)>0||(f&128)>0){T-=14;return}if(i<15)return qe(t,e,r,o,n,s,a,l,c,u,m,p,d,f);let g=te[T++];if((g&128)>0){T-=15;return}return qe(t,e,r,o,n,s,a,l,c,u,m,p,d,f,g)}}}}}function Pa(i){return pt.copyBuffers?Uint8Array.prototype.slice.call(te,T,T+=i):te.subarray(T,T+=i)}function Qr(i){let t=te[T++];if(it[t])return it[t](te.subarray(T,T+=i));throw new Error("Unknown extension type "+t)}var _p=new Array(4096);function Rp(){let i=te[T++];if(i>=160&&i<192){if(i=i-160,Wt>=T)return Dr.slice(T-Nt,(T+=i)-Nt);if(!(Wt==0&&Br<180))return Da(i)}else return T--,Oe();let t=(i<<5^(i>1?Te.getUint16(T):i>0?te[T]:0))&4095,e=_p[t],r=T,o=T+i-3,n,s=0;if(e&&e.bytes==i){for(;r<o;){if(n=Te.getUint32(r),n!=e[s++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=te[r++],n!=e[s++]){r=1879048192;break}if(r===o)return T=r,e.string;o-=3,r=T}for(e=[],_p[t]=e,e.bytes=i;r<o;)n=Te.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=te[r++],e.push(n);let a=i<16?Ga(i):Gp(i);return a!=null?e.string=a:e.string=Da(i)}var Dp=(i,t)=>{var e=Oe();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=xe[i];return o&&o.isShared&&((xe.restoreStructures||(xe.restoreStructures=[]))[i]=o),xe[i]=e,e.read=Ea(e,r),e.read()},Vp=typeof self=="object"?self:global;it[0]=()=>{};it[0].noBuffer=!0;it[101]=()=>{let i=Oe();return(Vp[i[0]]||Error)(i[1])};it[105]=i=>{let t=Te.getUint32(T-4);hr||(hr=new Map);let e=te[T],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};hr.set(t,o);let n=Oe();return o.used?Object.assign(r,n):(o.target=n,n)};it[112]=i=>{let t=Te.getUint32(T-4),e=hr.get(t);return e.used=!0,e.target};it[115]=()=>new Set(Oe());var Ra=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");it[116]=i=>{let t=i[0],e=Ra[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Vp[e](Uint8Array.prototype.slice.call(i,1).buffer)};it[120]=()=>{let i=Oe();return new RegExp(i[0],i[1])};it[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=T;T+=t-4,bt=[Oe(),Oe()],bt.position0=0,bt.position1=0;let r=T;T=e;try{return Oe()}finally{T=r}};it[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function zp(i){let t=Br,e=T,r=_a,o=Nt,n=Wt,s=Dr,a=Oa,l=hr,c=bt,u=new Uint8Array(te.slice(0,Br)),m=xe,p=xe.slice(0,xe.length),d=pt,f=zo,g=i();return Br=t,T=e,_a=r,Nt=o,Wt=n,Dr=s,Oa=a,hr=l,bt=c,te=u,zo=f,xe=m,xe.splice(0,xe.length,...p),pt=d,Te=new DataView(te.buffer,te.byteOffset,te.byteLength),g}function us(){te=null,hr=null,xe=null}function Fp(i){i.unpack?it[i.type]=i.unpack:it[i.type]=i}var ms=new Array(147);for(let i=0;i<256;i++)ms[i]=+("1e"+Math.floor(45.15-i*.30103));var ds=new qt({useRecords:!1}),Tv=ds.unpack,Nv=ds.unpackMultiple,Cv=ds.unpack,fs={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Lv=new Float32Array(1),cO=new Uint8Array(Lv.buffer,0,4);var hs;try{hs=new TextEncoder}catch{}var gs,za,ys=typeof Buffer<"u",Va=ys?Buffer.allocUnsafeSlow:Uint8Array,Hp=ys?Buffer:Uint8Array,Up=ys?4294967296:2144337920,R,De,C=0,$t,Xt=null,Iv=/[\u0080-\uFFFF]/,On=Symbol("record-id"),Jr=class extends qt{constructor(t){super(t),this.offset=0;let e,r,o,n,s,a,l=0,c=Hp.prototype.utf8Write?function(h,_,N){return R.utf8Write(h,_,N)}:hs&&hs.encodeInto?function(h,_){return hs.encodeInto(h,R.subarray(_)).written}:!1,u=this;t||(t={});let m=t&&t.sequential,p=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=p?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=t.maxOwnStructures;f==null&&(f=p?32:64),m&&!t.saveStructures&&(this.structures=[]);let g=d>32||f+d>64,x=d+64,y=d+f+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],A=0,S=0;this.pack=this.encode=function(h,_){if(R||(R=new Va(8192),De=new DataView(R.buffer,0,8192),C=0),$t=R.length-10,$t-C<2048?(R=new Va(R.length),De=new DataView(R.buffer,0,R.length),$t=R.length-10,C=0):C=C+7&2147483640,r=C,a=u.structuredClone?new Map:null,u.bundleStrings?(Xt=["",""],R[C++]=214,R[C++]=98,Xt.position=C-r,C+=4):Xt=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let N=o.sharedLength||0;if(N>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let I=0;I<N;I++){let L=o[I];if(!L)continue;let P,k=o.transitions;for(let W=0,oe=L.length;W<oe;W++){let ce=L[W];P=k[ce],P||(P=k[ce]=Object.create(null)),k=P}k[On]=I+64}l=N}m||(o.nextId=N+64)}n&&(n=!1),s=o||[];try{if(b(h),Xt){De.setUint32(Xt.position+r,C-Xt.position-r);let N=Xt;Xt=null,b(N[0]),b(N[1])}if(u.offset=C,a&&a.idsToInsert){C+=a.idsToInsert.length*6,C>$t&&w(C),u.offset=C;let N=Pv(R.subarray(r,C),a.idsToInsert);return a=null,N}return _&qp?(R.start=r,R.end=C,R):R.subarray(r,C)}finally{if(o){if(S<10&&S++,A>1e4)o.transitions=null,S=0,A=0,v.length>0&&(v=[]);else if(v.length>0&&!m){for(let N=0,I=v.length;N<I;N++)v[N][On]=0;v=[]}if(n&&u.saveStructures){let N=o.sharedLength||d;o.length>N&&(o=o.slice(0,N));let I=R.subarray(r,C);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(h)):(l=N,I)}}_&Gv&&(C=r)}};let b=h=>{C>$t&&(R=w(C));var _=typeof h,N;if(_==="string"){let I=h.length;if(Xt&&I>=8&&I<4096){let k=Iv.test(h);Xt[k?0:1]+=h,R[C++]=193,b(k?-I:I);return}let L;I<32?L=1:I<256?L=2:I<65536?L=3:L=5;let P=I*3;if(C+P>$t&&(R=w(C+P)),I<64||!c){let k,W,oe,ce=C+L;for(k=0;k<I;k++)W=h.charCodeAt(k),W<128?R[ce++]=W:W<2048?(R[ce++]=W>>6|192,R[ce++]=W&63|128):(W&64512)===55296&&((oe=h.charCodeAt(k+1))&64512)===56320?(W=65536+((W&1023)<<10)+(oe&1023),k++,R[ce++]=W>>18|240,R[ce++]=W>>12&63|128,R[ce++]=W>>6&63|128,R[ce++]=W&63|128):(R[ce++]=W>>12|224,R[ce++]=W>>6&63|128,R[ce++]=W&63|128);N=ce-C-L}else N=c(h,C+L,P);N<32?R[C++]=160|N:N<256?(L<2&&R.copyWithin(C+2,C+1,C+1+N),R[C++]=217,R[C++]=N):N<65536?(L<3&&R.copyWithin(C+3,C+2,C+2+N),R[C++]=218,R[C++]=N>>8,R[C++]=N&255):(L<5&&R.copyWithin(C+5,C+3,C+3+N),R[C++]=219,De.setUint32(C,N),C+=4),C+=N}else if(_==="number")if(h>>>0===h)h<64?R[C++]=h:h<256?(R[C++]=204,R[C++]=h):h<65536?(R[C++]=205,R[C++]=h>>8,R[C++]=h&255):(R[C++]=206,De.setUint32(C,h),C+=4);else if(h>>0===h)h>=-32?R[C++]=256+h:h>=-128?(R[C++]=208,R[C++]=h+256):h>=-32768?(R[C++]=209,De.setInt16(C,h),C+=2):(R[C++]=210,De.setInt32(C,h),C+=4);else{let I;if((I=this.useFloat32)>0&&h<4294967296&&h>=-2147483648){R[C++]=202,De.setFloat32(C,h);let L;if(I<4||(L=h*ms[(R[C]&127)<<1|R[C+1]>>7])>>0===L){C+=4;return}else C--}R[C++]=203,De.setFloat64(C,h),C+=8}else if(_==="object")if(!h)R[C++]=192;else{if(a){let L=a.get(h);if(L){if(!L.id){let P=a.idsToInsert||(a.idsToInsert=[]);L.id=P.push(L)}R[C++]=214,R[C++]=112,De.setUint32(C,L.id),C+=4;return}else a.set(h,{offset:C-r})}let I=h.constructor;if(I===Object)B(h,!0);else if(I===Array){N=h.length,N<16?R[C++]=144|N:N<65536?(R[C++]=220,R[C++]=N>>8,R[C++]=N&255):(R[C++]=221,De.setUint32(C,N),C+=4);for(let L=0;L<N;L++)b(h[L])}else if(I===Map){N=h.size,N<16?R[C++]=128|N:N<65536?(R[C++]=222,R[C++]=N>>8,R[C++]=N&255):(R[C++]=223,De.setUint32(C,N),C+=4);for(let[L,P]of h)b(L),b(P)}else{for(let L=0,P=gs.length;L<P;L++){let k=za[L];if(h instanceof k){let W=gs[L];if(W.write){W.type&&(R[C++]=212,R[C++]=W.type,R[C++]=0),b(W.write.call(this,h));return}let oe=R,ce=De,ie=C;R=null;let K;try{K=W.pack.call(this,h,U=>(R=oe,oe=null,C+=U,C>$t&&w(C),{target:R,targetView:De,position:C-U}),b)}finally{oe&&(R=oe,De=ce,C=ie,$t=R.length-10)}K&&(K.length+C>$t&&w(K.length+C),C=Av(K,R,C,W.type));return}}B(h,!h.hasOwnProperty)}}else if(_==="boolean")R[C++]=h?195:194;else if(_==="bigint"){if(h<BigInt(1)<<BigInt(63)&&h>=-(BigInt(1)<<BigInt(63)))R[C++]=211,De.setBigInt64(C,h);else if(h<BigInt(1)<<BigInt(64)&&h>0)R[C++]=207,De.setBigUint64(C,h);else if(this.largeBigIntToFloat)R[C++]=203,De.setFloat64(C,Number(h));else throw new RangeError(h+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");C+=8}else if(_==="undefined")this.encodeUndefinedAsNil?R[C++]=192:(R[C++]=212,R[C++]=0,R[C++]=0);else if(_==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},B=this.useRecords===!1?this.variableMapSize?h=>{let _=Object.keys(h),N=_.length;N<16?R[C++]=128|N:N<65536?(R[C++]=222,R[C++]=N>>8,R[C++]=N&255):(R[C++]=223,De.setUint32(C,N),C+=4);let I;for(let L=0;L<N;L++)b(I=_[L]),b(h[I])}:(h,_)=>{R[C++]=222;let N=C-r;C+=2;let I=0;for(let L in h)(_||h.hasOwnProperty(L))&&(b(L),b(h[L]),I++);R[N+++r]=I>>8,R[N+r]=I&255}:h=>{let _=Object.keys(h),N,I=s.transitions||(s.transitions=Object.create(null)),L=0;for(let k=0,W=_.length;k<W;k++){let oe=_[k];N=I[oe],N||(N=I[oe]=Object.create(null),L++),I=N}let P=I[On];if(P)P>=96&&g?(R[C++]=((P-=96)&31)+96,R[C++]=P>>5):R[C++]=P;else{P=s.nextId,P||(P=64),P<x&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(P=s.nextOwnId,P<y||(P=x),s.nextOwnId=P+1):(P>=y&&(P=x),s.nextId=P+1);let k=_.highByte=P>=96&&g?P-96>>5:-1;I[On]=P,s[P-64]=_,P<x?(_.isShared=!0,s.sharedLength=P-63,n=!0,k>=0?(R[C++]=(P&31)+96,R[C++]=k):R[C++]=P):(k>=0?(R[C++]=213,R[C++]=114,R[C++]=(P&31)+96,R[C++]=k):(R[C++]=212,R[C++]=114,R[C++]=P),L&&(A+=S*L),v.length>=f&&(v.shift()[On]=0),v.push(I),b(_))}for(let k=0,W=_.length;k<W;k++)b(h[_[k]])},w=h=>{let _;if(h>16777216){if(h-r>Up)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(Up,Math.round(Math.max((h-r)*(h>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(h-r<<2,R.length-1)>>12)+1<<12;let N=new Va(_);return De=new DataView(N.buffer,0,_),R.copy?R.copy(N,0,r,h):N.set(R.slice(r,h)),C-=r,r=0,$t=N.length-10,R=N}}useBuffer(t){R=t,De=new DataView(R.buffer,R.byteOffset,R.byteLength),C=0}};za=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Mn];gs=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:s}=t(6);o[s++]=214,o[s++]=255,n.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:s}=t(10);o[s++]=215,o[s++]=255,n.setUint32(s,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:s}=t(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:n,position:s}=t(15);o[s++]=199,o[s++]=12,o[s++]=255,n.setUint32(s,i.getMilliseconds()*1e6),n.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?jp(i,16,t):kp(ys?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==Hp&&this.structuredClone?jp(i,Ra.indexOf(e.name),t):kp(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function jp(i,t,e,r){let o=i.byteLength;if(o+1<256){var{target:n,position:s}=e(4+o);n[s++]=199,n[s++]=o+1}else if(o+1<65536){var{target:n,position:s}=e(5+o);n[s++]=200,n[s++]=o+1>>8,n[s++]=o+1&255}else{var{target:n,position:s,targetView:a}=e(7+o);n[s++]=201,a.setUint32(s,o+1),s+=4}n[s++]=116,n[s++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),s)}function kp(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function Av(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function Pv(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,s)=>n.offset>s.offset?1:-1);e=t.pop();){let n=e.offset,s=e.id;i.copyWithin(n+r,n,o),r-=6;let a=n+r;i[a++]=214,i[a++]=105,i[a++]=s>>24,i[a++]=s>>16&255,i[a++]=s>>8&255,i[a++]=s&255,o=n}return i}function Zr(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");za.unshift(i.Class),gs.unshift(i)}Fp(i)}var Wp=new Jr({useRecords:!1}),Mv=Wp.pack,Ov=Wp.pack;var{NEVER:_v,ALWAYS:Dv,DECIMAL_ROUND:Bv,DECIMAL_FIT:Ev}=fs,qp=512,Gv=1024;var $p=new Jr({structuredClone:!0});Zr({Class:ze.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,ze.prototype),i}});Zr({Class:Pe.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Pe.prototype),i}});Zr({Class:Tt.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Tt.prototype),i}});Zr({Class:An.prototype.constructor,type:4,write(i){return i.id},read(i){return new An(i)}});Zr({Class:Pn.prototype.constructor,type:5,write(i){return i.data},read(i){return new Pn(i)}});function Rv(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Fa(i){if(rs(i))return i;if(Array.isArray(i))return i.map(Fa);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Fa(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var xs;(r=>{function i(o){return $p.pack(o)}r.serialize=i;function t(o){return $p.unpack(o)}r.deserialize=t;function e(o){return Rv(i(Fa(o))).toString()}r.checksum=e})(xs||(xs={}));var vs;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(vs||(vs={}));var bs;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:vt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(r==="SpotLight")return{type:r,color:vt.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:vt.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(bs||(bs={}));var Ua;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(Ua||(Ua={}));var ja;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(ja||(ja={}));var Ss;(t=>t.defaultData={...ja.defaultData,...Ua.defaultData,cloner:null,booleanExclude:null})(Ss||(Ss={}));var ka=(o=>(o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify",o))(ka||{}),Ha=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Ha||{}),Wa=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Wa||{}),ws;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:vt.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(ws||(ws={}));var Er;(r=>{function i(o,n){return o==="light"&&n?t(n):e(o)}r.defaultData=i;function t(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function e(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:xt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...xt.fromHex(6710886),a:1},colorB:{...xt.fromHex(6710886),a:1},colorC:{...xt.fromHex(16777215),a:1},colorD:{...xt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:vt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:vt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:vt.fromHexAndA(0,1),contourColor:vt.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Er||(Er={}));var gr;(a=>{function i(l){return!l.layers.some(u=>{if(u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")return!0})&&!e(l)}a.isMergable=i;function t(l){let c="";return l.layers.forEach(u=>{Object.entries(u.data).forEach(([m,p])=>{c+=`${m}${p}`,Array.isArray(p)?p.forEach(d=>c+=`${d}`):typeof p=="object"?Object.values(p).forEach(d=>{typeof d=="number"?c+=`${d.toFixed(4)}`:c+=`${d}`}):c+=`${p}`})}),c}a.getHash=t;function e(l){let c=0;for(let u of l.layers)"alpha"in u.data&&u.data.type!=="light"&&u.data.type!=="fresnel"&&(c+=(1-c)*u.data.alpha);return c<1}a.isTransparent=e;function r(){return{layers:new Pe}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return n("phong",l,c)}a.defaultData=o;function n(l,c="layer1",u="layer2"){let m=new Pe;return m.push({fi:0,data:Er.defaultData("light",l),id:c}),m.push({fi:1,data:Er.defaultData("color"),id:u}),{layers:m}}a.defaultTwoLayerData=n;function s(l,c="basic",u="layer1",m="layer2"){let p=Er.defaultData("texture");Object.assign(p.texture,{image:l});let d=new Pe;return d.push({fi:0,data:p,id:u}),d.push({fi:1,data:Er.defaultData("light",c),id:m}),{layers:d}}a.defaultTwoLayerTextureData=s})(gr||(gr={}));var Fo;(t=>{function i(){return{points:new Pe,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Fo||(Fo={}));var Ts;(t=>{function i(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=i})(Ts||(Ts={}));var _n;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Fo.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}t.defaultData=i})(_n||(_n={}));var Dn;(o=>{o.identity={...Zi.identity,hiddenMatrix:_r.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,s){return{position:s?.position||n.position,rotation:s?.rotation||n.rotation,scale:s?.scale||n.scale,hiddenMatrix:s?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,s){return{position:Eo.isEqual(n.position,s.position)?null:s.position,rotation:Eo.isEqual(n.rotation,s.rotation)?null:s.rotation,scale:Eo.isEqual(n.scale,s.scale)?null:s.scale,hiddenMatrix:_r.isEqual(n.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=r})(Dn||(Dn={}));var yr;(t=>t.defaultData={states:new Pe,events:new Pe,visible:!0,raycastLock:!1,...Dn.identity})(yr||(yr={}));var Xp;(t=>t.defaultData={type:"Empty",...yr.defaultData})(Xp||(Xp={}));var Ns;(t=>t.defaultData={type:"Mesh",...yr.defaultData,...Ss.defaultData})(Ns||(Ns={}));var Yp;(t=>t.defaultData={type:"TextFrame",...yr.defaultData,...ws.defaultData})(Yp||(Yp={}));var Cs;(t=>t.defaultData={...yr.defaultData,...Dn.identity,...Kr.defaultData})(Cs||(Cs={}));var Kp;(t=>{function i(e){return{...yr.defaultData,...bs.defaultData(e)}}t.defaultData=i})(Kp||(Kp={}));var Qp;(r=>(r.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:_r.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Pe,events:new Pe,...Kr.defaultData},r.defaultMeshObject={name:"Rectangle",...yr.defaultData,...Ns.defaultData,geometry:_n.defaultData("RectangleGeometry"),material:gr.defaultTwoLayerData("basic","layer1","layer2")},r.defaultBooleanObject={name:"Boolean",...yr.defaultData,...Ns.defaultData,geometry:_n.defaultData("BooleanGeometry"),material:gr.defaultTwoLayerData("phong","layer1","layer2")}))(Qp||(Qp={}));var Jp;(e=>{function i(r,o){if(o===void 0)return r;let n={...r};return"material"in n&&"material"in o&&o.material&&(n.material=Ia(n.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=s.layers.data(a);c&&Yr(c,l)}}).data),n.materials&&o.materials&&(n.materials=Ia(n.materials,s=>{for(let a=0;a<n.materials.length;a++){let l=o.materials[a];if(typeof l!="string")for(let[c,u]of Object.entries(l.layers)){let m=s[a]?.layers?.data(c);m&&Yr(m,u)}}}).data),n}e.patchMaterialState=i;function t(r,o){if(o===void 0)return r;let n={...r};if(Object.assign(n,Dn.merge(n,o)),Bo.is(r.type)){n.orthographic={...n.orthographic},n.perspective={...n.perspective};let s=o;s.orthographic?.zoom!==void 0&&(n.orthographic.zoom=s.orthographic.zoom),s.perspective?.zoom!==void 0&&(n.perspective.zoom=s.perspective.zoom),s.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=s.isUpVectorFlipped),s.targetOffset!==void 0&&(n.targetOffset=s.targetOffset)}else if(r.type==="Mesh")n.geometry={...n.geometry},Object.assign(n.geometry,o.geometry),n=i(n,o);else if(vs.is(r.type)){let s=o;s.intensity!==void 0&&(n.intensity=s.intensity),s.color!==void 0&&(typeof s.color=="string"?n.color=s.color:n.color=xt.clone(s.color))}return n}e.patch=t})(Jp||(Jp={}));var Ls;(s=>{let i=["/_assets/_textures/texture_checkboard_default.png","/_assets/_textures/texture_dots_01.png","/_assets/_textures/texture_wood_01.jpg","/_assets/_textures/texture_wood_02.jpg","/_assets/_textures/texture_rock_01.jpg","/_assets/_textures/texture_rock_02.jpg","/_assets/_textures/texture_grass_01.jpg","/_assets/_textures/texture_grass_02.jpg","/_assets/_textures/texture_concrete_01.jpg","/_assets/_textures/texture_concrete_02.jpg","/_assets/_textures/texture_paper_01.jpg","/_assets/_textures/texture_roof_01.jpg","/_assets/_textures/texture_wall_02.jpg","/_assets/_textures/texture_planet_earth_color.jpg","/_assets/_textures/texture_planet_earth_clouds.jpg","/_assets/_textures/texture_planet_mars.jpg","/_assets/_textures/texture_space.jpg"],t=["/_assets/_textures/matcap_5_18.png","/_assets/_textures/matcap_5_1.png","/_assets/_textures/matcap_4_3.png","/_assets/_textures/matcap_2_7.png","/_assets/_textures/matcap_2_4.png","/_assets/_textures/matcap_1_11.png"];function e(){let a={},l=0;for(let c of i)a[`image_${l}`]={data:c,name:`Image ${l}`,asset:!1},l++;l=0;for(let c of t)a[`matcap_${l}`]={data:c,name:`Matcap ${l}`,asset:!1},l++;return a}s.defaultImages=e;function r(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},a}s.defaultColors=r;function o(){return{materials:new ze,images:new ze,colors:new ze,penumbraSize:[.5,.5,.5]}}s.emptyData=o;function n(){return{materials:new ze,images:ya(e(),ze.prototype),colors:ya(r(),ze.prototype),penumbraSize:new Array(5).fill(.5)}}s.defaultData=n})(Ls||(Ls={}));var Is;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",asset:!1})(Is||(Is={}));import{Color as Vv}from"three";var Qe=class extends Vv{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};import{ConeBufferGeometry as Uv}from"three";import{BufferGeometry as zv,CylinderBufferGeometry as Fv,Float32BufferAttribute as qa,Vector2 as Ot,Vector3 as As}from"three";var em=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=e.width/2,o=e.radiusTop??r,n=e.radiusBottom??r;return o===n?(o=r,n=r):o>n?(o=r,n=n*r/o):(o=o*r/n,n=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:n})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:m,cornerSegments:p,hollow:d}=i.parameters,f;return m||d?f=new Bn(c,u,r,o,n,s,a,l*Math.PI/180,m,m,p,d):f=new Fv(c,u,r,o,n,s,a,l*Math.PI/180),f.scale(1,1,e/t),Object.assign(f,{userData:{...i,type:"CylinderGeometry"}})}};function Gr(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Zp(i){return new Ot(i.y,-i.x)}var Bn=class extends zv{constructor(t,e,r,o,n,s,a,l,c,u,m,p,d=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,u=0);let f=[],g=[],x=[],y=[],v=0,A=r/2,S=new As,b=new As;d&&t==0&&(t=c),d&&e==0&&(e=u);let B=new Ot(t,A),w=new Ot(e,-A),h=null,_=null,N=null,I=null,L=B.clone().sub(w),P=0,k=0,W=0;p>0&&(P=Math.min(t,e)*(1-p),k=t-P,W=e-P);let oe=B.clone();oe.x-=P;let ce=Math.PI-L.angle(),ie=L.angle(),K=Math.tan(ie/2),U=Math.tan(ce/2),V=K+U,E=p?V:U,D=p?V:K;if(c=Math.min(c,(t-k)/E,L.length()/V),u=Math.min(u,(e-W)/D,L.length()/V),c>0){let F=c/K;h=B.clone().sub(new Ot(F,c)),p&&(N=h.clone(),N.x-=P-V*c),B.sub(L.clone().setLength(F))}if(u>0){let F=u/U;_=w.clone().sub(new Ot(F,-u)),w.add(L.clone().setLength(F)),p&&(I=_.clone(),I.x-=P-V*u,oe.sub(L.clone().setLength(F)))}L=B.clone().sub(w);let M=L.length()<.5,G=[];for(let F=0;F<=o;F++){let O=[],q=F/o,Z=q*l+a,ee=new Ot(Math.sin(Z),Math.cos(Z));I&&_?(Q(O,q,ee,ce,u,I,-1,!0),Q(O,q,ee,ie,u,_,-1,!1)):_?(j(O,ee,_.x,0,-1),Q(O,q,ee,ie,u,_,-1,!1)):s||j(O,ee,e,W,-1);let H=Zp(L).normalize();if(Gr(H,ee,S),!M)for(let J=0;J<=n;J++){let $=J/n,re=L.clone().multiplyScalar($).add(w);Gr(re,ee,b),g.push(b.x,b.y,b.z),x.push(S.x,S.y,S.z),y.push(q,.5+b.y/r),O.push(v++)}if(N&&h?(Q(O,q,ee,ce,c,h,1,!1),Q(O,q,ee,ie,c,N,1,!0)):h?(Q(O,q,ee,ce,c,h,1,!1),j(O,ee,h.x,0,1)):s||j(O,ee,t,k,1),p&&!M){let J=Zp(L).multiplyScalar(-1).normalize();Gr(J,ee,S);for(let $=0;$<=n;$++){let re=$/n,le=L.clone().multiplyScalar(-re).add(oe);Gr(le,ee,b),g.push(b.x,b.y,b.z),x.push(S.x,S.y,S.z),y.push(q,.5+b.y/r),O.push(v++)}}p&&!s&&O.push(O[0]),G.push(O)}for(let F=0;F<G.length-1;F++)for(let O=0;O<G[0].length-1;O++){if(s&&p&&O==n)continue;let q=G[F][O],Z=G[F+1][O],ee=G[F+1][O+1],H=G[F][O+1],J=g[ee*3+0],$=g[ee*3+2];f.push(q,Z,H),(J!=0||$!=0)&&f.push(Z,ee,H)}l<Math.PI*2&&(z(-1,G[0],a),z(1,G[G.length-1],a+l)),this.setIndex(f),this.setAttribute("position",new qa(g,3)),this.setAttribute("normal",new qa(x,3)),this.setAttribute("uv",new qa(y,2));function Q(F,O,q,Z,ee,H,J,$){for(let re=0;re<m+1;re++){let le=re/m,ne=J<0?le:1-le;$&&(ne-=1),ne*=Z;let de=new Ot(Math.sin(ne),Math.cos(ne)*J),Me=de.clone().multiplyScalar(ee).add(H);Gr(Me,q,b),g.push(b.x,b.y,b.z),Gr(de,q,S),x.push(S.x,S.y,S.z),y.push(O,.5+b.y/r),F.push(v++)}}function j(F,O,q,Z,ee){let H=new As,J=new Ot,$=[q,Z];ee<0&&$.reverse();for(let re of $)J.set(re,A*ee),Gr(J,O,H),g.push(H.x,H.y,H.z),x.push(0,ee,0),y.push(.5,.5),F.push(v++)}function z(F,O,q){let Z=new Ot(Math.sin(q),Math.cos(q)),ee=new Ot(-Math.cos(q),Math.sin(q)),H=new As,J=F<0?(le,ne,de)=>f.push(le,ne,de):(le,ne,de)=>f.push(le,de,ne),$=new Ot((t+e+k+W)/4,0);Gr($,Z,H),g.push(H.x,H.y,H.z),x.push(ee.x,0,ee.y),y.push(.5,.5);let re=v++;for(let le of O){let ne=g.slice(le*3,le*3+3);g.push(...ne),x.push(ee.x,0,ee.y);let de=y.slice(le*2,le*2+2);y.push(...de),v++}for(let le=re+1;le<v-1;le++)J(re,le,le+1);J(re,v-1,re+1)}}};var tm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:m}=i.parameters,p;return c>0||u>0||l<360?p=new Bn(0,t/2,r,o,n,s,a,l*Math.PI/180,c,u,m,0,!0):p=new Uv(t/2,r,o,n,s),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};import{BoxBufferGeometry as jv,BufferGeometry as kv,Float32BufferAttribute as $a,Vector3 as En}from"three";var rm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:s,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new jv(t,e,r,o,n,s):c=new Ya(t,e,r,o,n,s,a,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},Xa=Math.PI/2,Ya=class extends kv{constructor(t=1,e=1,r=1,o=1,n=1,s=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let u=[],m=[],p=[],d=[],f=0,g=0;x("z","y","x",-1,-1,r,e,t,s,n,0),x("z","y","x",1,-1,r,e,-t,s,n,1),x("x","z","y",1,1,t,r,e,o,s,2),x("x","z","y",1,-1,t,r,-e,o,s,3),x("x","y","z",1,-1,t,e,r,o,n,4),x("x","y","z",-1,-1,t,e,-r,o,n,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,s,0),y("z","y","x",1,-1,-1,r,e,t,s,1),y("z","y","x",-1,1,-1,r,e,t,s,1),y("z","y","x",1,1,1,r,e,t,s,0),y("x","y","z",-1,-1,-1,t,e,r,o,0),y("x","y","z",1,-1,1,t,e,r,o,1),y("x","y","z",-1,1,1,t,e,r,o,0),y("x","y","z",1,1,-1,t,e,r,o,1),y("y","x","z",-1,-1,1,e,t,r,n,0),y("y","x","z",1,-1,-1,e,t,r,n,1),y("y","x","z",1,1,1,e,t,r,n,1),y("y","x","z",-1,1,-1,e,t,r,n,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new $a(m,3)),this.setAttribute("normal",new $a(p,3)),this.setAttribute("uv",new $a(d,2));function x(A,S,b,B,w,h,_,N,I,L,P){let k=(h-2*a)/I,W=(_-2*a)/L,oe=h/2-a,ce=_/2-a,ie=N/2,K=I+1,U=L+1,V=0,E=0,D=new En;for(let M=0;M<U;M++){let G=M*W-ce;for(let Q=0;Q<K;Q++){let j=Q*k-oe;D[A]=j*B,D[S]=G*w,D[b]=ie,m.push(D.x,D.y,D.z),D[A]=0,D[S]=0,D[b]=N>0?1:-1,p.push(D.x,D.y,D.z),d.push(Q/I),d.push(1-M/L),V+=1}}for(let M=0;M<L;M++)for(let G=0;G<I;G++){let Q=f+G+K*M,j=f+G+K*(M+1),z=f+(G+1)+K*(M+1),F=f+(G+1)+K*M;u.push(Q,j,F),u.push(j,z,F),E+=6}c.addGroup(g,E,P),g+=E,f+=V}function y(A,S,b,B,w,h,_,N,I,L,P){let k=(_-2*a)/L,W=_/2-a,oe=N/2-a,ce=I/2,ie=L+1,K=0,U=0,V=new En,E=new En;for(let D=0;D<l+1;D++){let M=D/l*Xa,G=Math.sin(M)*a,Q=(1-Math.cos(M))*a,j=Math.sin(M),z=Math.cos(M);V[S]=(oe+G)*w,V[b]=(ce-Q)*h,E[A]=0,E[S]=j*Math.sign(V[S]),E[b]=z*Math.sign(V[b]);for(let F=0;F<ie;F++){let O=F*k-W;V[A]=O*B,m.push(V.x,V.y,V.z),p.push(E.x,E.y,E.z),d.push(F/L),d.push(0),K+=1}}for(let D=0;D<l;D++)for(let M=0;M<L;M++){let G=f+M+ie*D,Q=f+M+ie*(D+1),j=f+(M+1)+ie*(D+1),z=f+(M+1)+ie*D;u.push(G,Q,z),u.push(Q,j,z),U+=6}c.addGroup(g,U,P),g+=U,f+=K}function v(A,S,b){let B=new En,w=new En(t/2,e/2,r/2);w.subScalar(a);let h=[],_=A*S*b>0?(I,L,P)=>u.push(I,L,P):(I,L,P)=>u.push(I,P,L);for(let I=0;I<=l;I++){let L=[],P=Xa*(1-I/l),k=Math.cos(P),W=Math.sin(P),oe=0;for(let ce=0;ce<=I;ce++){let ie=Math.cos(oe),K=Math.sin(oe);B.x=k*ie,B.y=W,B.z=k*K;let U=w.clone().addScaledVector(B,a);m.push(A*U.x,S*U.y,b*U.z),p.push(A*B.x,S*B.y,b*B.z),d.push(0,0),L.push(f++),oe+=Xa/I}h.push(L)}let N=h.length-1;for(let I=0;I<N;I++){let L=h[I],P=h[I+1],k=L.length-1;_(L[0],P[1],P[0]);for(let W=1;W<=k;W++)_(L[W-1],L[W],P[W]),_(L[W],P[W+1],P[W])}}}};import{BufferGeometry as Hv,Float32BufferAttribute as Ka,Triangle as Wv,Vector3 as vr,Vector2 as Qa}from"three";var Rr=class extends Hv{constructor(t=[],e=[],r="",o=1,n=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),m(),this.setAttribute("position",new Ka(a,3)),this.setAttribute("normal",new Ka(c,3)),this.setAttribute("uv",new Ka(l,2));return;function u(){n=Math.min(1-1e-5,n),n==0&&(s=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],f=new vr,g=f.clone(),x=new Wv,y=n*o,v=o-y,A=s+1,S=new vr,b=(K,U)=>S.subVectors(K,U).normalize(),B=(K,U)=>Array(K).fill(void 0).map(U),w=B(t.length/3,(K,U)=>new vr().fromArray(t,U*3).setLength(o)),h=[],_=1e6;for(let K=0;K<w.length;K++){let U=w[K],V=[],E,D,M,G=1e10,Q=-1;for(;(Q=e.indexOf(K,Q+1))!=-1;){let O=Q-Q%3;E=e[O+(Q+1)%3],D=e[O+(Q+2)%3],M=U.distanceToSquared(w[E]),G=Math.min(G,M),V.push([E,D,M])}G+=1e-6;let j=[],z=0,F=V.length;for(let O=0;O<F;O++){[E,D,M]=V[z];let q=h[E]?.includes(K)==!0;M<=G&&j.push(E+ +q*_),z=V.findIndex(Z=>Z[0]==D)}h.push(j)}let N=[];{let K=0,U=0,V,E,D=d==3;for(let M=0;M<=s;M++){V=M*(M+1)/2,E=(M+1)*(M+2)/2;for(let G=0;G<s-M;G++)[K,U]=[V+G+M+2,E+G+M+3],N.push(V,E,...D?[U,V]:[K,E],U,K),[V,E]=[K,U];N.push(V,E,V+s+2)}}let I=f.clone(),L=f.clone(),P=f.clone(),k=f.clone(),W=f.clone(),oe=[],ce=B(w.length,()=>B(d,()=>f.clone()));for(let K=0;K<w.length;K++){f.copy(w[K]).normalize(),I.copy(f).multiplyScalar(v);let U=h[K];for(let j=0;j<U.length;j++){let z=U[j],F=U[(j+1)%d];x.setFromPointsAndIndices(w,K,z%_,F%_),x.b.sub(x.a).setLength(1e10).add(x.a),x.c.sub(x.a).setLength(1e10).add(x.a),x.closestPointToPoint(I,ce[K][j])}let V=[],E=[],D=[],M=new vr;s==0&&[...ce[K]].reduce((j,z)=>j.add(z),M).multiplyScalar(1/d);for(let j=0;j<d;j++){let z=[],F=(j-1+d)%d,O=ce[K][F],q=ce[K][j];f.copy(O).sub(I),g.copy(q).sub(I);let Z=I.angleTo(f),ee=f.angleTo(g),H=Math.cos(Z)*y;s==0?L.copy(M):L.copy(I).setLength(v+H),E.push(H);let J=[L,O,q];for(let $=0;$<2;$++){let re=J[$],le=J[$+1];k.subVectors(re,I),W.subVectors(le,I),P.crossVectors(k,W).normalize();for(let ne=0;ne<A;ne++){let de=[Z,ee][$]*ne/A;f.copy(k).applyAxisAngle(P,de).add(I),V.push(f.clone()),$&&(b(f,I),z.push([ne==0?re:f.clone(),S.clone()]))}$&&(b(le,I),z.push([le,S.clone()]))}D.push(z)}oe.push(D);let G=2*A,Q=2;for(let j=0;j<d;j++){let z=G*j,F=G*((j+1)%d),O=[V[z]];for(let Z=1;Z<A;Z++){k=V[z+Z],W=V[F+Z],O.push(k);for(let ee=1,H=Z-Q+1;ee<=H;ee++)f.lerpVectors(k,W,ee/(H+1)),f.sub(I).setLength(E[j]).add(I),O.push(f.clone());O.push(W)}for(let Z=0;Z<A;Z++)O.push(V[Z+A+z]);O.push(V[F+A]);let q=N.map(Z=>O[Z]);a.push(...q.map(Z=>[Z.x,Z.y,Z.z]).flat()),c.push(...q.map(Z=>(b(Z,I),[S.x,S.y,S.z])).flat())}}let ie=[];for(let K=0;K<h.length;K++)for(let U=0;U<d;U++){let V=h[K][U];if(V<_){let E=h[V].findIndex(G=>G%_==K),D=oe[K][U],M=oe[V][E];for(let G=0;G<A;G++){let Q=D[G],j=M[A-G],z=D[G+1],F=M[A-(G+1)];[Q,j,z,z,j,F].forEach(O=>{a.push(O[0].x,O[0].y,O[0].z),c.push(O[1].x,O[1].y,O[1].z)})}ie.push(D[0][0],M[A][0],D[A][0],M[0][0])}}for(;ie.length;){let K,U,V,E;[K,U]=ie.splice(0,2);let D=[K];for(;K!=U;)D.push(U),V=ie.indexOf(U),E=V%2,U=ie.splice(V-E,2)[1-E];S.subVectors(D[0],D[1]).cross(f.subVectors(D[0],D[2])).normalize();let M=S.dot(D[0])<0;M&&S.negate();for(let G=1;G<=D.length-2;G++)[D[G+ +M],D[G+1-+M],D[0]].forEach(Q=>{a.push(Q.x,Q.y,Q.z),c.push(S.x,S.y,S.z)})}}function m(){let p=new vr;for(let w=0;w<a.length;w+=3){p.x=a[w+0],p.y=a[w+1],p.z=a[w+2];let h=b(p)/2/Math.PI+.5,_=B(p)/Math.PI+.5;l.push(h,1-_)}let d=new vr,f=new vr,g=new vr,x=new vr,y=new Qa,v=new Qa,A=new Qa,S=(w,h,_,N)=>{N<0&&w.x===1&&(l[h]=w.x-1),_.x===0&&_.z===0&&(l[h]=N/2/Math.PI+.5)};for(let w=0,h=0;w<a.length;w+=9,h+=6){d.set(a[w+0],a[w+1],a[w+2]),f.set(a[w+3],a[w+4],a[w+5]),g.set(a[w+6],a[w+7],a[w+8]),y.set(l[h+0],l[h+1]),v.set(l[h+2],l[h+3]),A.set(l[h+4],l[h+5]),x.copy(d).add(f).add(g).divideScalar(3);let _=b(x);S(y,h+0,d,_),S(v,h+2,f,_),S(A,h+4,g,_)}for(let w=0;w<l.length;w+=6){let h=l[w+0],_=l[w+2],N=l[w+4],I=Math.max(h,_,N),L=Math.min(h,_,N);I>.9&&L<.1&&(h<.2&&(l[w+0]+=1),_<.2&&(l[w+2]+=1),N<.2&&(l[w+4]+=1))}function b(w){return Math.atan2(w.z,-w.x)}function B(w){return Math.atan2(-w.y,Math.sqrt(w.x*w.x+w.z*w.z))}}}static fromJSON(t){return new Rr(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as qv}from"three";var om=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new Gn(t*.5,n,s):new qv(t*.5,o);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Gn=class extends Rr{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(s,a,l,t,e,r),this.type=l}static fromJSON(t){return new Gn(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as ob,Plane as nb,Shape as xm,Vector2 as br,Vector3 as ib,MathUtils as nl,LineCurve as il,QuadraticBezierCurve as vm,CubicBezierCurve as _s}from"three";import{CubicBezierCurve as Ps,EllipseCurve as $v,LineCurve as Ms,LineCurve3 as Xv,MathUtils as Yv,QuadraticBezierCurve as Za,SplineCurve as Kv,Vector2 as tt,Vector3 as sm}from"three";var Rn=1e-12,Uo=class{constructor(t){this.position=new tt;this.startPosition=new tt;this.uuid=Yv.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Uo(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},jo=class extends Uo{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new jo(this.parent).copy(this)}},_t=class extends Uo{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new jo(this),new jo(this))}static create(e,r){let o=new _t(e,new tt(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let s=this.controls[o];this.position.distanceTo(s.position)<=r?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new _t(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new tt,r=new tt){let[o,n]=this.computeTangents();return o&&n&&(nm(o,e),nm(n,r)),[e,r]}computeTangent(e=new tt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new tt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function nm(i,t=new tt){let e=i.length();return t.set(-i.y/e,i.x/e)}var el=i=>i,ko=new tt,Os=new tt,Qv=new tt,Jv=new tt,Zv=new tt,eb=new tt,am=new sm,lm=new sm;function cm(i){let t=new tt;t.addVectors(i.v0,ko.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new tt;return e.addVectors(i.v2,Os.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ps(i.v0,t,e,i.v2)}function Vn(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function tb(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function rb(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function tl(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function um(i,t,e){return im(i,t)&&im(t,e)&&Ja(i.position,t.position,e.position)}function Ja(i,t,e){return ko.copy(t).sub(i).cross(Os.copy(e).sub(i))===0}function pm(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(a+l,s+c),o.set(a-l,s-c),[r,o]}function mm(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function dm(i,t,e,r,o,n){let s=t.x-i.x,a=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),m;return tl(t,i,e)>Math.PI&&(u*=-1),Vn(c,a)?m=(a+c)*(r/u-.5)*8/3/(s-l):m=(s+l)*(r/u-.5)*8/3/(c-a),o.set(t.x-m*a,t.y+m*s),n.set(e.x+m*c,e.y-m*l),[o,n]}function rl(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function im(i,t){return Ja(i.position,i.controls[1].position,t.position)&&Ja(i.position,t.controls[0].position,t.position)}function fm(i,t,e,r,o=.5){let n=ko.subVectors(t,i).multiplyScalar(o).add(i),s=Os.subVectors(e,t).multiplyScalar(o).add(t),a=Qv.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=Jv.subVectors(s,n).multiplyScalar(o).add(n),u=Zv.subVectors(a,s).multiplyScalar(o).add(s),m=a,p=eb.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,u.x,u.y,m.x,m.y,r.x,r.y]}function hm(i,t,e=12,r=!0){let o=lm.set(0,0,0),n,s=0,a=[];for(let l=0;l<t.length;l++){let c=el(t[l]),u=ko,m=Vr(c,e);a.push(m);for(let p=0;p<=m;p++)if(c instanceof Ps||c instanceof Za||c instanceof Ms){if(c.getPoint(p/m,u),o.set(u.x,u.y,0),n!==void 0&&rb(n,o))continue;n===void 0&&(n=am),n.copy(o),i.setXYZ(s,o.x,o.y,o.z),s++}}return r&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),i}function gm(i,t,e,r=12,o=!0){let n=lm.set(0,0,0),s=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=el(t[l]),m=ko,p=Vr(u,r);a.push(p);for(let d=0;d<=p;d++)if(u instanceof Ps||u instanceof Za||u instanceof Ms){if(u.getPoint(d/p,m),n.set(m.x,m.y,0),c?.equals(n))continue;c===void 0?c=am:(i.setXYZ(s,c.x,c.y,c.z),s++,i.setXYZ(s,n.x,n.y,n.z),s++),c.copy(n)}}return o&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),a}function ol(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let s=i[o],a=0;if(e&&s.roundedCurveCorner!==void 0){let l=Vr(s.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=Vr(s.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Vr(i[0].roundedCurveCorner,t)*.5),r}function Vr(i,t=12){return i&&i instanceof $v?t*2:i&&(i instanceof Ms||i instanceof Xv)?1:i&&i instanceof Kv?t*i.points.length:t}function ym(i,t,e=12,r=!0){let o,n=0;for(let s=0;s<t.length;s++){let a=el(t[s]),l=Vr(a,e),c=ko;for(let u=0;u<=l;u++)if(a instanceof Ps||a instanceof Za||a instanceof Ms){if(a.getPoint(u/l,c),o!==void 0&&tb(o,c,Rn))continue;o===void 0&&(o=Os),o.copy(c),i.push(c.x,c.y),n++}}return Vn(i[0],i[i.length-2],Rn)&&Vn(i[1],i[i.length-1],Rn)&&(i.pop(),i.pop()),r&&n>1&&!(Vn(i[n-1],i[1],Rn)&&Vn(i[n-2],i[0],Rn))&&(i.push(i[0],i[1]),n++),i}var sl=new br,sb=new br,ab=new br,lb=new br,cb=new br,ub=new br,Se=class extends xm{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new ob;this.plane=new nb(new ib(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=nl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Se;return n.isClosed=e.isClosed,n.points=e.points.map(s=>_t.create(s.id,s.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(s=>Se.createFromState(s)),r!==void 0&&o!==void 0&&n.applySize(r,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;for(let s=0,a=this.shapeHoles.length;s<a;s++){let l=this.shapeHoles[s],c=l.points.length-1,u=l.getPointIndexById(e);if(u<0)n+=c;else return u+n}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let r=0,o=this.shapeHoles.length;r<o;r++){let n=this.shapeHoles[r],s=e-this.points.length;if(s<=n.points.length-1)return n.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let s=this.shapeHoles[o],a=s.points.indexOf(e);if(a>=0)return r+a;r+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=sl.set(e,r);for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n];a.position.multiply(o),a.controls[0].position.multiply(o),a.controls[1].position.multiply(o)}for(let n=0,s=this.shapeHoles.length;n<s;n++)this.shapeHoles[n].applyScale(e,r);this._update(!1)}createPoint(e,r=0,o=nl.generateUUID()){let n;e instanceof br?n=e:n=new br(e,r);let s=new _t(o,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let s=this.shapeHoles[r].getPointByUuid(e);if(s)return s}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,o=this.shapeHoles.length;r<o;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return hm(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ol(this.points,e,!1),this.roundedCurveDivisions=ol(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return gm(e,this.curves,r,o,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),ym(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,s=0;r&&this.points[0].roundedCurveCorner!==void 0&&(s=Vr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let u=n[l];if(a<o+u)return[l,(a-o+1)/u];o+=u}return[0,1]}getCurveT(e,r,o){let n=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(rl(n,s)){let m=n.position.distanceTo(s.position);return n.position.distanceTo(sl.set(o.x,o.y))/m}let c=0;for(let m=0;m<e;m++)c+=a[m];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){rl(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(e=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];if(o===0)this.moveTo(s.position.x,s.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(s,a)}}let r=this.getLastPoint();if(r?.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(o,n)}if(this.points.length>2){let o=0;for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n],l=this.points[n-1]??this.points[this.points.length-1],c=this.points[n+1]??this.points[0],u=a.roundness,m=l&&c&&um(l,a,c);if(!a.controlsMoved()&&u>0&&!m){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let f=a.roundedCurveBefore,g=a.roundedCurveAfter,x=p.getLength(),y=d.getLength(),v=Math.min(u,x*.499),A=Math.min(u,y*.499),S=Math.min(v,A),b=1-S/x,B=S/y,w=p.getPointAt(b,sl),h=d.getPointAt(B,sb);this._subSplitCurve(p,f,b,w,void 0),this._subSplitCurve(d,g,B,void 0,h);let _;if(this.useCubicForRoundedCorners){let N=tl(w,a.position,h)/2,I=Math.tan(N)*w.distanceTo(a.position),[L,P]=pm(w,h,I,ab,lb),k=mm(L,P,a.position),[W,oe]=dm(k,w,h,I,cb,ub);_=new _s(w.clone(),W.clone(),oe.clone(),h.clone())}else _=new vm(w.clone(),a.position.clone(),h.clone());a.roundedCurveCorner=_,this.roundedCurves.splice(n+o,0,_),o++}}}e&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(e,r,o,n,s){if(e instanceof il)n!==void 0&&r.v2.copy(n),s!==void 0&&r.v1.copy(s);else{let a=e,l=r,c=a.getUtoTmapping(o,0),u=fm(a.v0,a.v1,a.v2,a.v3,c);return n!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),s!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Se(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let n=o*7,s=e.points[n+0],a=e.points[n+1],l=e.points[n+2],c=e.points[n+3],u=e.points[n+4],m=e.points[n+5],p=e.points[n+6],d=new _t(nl.generateUUID(),new br(s,a));d.controls[0].position.set(l,c),d.controls[1].position.set(u,m),d.roundness=p,this.points.push(d)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Se;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(n,s)=>{s instanceof _s&&s.v3.equals(n.position)&&n.controls[0].position.copy(s.v2)},o=n=>{let s=[],a,l;for(a=0,l=n.length;a<l;a++)n[a]instanceof vm&&(n[a]=cm(n[a]));for(a=0,l=n.length;a<l;a++){let m=n[a],p=a>0?n[a-1]:null,d;m instanceof _s?(d=this.createPoint(m.v0),d.controls[1].position.copy(m.v1)):m instanceof il&&(d=this.createPoint(m.v1)),d!==void 0&&(p!==null&&r(d,p),s.push(d))}let c=n[n.length-1],u=!1;return c instanceof _s?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),u=!0):c instanceof il&&c.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=o(e.curves),e instanceof xm&&(this.shapeHoles=e.holes.map(n=>{let s=new Se;return s.fromShape(n),s})),this.update(),this}};var ll=Math.PI*2;function al({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function pb(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),s=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+s*e,y:s-n*e},{x:n,y:s}]}function bm(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function mb(i,t,e,r,o,n,s,a,l,c){let u=Math.pow(o,2),m=Math.pow(n,2),p=Math.pow(s,2),d=Math.pow(a,2),f=u*m-u*d-m*p;f<0&&(f=0),f/=u*d+m*p,f=Math.sqrt(f)*(l===c?-1:1);let g=f*o/n*a,x=f*-n/o*s,y=g+(i+e)/2,v=x+(t+r)/2,A=(s-g)/o,S=(a-x)/n,b=(-s-g)/o,B=(-a-x)/n,w=bm(1,0,A,S),h=bm(A,S,b,B);return!c&&h>0&&(h-=ll),c&&h<0&&(h+=ll),{centerx:y,centery:v,ang1:w,ang2:h}}function Sm({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:s,sweepFlag:a}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let m=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);m>1&&(o*=Math.sqrt(m),n*=Math.sqrt(m));let p=mb(i,t,e,r,o,n,c,u,s,a),{ang1:d,ang2:f}=p,{centerx:g,centery:x}=p,y=Math.abs(f)/(ll/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);f/=v;for(let A=0;A<v;A++)l.push(pb(d,f)),d+=f;return l.map(A=>{let{x:S,y:b}=al(A[0],o,n,g,x),{x:B,y:w}=al(A[1],o,n,g,x),{x:h,y:_}=al(A[2],o,n,g,x);return{x1:S,y1:b,x2:B,y2:w,x:h,y:_}})}import{BufferAttribute as Bs,BufferGeometry as yb}from"three";var Ae;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ae||(Ae={}));var Fe;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Fe||(Fe={}));function ue(i,t){if(!i)throw t||"Assertion Failed!"}var se=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){ue(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){ue(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){ue(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){ue(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var s,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(s=i.edgeEval(t,r,e),a=i.edgeEval(r,e,o),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,e.s)):(s=i.edgeSign(t,r,e),a=-i.edgeSign(t,o,e),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(s=i.transEval(t,r,e),a=i.transEval(r,e,o),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,e.t)):(s=i.transSign(t,r,e),a=-i.transSign(t,o,e),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,o.t)):n.t=(r.t+e.t)/2},i}(),zn=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Ds=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Ho=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),wm=function(){function i(){var t=new Ho,e=new zn,r=new Ds(0),o=new Ds(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Ds(0),r=new Ds(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;ue(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;ue(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var s=e;do s.Lface=o,s=s.Lnext;while(s!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,s=t.next;s.prev=n,n.next=s},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,s=t.next;s.prev=n,n.next=s},i.prototype.makeEdge=function(){var t=new Ho,e=new Ho,r=new zn,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Ho;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var s=new zn;this.makeFace_(s,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new zn;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Ho;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var s=new zn;this.makeFace_(s,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,s,a;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);s=t.prev,a=t.next,a.prev=s,s.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,s,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,s=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),a+l-2<=t&&se.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&se.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===s);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,s,a,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){ue(o.prev===n),l=o.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ue(o.prev===n&&o.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){ue(s.prev===a),l=s.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ue(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ue(l.Sym.next===c.Sym),ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Org!==null),ue(l.Dst!==null),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l);ue(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Tm=function(){function i(){this.handle=null}return i}(),Nm=function(){function i(){this.key=null,this.node=0}return i}(),db=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Tm,this.handles[r]=new Nm;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,s;for(o=e[t].handle;;){if(s=t<<1,s<this.size&&this.leq(r[e[s+1].handle].key,r[e[s].handle].key)&&++s,ue(s<=this.max),n=e[s].handle,s>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=s}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,s;for(o=e[t].handle;;){if(s=t>>1,n=e[s].handle,s===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=s}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Tm;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new Nm}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;ue(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),cl=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Cm=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),fb=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Cm,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new Cm;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),hb=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,s=r.eUp;if(n.Dst===o)return s.Dst===o?se.vertLeq(n.Org,s.Org)?se.edgeSign(s.Dst,n.Org,s.Org)<=0:se.edgeSign(n.Dst,s.Org,n.Org)>=0:se.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return se.edgeSign(n.Dst,o,n.Org)>=0;var a=se.edgeEval(n.Dst,o,n.Org),l=se.edgeEval(s.Dst,o,s.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&ue(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){ue(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new cl;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case Ae.ODD:return(e&1)!==0;case Ae.NONZERO:return e!==0;case Ae.POSITIVE:return e>0;case Ae.NEGATIVE:return e<0;case Ae.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,s=e,a=e.eUp;s!==r;){if(s.fixUpperEdge=!1,n=i.regionBelow(s),o=n.eUp,o.Org!=a.Org){if(!n.fixUpperEdge){i.finishRegion(t,s);break}o=t.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}a.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(a,o)),i.finishRegion(t,s),a=n.eUp,s=n}return a},i.addRightEdges=function(t,e,r,o,n,s){var a,l,c,u,m=!0;c=r;do ue(se.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,u=n;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!m&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),m=!1,l=a,u=c;l.dirty=!0,ue(l.windingNumber-c.winding===a.windingNumber),s&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=se.vertL1dist(e,t),n=se.vertL1dist(r,t),s=.5*n/(o+n),a=.5*o/(o+n);t.coords[0]+=s*e.coords[0]+a*r.coords[0],t.coords[1]+=s*e.coords[1]+a*r.coords[1],t.coords[2]+=s*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,s)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp;if(se.vertLeq(o.Org,n.Org)){if(se.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;se.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(se.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,s;if(ue(!se.vertEq(o.Dst,n.Dst)),se.vertLeq(o.Dst,n.Dst)){if(se.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,s=t.mesh.splitEdge(o),t.mesh.splice(n.Sym,s),s.Lface.inside=e.inside}else{if(se.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=r.dirty=!0,s=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),s.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,s=o.Org,a=n.Org,l=o.Dst,c=n.Dst,u,m,p=new Ho,d,f;if(ue(!se.vertEq(c,l)),ue(se.edgeSign(l,t.event,s)<=0),ue(se.edgeSign(c,t.event,a)>=0),ue(s!==t.event&&a!==t.event),ue(!e.fixUpperEdge&&!r.fixUpperEdge),s===a||(u=Math.min(s.t,l.t),m=Math.max(a.t,c.t),u>m))return!1;if(se.vertLeq(s,a)){if(se.edgeSign(c,s,a)>0)return!1}else if(se.edgeSign(l,a,s)<0)return!1;return i.debugEvent(t),se.intersect(l,s,c,a,p),ue(Math.min(s.t,l.t)<=p.t),ue(p.t<=Math.max(a.t,c.t)),ue(Math.min(c.s,l.s)<=p.s),ue(p.s<=Math.max(a.s,s.s)),se.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),d=se.vertLeq(s,a)?s:a,se.vertLeq(d,p)&&(p.s=d.s,p.t=d.t),se.vertEq(p,s)||se.vertEq(p,a)?(i.checkForRightSplice(t,e),!1):!se.vertEq(l,t.event)&&se.edgeSign(l,t.event,p)>=0||!se.vertEq(c,t.event)&&se.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),f=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,f,!0),!0):(se.edgeSign(l,t.event,p)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),se.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,s,l,a,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,s=i.regionBelow(e),a=e.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),se.vertEq(a.Org,t.event)&&(t.mesh.splice(n.Oprev,a),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),s),c=!0),se.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,s,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}se.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,s,a,l;if(o=e.eUp,se.vertEq(o.Org,r)){ue(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!se.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}ue(!1),e=i.topRightRegion(e),l=i.regionBelow(e),s=l.eUp.Sym,n=a=s.Onext,l.fixUpperEdge&&(ue(n!==s),i.deleteRegion(t,l),t.mesh.delete(s),s=n.Oprev),t.mesh.splice(r.anEdge,s),se.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,s.Onext,a,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,s,a,l,c=new cl;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(s=r.eUp,a=o.eUp,se.edgeSign(s.Dst,e,s.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=se.vertLeq(a.Dst,s.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,s.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);ue(o!==null);var n=i.regionBelow(o),s=n.eUp,a=i.finishLeftRegions(t,n,null);a.Onext===s?i.connectRightVertex(t,o,a):i.addRightEdges(t,o,a.Onext,s,s,!0)},i.addSentinel=function(t,e,r,o){var n=new cl,s=t.mesh.makeEdge();s.Org.s=r,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,t.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new fb(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,s=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,o,n,s),i.addSentinel(t,o,n,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ue(e.fixUpperEdge),ue(++r===1)),ue(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,se.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new db(n,se.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,ue(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!se.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),gb=function(){function i(){this.mesh=new wm,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ae.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,s,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],m=[0,0,0],p=[0,0,0],d=[null,null,null],f=[null,null,null],g=this.mesh.vHead;e=g.next;for(var x=0;x<3;++x)n=e.coords[x],c[x]=n,f[x]=e,l[x]=n,d[x]=e;for(e=g.next;e!==g;e=e.next)for(var y=0;y<3;++y)n=e.coords[y],n<c[y]&&(c[y]=n,f[y]=e),n>l[y]&&(l[y]=n,d[y]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=f[v],o=d[v],u[0]=r.coords[0]-o.coords[0],u[1]=r.coords[1]-o.coords[1],u[2]=r.coords[2]-o.coords[2],e=g.next;e!==g;e=e.next)m[0]=e.coords[0]-o.coords[0],m[1]=e.coords[1]-o.coords[1],m[2]=e.coords[2]-o.coords[2],p[0]=u[1]*m[2]-u[2]*m[1],p[1]=u[2]*m[0]-u[0]*m[2],p[2]=u[0]*m[1]-u[1]*m[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>a&&(a=s,t[0]=p[0],t[1]=p[1],t[2]=p[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,s=t.next;s!==t;s=s.next)if(o=s.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(n<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,n=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),n=!0),r=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;se.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;se.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(se.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(se.edgeGoesLeft(o.Lnext)||se.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(se.edgeGoesRight(r.Lprev)||se.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,s=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=a,a++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=s,++s}this.elementCount=s,e===Fe.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var m=c.n*o;this.vertices[m+0]=c.coords[0],this.vertices[m+1]=c.coords[1],o>2&&(this.vertices[m+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;this.elements[p++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var d=l;d<r;++d)this.elements[p++]=-1;if(e===Fe.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;n=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){s=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==o);this.elements[u++]=n,this.elements[u++]=s,n+=s}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new wm),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,o,n,s){if(t===void 0&&(t=Ae.ODD),e===void 0&&(e=Fe.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),hb.computeInterior(this,s);var a=this.mesh;return e===Fe.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===Fe.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,e,r,o),!0},i}();function eo(i){var t=i.windingRule,e=t===void 0?Ae.ODD:t,r=i.elementType,o=r===void 0?Fe.POLYGONS:r,n=i.polySize,s=n===void 0?3:n,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,u=c===void 0?[0,0,1]:c,m=i.contours,p=m===void 0?[]:m,d=i.strict,f=d===void 0?!0:d,g=i.debug,x=g===void 0?!1:g;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var y=new gb;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<p.length;v++)y.addContour(l||2,p[v]);return y.tesselate(e,o,s,l,u,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:x?y.mesh:void 0}}}var o3=Ae.ODD,n3=Ae.NONZERO,i3=Ae.POSITIVE,s3=Ae.NEGATIVE,a3=Ae.ABS_GEQ_TWO,l3=Fe.POLYGONS,c3=Fe.CONNECTED_POLYGONS,u3=Fe.BOUNDARY_CONTOURS;var Wo=class extends yb{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Ae.ODD;this.elementType=Fe.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Ae.ODD,elementType:Fe.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,m;for(let f=0,g=n.length/2;f<g;f++){let x=f*2,y=n[x+0],v=n[x+1];if(u!==void 0&&y!==u&&(l=!1),m!==void 0&&v!==m&&(c=!1),u=y,m=v,!l&&!c)break}!l&&!c&&(a=eo({contours:[n,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let p=a?.vertexCount??1,d=a?.elementCount??1;if(this._positionAttribute=new Bs(new Float32Array(p*3),3),this._normalAttribute=new Bs(new Float32Array(p*3),3),this._uvAttribute=new Bs(new Float32Array(p*2),2),this._indexAttribute=new Bs(new Uint32Array(d*3),1),a){let f=1/0,g=-1/0,x=1/0,y=-1/0;for(let S=0,b=p;S<b;S++){let B=S*2,w=a.vertices[B+0],h=a.vertices[B+1];w<f&&(f=w),w>g&&(g=w),h<x&&(x=h),h>y&&(y=h)}let v=g-f,A=y-x;for(let S=0,b=p;S<b;S++){let B=S*2,w=a.vertices[B+0],h=a.vertices[B+1],_=(w-f)/v,N=(h-x)/A;this._positionAttribute.setXYZ(S,w,h,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,_,N)}for(let S=0,b=d;S<b;S++){let B=S*3,w=a.elements[B+0],h=a.elements[B+1],_=a.elements[B+2];this._indexAttribute.setX(B+0,w),this._indexAttribute.setX(B+1,h),this._indexAttribute.setX(B+2,_)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Wo(this._shape,this._curveSegments);return e.userData=Nn(this.userData),e}};import{BufferAttribute as Gs,BufferGeometry as xb}from"three";var Es=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Es.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Es.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*n,3*t);s+=3*t;let l=new Float32Array(o,s*n,3*t);s+=3*t;let c=new Float32Array(o,s*n,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Fn=Es;Fn.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var ul=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),qo=class extends xb{constructor(e,r,o=0,n=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=o,this._curveSegments=n,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,r/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],n),l=this._shape.shapeHoles.map(w=>{let h=w.extractShapePointsToFlatArray([],n),_=[];for(let N=h.length-1;N>=1;N-=2){let I=h[N-1],L=h[N-0];_.push(I,L)}return _}),c=eo({windingRule:Ae.ODD,elementType:Fe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),u=eo({windingRule:Ae.ODD,elementType:Fe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let m=c.elementCount;if(u){c.elementCount+=u.elementCount;for(let w=0;w<u.elements.length;w++){let h=u.elements[w],_=w%2===0?c.vertexCount:0;c.elements.push(h+_)}for(let w=0;w<u.vertexIndices.length;w++){let h=u.vertexIndices[w],_=c.vertexCount;c.vertexIndices.push(h+_)}for(let w=0;w<u.vertices.length;w++){let h=u.vertices[w];c.vertices.push(h)}}let p=1/0,d=-1/0,f=1/0,g=-1/0;for(let w=0,h=c.vertexCount;w<h;w++){let _=w*2,N=c.vertices[_+0],I=c.vertices[_+1];N<p&&(p=N),N>d&&(d=N),I<f&&(f=I),I>g&&(g=I)}this._minX=p,this._minY=f,this._width=d-p,this._height=g-f;let x=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Fn(x);let y=[],v=[];for(let w=c.elementCount-1;w>=0;w--){let h=w>=m,_=w*2,N=c.elements[_+0],I=c.elements[_+1],L=N+I,P={start:N,count:I,normals:[],continuous:[],concave:[]},k=N,W=L-1,oe=N+1,ce=this._shape.roundedCurves.length;do{let V=k-N,E=c.vertices[W*2+0],D=c.vertices[W*2+1],M=c.vertices[k*2+0],G=c.vertices[k*2+1],Q=c.vertices[oe*2+0],j=c.vertices[oe*2+1],z=M-E,F=G-D,O=Math.sqrt(z*z+F*F);z/=O,F/=O;let q=M-Q,Z=G-j,ee=Math.sqrt(q*q+Z*Z);q/=ee,Z/=ee,P.normals[V*2+0]=-Z,P.normals[V*2+1]=q,P.concave[V]=z*Z-F*q>0;let H=c.vertexIndices[k];if(Array.isArray(H))P.continuous[V]=!1;else{let[J,$]=this._shape.getCurveIndexFromVertexId(H-1,!0);if($>0&&$<1)P.continuous[V]=!0;else{let re=$===1?J+1:J-1;re=(re+ce)%ce;let le=$===1?0:1,ne=this._shape.roundedCurves[J].getTangent($),de=this._shape.roundedCurves[re].getTangent(le);P.continuous[V]=ne.dot(de)>.95}}h&&(P.normals[V*2+0]*=-1,P.normals[V*2+1]*=-1),[W,k,oe]=[k,oe,oe+1],oe>=L&&(oe-=I)}while(oe!==N+1);let ie=[];ie.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(N*2,L*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((V,E)=>[E,E]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(N*2,L*2)});for(let V=1;V<=this._bevelSegments;V++){let E=V/this._bevelSegments*Math.PI/2,D=(1-Math.cos(E))*this._bevelSize,M=[],G=[],Q=[],j=[],z=0;for(let O=0;O<I;O++){let q=O*2,Z=(O-1+I)%I*2,ee=c.vertices[P.start*2+q+0],H=c.vertices[P.start*2+q+1],J=-P.normals[Z+0]*D,$=-P.normals[Z+1]*D,re=-P.normals[q+0]*D,le=-P.normals[q+1]*D;if(P.concave[O]||!P.concave[O]&&h){let ne=Math.atan2($,J),de=Math.atan2(le,re);de>ne&&(de-=Math.PI*2);let Me=de-ne;if(P.continuous[O]||h){let fe=ne+Me/2,Ee=Math.cos(fe)*D,be=Math.sin(fe)*D;M[2*z+0]=ee+Ee*(h?-1:1),M[2*z+1]=H+be*(h?-1:1),j[z]=O,z++}else{let fe=Math.max(1,Math.floor(n/4*Math.abs(Me)/Math.PI));for(let Ee=0;Ee<=fe;Ee++){let be=ne+Me*(Ee/fe),lt=Math.cos(be)*D,St=Math.sin(be)*D;M[2*z+0]=ee+lt,M[2*z+1]=H+St,j[z]=O,z++}}}else M[2*z+0]=ee+J,M[2*z+1]=H+$,j[z]=O,G[O]=z,z++,M[2*z+0]=ee,M[2*z+1]=H,j[z]=O,z++,M[2*z+0]=ee+re,M[2*z+1]=H+le,j[z]=O,Q[O]=z,z++}let F=eo({windingRule:Ae.POSITIVE,elementType:Fe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[M],edgeCreateCallback:O=>{let Z=O.Org.idx,ee=j[Z],H=j[(Z+1)%j.length];O.idx=[ee,H],O.Sym.idx=[H,ee]},vertexIdCallback:O=>{let q=O.Lprev.idx;return[q?q[1]:0,O.idx[0]]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!F.vertexCount)break;for(let O=0;O<F.vertexIndices.length;O++){let[q,Z]=F.vertexIndices[O];if(q===Z)continue;let ee=Z;Z<q&&(ee+=I);for(let H=q;H<ee;H++){let J=H%I,$=(H+1)%I;if(!P.continuous[J]||!P.continuous[$]){F.vertexIndices[O]=[q,J],F.vertexIndices.splice(O+1,0,[$,Z]),F.vertices.splice((O+1)*2,0,F.vertices[O*2],F.vertices[O*2+1]);break}}}ie.push({bevelI:V,angle:E,size:D,boundary:F,reverseMap:j,insetPoints:M})}let K=(V,E,D)=>{let M=0,G=V.boundary.vertexIndices.length;for(;M<G&&D(V.boundary.vertexIndices[E]);)E=(E+1)%G,M++;return M},U=y.length;for(let V=1;V<ie.length;V++){let E=ie[V-1],D=ie[V],M=E.boundary.vertexIndices.length,G=D.boundary.vertexIndices.length;if(!M||!G)break;let Q=P.concave.length,j=0,z=ul(j,I);for(;!E.boundary.vertexIndices.filter(z).length||!D.boundary.vertexIndices.filter(z).length;)j++,z=ul(j,I);let F=E.boundary.vertexIndices.findIndex(z),O=D.boundary.vertexIndices.findIndex(z);do F=(F+1)%M;while(z(E.boundary.vertexIndices[F]));do O=(O+1)%G;while(z(D.boundary.vertexIndices[O]));j=(j+1)%I;let q=j,Z=this.buildBevelVert(P,E,(F-1+M)%M),ee=this.buildBevelVert(P,D,(O-1+G)%G),H=Z,J=ee,$,re,le=!1;do{z=ul(j,I);let ne=K(E,F,z),de=K(D,O,z),Me=le;if(le=!1,ne&&!de){for(let fe=0;fe<ne;fe++)$=this.buildBevelVert(P,E,(F+fe)%M,fe/(ne-1)),y.push(H.topN,$.topP,J.topN),y.push($.bottomP,H.bottomN,J.bottomN),H=$;le=!0}else if(!ne&&de)for(let fe=0;fe<de;fe++)re=this.buildBevelVert(P,D,(O+fe)%G,fe/(de-1)),y.push(J.topN,H.topP,re.topP),y.push(H.bottomP,J.bottomN,re.bottomP),J=re;else if(ne&&de)if($=this.buildBevelVert(P,E,F,0),re=this.buildBevelVert(P,D,O,0),Me?(y.push(H.topN,re.topP,J.topN),y.push(H.topN,$.topP,re.topP),y.push(re.bottomP,H.bottomN,J.bottomN),y.push(re.bottomP,$.bottomP,H.bottomN)):(y.push(J.topN,H.topN,$.topP),y.push(J.topN,$.topP,re.topP),y.push($.bottomP,H.bottomN,J.bottomN),y.push($.bottomP,J.bottomN,re.bottomP)),H=$,J=re,ne===de)for(let fe=1;fe<ne;fe++)$=this.buildBevelVert(P,E,(F+fe)%M,fe/(ne-1)),re=this.buildBevelVert(P,D,(O+fe)%G,fe/(de-1)),y.push(H.topN,$.topP,J.topN),y.push(J.topN,$.topP,re.topP),y.push($.bottomP,H.bottomN,J.bottomN),y.push($.bottomP,J.bottomN,re.bottomP),H=$,J=re;else if(ne>de){let fe=ne/de,Ee=0;for(let be=1;be<ne;be++)$=this.buildBevelVert(P,E,(F+be)%M,be/(ne-1)),y.push(H.topN,$.topP,J.topN),y.push($.bottomP,H.bottomN,J.bottomN),H=$,be>(Ee+1)*fe&&(Ee++,re=this.buildBevelVert(P,D,(O+Ee)%G,Ee/(de-1)),y.push(J.topN,$.topP,re.topP),y.push($.bottomP,J.bottomN,re.bottomP),J=re)}else{let fe=de/ne,Ee=0;for(let be=1;be<de;be++)re=this.buildBevelVert(P,D,(O+be)%G,be/(de-1)),y.push(J.topN,$.topP,re.topP),y.push($.bottomP,J.bottomN,re.bottomP),J=re,be>(Ee+1)*fe&&(Ee++,$=this.buildBevelVert(P,E,(F+Ee)%M,Ee/(ne-1)),y.push(H.topN,$.topP,J.topN),y.push($.bottomP,H.bottomN,J.bottomN),H=$)}F=(F+ne)%M,O=(O+de)%G,j=(j+1)%Q}while(j!==q)}{let V=ie[0];for(let E=0,D=V.boundary.vertexCount;E<D;E++){let M=this.buildBevelVert(P,V,E),G=this.buildBevelVert(P,V,(E+1)%D);y.push(G.topP,M.topN,M.bottomN),y.push(G.topP,M.bottomN,G.bottomP)}}if(h){let V=[];for(let E=y.length-1;E>=U+2;E-=3){let D=y[E-2],M=y[E-1],G=y[E-0];V.push(G,M,D)}y.splice(U,y.length-U,...V)}if(h){let V=[];for(let E=ie[ie.length-1].boundary.vertices.length-1;E>=1;E-=2){let D=ie[ie.length-1].boundary.vertices[E-1],M=ie[ie.length-1].boundary.vertices[E-0];V.push(D,M)}v.push(V)}if(!h){let V=ie[ie.length-1],E=eo({windingRule:ie.length>1?Ae.POSITIVE:Ae.ODD,elementType:Fe.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]});if(!E)throw new Error("Error generating geometry for surface");l.length===0&&Object.assign(this,{capStartIndex:y.length});for(let D=0;D<E.elementCount*3;D+=3){let M=this.buildSurfaceVert(E,E.elements[D+0]),G=this.buildSurfaceVert(E,E.elements[D+1]),Q=this.buildSurfaceVert(E,E.elements[D+2]);y.push(M.top,G.top,Q.top),y.push(Q.bottom,G.bottom,M.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new Gs(Uint32Array.from(y),1),S=new Gs(this._buffer.positions,3),b=new Gs(this._buffer.normals,3),B=new Gs(this._buffer.uvs,2);S.needsUpdate=!0,b.needsUpdate=!0,B.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",b),this.setAttribute("uv",B),this.setIndex(A)}buildSurfaceVert(e,r){let o=r.toString();if(o in this.vertexCache)return this.vertexCache[o];let n=e.vertices[r*2+0],s=e.vertices[r*2+1],a=(n-this._minX)/this._width,l=(s-this._minY)/this._height,c=this._buffer.get(2),u=c*3,m=c*2,p={top:c+0,bottom:c+1};return this._buffer.positions[u+0]=n,this._buffer.positions[u+1]=s,this._buffer.positions[u+2]=this._depth,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[m+0]=a,this._buffer.uvs[m+1]=l,this._buffer.positions[u+3]=n,this._buffer.positions[u+4]=s,this._buffer.positions[u+5]=0,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[m+2]=a,this._buffer.uvs[m+3]=l,this.vertexCache[o]=p,p}buildBevelVert(e,r,o,n=1){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[a,l]=r.boundary.vertexIndices[o],c,u,m,p;a!==l?(u=a,c=l,p=!1,m=e.continuous[u]&&e.continuous[c]):(c=a,u=(c-1+e.count)%e.count,p=e.concave[c]&&r.bevelI>0,m=e.continuous[c]||p);let d=Math.cos(r.angle),f=Math.sin(r.angle),g=o*2,x=c*2,y=u*2,v=r.boundary.vertices[g+0],A=r.boundary.vertices[g+1],S=(1-f)*this._bevelSize,b=(v-this._minX)/this._width,B=(A-this._minY)/this._height,w=e.normals[x+0],h=e.normals[x+1],_=e.normals[y+0],N=e.normals[y+1];if(p){let W=_-w,oe=N-h;w=w+W*(1-n),h=h+oe*(1-n);let ce=Math.sqrt(w*w+h*h);w/=ce,h/=ce}let I=this._buffer.get(m?2:4),L=I*3,P=I*2,k={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=A,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=w*d,this._buffer.normals[L+1]=h*d,this._buffer.normals[L+2]=f,this._buffer.uvs[P+0]=b,this._buffer.uvs[P+1]=B,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=A,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=w*d,this._buffer.normals[L+4]=h*d,this._buffer.normals[L+5]=-f,this._buffer.uvs[P+2]=B,this._buffer.uvs[P+3]=b,m||(I+=2,L+=6,P+=4,k.topP=I+0,k.bottomP=I+1,this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=A,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=_*d,this._buffer.normals[L+1]=N*d,this._buffer.normals[L+2]=f,this._buffer.uvs[P+0]=b,this._buffer.uvs[P+1]=B,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=A,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=_*d,this._buffer.normals[L+4]=N*d,this._buffer.normals[L+5]=-f,this._buffer.uvs[P+2]=B,this._buffer.uvs[P+3]=b),this.vertexCache[s]=k,k}clone(){let e=new qo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Nn(this.userData),e}};var st=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),s=i.shape??t?.shape,a=s?.roundness??e.roundness;s!==void 0&&(s instanceof Se?(s.width!==r||s.height!==o)&&s.applySize(r,o):s=new Se(r,o).fromJSON(s),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&s.update(!1));let l=s??new Se(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:n,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:n}=i.parameters;i.shape.roundness=n;let s;return t<=0?s=new Wo(i.shape,o):s=new qo(i.shape,t,e,o,r),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};import{MathUtils as Im,Vector2 as Am}from"three";var Pm=Math.PI*2,Mm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Se?i.shape:new Se,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:o,innerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,m=e*.5,p=vb(c,u,m,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let d=st.create({shape:c,parameters:{subdivisions:p,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:{...i,type:"EllipseGeometry"}})}};function vb(i,t,e,r,o,n){if(r>=Pm)return o>30||o%4===0?(Sb(i,t,e,n),Math.round(o/4)):Lm(i,r,o,t,e,n);let s={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=Sm({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?bb(i,s.x,s.y,c,o,t,e,n):Lm(i,r,o,t,e,n)}function bb(i,t,e,r,o,n,s,a){let l=Math.round(o/r.length);i.addPoint($o(t,e));for(let c=0,u=r.length;c<u;c++){let m=r[c],p=i.points[c],d=$o(m.x,m.y);p.controls[1].position.set(m.x1,m.y1),d.controls[0].position.set(m.x2,m.y2),i.addPoint(d)}return a>0?Om(i,n,s,a):i.addPoint($o(0,0)),l}function Lm(i,t,e,r,o,n){let s=-t/e;for(let a=0;a<=e;a++){let l=s*a,c=Math.sin(l)*r,u=Math.cos(l)*o;i.addPoint($o(c,u))}return t<Pm?n>0?Om(i,r,o,n):i.addPoint($o(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&_m(i,r,o,n)),1}function Sb(i,t,e,r=0,o=0,n=0){let s=.5522847498,a=t*s,l=e*s;i.addPoint(Rs(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Rs(o,n+e,o-a,n+e,o+a,n+e)),i.addPoint(Rs(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Rs(o,n-e,o+a,n-e,o-a,n-e)),r>0&&_m(i,t,e,r)}function $o(i,t){return new _t(Im.generateUUID(),new Am(i,t))}function Rs(i,t,e,r,o,n){let s=$o(i,t);return s.controls[0].position.set(e,r),s.controls[1].position.set(o,n),s}function Om(i,t,e,r){Dm(i,t,e,r).forEach(n=>i.addPoint(n))}function _m(i,t,e,r){let o=Dm(i,t,e,r),n=new Se;o.forEach(s=>n.addPoint(s)),n.isClosed=!0,i.shapeHoles.push(n)}function Dm(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),s=new Am(o/t,n/e),a=i.points.map(l=>{let c=l.clone();return c.uuid=Im.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),u=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}import{BufferGeometry as wb,Float32BufferAttribute as pl,Vector3 as Bm}from"three";var Em=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),n=Math.abs(e.depth??r),s=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:n,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:o,revolutions:n,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:m}=i.parameters,p=new Un(!1,t,e,r,o,n,s,a,l,c,u,m);return Object.assign(p,{userData:{...i,type:"HelixGeometry"}})}},Un=class extends wb{constructor(t=!0,e=1,r=1,o=1,n=1,s=1,a=1,l=1,c=1,u=1,m=1,p=1){super();let d=t&&s===1;d&&(p=0),m>100&&(m=100);let f=()=>new Bm,g=new Bm,x=f(),y=f(),v=f(),A,S,b,B,w,h,_,N,I=f(),L=f(),P=f(),k=f(),W=f(),oe=f(),ce=f(),ie=f(),K=r-2*l+.001,U=K/s,V=Math.ceil(a*s),E=V+1,D=K/V,M=-K/2,G=u+1,Q=2*Math.PI/u,j=Math.PI/2/p,z=.01,F=Math.min((1-m/100)*l,l-z),O=l-F,q=0,Z=2,ee=p*Z+Z,H=G*ee/Z,J=H+G*E,$=G*(E+ee),[re,le,ne]=[3,3,2].map(_e=>Array($*_e).fill(0)),de=[],Me=n-l;function fe(_e,gt){let jt=Math.PI/2;h=gt*D,N=2*Math.PI*(h%U)/U+jt,h+=M,_=Math.sin(N)*Me,w=Math.cos(N)*Me,t?_e.set(w,_,h):_e.set(w,h,_)}fe(g,-1e-10),fe(x,0),I.copy(g),fe(g,1);let Ee=g.distanceTo(x),be=O+F,lt=Ee*V+2*be,St=F,mo=lt-be;for(let _e=0;_e<=V;_e++){fe(y,_e),ie.subVectors(y,I).normalize(),I.copy(y),oe.copy(y).setComponent(+t+1,0).normalize(),ce.crossVectors(ie,oe).normalize();let gt=_e===0,jt=_e===V,Df=gt?3*Math.PI/2:j,Bf=gt?St:mo,Ef=gt?G:J,Gf=gt?0:$-G,Rf=ie.clone().multiplyScalar(gt?-O:O).add(y),Vf=ie.clone().multiplyScalar(gt?-1:1).normalize();for(let pr=0;pr<G;pr++){let cc=pr*Q;if(L.addVectors(g.copy(oe).multiplyScalar(l*Math.cos(cc)),x.copy(ce).multiplyScalar(l*Math.sin(cc))),P.copy(L).normalize(),gt||jt){d||(q=Gf+pr,[0,1,2].forEach(ct=>{re[q*3+ct]=Rf.getComponent(ct),le[q*3+ct]=Vf.getComponent(ct)}),ne[q*2]=+jt,ne[q*2+1]=pr/u),x.copy(P).multiplyScalar(F),v.addVectors(y,x);for(let ct=0;ct<p;ct++){let ha=ct*j+Df;k.addVectors(g.copy(ie).multiplyScalar(O*Math.sin(ha)),x.copy(P).multiplyScalar(O*Math.cos(ha))),W.copy(k).normalize(),x.addVectors(v,k),k.normalize(),q=Ef+ct*G+pr,[0,1,2].forEach(Ti=>{re[q*3+Ti]=x.getComponent(Ti),le[q*3+Ti]=W.getComponent(Ti)});let zf=+gt+Math.sin(ha);ne[q*2]=(Bf+O*zf)/lt,ne[q*2+1]=pr/u}}x.addVectors(y,L),q=H+_e*G+pr,[0,1,2].forEach(ct=>{re[q*3+ct]=x.getComponent(ct),le[q*3+ct]=P.getComponent(ct)}),ne[q*2]=(be+_e*Ee)/lt,ne[q*2+1]=pr/u}}let ht=E+2*p+Z,fo=1,[Si,wi]=d?[fo,fo+E-1]:[0,ht-1];for(let _e=Si;_e<=wi-1;_e++){let gt=d&&_e===wi-1;for(let jt=0;jt<G-1;jt++)A=_e*G+jt,S=A+1,b=(gt?jt:A)+G,B=(gt?jt+1:S)+G,_e===0?de.push(S,B,b):_e===ht-2?de.push(A,S,b):de.push(A,S,b,S,B,b)}this.setIndex(de),this.setAttribute("position",new pl(re,3)),this.setAttribute("normal",new pl(le,3)),this.setAttribute("uv",new pl(ne,2))}};import{IcosahedronBufferGeometry as Tb}from"three";var Gm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new jn(t*.5,n,s):new Tb(t*.5,o);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},jn=class extends Rr{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(n,s,a,t,e,r),this.type=a}static fromJSON(t){return new jn(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as Nb,Shape as Cb}from"three";var Rm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,o=new Cb;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new Nb(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};import{BufferGeometry as km,BufferGeometryLoader as Eb,Vector3 as Gb,BoxBufferGeometry as Hm}from"three";import{BufferGeometry as Ob,Vector2 as fl,Vector3 as jm}from"three";import{Box3 as Lb,BufferAttribute as kn,BufferGeometry as Vm,Color as Fm,EventDispatcher as Ib,Float32BufferAttribute as Xo,Matrix3 as zm,Matrix4 as Um,MathUtils as Ab,Object3D as Pb,Sphere as Mb,Vector2 as Ct,Vector3 as rt}from"three";var Yt=new Um,ml=new Pb,Vs=new rt,zr=class extends Ib{constructor(){super(),this.uuid=Ab.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new zm().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];n.normal.applyMatrix3(e).normalize();for(let s=0,a=n.vertexNormals.length;s<a;s++)n.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Yt.makeRotationX(t),this.applyMatrix4(Yt),this}rotateY(t){return Yt.makeRotationY(t),this.applyMatrix4(Yt),this}rotateZ(t){return Yt.makeRotationZ(t),this.applyMatrix4(Yt),this}translate(t,e,r){return Yt.makeTranslation(t,e,r),this.applyMatrix4(Yt),this}scale(t,e,r){return Yt.makeScale(t,e,r),this.applyMatrix4(Yt),this}lookAt(t){return ml.lookAt(t),ml.updateMatrix(),this.applyMatrix4(ml.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let n=o.position,s=o.normal,a=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<n.count;p++)e.vertices.push(new rt().fromBufferAttribute(n,p)),a!==void 0&&e.colors.push(new Fm().fromBufferAttribute(a,p));function u(p,d,f,g){let x=a===void 0?[]:[e.colors[p].clone(),e.colors[d].clone(),e.colors[f].clone()],y=s===void 0?[]:[new rt().fromBufferAttribute(s,p),new rt().fromBufferAttribute(s,d),new rt().fromBufferAttribute(s,f)],v=new Yo(p,d,f,y,x,g);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new Ct().fromBufferAttribute(l,p),new Ct().fromBufferAttribute(l,d),new Ct().fromBufferAttribute(l,f)]),c!==void 0&&e.faceVertexUvs[1].push([new Ct().fromBufferAttribute(c,p),new Ct().fromBufferAttribute(c,d),new Ct().fromBufferAttribute(c,f)])}let m=t.groups;if(m.length>0)for(let p=0;p<m.length;p++){let d=m[p],f=d.start,g=d.count;for(let x=f,y=f+g;x<y;x+=3)r!==void 0?u(r.getX(x),r.getX(x+1),r.getX(x+2),d.materialIndex):u(x,x+1,x+2,d.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)u(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<n.count;p+=3)u(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vs).negate(),this.translate(Vs.x,Vs.y,Vs.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new Um;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new rt,e=new rt;for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],s=this.vertices[n.a],a=this.vertices[n.b],l=this.vertices[n.c];t.subVectors(l,a),e.subVectors(s,a),t.cross(e),t.normalize(),n.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new rt;if(t){let r=new rt,o=new rt;for(let n=0,s=this.faces.length;n<s;n++){let a=this.faces[n],l=this.vertices[a.a],c=this.vertices[a.b],u=this.vertices[a.c];r.subVectors(u,c),o.subVectors(l,c),r.cross(o),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],s=n.vertexNormals;s.length===3?(s[0].copy(e[n.a]),s[1].copy(e[n.b]),s[2].copy(e[n.c])):(s[0]=e[n.a].clone(),s[1]=e[n.b].clone(),s[2]=e[n.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let n=0,s=o.vertexNormals.length;n<s;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let t=new zr;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let n=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new rt,u={a:new rt,b:new rt,c:new rt};n.push(c),s.push(u)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let n=0,s=this.faces.length;n<s;n++){let a=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Lb),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mb),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,n=this.vertices.length,s=this.vertices,a=t.vertices,l=this.faces,c=t.faces,u=this.colors,m=t.colors;e!==void 0&&(o=new zm().getNormalMatrix(e));for(let p=0,d=a.length;p<d;p++){let g=a[p].clone();e!==void 0&&g.applyMatrix4(e),s.push(g)}for(let p=0,d=m.length;p<d;p++)u.push(m[p].clone());for(let p=0,d=c.length;p<d;p++){let f=c[p],g,x,y=f.vertexNormals,v=f.vertexColors,A=new Yo(f.a+n,f.b+n,f.c+n);A.normal.copy(f.normal),o!==void 0&&A.normal.applyMatrix3(o).normalize();for(let S=0,b=y.length;S<b;S++)g=y[S].clone(),o!==void 0&&g.applyMatrix3(o).normalize(),A.vertexNormals.push(g);A.color.copy(f.color);for(let S=0,b=v.length;S<b;S++)x=v[S],A.vertexColors.push(x.clone());A.materialIndex=f.materialIndex+r,l.push(A)}for(let p=0,d=t.faceVertexUvs.length;p<d;p++){let f=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let g=0,x=f.length;g<x;g++){let y=f[g],v=[];for(let A=0,S=y.length;A<S;A++)v.push(y[A].clone());this.faceVertexUvs[p].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],n=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],m=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[m]===void 0?(e[m]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[m]]}let s=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let m=[u.a,u.b,u.c];for(let p=0;p<3;p++)if(m[p]===m[(p+1)%3]){s.push(l);break}}for(let l=s.length-1;l>=0;l--){let c=s[l];this.faces.splice(c,1);for(let u=0,m=this.faceVertexUvs.length;u<m;u++)this.faceVertexUvs[u].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new rt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],n=this.faceVertexUvs[1],s,a;o&&o.length===e&&(s=[]),n&&n.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;s&&s.push(o[c]),a&&a.push(n[c])}s&&(this.faceVertexUvs[0]=s),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let f=this.parameters;for(let g in f)f[g]!==void 0&&(t[g]=f[g]);return t}let e=[];for(let f=0;f<this.vertices.length;f++){let g=this.vertices[f];e.push(g.x,g.y,g.z)}let r=[],o=[],n={},s=[],a={},l=[],c={};for(let f=0;f<this.faces.length;f++){let g=this.faces[f],x=!0,y=!1,v=this.faceVertexUvs[0][f]!==void 0,A=g.normal.length()>0,S=g.vertexNormals.length>0,b=g.color.r!==1||g.color.g!==1||g.color.b!==1,B=g.vertexColors.length>0,w=0;if(w=u(w,0,0),w=u(w,1,x),w=u(w,2,y),w=u(w,3,v),w=u(w,4,A),w=u(w,5,S),w=u(w,6,b),w=u(w,7,B),r.push(w),r.push(g.a,g.b,g.c),r.push(g.materialIndex),v){let h=this.faceVertexUvs[0][f];r.push(d(h[0]),d(h[1]),d(h[2]))}if(A&&r.push(m(g.normal)),S){let h=g.vertexNormals;r.push(m(h[0]),m(h[1]),m(h[2]))}if(b&&r.push(p(g.color)),B){let h=g.vertexColors;r.push(p(h[0]),p(h[1]),p(h[2]))}}function u(f,g,x){return x?f|1<<g:f&~(1<<g)}function m(f){let g=f.x.toString()+f.y.toString()+f.z.toString();return n[g]!==void 0||(n[g]=o.length/3,o.push(f.x,f.y,f.z)),n[g]}function p(f){let g=f.r.toString()+f.g.toString()+f.b.toString();return a[g]!==void 0||(a[g]=s.length,s.push(f.getHex())),a[g]}function d(f){let g=f.x.toString()+f.y.toString();return c[g]!==void 0||(c[g]=l.length/2,l.push(f.x,f.y)),c[g]}return t.data={},t.data.vertices=e,t.data.normals=o,s.length>0&&(t.data.colors=s),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new zr().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let p=0,d=e.length;p<d;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,d=r.length;p<d;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,d=o.length;p<d;p++)this.faces.push(o[p].clone());for(let p=0,d=t.faceVertexUvs.length;p<d;p++){let f=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let g=0,x=f.length;g<x;g++){let y=f[g],v=[];for(let A=0,S=y.length;A<S;A++){let b=y[A];v.push(b.clone())}this.faceVertexUvs[p].push(v)}}let n=t.morphTargets;for(let p=0,d=n.length;p<d;p++){let f={};if(f.name=n[p].name,n[p].vertices!==void 0){f.vertices=[];for(let g=0,x=n[p].vertices.length;g<x;g++)f.vertices.push(n[p].vertices[g].clone())}if(n[p].normals!==void 0){f.normals=[];for(let g=0,x=n[p].normals.length;g<x;g++)f.normals.push(n[p].normals[g].clone())}this.morphTargets.push(f)}let s=t.morphNormals;for(let p=0,d=s.length;p<d;p++){let f={};if(s[p].vertexNormals!==void 0){f.vertexNormals=[];for(let g=0,x=s[p].vertexNormals.length;g<x;g++){let y=s[p].vertexNormals[g],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),f.vertexNormals.push(v)}}if(s[p].faceNormals!==void 0){f.faceNormals=[];for(let g=0,x=s[p].faceNormals.length;g<x;g++)f.faceNormals.push(s[p].faceNormals[g].clone())}this.morphNormals.push(f)}let a=t.skinWeights;for(let p=0,d=a.length;p<d;p++)this.skinWeights.push(a[p].clone());let l=t.skinIndices;for(let p=0,d=l.length;p<d;p++)this.skinIndices.push(l[p].clone());let c=t.lineDistances;for(let p=0,d=c.length;p<d;p++)this.lineDistances.push(c[p]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let m=t.boundingSphere;return m!==null&&(this.boundingSphere=m.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new dl().fromGeometry(this),e=new Vm,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",new kn(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",new kn(o,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",new kn(o,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",new kn(o,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",new kn(o,2).copyVector2sArray(t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let n=[],s=t.morphTargets[o];for(let a=0,l=s.length;a<l;a++){let c=s[a],u=new Xo(c.data.length*3,3);u.name=c.name,n.push(u.copyVector3sArray(c.data))}e.morphAttributes[o]=n}if(t.skinIndices.length>0){let o=new Xo(t.skinIndices.length*4,4);e.setAttribute("skinIndex",o.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let o=new Xo(t.skinWeights.length*4,4);e.setAttribute("skinWeight",o.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Vm,r=t.geometry;if(t.isPoints||t.isLine){let o=new Xo(r.vertices.length*3,3),n=new Xo(r.colors.length*3,3);if(e.setAttribute("position",o.copyVector3sArray(r.vertices)),e.setAttribute("color",n.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let s=new Xo(r.lineDistances.length,1);e.setAttribute("lineDistance",s.copyArray(r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};zr.prototype.isGeometry=!0;var dl=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,n,s=t.faces;for(o=0;o<s.length;o++){let a=s[o];a.materialIndex!==n&&(n=a.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:n})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,n=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let y=0;y<l;y++)c[y]={name:a[y].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,m=u.length,p;if(m>0){p=[];for(let y=0;y<m;y++)p[y]={name:u[y].name,data:[]};this.morphTargets.normal=p}let d=t.skinIndices,f=t.skinWeights,g=d.length===r.length,x=f.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let A=v.vertexNormals;if(A.length===3)this.normals.push(A[0],A[1],A[2]);else{let b=v.normal;this.normals.push(b,b,b)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let b=v.color;this.colors.push(b,b,b)}if(n===!0){let b=o[0][y];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new Ct,new Ct,new Ct))}if(s===!0){let b=o[1][y];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new Ct,new Ct,new Ct))}for(let b=0;b<l;b++){let B=a[b].vertices;c[b].data.push(B[v.a],B[v.b],B[v.c])}for(let b=0;b<m;b++){let B=u[b].vertexNormals[y];p[b].data.push(B.a,B.b,B.c)}g&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),x&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Yo=class{constructor(t,e,r,o,n,s=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new rt,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new Fm,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};var _b=["a","b","c"];function Db(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function hl(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function gl(i,t,e,r,o,n){let s=Math.min(i,t),a=Math.max(i,t),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let u=e[s],m=e[a];c={a:u,b:m,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function Bb(i,t,e,r){let o,n,s;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=t.length;o<n;o++)s=t[o],gl(s.a,s.b,i,r,s,e),gl(s.b,s.c,i,r,s,e),gl(s.c,s.a,i,r,s,e)}function zs(i,t,e,r,o){i.push(new Yo(t,e,r,void 0,void 0,o))}function Ko(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Fs(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Us=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ob?t=new zr().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new jm,r,o,n,s,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],m=u!==void 0&&u.length>0,p=[],d=new Map;Bb(l,c,p,d);let f=[],g,x,y,v,A,S,b;for(let z of Array.from(d.keys())){for(x=d.get(z),y=new jm,A=3/8,S=1/8,b=x.faces.length,b!=2&&(A=.5,S=0,b!=1),y.addVectors(x.a,x.b).multiplyScalar(A),e.set(0,0,0),s=0;s<b;s++){for(v=x.faces[s],a=0;a<3&&(g=l[Db(v,_b[a])],!(g!==x.a&&g!==x.b));a++);g&&e.add(g)}e.multiplyScalar(S),y.add(e),x.newEdge=f.length,f.push(y)}let B,w,h,_,N,I,L,P=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],N=p[o].edges,r=N.length,r==3?B=3/16:r>3&&(B=3/(8*r)),w=1-r*Number(B),h=B,r<=2&&(r==2?(w=3/4,h=1/8):r==1||r==0),L=I.clone().multiplyScalar(w),e.set(0,0,0),s=0;s<r;s++)_=N[s],g=_.a!==I?_.a:_.b,e.add(g);e.multiplyScalar(Number(h)),L.add(e),P.push(L)}let k=P.concat(f),W=P.length,oe,ce,ie,K=[],U=[],V,E,D,M,G=new fl,Q=new fl,j=new fl;for(o=0,n=c.length;o<n;o++)v=c[o],oe=Number(hl(v.a,v.b,d).newEdge)+W,ce=Number(hl(v.b,v.c,d).newEdge)+W,ie=Number(hl(v.c,v.a,d).newEdge)+W,zs(K,oe,ce,ie,v.materialIndex),zs(K,v.a,oe,ie,v.materialIndex),zs(K,v.b,ce,oe,v.materialIndex),zs(K,v.c,ie,ce,v.materialIndex),m&&(V=u[o],E=V[0],D=V[1],M=V[2],G.set(Ko(E.x,D.x),Ko(E.y,D.y)),Q.set(Ko(D.x,M.x),Ko(D.y,M.y)),j.set(Ko(E.x,M.x),Ko(E.y,M.y)),Fs(U,G,Q,j),Fs(U,E,G,j),Fs(U,D,Q,G),Fs(U,M,j,Q));t.vertices=k,t.faces=K,m&&(t.faceVertexUvs[0]=U)}};var Ue=new Gb,Wm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new km().copy(new Hm(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ue),r={width:Ue.x,height:Ue.y,depth:Ue.z,subdivisions:0}):r=t.parameters;let o={...r,...i.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:o}=i.parameters,n=i.geometry??new km().copy(new Hm(100,100,100)),s=n.userData.parameters;s===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(Ue)):Ue.set(s.width,s.height,s.depth),(t!==Ue.x||e!==Ue.y||r!==Ue.z)&&n.scale(Ue.x===0?1:t/Ue.x,Ue.y===0?1:e/Ue.y,Ue.z===0?1:r/Ue.z);let a=n.originalGeometry;return o>0?(a===void 0||s?.subdivisions!==o)&&(a===void 0&&(a=n),n=new Us(o).modify(a).toBufferGeometry()):(a!==void 0&&(n=a),a=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),a!==void 0&&Object.assign(n,{originalGeometry:a}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Eb(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ue);let s=100/Ue.x;Object.assign(n.parameters,{width:100,height:Ue.y*s,depth:Ue.z*s}),t(this.build(n))})}};var qm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Se?i.shape:new Se,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5,m=0,p=0,d=2*Math.PI/r;for(let g=0;g<r;g++){let x=d*g,y=m+Math.sin(x)*c,v=p+Math.cos(x)*u;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let g=0,x=l.points.length;g<x;g++)l.points[g].roundness=o;l.roundness=o,l.update();let f=st.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(f,{userData:{...i,type:"PolygonGeometry"}})}};import{BufferGeometry as Rb,Float32BufferAttribute as yl,Vector2 as Kt,Vector3 as $e}from"three";var $m=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:n,openEnded:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=new vl(t*.5,e,o,n,s,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Hn(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function xl(i,t,e,r,o,n){let s=t.clone().sub(i),a=e.clone().sub(i),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===o){let c=s.add(a).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);n.copy(i),n.addScaledVector(s,o/Math.sin(c)),n.addScaledVector(a,r/Math.sin(c))}}function Vb(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var vl=class extends Rb{constructor(t=.5,e=1,r=4,o=1,n=!1,s=0,a=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],u=[],m=[],p=0,d=e/2,f=Math.PI/r,g=t*Math.cos(Math.PI/r),x=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,A=new $e(0,-d,0),S=new $e(0,d,0),b=new Kt(t,-d),B=new Kt(g,-d),w=new Kt(0,S.y).sub(B),h=new Kt(0,S.y).sub(b),_=new Kt(w.y,-w.x).normalize(),N=new Kt(h.y,-h.x).normalize(),L=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-w.angle())/2)-1e-8;s=Math.min(s,L);let P;{let U=new $e(_.x,_.y,0),V=new $e(Math.cos(x)*U.x,U.y,Math.sin(x)*U.x);P=U.angleTo(V)}let k=s/Math.tan((Math.PI-w.angle())/2),W=s/Math.tan((Math.PI-P)/2),oe=new $e;if(!n){c.push(A.x,A.y,A.z),u.push(0,-1,0),m.push(0,0);let U=p++,V=[],E=b.clone(),D=k/Math.cos(Math.PI/r);E.x-=D;for(let M=0;M<r;M++){let G=M/r*Math.PI*2+f,Q=new Kt(Math.sin(G),Math.cos(G));Hn(E,Q,oe),c.push(oe.x,oe.y,oe.z),u.push(0,-1,0),m.push(0,0),V.push(p++)}for(let M=0;M<V.length;M++)l.push(V[M],U,V[(M+1)%V.length])}let ce=[];{let U=new $e,V=new $e,E=new $e,D=new $e,M=new $e,G=new $e;for(let Q=0;Q<r;Q++){let j=Q/r*Math.PI*2+f,z=(Q+.5)/r*Math.PI*2+f,F=(Q+1)/r*Math.PI*2+f,O=new Kt(Math.sin(j),Math.cos(j)),q=new Kt(Math.sin(z),Math.cos(z)),Z=new Kt(Math.sin(F),Math.cos(F));Hn(b,O,V),Hn(b,Z,E),Hn(_,q,U),xl(S,V,E,W,W,D),c.push(D.x,D.y,D.z),xl(V,S,E,W,k,M),c.push(M.x,M.y,M.z),xl(E,V,S,k,W,G),c.push(G.x,G.y,G.z),u.push(U.x,U.y,U.z),u.push(U.x,U.y,U.z),u.push(U.x,U.y,U.z),m.push(0,0),m.push(0,0),m.push(0,0);let ee=p++,H=p++,J=p++;if(l.push(ee,H,J),s>0){{let le=V.clone().add(E).multiplyScalar(.5),ne=S.clone().sub(le).normalize(),Me=A.clone().sub(le).normalize().add(ne).normalize().multiplyScalar(-1),fe=G.clone().sub(M);ie(le,fe,Me,w.angle())}let $,re;{let le=new $e;Hn(N,Z,le);let ne=G.clone().add(D).multiplyScalar(.5);ne=Vb(ne,E,S);let de=G.clone().sub(D);[$,re]=ie(ne,de,le,P,D.y)}{let le=$,ne=le.clone().setY(0).normalize(),de=new $e(0,-1,0),Me=ne.clone().cross(de);K(le,ne,de,Me)}ce.concat(re);{let le=w.angle(),ne=Math.PI-le,de=S.clone();de.y-=s/Math.sin(le-Math.PI/2);let Me=new $e,fe=[];for(let be=0;be<a;be++){let lt=[],St=Math.PI/2-ne*be/a,mo=Math.cos(St),ht=Math.sin(St),fo=z;for(let Si=0;Si<=be;Si++){let wi=Math.cos(fo),_e=Math.sin(fo);U.x=mo*_e,U.y=ht,U.z=mo*wi,Me.copy(de).addScaledVector(U,s),c.push(Me.x,Me.y,Me.z),u.push(U.x,U.y,U.z),m.push(0,0),lt.push(p++),fo+=Math.PI*2/be/r}fe.push(lt)}re.reverse(),fe.push(re);let Ee=fe.length-1;for(let be=0;be<Ee;be++){let lt=fe[be],St=fe[be+1],mo=lt.length-1;l.push(St[1],lt[0],St[0]);for(let ht=1;ht<=mo;ht++)l.push(lt[ht],lt[ht-1],St[ht]),l.push(St[ht+1],lt[ht],St[ht])}}}}}this.setIndex(l),this.setAttribute("position",new yl(c,3)),this.setAttribute("normal",new yl(u,3)),this.setAttribute("uv",new yl(m,2));function ie(U,V,E,D,M){let G=-D/2,Q=(Math.PI-D)/2,j=V.clone().normalize().cross(E);U.addScaledVector(E,-s/Math.sin(Q));let z=new $e,F=new $e,O=1,q=p,Z=[];for(let ee=0;ee<=a;ee++){let H=G+ee/a*D;F.set(0,0,0),F.addScaledVector(j,Math.sin(H)),F.addScaledVector(E,Math.cos(H));for(let J=0;J<=O;J++){let $=J/O-.5;if(z.copy(U),z.addScaledVector(V,$),z.addScaledVector(F,s),M!=null){let re=Math.max(0,z.y-M);z.addScaledVector(V,-re/V.y)}c.push(z.x,z.y,z.z),u.push(F.x,F.y,F.z),m.push(0,0),J===0&&Z.push(p),p++}}for(let ee=0;ee<a;ee++)for(let H=0;H<O;H++){let J=q+H+(O+1)*ee,$=J+(O+1),re=$+1,le=J+1;l.push(J,$,le),l.push($,re,le)}return[U.clone().addScaledVector(V,.5),Z]}function K(U,V,E,D){let M=Math.PI/2,G=h.angle()-M,Q=[],j=new $e,z=new $e;for(let O=0;O<=a;O++){let q=[],Z=O/a;for(let ee=0;ee<=O;ee++){let J=((O?ee/O:0)-.5)*v,$=Math.cos(J),re=Math.sin(J),le=Math.atan(Math.tan(G)*$),ne=(M+le)*Z,de=Math.cos(ne),Me=Math.sin(ne);j.set(0,0,0),j.addScaledVector(V,Me*$),j.addScaledVector(E,de),j.addScaledVector(D,Me*re),z.copy(U).addScaledVector(j,s),c.push(z.x,z.y,z.z),u.push(j.x,j.y,j.z),m.push(0,0),q.push(p++)}Q.push(q)}let F=Q.length-1;for(let O=0;O<F;O++){let q=Q[O],Z=Q[O+1],ee=q.length-1;l.push(q[0],Z[1],Z[0]);for(let H=1;H<=ee;H++)l.push(q[H-1],q[H],Z[H]),l.push(q[H],Z[H+1],Z[H])}}}};var Xm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Se?i.shape:new Se,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:o,cornerType:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},m={x:c.x,y:c.y};function p(S,b,B){return b>e&&B>r?Math.min(S*e/b,S*r/B):b>e?S*e/b:B>r?S*r/B:S}let d=[];d[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),d[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),d[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),d[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let f=u.x,g=m.x,x=m.y,y=u.y;t.addPoint(t.createPoint(f,x)),t.addPoint(t.createPoint(g,x)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let v=!0;for(let S=0,b=t.points.length;S<b;S++)t.points[S].roundness=d[S],S>0&&d[S]!==d[S-1]&&(v=!1);v&&(t.roundness=d[0]),t.useCubicForRoundedCorners=n!==1,t.update();let A=st.create({shape:t,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(A,{userData:{...i,type:"RectangleGeometry"}})}};import{SphereBufferGeometry as zb}from"three";var Ym=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:n=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,u=new zb(.5*t,o,n,s,a,l,c);return u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};import{PlaneBufferGeometry as Fb}from"three";var Km=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Fb(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};import{BufferGeometry as Ub,Float32BufferAttribute as bl,Vector3 as jb}from"three";var Qm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:o,cornerRadius:n,cornerSegments:s}=i.parameters,a=new Sl(t,e,r,o,n,s);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},Sl=class extends Ub{constructor(t=1,e=1,r=1,o=90,n=10,s=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;n==0&&(s=1),s=Math.max(1,Math.floor(s)),n=Math.min(n,100),o=Math.min(180-u,o),o*=Math.PI/180;let m=[],p=Math.PI/2,d=(z=0,F=0,O=0)=>new jb(z,F,O),f=d(),g=d(),[x,y,v]=[e/2,t/2,r/2],A=-y,S=+y,[b,B,w]=[d(A,-x,+v),d(A,-x,-v),d(A,+x,-v)],h=(z,F=!1)=>Math.sin(z-Math.PI/(1+ +F)),_=(z,F=!1)=>Math.cos(z-Math.PI/(1+ +F));w.y=Math.sin(o)*e-x;let N=Math.cos(o)*e-v,I=b.z-u;o<=p?(w.z=Math.min(N,I),w.z==I&&(w.y-=(N-I)/Math.tan(p-o))):B.z=Math.min(B.z-N-v,b.z-u),f.subVectors(b,B),g.subVectors(w,B);let L=Math.min(f.length(),g.length())*n/100,P=L*Math.tan(o/2),k=L/Math.cos(o/2),W=f.clone().normalize().add(g.normalize()).setLength(k).add(B);f.set(0,h(o,!0),_(o,!0)),m.push([w,f.clone()]);let oe=(Math.PI-o)/s;for(let z=0;z<=s;z++){let F=p+o+z*oe;f.set(0,Math.sin(F)*P,Math.cos(F)*P),f.add(W),g.set(0,h(F),_(F)),m.push([f.clone(),g.clone()])}m.push([b,d(0,1,0)]);let ce=Math.sin(oe/2)*P*2,ie=m.length-1,K=m[0][0].distanceTo(m[1][0]),U=m[ie-1][0].distanceTo(m[ie][0]),V=K+ce*s+U;m[0].push(1);for(let z=0;z<=s;z++)m[z+1].push(1-(K+z*ce)/V);m[ie].push(0);let[E,D,M]=m[0],G,Q,j;for(let z=1;z<m.length;z++)[G,Q,j]=m[z],a.push(A,E.y,E.z,A,G.y,G.z,S,E.y,E.z,S,E.y,E.z,A,G.y,G.z,S,G.y,G.z),l.push(0,D.y,D.z,0,Q.y,Q.z,0,D.y,D.z,0,D.y,D.z,0,Q.y,Q.z,0,Q.y,Q.z),c.push(0,M,0,j,1,M,1,M,0,j,1,j),[E,D,M]=[G,Q,j];this.setAttribute("position",new bl(a,3)),this.setAttribute("normal",new bl(l,3)),this.setAttribute("uv",new bl(c,2))}};var Jm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Se?i.shape:new Se,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,m=t*.5,p=e*.5,d=0,f=0,g=s*Math.PI/360/o,x=Math.PI/2*3*-1,y=m*r/100,v=p*r/100;if(o===3&&r===50){g=2*Math.PI/o;for(let S=0;S<o;S++){let b=g*S,B=d+Math.sin(b)*m,w=f+Math.cos(b)*p;u.addPoint(u.createPoint(B,w))}}else for(let S=0;S<o;S++){let b=d+Math.cos(x)*m,B=f+Math.sin(x)*p;u.addPoint(u.createPoint(b,B)),x+=g,b=d+Math.cos(x)*y,B=f+Math.sin(x)*v,S<=o,u.addPoint(u.createPoint(b,B)),x+=g}u.isClosed=!0;for(let S=0,b=u.points.length;S<b;S++)u.points[S].roundness=n;u.roundness=n,u.update();let A=st.create({shape:u,parameters:{roundness:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(A,{userData:{...i,type:"StarGeometry"}})}};import{PlaneBufferGeometry as kb}from"three";var js=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new kb(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var Zm=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??e.width*.25);return{parameters:Object.assign(e,{width:r,height:o,depth:n})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:n,arc:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=Hb(t,e,r,t*.5,s,n,0,0,o,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function Hb(i,t,e,r,o,n,s,a,l,c,u){return[t,e]=[e,t],s=t/2,o/=2*Math.PI,o==1&&(c=0),new Un(!0,i,t,e,r,o,n,s,a,l,c,u)}import{TorusKnotBufferGeometry as Wb}from"three";var ed=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:n,q:s}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new Wb(a,e,r,o,n,s);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var td=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Se?i.shape:new Se,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s,isRect:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5;a?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let p=0,d=l.points.length;p<d;p++)l.points[p].roundness=r;l.roundness=r,l.update();let m=st.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s}});return Object.assign(m,{userData:{...i,type:"TriangleGeometry"}})}};import{BufferGeometry as Vd,BufferAttribute as zd,Uint32BufferAttribute as $l,Float32BufferAttribute as Xl,Matrix4 as dw,Vector3 as ta}from"three";var qb,ks=new Promise(i=>{qb=i});import{BufferGeometryLoader as pw}from"three";import{EventDispatcher as lw,Matrix3 as cw,Vector3 as ql}from"three";import{Mesh as sw,Matrix4 as aw}from"three";import{Matrix4 as cd}from"three";import{Object3D as Yb,Matrix4 as Kb}from"three";import{HemisphereLight as rd}from"three";function Ve(i,t){return t.color(i)}var wl=i=>"isEntity"in i,Qt=i=>"isAbstractMesh"in i,Jt=i=>i!==null&&i.isBooleanMesh,od=i=>i.objectType==="CombinedCamera";var Sr=i=>"objectHelper"in i;function $b(i,t){let e=!1;t.position&&(i.position.fromArray(t.position),e=!0),t.rotation&&(i.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,i.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(e=!0,i.hiddenMatrix.fromArray(t.hiddenMatrix??_r.identity)),e&&(i.updateMatrix(),Jt(i.parent)&&Qt(i)&&i.invalidateDownstreamBooleanData(!0).recomputeBoolean()),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=t.isUpVectorFlipped),i.updateUp())}function Xb(i,t){$b(i,t),t.name!==void 0&&(i.name=t.name),t.visible!==void 0&&(i.isEntity?i.visibility=t.visible:i.visible=t.visible)}function nd(i,t,e){Xb(i,t),t.color!==void 0&&(i.color=Ve(t.color,e)),t.intensity!==void 0&&(i.intensity=t.intensity),t.shadows!==void 0&&!(i instanceof rd)&&(i.castShadow=t.shadows),i.shadow&&!(i instanceof rd)&&t.depth!==void 0&&(i.shadow.camera.far=t.depth,i.shadow.needsUpdate=!0),t.helper!==void 0&&Sr(i)&&(i.enableHelper=t.helper,i.gizmos.shadowmap.visible=t.helper)}function id(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var Hs=i=>class extends i{hasEntityChild(){return this.children.some(e=>wl(e))}isDescendantOf(e){e instanceof Yb&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let o=new Kb().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),o.multiply(e.parent.matrixWorld)),wl(e)?e.hiddenMatrix.premultiply(o):e.applyMatrix4(o),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let o=0;o<e.children.length;o++){let n=e.children[o];this.add(n.clone())}return this}};import{Box3 as ad,Line3 as Qb,Matrix4 as Tl,Vector3 as Lt}from"three";var Qo=new ad,Zt=new Lt,er=new Lt,Jo=new Tl,ld=[new Lt(-1,1,1),new Lt(-1,-1,1),new Lt(1,-1,1),new Lt(1,1,1),new Lt(-1,1,-1),new Lt(-1,-1,-1),new Lt(1,-1,-1),new Lt(1,1,-1)],Jb=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Zb=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function eS(i,t,e=0,r=t.count){let o=1/0,n=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=e;u<r;u++){let m=t.getX(u),p=t.getY(u),d=t.getZ(u);m<o&&(o=m),p<n&&(n=p),d<s&&(s=d),m>a&&(a=m),p>l&&(l=p),d>c&&(c=d)}return i.min.set(o,n,s),i.max.set(a,l,c),i}var sd=(i,t,e,r)=>{if(Qt(i)){let o=i.geometry.userData.parameters,n=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?Zt.copy(i.originalGeometry.boundingSphere.center):n!==void 0&&(eS(Qo,n,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:n.count),Qo.getCenter(Zt)),i.forceComputeSize?Qo.getSize(er).multiplyScalar(.5):er.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}else if(Sr(i)&&r===!0){let o=i.geometryHelper.getAttribute("position");Qo.setFromArray(o.array),Qo.getCenter(Zt),Qo.getSize(er).multiplyScalar(.5)}else Zt.setScalar(0),er.setScalar(0);Jo.copy(t).multiply(i.matrixWorld),er.x===0&&er.y===0&&er.z===0?e.push(new Lt(Zt.x,Zt.y,Zt.z).applyMatrix4(Jo)):ld.forEach(o=>{e.push(o.clone().multiply(er).add(Zt).applyMatrix4(Jo))})},Wn=class extends ad{constructor(){super(...arguments);this.matrix=new Tl;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Tl().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let n=[];return o===!0?e.traverseEntity(s=>{s.visible&&sd(s,r,n,e.enableHelper===!0)}):sd(e,r,n,e.enableHelper===!0),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Jo.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(er).multiplyScalar(.5),this.getCenter(Zt),Jo.copy(this.matrix).setPosition(Zt),this.vertices=ld.map(e=>e.clone().multiply(er).applyMatrix4(Jo))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Jb.map(([e,r])=>new Qb(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Lt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Zb.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Dt=i=>"isEntity"in i,ud=i=>"isAbstractMesh"in i,It=i=>class extends Hs(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new cd;this._singleBBox=new Wn;this._recursiveBBox=new Wn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let o of this.children)Dt(o)&&o.traverseEntity(n=>{Sr(n)&&n.visible&&(n.objectHelper.visible=r)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(r=>{Dt(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let o of this.children)Dt(o)&&o.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}clone(r){return new this.constructor().copy(this,r)}copy(r,o=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),o===!0)for(let n of r.children)Dt(n)&&this.add(n.clone());return this}keepChildrenMatrixWorld(){let r=new cd,o=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(o);for(let n of this.children)Dt(n)&&n.hiddenMatrix.premultiply(r)}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Do(o,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Do(o,r)}fromState(r,o){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as rS,Vector3 as qn,Euler as pd,MathUtils as Fr}from"three";import{Object3D as tS}from"three";var Nl=class extends tS{},Ws=class extends Nl{constructor(e){super();this.object=e;this.matrixAutoUpdate=!0}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return!0}get isLight(){return!1}get isCamera(){return!1}get geometry(){return this.object.geometry}get material(){return this.object.material}};var to=class extends rS{constructor(e,r={}){super();this.object=e;let o=e.recursiveBBox.getSize(new qn),n=.1;this.parameters=es.defaultData(o.toArray(),n),Yr(this.parameters,r),this.update(),this.setHideBase(this.parameters.hideBase)}setHideBase(e){this.parameters.hideBase=e}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let r=0,o=e-this.children.length;r<o;++r){let n=new Ws(this.object);n.visible=!0,this.add(n),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,o=this.children.length-e;r<o;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,o=r.start*Fr.DEG2RAD,n=r.end*Fr.DEG2RAD,s=o-n,a=new pd(r.rotation[0]*Fr.DEG2RAD,r.rotation[1]*Fr.DEG2RAD,r.rotation[2]*Fr.DEG2RAD),l;switch(r.axis){case"z":l=new qn(0,0,1);break;case"y":l=new qn(0,1,0);break;default:case"x":l=new qn(1,0,0);break}for(let[c,u]of this.children.entries()){u.scale.x=r.scale[0],u.scale.y=r.scale[1],u.scale.z=r.scale[2],u.position.setScalar(0);let m=s/e.count*c-o;switch(r.axis){case"x":u.rotation.set(0,m,0);break;case"y":u.rotation.set(0,0,m);break;case"z":u.rotation.set(m,0,0);break}u.translateOnAxis(l,r.radius),u.position.x+=r.position[0],u.position.y+=r.position[1],u.position.z+=r.position[2],r.alignment===!0?(u.rotation.x+=a.x,u.rotation.y+=a.y,u.rotation.z+=a.z):u.rotation.copy(a)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new pd(r.rotation[0]*Fr.DEG2RAD,r.rotation[1]*Fr.DEG2RAD,r.rotation[2]*Fr.DEG2RAD);for(let[n,s]of this.children.entries())s.scale.x=1+(r.scale[0]-1)*n,s.scale.y=1+(r.scale[1]-1)*n,s.scale.z=1+(r.scale[2]-1)*n,s.rotation.x=o.x*n,s.rotation.y=o.y*n,s.rotation.z=o.z*n,s.position.x=r.position[0]*n,s.position.y=r.position[1]*n,s.position.z=r.position[2]*n}_updateGrid(e){let r=0,o=e.grid;if(o.useCenter===!0){let n={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},s=new qn(o.size[0]*(o.count[0]-n.x)*.5,o.size[1]*(o.count[1]-n.y)*.5,o.size[2]*(o.count[2]-n.z)*.5);for(let a=0;a<o.count[0];a++)for(let l=0;l<o.count[1];l++)for(let c=0;c<o.count[2];c++){let u=this.children[r++];u.scale.setScalar(1),u.rotation.set(0,0,0),u.position.x=o.size[0]*a-s.x,u.position.y=o.size[1]*l-s.y,u.position.z=o.size[2]*c-s.z}}else for(let n=0;n<o.count[0];n++)for(let s=0;s<o.count[1];s++)for(let a=0;a<o.count[2];a++){let l=this.children[r++];l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=o.size[0]*n,l.position.y=-o.size[1]*s,l.position.z=-o.size[2]*a}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),Yr(this.parameters,e),this.update(),this}};import{NormalBlending as HS,ShaderMaterial as WS}from"three";import{CubeReflectionMapping as dS,CubeRefractionMapping as fS,CubeUVReflectionMapping as hS,LinearEncoding as hd,sRGBEncoding as gS}from"three";var $n=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as oS}from"three";var Xe=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=oS.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,s){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Xe&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Cl=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},je=new Cl;import{Vector2 as md}from"three";import{MathUtils as nS}from"three";var ae=class extends Xe{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let s=this.getUnique(e,r);s&&this.uuid===void 0&&(this.uuid=nS.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,o)):super.build(e,r,o);if(s)return a.name=a.name||super.build(e,r,o),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,a.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,s){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),s,this.getLabel()).name}};var Ce=class extends ae{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,s,a){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,s,a,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,s,a,this.getLabel())),e.format(l.fragment.name,n,r))}};var ke=class extends Ce{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof md?e:new md(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};import{Vector3 as dd}from"three";var Je=class extends Ce{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof dd?e:new dd(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var At=class extends Ce{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Qe?e:new Qe(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var iS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,fd=/[a-z_0-9]+/gi,X=class extends ae{constructor(e,r,o,n,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,s){let a,l=0,c=this.src;if(this.includes)for(let m=0;m<this.includes.length;m++)e.include(this.includes[m],this);for(let m in this.extensions)e.extensions[m]=!0;let u=[];for(;a=fd.exec(this.src);)u.push(a);for(let m=0;m<u.length;m++){let p=u[m],d=p[0],f=this.isMethod?!this.getInputByName(d):!0,g=d;if(this.keywords[d]||this.useKeywords&&f&&je.containsKeyword(d)){let x=this.keywords[d];if(!x){let y=je.getKeywordData(d);y.cache&&(x=e.keywords[d]),x=x||je.getKeyword(d,e),y.cache&&(e.keywords[d]=x)}g=x.build(e)}d!==g&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+g+c.substring(p.index+d.length+l),l+=g.length-d.length),this.getIncludeByName(g)===void 0&&je.contains(g)&&e.include(je.get(g))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let s=iS.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(fd);if(a){let l=0;for(;l<a.length;){let c=a[l++],u;c==="in"||c==="out"||c==="inout"?u=a[l++]:(u=c,c="");let m=a[l++];this.inputs.push({name:m,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var sS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ll=class extends ae{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ll.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,s){this.src=e||"";let a,l,c="",u=sS.exec(e);this.useDefine=s??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,s){return e.format(this.name,this.getType(e),r)}},ye=Ll;ye.PI="PI",ye.PI2="PI2",ye.RECIPROCAL_PI="RECIPROCAL_PI",ye.RECIPROCAL_PI2="RECIPROCAL_PI2",ye.LOG2="LOG2",ye.EPSILON="EPSILON";var aS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
2
+ )*?)}`,"gim"),lS=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Zo=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,s){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=aS.exec(e);if(r){let o=r[2],n;for(;n=lS.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var en=class extends ae{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};je.addKeyword("uv",function(){return new en});je.addKeyword("uv2",function(){return new en(1)});import{LinearEncoding as cS,sRGBEncoding as uS}from"three";var ro=class extends ae{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??ro.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case cS:return["Linear"];case uS:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),s=ro.Nodes[this.method],a=e.include(s);if(a===ro.LINEAR_TO_LINEAR)return e.format(o,n,r);if(s.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+o+", "+l+" )",n,r)}else return e.format(a+"( "+o+" )",n,r)}fromEncoding(e){let r=ro.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=ro.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},at=ro;at.Nodes={LinearToLinear:new X(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3
+ `)),sRGBToLinear:new X(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
4
+ `)),LinearTosRGB:new X(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
5
+ `))},at.LINEAR_TO_LINEAR="LinearToLinear",at.SRGB_TO_LINEAR="sRGBToLinear",at.LINEAR_TO_SRGB="LinearTosRGB";var ve=class extends X{constructor(e="",r,o,n,s){super(e,s,n,o,r);this.nodeType="Expression"}};import{Texture as pS}from"three";var mt=class extends Ce{constructor(e=new pS,r,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new en,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?l=a+"( "+o+", "+n+", "+s+" )":l=a+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new at(new ve("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,r)}};var Y=class extends Ce{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,n,s,a){return e.format(this.value+(this.value%1?"":".0"),n,r)}};var Xn=class extends ae{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,n,s){n=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let u=0;u<a.inputs.length;u++){let m=a.inputs[u],p=this.inputs[u]||this.inputs[m.name];c.push(p.build(e,e.getTypeByFormat(m.type)))}l+=c.join(", ")+" )"}return e.format(l,n,r)}};var Il=class extends ae{constructor(e,r,o=Il.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),s=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+s+" )",o,r)}},dt=Il;dt.ADD="+",dt.SUB="-",dt.MUL="*",dt.DIV="/";var Ne=class extends ae{constructor(e,r=Ne.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:n=r,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Ne.MIX:case Ne.CLAMP:case Ne.REFRACT:case Ne.SMOOTHSTEP:case Ne.FACEFORWARD:return 3;case Ne.MIN:case Ne.MAX:case Ne.MOD:case Ne.STEP:case Ne.REFLECT:case Ne.DISTANCE:case Ne.DOT:case Ne.CROSS:case Ne.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Ne.LENGTH:case Ne.DISTANCE:case Ne.DOT:return"f";case Ne.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,n,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),m=this.getType(e);switch(this.type=m,this.method){case Ne.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,r);case Ne.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,r);case Ne.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case Ne.STEP:o=this.a.build(e,a===1?"f":u),n=this.b.build(e,u);break;case Ne.MIN:case Ne.MAX:case Ne.MOD:o=this.a.build(e,u),n=this.b.build(e,l===1?"f":u);break;case Ne.REFRACT:o=this.a.build(e,u),n=this.b.build(e,u),s=this.c.build(e,"f");break;case Ne.MIX:o=this.a.build(e,u),n=this.b.build(e,u),s=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(n=this.b.build(e,u)),this.c&&(s=this.c.build(e,u));break}let p=[];p.push(o),n&&p.push(n),s&&p.push(s);let d=this.getNumInputs(e);if(p.length!==d)throw Error(`Arguments not match used in "${this.method}". Require ${d}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",m,r)}},me=Ne;me.RAD="radians",me.DEG="degrees",me.EXP="exp",me.EXP2="exp2",me.LOG="log",me.LOG2="log2",me.SQRT="sqrt",me.INV_SQRT="inversesqrt",me.FLOOR="floor",me.CEIL="ceil",me.NORMALIZE="normalize",me.FRACT="fract",me.SATURATE="saturate",me.SIN="sin",me.COS="cos",me.TAN="tan",me.ASIN="asin",me.ACOS="acos",me.ARCTAN="atan",me.ABS="abs",me.SIGN="sign",me.LENGTH="length",me.NEGATE="negate",me.INVERT="invert",me.MIN="min",me.MAX="max",me.MOD="mod",me.STEP="step",me.REFLECT="reflect",me.DISTANCE="distance",me.DOT="dot",me.CROSS="cross",me.POW="pow",me.MIX="mix",me.CLAMP="clamp",me.REFRACT="refract",me.SMOOTHSTEP="smoothstep",me.FACEFORWARD="faceforward";var tn=class extends ae{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,n){let s=new Xn(tn.Nodes.bilinearCubeUV,[r,o,n]);this.colorSpaceTL=this.colorSpaceTL??new at(new ve("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new at(new ve("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new at(new ve("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new at(new ve("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new ve(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new ve(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new ve(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new ve(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new ve("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=s,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,s=new Xn(tn.Nodes.roughnessToMip,[n]),a=new me(s,tn.Nodes.m0,tn.Nodes.cubeUV_maxMipLevel,me.CLAMP),l=new me(a,me.FLOOR),c=new me(a,me.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),m=this.bilinearCubeUV(e,this.value,o,new dt(l,new Y(1).setReadonly(!0),dt.ADD)),p=new me(u,m,c,me.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},rn=tn;rn.Nodes=function(){let e=new Zo(`struct TextureCubeUVData {
6
+ vec4 tl;
7
+ vec4 tr;
8
+ vec4 br;
9
+ vec4 bl;
10
+ vec2 f;
11
+ }`),r=new ye("float cubeUV_maxMipLevel 8.0",!0),o=new ye("float cubeUV_minMipLevel 4.0",!0),n=new ye("float cubeUV_maxTileSize 256.0",!0),s=new ye("float cubeUV_minTileSize 16.0",!0),a=new X(`float getFace(vec3 direction) {
12
+ vec3 absDirection = abs(direction);
13
+ float face = -1.0;
14
+ if (absDirection.x > absDirection.z) {
15
+ if (absDirection.x > absDirection.y)
16
+ face = direction.x > 0.0 ? 0.0 : 3.0;
17
+ else
18
+ face = direction.y > 0.0 ? 1.0 : 4.0;
19
+ } else {
20
+ if (absDirection.z > absDirection.y)
21
+ face = direction.z > 0.0 ? 2.0 : 5.0;
22
+ else
23
+ face = direction.y > 0.0 ? 1.0 : 4.0;
19
24
  }
20
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
21
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
22
- return col;
23
- }`);n=e.include(l);break;default:n=e.include(Xn.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let a=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${a})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.texture.getTexture(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+s.join(",")+")",this.getType(e),r)}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},$n=Xn;$n.Nodes=function(){let e=new K(`
24
- vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
25
- vec3 posN = normalize(position);
26
- float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
27
- float scaledHeight = position.y / (size.y * 0.5);
28
- float v = (scaledHeight / 2.) + .5;
29
-
30
- vec2 calculatedUv = vec2(u,v);
31
- vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
32
-
33
- vec2 df = fwidth(uvs);
34
- if(df.x > 0.5) df.x = 0.;
25
+ return face;
26
+ }`);a.useKeywords=!1;let l=new X(`vec2 getUV(vec3 direction, float face) {
27
+ vec2 uv;
28
+ if (face == 0.0) {
29
+ uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
30
+ } else if (face == 1.0) {
31
+ uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
32
+ } else if (face == 2.0) {
33
+ uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
34
+ } else if (face == 3.0) {
35
+ uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
36
+ } else if (face == 4.0) {
37
+ uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
38
+ } else {
39
+ uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
40
+ }
41
+ return 0.5 * (uv + 1.0);
42
+ }`);l.useKeywords=!1;let c=new X(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
43
+ float face = getFace(direction);
44
+ float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
45
+ mipInt = max(mipInt, cubeUV_minMipLevel);
46
+ float faceSize = exp2(mipInt);
47
+ float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
48
+ vec2 uv = getUV(direction, face) * (faceSize - 1.0);
49
+ vec2 f = fract(uv);
50
+ uv += 0.5 - f;
51
+ if (face > 2.0) {
52
+ uv.y += faceSize;
53
+ face -= 3.0;
54
+ }
55
+ uv.x += face * faceSize;
56
+ if(mipInt < cubeUV_maxMipLevel){
57
+ uv.y += 2.0 * cubeUV_maxTileSize;
58
+ }
59
+ uv.y += filterInt * 2.0 * cubeUV_minTileSize;
60
+ uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
61
+ uv *= texelSize;
62
+ vec4 tl = texture2D(envMap, uv);
63
+ uv.x += texelSize;
64
+ vec4 tr = texture2D(envMap, uv);
65
+ uv.y += texelSize;
66
+ vec4 br = texture2D(envMap, uv);
67
+ uv.x -= texelSize;
68
+ vec4 bl = texture2D(envMap, uv);
69
+ return TextureCubeUVData( tl, tr, br, bl, f );
70
+ }`,[e,a,l,r,o,n,s]);c.useKeywords=!1;let u=new ye("float r0 1.0",!0),m=new ye("float v0 0.339",!0),p=new ye("float m0 -2.0",!0),d=new ye("float r1 0.8",!0),f=new ye("float v1 0.276",!0),g=new ye("float m1 -1.0",!0),x=new ye("float r4 0.4",!0),y=new ye("float v4 0.046",!0),v=new ye("float m4 2.0",!0),A=new ye("float r5 0.305",!0),S=new ye("float v5 0.016",!0),b=new ye("float m5 3.0",!0),B=new ye("float r6 0.21",!0),w=new ye("float v6 0.0038",!0),h=new ye("float m6 4.0",!0),_=[u,m,p,d,f,g,x,y,v,A,S,b,B,w,h],N=new X(`float roughnessToMip(float roughness) {
71
+ float mip = 0.0;
72
+ if (roughness >= r1) {
73
+ mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
74
+ } else if (roughness >= r4) {
75
+ mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
76
+ } else if (roughness >= r5) {
77
+ mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
78
+ } else if (roughness >= r6) {
79
+ mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
80
+ } else {
81
+ mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
82
+ }
83
+ return mip;
84
+ }`,_);return{bilinearCubeUV:c,roughnessToMip:N,m0:p,cubeUV_maxMipLevel:r}}();var oo=class extends ae{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??oo.VIEW}getShared(){return this.scope===oo.WORLD}build(e,r,o,n){let s=e.context[this.scope+"Normal"];return s?s.build(e,r,o,n):super.build(e,r,o)}generate(e,r,o,n,s){let a;switch(this.scope){case oo.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case oo.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case oo.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}},Ye=oo;Ye.LOCAL="local",Ye.WORLD="world",Ye.VIEW="view",Ye.NORMAL="normal";je.addKeyword("viewNormal",function(){return new Ye(Ye.VIEW)});je.addKeyword("localNormal",function(){return new Ye(Ye.NORMAL)});je.addKeyword("worldNormal",function(){return new Ye(Ye.WORLD)});var tr=class extends ae{constructor(e){super("v3");this.nodeType="Position";this.scope=e??tr.LOCAL}getType(){switch(this.scope){case tr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case tr.LOCAL:case tr.WORLD:return!1}return!0}generate(e,r,o,n,s){let a;switch(this.scope){case tr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case tr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case tr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case tr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}},ft=tr;ft.LOCAL="local",ft.WORLD="world",ft.VIEW="view",ft.PROJECTION="projection";je.addKeyword("position",function(){return new ft});je.addKeyword("worldPosition",function(){return new ft(ft.WORLD)});je.addKeyword("viewPosition",function(){return new ft(ft.VIEW)});var Bt=class extends ae{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Bt.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Bt.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case Bt.VECTOR:{let s=new Ye(Ye.VIEW),a=e.context.roughness,l=s.build(e,"v3"),c=new ft(ft.VIEW).build(e,"v3"),u=a?a.build(e,"f"):void 0,m=`reflect( -normalize( ${c} ), ${l} )`;u&&(m=`normalize( mix( ${m}, ${l}, ${u} * ${u} ) )`);let p=`inverseTransformDirection( ${m}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),n="reflectVec"):n=p;break}case Bt.CUBE:{let s=new Bt(Bt.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),n="reflectCubeVec"):n=a;break}case Bt.SPHERE:{let s=new Bt(Bt.VECTOR).build(e,"v3"),a="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),n="reflectSphereVec"):n=a;break}}return e.format(n,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},rr=Bt;rr.CUBE="cube",rr.SPHERE="sphere",rr.VECTOR="vector";var qs=class extends ae{constructor(e=new mt,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new rn(this.value,r??new rr(rr.VECTOR),o),this.irradianceNode=new rn(this.value,new Ye(Ye.WORLD),new Y(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};import{CubeTexture as mS}from"three";var $s=class extends Ce{constructor(e=new mS,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new rr,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv?.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+o+", "+n+", "+s+" )":a="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new at(new ve("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,r)}};var gd=["x","y","z","w"],yS=["float","vec2","vec3","vec4"],xS={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},vS={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Xs=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let s="";n=n.sort(t);for(let a=0;a<n.length;a++)n[a].src&&(s+=n[a].src+`
85
+ `);return s}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
86
+ // NOTE: Include Spline's blending modes. This could be part of BlendNode
87
+ #define SPE_BLENDING_NORMAL 0
88
+ #define SPE_BLENDING_MULTIPLY 1
89
+ #define SPE_BLENDING_SCREEN 2
90
+ #define SPE_BLENDING_OVERLAY 3
35
91
 
36
- #ifdef GL_EXT_shader_texture_lod
37
- vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
38
- #else
39
- vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
40
- #endif
92
+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
93
+ return mix( a, b, alpha );
94
+ }
41
95
 
42
- vec3 col = tmp.rgb;
43
- float lalpha = alpha * tmp.a;
44
- if ( crop > 0.5 ) {
45
- if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
46
- lalpha = 0.0;
47
- }
48
- }
49
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
50
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
51
- return col;
96
+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
97
+ return mix( a, a * b, alpha );
52
98
  }
53
- `),r=new K(`
54
- vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
55
- vec3 posN = normalize(vPosition);
56
- float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
57
- float v = 0.5 + asin(posN.y) / 3.1415;
58
99
 
59
- vec2 calculatedUv = vec2(u,v);
60
- vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
100
+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
101
+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
102
+ return mix( a, tmp, alpha );
103
+ }
61
104
 
62
- vec2 df = fwidth(uvs);
63
- if(df.x > 0.5) df.x = 0.;
64
- #ifdef GL_EXT_shader_texture_lod
65
- vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
66
- #else
67
- vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
68
- #endif
105
+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
106
+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
107
+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
108
+ }
69
109
 
70
- vec3 col = tmp.rgb;
71
- float lalpha = alpha * tmp.a;
72
- if ( crop > 0.5 ) {
73
- if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
74
- lalpha = 0.0;
75
- }
76
- }
77
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
78
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
79
- return col;
110
+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
111
+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
112
+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
113
+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
114
+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
115
+ return vec3( 1.0 );
80
116
  }
81
- `),o=new K(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
117
+ `,"#include <packing>","#include <common>"].join(`
118
+ `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
119
+ `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
120
+ accumAlpha += (1.0 - accumAlpha) * alpha;
121
+ }`,""].join(`
122
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.material=t,this.renderer=e,this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
123
+ `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
124
+ `}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
125
+ `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
126
+ `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,o="varying",n="V",s=""){let a=this.getVars(o),l=a[t];if(!l){let c=a.length;l={name:r||"node"+n+c+(s?"_"+s:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,o){return this.getVar(t,e,r,this.shader,"T",o)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
127
+ `)}getVarListCode(t,e){e=e??"";let r="";for(let o=0,n=t.length;o<n;++o){let s=t[o],a=s.type,l=s.name,c=s.size,u=this.getFormatByType(a);if(u===void 0)throw new Error("Node pars "+u+" not found.");u.includes("[]")?r+=e+" "+u.substring(0,u.length-2)+" "+l+`[${c}];
128
+ `:r+=e+" "+u+" "+l+`;
129
+ `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof Xe?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,n,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new $n({type:e,size:r.size,name:o||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new $n({type:e,name:o||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,o,n){return this.createUniform("vertex",t,e,r,o,n)}createFragmentUniform(t,e,r,o,n){return this.createUniform("fragment",t,e,r,o,n)}include(t,e,r){let o;if(t=typeof t=="string"?je.get(t):t,this.context.include===!1)return t.name;t instanceof X?o=this.includes.functions:t instanceof ye?o=this.includes.consts:t instanceof Zo&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(t){let s=n[t.name];if(s||(s=n[t.name]={node:t,deps:[]},n.push(s),s.src=t.build(this,"source")),t instanceof X&&e&&n[e.name]&&n[e.name].deps.indexOf(t)===-1&&(n[e.name].deps.push(t),t.includes?.length)){let a=0;do this.include(t.includes[a++],e);while(a<t.includes.length)}return r&&(s.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return yS[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case dS:case fS:return new $s(r);case hS:return new qs(new mt(r));default:return new mt(r)}else{if(r.isVector2)return new ke(r);if(r.isVector3)return new Je(r);if(r.isVector4)return new At(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return xS[t]||t}getFormatByType(t){return vS[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return gd[t]}getIndexByElement(t){return gd.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=hd,e===hd&&this.context.gamma&&(e=gS),e}};import{Texture as Js,Vector2 as Tr,Vector3 as ir,Vector4 as ln}from"three";var we=class extends Ce{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof Qe?e:new Qe(e||0,r,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,n,s,a){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,r,o,n,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,s,a,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,s,a,this.getLabel())),e.format(l.fragment.name,n,r))}generateReadonly(e,r,o,n,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,r)}};var he=class extends Ce{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,n,s,a){return e.format(this.value.toString(),n,r)}};import{UniformsLib as bS,UniformsUtils as SS}from"three";var Ur=class extends Xe{constructor(){super("basic");this.nodeType="Basic";this.color=new we(5855577),this.shadingAlpha=new Y(1),this.shadingBlend=new he(0)}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(SS.merge([bS.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
130
+ `));let n=["#include <beginnormal_vertex>",`
131
+ #if !defined( USE_LAYER_DISPLACE )
132
+ #include <defaultnormal_vertex>
133
+ #endif
82
134
 
83
- vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
84
- vec4 tmp = texture2D( tex, uvs );
135
+ vec3 displaced_position = position;
136
+ vec3 displaced_normal = normal;
85
137
 
86
- vec3 col = tmp.rgb;
138
+ #if defined( USE_LAYER_DISPLACE )
139
+ vec3 transformed;
140
+ vec3 transformedNormal;
141
+ #endif
142
+ `,"#include <normal_vertex>",`
143
+ #if !defined( USE_LAYER_DISPLACE )
144
+ #include <begin_vertex>
145
+ #endif /* !USE_LAYER_DISPLACE */
146
+ `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
147
+ `)}else{this.color===void 0&&(this.color=new we(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
148
+ `));let a=["#include <normal_fragment_begin>",o.code];n&&a.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?a.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):a.push(`vec3 finalColor = ${o.result};`),n?a.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} );`):a.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a.push("#include <fog_fragment>","#include <dithering_fragment>"),r=a.join(`
149
+ `)}return r}};import{UniformsLib as yd,UniformsUtils as wS}from"three";var He=class extends Ce{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var Yn=class extends Xe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new we(5855577),this.emissive=new we(0),this.emissiveIntensity=new Y(1),this.penumbraSize=new He(5,.5),this.shadingAlpha=new Y(1),this.shadingBlend=new he(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(wS.merge([yd.fog,yd.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
150
+ `));let n=["#include <beginnormal_vertex>",`
151
+ #ifndef USE_LAYER_DISPLACE
152
+ #include <defaultnormal_vertex>
153
+ #endif
87
154
 
88
- float lalpha = alpha * tmp.a;
89
- if ( crop > 0.5 ) {
90
- if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
91
- lalpha = 0.0;
92
- }
93
- }
94
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
95
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
96
- return col;
97
- }`);return{cylindrical:e,spherical:r,uv:o}}();var Ml=class extends ae{constructor(e,r,o,n,s,a,l){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=o,this.intensity=n,this.factor=s,this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Ml.Nodes.fresnel),n=[];return n.push(this.color.build(e,"c")),n.push(this.bias.build(e,"f")),n.push(this.scale.build(e,"f")),n.push(this.intensity.build(e,"f")),n.push(this.factor.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},Kn=Ml;Kn.Nodes=function(){return{fresnel:new K(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
98
- float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
155
+ vec3 displaced_position = position;
156
+ vec3 displaced_normal = normal;
99
157
 
100
- float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
101
- calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
102
- accumAlpha += (1.0 - accumAlpha) * lalpha;
103
- return color;
104
- }`)}}();var SS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Al=class extends ae{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Al.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,s){this.src=e||"";let a,l,c="",h=SS.exec(e);this.useDefine=s??this.src.charAt(0)==="#",h&&h.length>1?(l=h[1],a=h[2],c=h[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,s){return e.format(this.name,this.getType(e),r)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},xe=Al;xe.PI="PI",xe.PI2="PI2",xe.RECIPROCAL_PI="RECIPROCAL_PI",xe.RECIPROCAL_PI2="RECIPROCAL_PI2",xe.LOG2="LOG2",xe.EPSILON="EPSILON";var Yn=(n=>(n.SIMPLEX="simplex3d",n.SIMPLEX_FRACTAL="simplex3dFractal",n.ASHIMA="simplexAshima",n.FBM="fbm",n.PERLIN="perlin",n))(Yn||{}),nt=function(){let t=new K(`vec3 random3(vec3 c) {
105
- float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
106
- vec3 r;
107
- r.z = fract(512.0*j);
108
- j *= .125;
109
- r.x = fract(512.0*j);
110
- j *= .125;
111
- r.y = fract(512.0*j);
112
- return r-0.5;
113
- }`),e=new K(`float simplex3d(vec3 p) {
114
- vec3 s = floor(p + dot(p, vec3(F3)));
115
- vec3 x = p - s + dot(s, vec3(G3));
116
-
117
- vec3 e = step(vec3(0.0), x - x.yzx);
118
- vec3 i1 = e*(1.0 - e.zxy);
119
- vec3 i2 = 1.0 - e.zxy*(1.0 - e);
120
-
121
- vec3 x1 = x - i1 + G3;
122
- vec3 x2 = x - i2 + 2.0*G3;
123
- vec3 x3 = x - 1.0 + 3.0*G3;
124
-
125
- vec4 w, d;
126
-
127
- w.x = dot(x, x);
128
- w.y = dot(x1, x1);
129
- w.z = dot(x2, x2);
130
- w.w = dot(x3, x3);
131
-
132
- w = max(0.6 - w, 0.0);
133
-
134
- d.x = dot(random3(s), x);
135
- d.y = dot(random3(s + i1), x1);
136
- d.z = dot(random3(s + i2), x2);
137
- d.w = dot(random3(s + 1.0), x3);
138
-
139
- w *= w;
140
- w *= w;
141
- d *= w;
142
-
143
- return dot(d, vec4(52.0));
144
- }`,[t]);e.keywords.F3=new xe("float F3 0.3333333"),e.keywords.G3=new xe("float G3 0.1666667");let r=new K(`float simplex3dFractal(vec3 m) {
145
- mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
146
- mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
147
- mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
148
- return 0.5333333 * simplex3d(m * rot1)
149
- + 0.2666667 * simplex3d(2.0 * m * rot2)
150
- + 0.1333333 * simplex3d(4.0 * m * rot3)
151
- + 0.0666667 * simplex3d(8.0 * m);
152
- }`,[e]),o=new K("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),n=new K("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new K(`float simplexAshima(vec3 v) {
153
- const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
154
- const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
155
- vec3 i = floor(v + dot(v, C.yyy) );
156
- vec3 x0 = v - i + dot(i, C.xxx) ;
157
- vec3 g = step(x0.yzx, x0.xyz);
158
- vec3 l = 1.0 - g;
159
- vec3 i1 = min( g.xyz, l.zxy );
160
- vec3 i2 = max( g.xyz, l.zxy );
161
- vec3 x1 = x0 - i1 + 1.0 * C.xxx;
162
- vec3 x2 = x0 - i2 + 2.0 * C.xxx;
163
- vec3 x3 = x0 - 1. + 3.0 * C.xxx;
164
- i = mod(i, 289.0 );
165
- vec4 p = permute( permute( permute(
166
- i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
167
- + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
168
- + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
169
- float n_ = 1.0/7.0; // N=7
170
- vec3 ns = n_ * D.wyz - D.xzx;
171
- vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
172
- vec4 x_ = floor(j * ns.z);
173
- vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
174
- vec4 x = x_ *ns.x + ns.yyyy;
175
- vec4 y = y_ *ns.x + ns.yyyy;
176
- vec4 h = 1.0 - abs(x) - abs(y);
177
- vec4 b0 = vec4( x.xy, y.xy );
178
- vec4 b1 = vec4( x.zw, y.zw );
179
- vec4 s0 = floor(b0)*2.0 + 1.0;
180
- vec4 s1 = floor(b1)*2.0 + 1.0;
181
- vec4 sh = -step(h, vec4(0.0));
182
- vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
183
- vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
184
- vec3 p0 = vec3(a0.xy,h.x);
185
- vec3 p1 = vec3(a0.zw,h.y);
186
- vec3 p2 = vec3(a1.xy,h.z);
187
- vec3 p3 = vec3(a1.zw,h.w);
188
- vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
189
- p0 *= norm.x;
190
- p1 *= norm.y;
191
- p2 *= norm.z;
192
- p3 *= norm.w;
193
- vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
194
- m = m * m;
195
- return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
196
- dot(p2,x2), dot(p3,x3) ) );
197
- }`,[o,n]),a=new K("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new K("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new K(`float noise(vec3 p){
198
- vec3 a = floor(p);
199
- vec3 d = p - a;
200
- d = d * d * (3.0 - 2.0 * d);
201
- vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
202
- vec4 k1 = perm(b.xyxy);
203
- vec4 k2 = perm(k1.xyxy + b.zzww);
204
- vec4 c = k2 + a.zzzz;
205
- vec4 k3 = perm(c);
206
- vec4 k4 = perm(c + 1.0);
207
- vec4 o1 = fract(k3 * (1.0 / 41.0));
208
- vec4 o2 = fract(k4 * (1.0 / 41.0));
209
- vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
210
- vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
211
- return o4.y * d.y + o4.x * (1.0 - d.y);
212
- }`,[l]),h=new K(`float fbm(vec3 x) {
213
- float v = 0.0;
214
- float a = 0.5;
215
- vec3 shift = vec3(100);
216
- for (int i = 0; i < NUM_OCTAVES; ++i) {
217
- v += a * noise(x);
218
- x = x * 2.0 + shift;
219
- a *= 0.5;
220
- }
221
- return v;
222
- }`,[c]);h.keywords.NUM_OCTAVES=new xe(`int NUM_OCTAVES ${5}`);let p=new K("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),u=new K(`float perlin(vec3 P){
223
- vec3 Pi0 = floor(P);
224
- vec3 Pi1 = Pi0 + vec3(1.0);
225
- Pi0 = mod(Pi0, 289.0);
226
- Pi1 = mod(Pi1, 289.0);
227
- vec3 Pf0 = fract(P);
228
- vec3 Pf1 = Pf0 - vec3(1.0);
229
- vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
230
- vec4 iy = vec4(Pi0.yy, Pi1.yy);
231
- vec4 iz0 = Pi0.zzzz;
232
- vec4 iz1 = Pi1.zzzz;
233
- vec4 ixy = permute(permute(ix) + iy);
234
- vec4 ixy0 = permute(ixy + iz0);
235
- vec4 ixy1 = permute(ixy + iz1);
236
- vec4 gx0 = ixy0 / 7.0;
237
- vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
238
- gx0 = fract(gx0);
239
- vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
240
- vec4 sz0 = step(gz0, vec4(0.0));
241
- gx0 -= sz0 * (step(0.0, gx0) - 0.5);
242
- gy0 -= sz0 * (step(0.0, gy0) - 0.5);
243
- vec4 gx1 = ixy1 / 7.0;
244
- vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
245
- gx1 = fract(gx1);
246
- vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
247
- vec4 sz1 = step(gz1, vec4(0.0));
248
- gx1 -= sz1 * (step(0.0, gx1) - 0.5);
249
- gy1 -= sz1 * (step(0.0, gy1) - 0.5);
250
- vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
251
- vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
252
- vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
253
- vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
254
- vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
255
- vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
256
- vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
257
- vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
258
- vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
259
- g000 *= norm0.x;
260
- g010 *= norm0.y;
261
- g100 *= norm0.z;
262
- g110 *= norm0.w;
263
- vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
264
- g001 *= norm1.x;
265
- g011 *= norm1.y;
266
- g101 *= norm1.z;
267
- g111 *= norm1.w;
268
- float n000 = dot(g000, Pf0);
269
- float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
270
- float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
271
- float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
272
- float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
273
- float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
274
- float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
275
- float n111 = dot(g111, Pf1);
276
- vec3 fade_xyz = fade(Pf0);
277
- vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
278
- vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
279
- float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
280
- return 2.2 * n_xyz;
281
- }`,[o,n,p]);return{simplex:e,simplexFractal:r,simplexAshima:s,fbm:h,perlin:u}}();var Ol=class extends ae{constructor(e,r,o,n,s,a,l){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=s,this.offset=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Ol.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Jn=Ol;Jn.Nodes=function(){let e=new K(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
282
- vec3 st = position / noiseScale;
283
- vec3 q = vec3(simplex3d(st),
284
- simplex3d(st + vec3(1.0)),
285
- simplex3d(st + vec3(1.0)));
286
-
287
- vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
288
- simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
289
- simplex3d(st * q));
290
-
291
- float noise = simplex3d(st + r);
292
-
293
- return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
294
- }`,[nt.simplex]);return{rainbow:new K(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
295
- vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
296
-
297
- float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
298
- float lalpha = alpha * rainbowContribution;
299
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
300
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
301
-
302
- return res;
303
- }`,[e])}}();var Dl=class extends ae{constructor(e,r,o,n,s,a,l,c,h,p){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=n,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=c,this.offset=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Dl.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.positioning=e.positioning.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.source=e.source.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.shadowColor=e.shadowColor.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Qn=Dl;Qn.Nodes=function(){let e=new K(`float rand(float n) {
304
- return fract(sin(n) * 43758.5453123);
305
- }`),r=new K(`float hash1(float p) {
306
- p = fract(p * 0.011);
307
- p *= p + 7.5;
308
- p *= p + p;
309
- return fract(p);
310
- }`),o=new K(`float valueNoise(vec3 x) {
311
- const vec3 step = vec3(110, 241, 171);
312
-
313
- vec3 i = floor(x);
314
- vec3 f = fract(x);
315
-
316
- // For performance, compute the base input to a 1D hash from the integer part of the argument and the
317
- // incremental change to the 1D based on the 3D -> 1D wrapping
318
- float n = dot(i, step);
319
-
320
- vec3 u = f * f * (3.0 - 2.0 * f);
321
- return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
322
- mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
323
- mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
324
- mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
325
- }`,[r]),n=new K(`vec3 hash3(vec3 x) {
326
- x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
327
- dot(x,vec3(269.5, 183.3, 246.1)),
328
- dot(x,vec3(113.5, 271.9, 124.6)));
329
-
330
- return fract(sin(x)*43758.5453123);
331
- }`),s=new K(`vec3 voronoiNoise(in vec3 x)
332
- {
333
- vec3 p = floor(x);
334
- vec3 f = fract(x);
335
-
336
- float id = 0.0;
337
- vec2 res = vec2(100.0);
338
-
339
- for(int k=-1; k<=1; k++)
340
- for(int j=-1; j<=1; j++)
341
- for(int i=-1; i<=1; i++)
342
- {
343
- vec3 b = vec3(float(i), float(j), float(k));
344
-
345
- // Comment out the "+ hash(p + b);" part below to get "square" cells
346
- vec3 r = vec3(b) - f + hash3(p + b);
347
- float d = dot(r, r);
348
-
349
- if (d < res.x)
350
- {
351
- id = dot(p + b, vec3(1.0, 57.0, 113.0));
352
- res = vec2(d, res.x);
353
- }
354
- else if (d < res.y)
355
- {
356
- res.y = d;
357
- }
358
- }
359
-
360
- return vec3(sqrt(res), abs(id));
361
- }
362
- `,[n]);return{toon:new K(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float alpha, out float calpha) {
363
- float t = 0.0;
364
- float shadow = 1.0;
365
-
366
- if (positioning == 0) {
367
-
368
- // Can't do this mode if lighting is "none"
369
- #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
370
-
371
- // Algorithm from Chapter 10 of Graphics Shaders
372
- const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
373
- vec3 lpos;
374
- vec3 l;
375
- float dproduct;
376
-
377
- #if (NUM_POINT_LIGHTS > 0)
378
-
379
- #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
380
- PointLightShadow pointLightShadow;
381
- #endif
382
-
383
- #pragma unroll_loop_start
384
- for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
385
- // Light positions are in view-space for some reason?
386
- lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
387
- l = normalize(lpos - worldPosition);
388
-
389
- dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
390
-
391
- // TODO: we want to use "intensity" but it isn't available in the shader code
392
- //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
393
-
394
- t = max(t, dproduct);
395
-
396
- // Accumulate shadow contribution
397
- #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
398
- pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
399
- shadow *= getPointShadow(
400
- pointShadowMap[UNROLLED_LOOP_INDEX],
401
- pointLightShadow.shadowMapSize,
402
- pointLightShadow.shadowBias,
403
- pointLightShadow.shadowRadius,
404
- vPointShadowCoord[UNROLLED_LOOP_INDEX],
405
- pointLightShadow.shadowCameraNear,
406
- pointLightShadow.shadowCameraFar);
407
- #endif
408
- }
409
- #pragma unroll_loop_end
410
-
411
- #endif
412
-
413
- #if NUM_DIR_LIGHTS > 0
414
-
415
- #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
416
- DirectionalLightShadow directionalLightShadow;
417
- #endif
418
-
419
- #pragma unroll_loop_start
420
- for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
421
- // Use the direction vector for directional lights instead
422
- l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
423
-
424
- dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
425
- t = max(t, dproduct);
426
-
427
- // Accumulate shadow contribution
428
- #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
429
- directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
430
- shadow *= getShadow(
431
- UNROLLED_LOOP_INDEX,
432
- directionalShadowMap[UNROLLED_LOOP_INDEX],
433
- directionalLightShadow.shadowMapSize,
434
- directionalLightShadow.shadowBias,
435
- directionalLightShadow.shadowRadius,
436
- vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
437
- #endif
438
- }
439
- #pragma unroll_loop_end
440
-
441
- #endif
442
-
443
- #if NUM_SPOT_LIGHTS > 0
444
-
445
- #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
446
- SpotLightShadow spotLightShadow;
447
- #endif
448
-
449
- #pragma unroll_loop_start
450
- for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
451
- lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
452
- l = normalize(lpos - worldPosition);
453
-
454
- dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
455
- t = max(t, dproduct);
456
-
457
- // Accumulate shadow contribution
458
- #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
459
- spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
460
- shadow *= getShadow(
461
- UNROLLED_LOOP_INDEX,
462
- spotShadowMap[UNROLLED_LOOP_INDEX],
463
- spotLightShadow.shadowMapSize,
464
- spotLightShadow.shadowBias,
465
- spotLightShadow.shadowRadius,
466
- vSpotShadowCoord[UNROLLED_LOOP_INDEX]);
467
- #endif
468
- }
469
- #pragma unroll_loop_end
470
-
471
- #endif
472
-
473
- t = clamp(t, 0.0, 1.0);
474
-
158
+ #ifdef USE_LAYER_DISPLACE
159
+ vec3 transformed;
160
+ vec3 transformedNormal;
161
+ #endif
162
+ `,"#include <normal_vertex>",`
163
+ #ifndef USE_LAYER_DISPLACE
164
+ #include <begin_vertex>
165
+ #endif
166
+ `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
167
+ vec3 diffuse = vec3( 1.0 );
168
+ GeometricContext geometry;
169
+ geometry.position = mvPosition.xyz;
170
+ geometry.normal = normalize( transformedNormal );
171
+ geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
172
+ GeometricContext backGeometry;
173
+ backGeometry.position = geometry.position;
174
+ backGeometry.normal = -geometry.normal;
175
+ backGeometry.viewDir = geometry.viewDir;
176
+ vLightFront = vec3( 0.0 );
177
+ vIndirectFront = vec3( 0.0 );
178
+ #ifdef DOUBLE_SIDED
179
+ vLightBack = vec3( 0.0 );
180
+ vIndirectBack = vec3( 0.0 );
181
+ #endif
182
+ IncidentLight directLight;
183
+ float dotNL;
184
+ vec3 directLightColor_Diffuse;
185
+ vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
186
+ vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
187
+ #ifdef DOUBLE_SIDED
188
+ vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
189
+ vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
190
+ #endif
191
+ #if NUM_POINT_LIGHTS > 0
192
+ #pragma unroll_loop_start
193
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
194
+ getPointLightInfo( pointLights[ i ], geometry, directLight );
195
+ dotNL = dot( geometry.normal, directLight.direction );
196
+ directLightColor_Diffuse = directLight.color;
197
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
198
+ #ifdef DOUBLE_SIDED
199
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
200
+ #endif
201
+ }
202
+ #pragma unroll_loop_end
203
+ #endif
204
+ #if NUM_SPOT_LIGHTS > 0
205
+ #pragma unroll_loop_start
206
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
207
+ getSpotLightInfo( spotLights[ i ], geometry, directLight );
208
+ dotNL = dot( geometry.normal, directLight.direction );
209
+ directLightColor_Diffuse = directLight.color;
210
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
211
+ #ifdef DOUBLE_SIDED
212
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
213
+ #endif
214
+ }
215
+ #pragma unroll_loop_end
216
+ #endif
217
+ #if NUM_DIR_LIGHTS > 0
218
+ #pragma unroll_loop_start
219
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
220
+ getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
221
+ dotNL = dot( geometry.normal, directLight.direction );
222
+ directLightColor_Diffuse = directLight.color;
223
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
224
+ #ifdef DOUBLE_SIDED
225
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
226
+ #endif
227
+ }
228
+ #pragma unroll_loop_end
229
+ #endif
230
+ #if NUM_HEMI_LIGHTS > 0
231
+ #pragma unroll_loop_start
232
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
233
+ vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
234
+ #ifdef DOUBLE_SIDED
235
+ vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
236
+ #endif
237
+ }
238
+ #pragma unroll_loop_end
475
239
  #endif
240
+ `," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
241
+ `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new we(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
242
+ `));let m=["#include <normal_fragment_begin>",`
243
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
244
+ vec3 viewdx = dFdx(vViewPosition);
245
+ vec3 viewdy = dFdy(vViewPosition);
246
+ vec3 faceNormal = normalize(cross(viewdx, viewdy));
247
+ bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
248
+ `,"#include <clipping_planes_fragment>"];m.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),u&&m.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),m.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),n&&m.push(n.code,"reflectedLight.directDiffuse += "+n.result+" * "+s.result+";"),m.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),m.push(`
249
+ if (outgoingLight != diffuseColor) {
250
+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
251
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
252
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
253
+ }
254
+ `),c&&m.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
255
+ `)}return r}};import{UniformsLib as xd,UniformsUtils as TS}from"three";var Ys=class extends Xe{constructor(){super("phong");this.nodeType="Phong";this.color=new we(5855577),this.specular=new we(1118481),this.shininess=new Y(30),this.penumbraSize=new He(5,.5),this.shadingAlpha=new Y(1),this.shadingBlend=new he(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(TS.merge([xd.fog,xd.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
256
+ `));let n=["#include <beginnormal_vertex>",`
257
+ #ifndef USE_LAYER_DISPLACE
258
+ #include <defaultnormal_vertex>
259
+ #endif
476
260
 
477
- } else if (positioning == 1) {
478
-
479
- vec3 origin = mix(position, worldPosition, float(isWorldSpace));
480
- vec3 direction = normalize(source - origin);
481
- t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
482
261
 
483
- } else {
262
+ vec3 displaced_position = position;
263
+ vec3 displaced_normal = normal;
484
264
 
485
- vec3 origin = worldPosition;
486
- vec3 source = cameraPosition - offset;
487
- vec3 direction = normalize(source - origin);
488
- t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
489
-
265
+ #ifdef USE_LAYER_DISPLACE
266
+ vec3 transformed;
267
+ vec3 transformedNormal;
268
+ #endif
269
+ `,"#include <normal_vertex>",`
270
+ #ifndef USE_LAYER_DISPLACE
271
+ #include <begin_vertex>
272
+ #endif
273
+ `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
274
+ `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new we(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
275
+ `));let m=["#include <normal_fragment_begin>",`
276
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
277
+ vec3 viewdx = dFdx(vViewPosition);
278
+ vec3 viewdy = dFdy(vViewPosition);
279
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
280
+ if (dot(normal, faceNormal) < 0.0) {
281
+ normal *= -1.0;
282
+ }
283
+ `," BlinnPhongMaterial material;"];m.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),u&&m.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),m.push("material.diffuseColor = diffuseColor;"),m.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),m.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),m.push(`
284
+ if (outgoingLight != diffuseColor) {
285
+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
286
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
287
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
490
288
  }
289
+ `),c&&m.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
290
+ `)}return r}};import{UniformsLib as Al,UniformsUtils as NS}from"three";var Kn=class extends Xe{constructor(){super("standard");this.nodeType="Standard";this.color=new we(5855577),this.roughness=new Y(.3),this.metalness=new Y(0),this.reflectivity=new Y(.5),this.penumbraSize=new He(5,.5),this.shadingAlpha=new Y(1),this.shadingBlend=new he(0)}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(NS.merge([Al.fog,Al.lights])),Al.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
291
+ `));let n=["#include <beginnormal_vertex>",`
292
+ #if !defined( USE_LAYER_DISPLACE )
293
+ #include <defaultnormal_vertex>
294
+ #endif
491
295
 
492
- if (noiseStrength > 0.0) {
493
- // Distort with noise
494
- vec3 st = position / noiseScale;
495
-
496
- // Voronoi "smooth" noise
497
- float noise = 1.0 - voronoiNoise(st).x;
296
+ vec3 displaced_position = position;
297
+ vec3 displaced_normal = normal;
498
298
 
499
- // Voronoi cellular noise
500
- //float noise = 1.0 - rand(voronoiNoise(st).z);
299
+ #if defined( USE_LAYER_DISPLACE )
300
+ vec3 transformed;
301
+ vec3 transformedNormal;
302
+ #endif
303
+ `,"#include <normal_vertex>",`
304
+ #if !defined( USE_LAYER_DISPLACE )
305
+ #include <begin_vertex>
306
+ #endif /* !USE_LAYER_DISPLACE */
307
+ `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
308
+ `)}else{e.mergeUniform({penumbraSize:this.penumbraSize});let o={gamma:!0};this.color===void 0&&(this.color=new we(5855577)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let n=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),a=this.metalness.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,m=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=m!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
309
+ `));let d=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
310
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
311
+ vec3 viewdx = dFdx(vViewPosition);
312
+ vec3 viewdy = dFdy(vViewPosition);
313
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
314
+ if (dot(normal, faceNormal) < 0.0) {
315
+ normal *= -1.0;
316
+ }
317
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];d.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",a.code," float metalnessFactor = "+a.result+";"),m&&d.push(m.code,"#ifdef ALPHATEST"," if ( "+m.result+" <= ALPHATEST ) discard;","#endif"),d.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),d.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),p?d.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):d.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),d.push("#include <lights_fragment_begin>"),d.push("#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),d.push(`
318
+ if (outgoingLight != diffuseColor) {
319
+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
320
+ accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
321
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
322
+ }
323
+ `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),m?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${m.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
324
+ `)}return r}};import{UniformsLib as vd,UniformsUtils as CS}from"three";var Qn=class extends Xe{constructor(){super("toon");this.nodeType="Toon";this.color=new we(5855577),this.specular=new we(1118481),this.shininess=new Y(30),this.penumbraSize=new He(5,.5),this.shadingAlpha=new Y(1),this.shadingBlend=new he(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(CS.merge([vd.fog,vd.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
325
+ `));let n=["#include <beginnormal_vertex>",`
326
+ #ifndef USE_LAYER_DISPLACE
327
+ #include <defaultnormal_vertex>
328
+ #endif
501
329
 
502
- // Position warp noise
503
- // vec3 offset = vec3(
504
- // simplex3d(st),
505
- // simplex3d(st + vec3(111.1, 143.89, 217.19)),
506
- // simplex3d(st + vec3(171.1, 247.89, 117.23))
507
- // );
508
- // st += offset;
509
- // float noise = valueNoise(st);
330
+ vec3 displaced_position = position;
331
+ vec3 displaced_normal = normal;
332
+
333
+ #ifdef USE_LAYER_DISPLACE
334
+ vec3 transformed;
335
+ vec3 transformedNormal;
336
+ #endif
337
+ `,"#include <normal_vertex>",`
338
+ #ifndef USE_LAYER_DISPLACE
339
+ #include <begin_vertex>
340
+ #endif
341
+ `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
342
+ `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new we(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
343
+ varying vec3 vViewPosition;
344
+ struct ToonMaterial {
345
+ vec3 diffuseColor;
346
+ vec3 specularColor;
347
+ float specularShininess;
348
+ float specularStrength;
349
+ };
350
+ void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
351
+ vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
352
+
353
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
354
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
355
+ }
356
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
357
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
358
+ }
359
+ #define RE_Direct RE_Direct_Toon
360
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
361
+ #define Material_LightProbeLOD( material ) (0)
362
+ `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
363
+ `));let m=["#include <normal_fragment_begin>",`
364
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
365
+ vec3 viewdx = dFdx(vViewPosition);
366
+ vec3 viewdy = dFdy(vViewPosition);
367
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
368
+ if (dot(normal, faceNormal) < 0.0) {
369
+ normal *= -1.0;
370
+ }
371
+ `," ToonMaterial material;"];m.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),u&&m.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),m.push("material.diffuseColor = diffuseColor;"),m.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),m.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),m.push(`
372
+ if (outgoingLight != diffuseColor) {
373
+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
374
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
375
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
376
+ }
377
+ `),c&&m.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
378
+ `)}return r}};var jr=class extends Ce{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,n){return e.format(this.value?"true":"false",n,r)}};import{Matrix3 as LS}from"three";var on=class extends Ce{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new LS}generateReadonly(e,r,o,n,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",n,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Vector4 as bd}from"three";var Et=class extends Ce{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof bd?new Array(e).fill(r):new Array(e).fill(new bd(0))}};var Jn=(n=>(n.SIMPLEX="simplex3d",n.SIMPLEX_FRACTAL="simplex3dFractal",n.ASHIMA="simplexAshima",n.FBM="fbm",n.PERLIN="perlin",n))(Jn||{}),ot=function(){let t=new X(`vec3 random3(vec3 c) {
379
+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
380
+ vec3 r;
381
+ r.z = fract(512.0*j);
382
+ j *= .125;
383
+ r.x = fract(512.0*j);
384
+ j *= .125;
385
+ r.y = fract(512.0*j);
386
+ return r-0.5;
387
+ }`),e=new X(`float simplex3d(vec3 p) {
388
+ vec3 s = floor(p + dot(p, vec3(F3)));
389
+ vec3 x = p - s + dot(s, vec3(G3));
390
+
391
+ vec3 e = step(vec3(0.0), x - x.yzx);
392
+ vec3 i1 = e*(1.0 - e.zxy);
393
+ vec3 i2 = 1.0 - e.zxy*(1.0 - e);
394
+
395
+ vec3 x1 = x - i1 + G3;
396
+ vec3 x2 = x - i2 + 2.0*G3;
397
+ vec3 x3 = x - 1.0 + 3.0*G3;
398
+
399
+ vec4 w, d;
400
+
401
+ w.x = dot(x, x);
402
+ w.y = dot(x1, x1);
403
+ w.z = dot(x2, x2);
404
+ w.w = dot(x3, x3);
405
+
406
+ w = max(0.6 - w, 0.0);
407
+
408
+ d.x = dot(random3(s), x);
409
+ d.y = dot(random3(s + i1), x1);
410
+ d.z = dot(random3(s + i2), x2);
411
+ d.w = dot(random3(s + 1.0), x3);
412
+
413
+ w *= w;
414
+ w *= w;
415
+ d *= w;
416
+
417
+ return dot(d, vec4(52.0));
418
+ }`,[t]);e.keywords.F3=new ye("float F3 0.3333333"),e.keywords.G3=new ye("float G3 0.1666667");let r=new X(`float simplex3dFractal(vec3 m) {
419
+ mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
420
+ mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
421
+ mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
422
+ return 0.5333333 * simplex3d(m * rot1)
423
+ + 0.2666667 * simplex3d(2.0 * m * rot2)
424
+ + 0.1333333 * simplex3d(4.0 * m * rot3)
425
+ + 0.0666667 * simplex3d(8.0 * m);
426
+ }`,[e]),o=new X("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),n=new X("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new X(`float simplexAshima(vec3 v) {
427
+ const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
428
+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
429
+ vec3 i = floor(v + dot(v, C.yyy) );
430
+ vec3 x0 = v - i + dot(i, C.xxx) ;
431
+ vec3 g = step(x0.yzx, x0.xyz);
432
+ vec3 l = 1.0 - g;
433
+ vec3 i1 = min( g.xyz, l.zxy );
434
+ vec3 i2 = max( g.xyz, l.zxy );
435
+ vec3 x1 = x0 - i1 + 1.0 * C.xxx;
436
+ vec3 x2 = x0 - i2 + 2.0 * C.xxx;
437
+ vec3 x3 = x0 - 1. + 3.0 * C.xxx;
438
+ i = mod(i, 289.0 );
439
+ vec4 p = permute( permute( permute(
440
+ i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
441
+ + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
442
+ + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
443
+ float n_ = 1.0/7.0; // N=7
444
+ vec3 ns = n_ * D.wyz - D.xzx;
445
+ vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
446
+ vec4 x_ = floor(j * ns.z);
447
+ vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
448
+ vec4 x = x_ *ns.x + ns.yyyy;
449
+ vec4 y = y_ *ns.x + ns.yyyy;
450
+ vec4 h = 1.0 - abs(x) - abs(y);
451
+ vec4 b0 = vec4( x.xy, y.xy );
452
+ vec4 b1 = vec4( x.zw, y.zw );
453
+ vec4 s0 = floor(b0)*2.0 + 1.0;
454
+ vec4 s1 = floor(b1)*2.0 + 1.0;
455
+ vec4 sh = -step(h, vec4(0.0));
456
+ vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
457
+ vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
458
+ vec3 p0 = vec3(a0.xy,h.x);
459
+ vec3 p1 = vec3(a0.zw,h.y);
460
+ vec3 p2 = vec3(a1.xy,h.z);
461
+ vec3 p3 = vec3(a1.zw,h.w);
462
+ vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
463
+ p0 *= norm.x;
464
+ p1 *= norm.y;
465
+ p2 *= norm.z;
466
+ p3 *= norm.w;
467
+ vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
468
+ m = m * m;
469
+ return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
470
+ dot(p2,x2), dot(p3,x3) ) );
471
+ }`,[o,n]),a=new X("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new X("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new X(`float noise(vec3 p){
472
+ vec3 a = floor(p);
473
+ vec3 d = p - a;
474
+ d = d * d * (3.0 - 2.0 * d);
475
+ vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
476
+ vec4 k1 = perm(b.xyxy);
477
+ vec4 k2 = perm(k1.xyxy + b.zzww);
478
+ vec4 c = k2 + a.zzzz;
479
+ vec4 k3 = perm(c);
480
+ vec4 k4 = perm(c + 1.0);
481
+ vec4 o1 = fract(k3 * (1.0 / 41.0));
482
+ vec4 o2 = fract(k4 * (1.0 / 41.0));
483
+ vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
484
+ vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
485
+ return o4.y * d.y + o4.x * (1.0 - d.y);
486
+ }`,[l]),u=new X(`float fbm(vec3 x) {
487
+ float v = 0.0;
488
+ float a = 0.5;
489
+ vec3 shift = vec3(100);
490
+ for (int i = 0; i < NUM_OCTAVES; ++i) {
491
+ v += a * noise(x);
492
+ x = x * 2.0 + shift;
493
+ a *= 0.5;
494
+ }
495
+ return v;
496
+ }`,[c]);u.keywords.NUM_OCTAVES=new ye(`int NUM_OCTAVES ${5}`);let m=new X("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new X(`float perlin(vec3 P){
497
+ vec3 Pi0 = floor(P);
498
+ vec3 Pi1 = Pi0 + vec3(1.0);
499
+ Pi0 = mod(Pi0, 289.0);
500
+ Pi1 = mod(Pi1, 289.0);
501
+ vec3 Pf0 = fract(P);
502
+ vec3 Pf1 = Pf0 - vec3(1.0);
503
+ vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
504
+ vec4 iy = vec4(Pi0.yy, Pi1.yy);
505
+ vec4 iz0 = Pi0.zzzz;
506
+ vec4 iz1 = Pi1.zzzz;
507
+ vec4 ixy = permute(permute(ix) + iy);
508
+ vec4 ixy0 = permute(ixy + iz0);
509
+ vec4 ixy1 = permute(ixy + iz1);
510
+ vec4 gx0 = ixy0 / 7.0;
511
+ vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
512
+ gx0 = fract(gx0);
513
+ vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
514
+ vec4 sz0 = step(gz0, vec4(0.0));
515
+ gx0 -= sz0 * (step(0.0, gx0) - 0.5);
516
+ gy0 -= sz0 * (step(0.0, gy0) - 0.5);
517
+ vec4 gx1 = ixy1 / 7.0;
518
+ vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
519
+ gx1 = fract(gx1);
520
+ vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
521
+ vec4 sz1 = step(gz1, vec4(0.0));
522
+ gx1 -= sz1 * (step(0.0, gx1) - 0.5);
523
+ gy1 -= sz1 * (step(0.0, gy1) - 0.5);
524
+ vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
525
+ vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
526
+ vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
527
+ vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
528
+ vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
529
+ vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
530
+ vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
531
+ vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
532
+ vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
533
+ g000 *= norm0.x;
534
+ g010 *= norm0.y;
535
+ g100 *= norm0.z;
536
+ g110 *= norm0.w;
537
+ vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
538
+ g001 *= norm1.x;
539
+ g011 *= norm1.y;
540
+ g101 *= norm1.z;
541
+ g111 *= norm1.w;
542
+ float n000 = dot(g000, Pf0);
543
+ float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
544
+ float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
545
+ float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
546
+ float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
547
+ float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
548
+ float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
549
+ float n111 = dot(g111, Pf1);
550
+ vec3 fade_xyz = fade(Pf0);
551
+ vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
552
+ vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
553
+ float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
554
+ return 2.2 * n_xyz;
555
+ }`,[o,n,m]);return{simplex:e,simplexFractal:r,simplexAshima:s,fbm:u,perlin:p}}();var Zn=class extends ae{constructor(e,r,o,n,s,a,l,c,u,m,p,d){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=n,this.fB=s,this.distortion=a,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=m,this.alpha=p,this.noiseType=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,n,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(Jn)[this.noiseType.value],l=new X(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
556
+ vec3 st = position / size;
557
+ st /= scale;
558
+ vec3 q = vec3(${a}(st),
559
+ ${a}(st + vec3(1.0)),
560
+ ${a}(st + vec3(1.0)));
561
+ vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
562
+ ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
563
+ ${a}(st * q));
564
+ float f = ${a}(st + r);
565
+ vec4 color;
566
+ color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
567
+ color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
568
+ color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
510
569
 
511
- t += noise * noiseStrength;
512
- }
570
+ float lalpha = alpha * color.a;
571
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
513
572
 
514
- t = clamp(t, 0.0, 1.0);
573
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
574
+ return clamp(color, 0.0, 1.0).rgb;
575
+ }`,[ot.simplex,ot.simplexFractal,ot.simplexAshima,ot.fbm,ot.perlin]),c=e.include(l),u=[];return u.push(this.scale.build(e,"f")),u.push(this.size.build(e,"v3")),u.push(this.move.build(e,"f")),u.push(this.fA.build(e,"v2")),u.push(this.fB.build(e,"v2")),u.push(this.distortion.build(e,"v2")),u.push(this.colorA.build(e,"v4")),u.push(this.colorB.build(e,"v4")),u.push(this.colorC.build(e,"v4")),u.push(this.colorD.build(e,"v4")),u.push(this.alpha.build(e,"f")),u.push(this.calpha),e.format(c+"("+u.join(",")+")",this.getType(e),r)}};Zn.numOctaves=5;var Pl=class extends ae{constructor(e,r,o,n,s,a,l){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=o,this.intensity=n,this.factor=s,this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Pl.Nodes.fresnel),n=[];return n.push(this.color.build(e,"c")),n.push(this.bias.build(e,"f")),n.push(this.scale.build(e,"f")),n.push(this.intensity.build(e,"f")),n.push(this.factor.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ei=Pl;ei.Nodes=function(){return{fresnel:new X(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
576
+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
515
577
 
516
- // Compute ramp color
517
- float p;
518
- vec4 color = colors[0];
519
- for (int i = 1; i < COLORS_MAX; i++) {
520
- p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
521
- color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
522
- }
578
+ float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
579
+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
580
+ accumAlpha += (1.0 - accumAlpha) * lalpha;
581
+ return color;
582
+ }`)}}();var Ml=class extends ae{constructor(e,r,o,n,s,a,l){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=s,this.offset=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Ml.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ti=Ml;ti.Nodes=function(){let e=new X(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
583
+ vec3 st = position / noiseScale;
584
+ vec3 q = vec3(simplex3d(st),
585
+ simplex3d(st + vec3(1.0)),
586
+ simplex3d(st + vec3(1.0)));
523
587
 
524
- // Incorporate custom shadow color
525
- if (positioning == 0) {
588
+ vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
589
+ simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
590
+ simplex3d(st * q));
526
591
 
527
- vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
528
- color.rgb = mix(blendedShadow, color.rgb, shadow);
529
-
530
- }
592
+ float noise = simplex3d(st + r);
531
593
 
532
- // Accumulate alpha as usual
533
- float lalpha = alpha * color.a;
534
- calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
535
- accumAlpha += (1.0 - accumAlpha) * lalpha;
594
+ return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
595
+ }`,[ot.simplex]);return{rainbow:new X(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
596
+ vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
536
597
 
537
- return color.xyz;
598
+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
599
+ float lalpha = alpha * rainbowContribution;
600
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
601
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
538
602
 
539
- }`,[nt.simplex,e,o,s])}}();var _l=class extends ae{constructor(e,r,o,n,s,a,l,c,h,p,u,d,m,g,x,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=s,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=h,this.positionalLines=p,this.compensation=u,this.resolution=d,this.normalMap=m,this.depthMap=g,this.pixelRatio=x,this.alpha=y,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.firstTime){let o=this.outlineWidth.build(e,"f"),n=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),a=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(o,"uniform float"),e.addVertexParsVariable(n,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(a,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float");let l=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexFinalCode(`
603
+ return res;
604
+ }`,[e])}}();var Ol=class extends ae{constructor(e,r,o,n,s,a,l,c,u,m,p,d,f,g,x,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=s,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=m,this.compensation=p,this.resolution=d,this.normalMap=f,this.depthMap=g,this.pixelRatio=x,this.alpha=y,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.firstTime){let o=this.outlineWidth.build(e,"f"),n=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),a=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(o,"uniform float"),e.addVertexParsVariable(n,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(a,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float");let l=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexFinalCode(`
540
605
  vID = randomColor.r;
541
606
  if (${s}) {
542
607
  vec4 ${l}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
@@ -547,7 +612,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
547
612
  // if this offset is the biggest of all the potential offsets
548
613
  gl_Position = ${l}_clipPosition;
549
614
  }
550
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(_l.Nodes.outline),n=[];return n.push(this.outlineColor.build(e,"c")),n.push(this.contourColor.build(e,"c")),n.push(this.outlineWidth.build(e,"f")),n.push(this.contourWidth.build(e,"f")),n.push(this.contourThreshold.build(e,"f")),n.push(this.outlineThreshold.build(e,"f")),n.push(this.contourFrequency.build(e,"f")),n.push(this.outlineSmoothing.build(e,"f")),n.push(this.contourDirection.build(e,"v3")),n.push(this.positionalLines.build(e,"b")),n.push(this.resolution.build(e,"v2")),n.push(this.normalMap.getTexture(e,"t")),n.push(this.depthMap.getTexture(e,"t")),n.push(this.pixelRatio.build(e,"f")),n.push(this.compensation.build(e,"b")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),this.firstTime=!this.firstTime,e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}copy(e){return super.copy(e),this.outlineColor=e.outlineColor.clone(),this.contourColor=e.contourColor.clone(),this.outlineWidth=e.outlineWidth.clone(),this.contourWidth=e.contourWidth.clone(),this.contourThreshold=e.contourThreshold.clone(),this.outlineThreshold=e.outlineThreshold.clone(),this.contourFrequency=e.contourFrequency.clone(),this.outlineSmoothing=e.outlineSmoothing.clone(),this.contourDirection=e.contourDirection.clone(),this.positionalLines=e.positionalLines.clone(),this.compensation=e.compensation.clone(),this.alpha=e.alpha.clone(),this.normalMap=e.normalMap,this.depthMap=e.depthMap,this.resolution=e.resolution,this.pixelRatio=e.pixelRatio,this.calpha=e.calpha,this}},Zn=_l;Zn.Nodes=function(){let e=new K(`
615
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Ol.Nodes.outline),n=[];return n.push(this.outlineColor.build(e,"c")),n.push(this.contourColor.build(e,"c")),n.push(this.outlineWidth.build(e,"f")),n.push(this.contourWidth.build(e,"f")),n.push(this.contourThreshold.build(e,"f")),n.push(this.outlineThreshold.build(e,"f")),n.push(this.contourFrequency.build(e,"f")),n.push(this.outlineSmoothing.build(e,"f")),n.push(this.contourDirection.build(e,"v3")),n.push(this.positionalLines.build(e,"b")),n.push(this.resolution.build(e,"v2")),n.push(this.normalMap.getTexture(e,"t")),n.push(this.depthMap.getTexture(e,"t")),n.push(this.pixelRatio.build(e,"f")),n.push(this.compensation.build(e,"b")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),this.firstTime=!this.firstTime,e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},ri=Ol;ri.Nodes=function(){let e=new X(`
551
616
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
552
617
  {
553
618
  vec2 texelSize = (vec2(1.0) / resolution) * outlineWidth * pixelRatio;
@@ -648,7 +713,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
648
713
  float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
649
714
  return edgeNormal;
650
715
  }
651
- `);return{outline:new K(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float alpha, out float calpha) {
716
+ `);return{outline:new X(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float alpha, out float calpha) {
652
717
  vec3 result = outlineColor;
653
718
  float resultAlpha = 0.0;
654
719
 
@@ -687,11 +752,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
687
752
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
688
753
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
689
754
  return result;
690
- }`,[e])}}();var Bl=class extends ae{constructor(e,r,o,n,s,a,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(Bl.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ei=Bl;ei.Nodes=function(){let e=new K(`
755
+ }`,[e])}}();var _l=class extends ae{constructor(e,r,o,n,s,a,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(_l.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},oi=_l;oi.Nodes=function(){let e=new X(`
691
756
  float gaussian(vec2 i) {
692
757
  const float sigma = float(NUM_SAMPLES) * .25;
693
758
  return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
694
- }`),r=new K(`
759
+ }`),r=new X(`
695
760
  vec4 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
696
761
  // Slightly modified version of this:
697
762
  // https://www.shadertoy.com/view/ltScRG
@@ -718,7 +783,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
718
783
  #endif
719
784
  }
720
785
  return O / O.a;
721
- }`,[e]),o=new K(`
786
+ }`,[e]),o=new X(`
722
787
  vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
723
788
  // Direction of refracted light.
724
789
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
@@ -729,18 +794,18 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
729
794
  modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
730
795
  // The thickness is specified in local space.
731
796
  return normalize( refractionVector ) * thickness * modelScale;
732
- }`),n=new K(`
797
+ }`),n=new X(`
733
798
  float applyIorToRoughness( float roughness, float ior ) {
734
799
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
735
800
  // an IOR of 1.5 results in the default amount of microfacet refraction.
736
801
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
737
- } `),s=new K(`
802
+ } `),s=new X(`
738
803
  vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
739
804
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
740
805
  float lod = applyIorToRoughness(roughness, ior);
741
806
 
742
807
  return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
743
- }`,[n,r]),a=new K(`
808
+ }`,[n,r]),a=new X(`
744
809
  vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
745
810
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
746
811
  vec3 refractedRayExit = position + transmissionRay;
@@ -760,7 +825,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
760
825
  vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
761
826
  // Get the specular component.
762
827
  return vec4( ( 1.0 ) * transmittedLight.rgb, transmittedLight.a );
763
- }`,[s,o]);return{transmission:new K(`
828
+ }`,[s,o]);return{transmission:new X(`
764
829
  vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
765
830
  vec3 v = vec3(0.);
766
831
  if (isOrthographic) {
@@ -774,14 +839,103 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
774
839
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
775
840
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
776
841
  return transmission.rgb;
777
- }`,[a])}}();var El=class extends ae{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r}generate(e,r){if(e.isShader("fragment")){let o=e.include(El.Nodes.customNormal),n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.alpha.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},ti=El;ti.Nodes=function(){return{customNormal:new K(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
778
- vec3 normal = packNormalToRGB( norm ).rgb;
779
- normal *= step( vec3(0.5), cnormal );
842
+ }`,[a])}}();var nn=class extends ae{constructor(e,r,o,n,s,a,l,c,u,m,p,d){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=n,this.isVector=s,this.isWorldSpace=a,this.origin=l,this.direction=c,this.colors=u,this.steps=m,this.num=p,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,n=new X(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], float alpha, out float calpha) {
843
+ vec4 color = colors[0];
844
+ #ifdef ${o}_IS_VECTOR
845
+ #ifdef ${o}_LINEAR
846
+ #ifdef ${o}_WORLDSPACE
847
+ float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
848
+ #else
849
+ float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
850
+ #endif
851
+ #else
852
+ #ifdef ${o}_WORLDSPACE
853
+ float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
854
+ #else
855
+ float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
856
+ #endif
857
+ #endif
858
+ #else
859
+ float dist = length(vWPosition - cameraPosition);
860
+ float depth = ( dist - near ) / ( far - near );
861
+ #endif
780
862
 
781
- accumAlpha += ( 1.0 - accumAlpha ) * alpha;
782
863
 
783
- return normal;
784
- }`)}}();var Gl=class extends ae{constructor(e,r,o,n,s,a,l,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=n,this.offset=s,this.morph=a,this.angle=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Gl.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ri=Gl;ri.Nodes=function(){return{gradient:new K(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
864
+ float p;
865
+ #ifdef ${o}_SMOOTH
866
+ for ( int i = 1; i < ${o}_MAX_COLORS; i++ ) {
867
+ p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
868
+ color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
869
+ }
870
+ #else
871
+ for ( int i = 1; i < ${o}_MAX_COLORS; i++ ) {
872
+ p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
873
+ color = mix(color, colors[i], p);
874
+ }
875
+ #endif
876
+
877
+ float lalpha = alpha * color.a;
878
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
879
+
880
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
881
+ return color.rgb;
882
+ }`,[nn.Nodes.vectorLinearWorldSpaceDepth,nn.Nodes.vectorLinearObjectSpaceDepth,nn.Nodes.vectorSphericalObjectSpaceDepth,nn.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(n),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ni=nn;ni.Nodes=function(){let e=new X(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
883
+ vec3 n = normalize(direction);
884
+ float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
885
+ return ( dist - near ) / ( far - near );
886
+ }`),r=new X(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
887
+ vec3 n = normalize(direction);
888
+ float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
889
+ return ( dist - near ) / ( far - near );
890
+ }`),o=new X(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
891
+ float dist = length(vWPosition - origin);
892
+ return ( dist - near ) / ( far - near );
893
+ }`),n=new X(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
894
+ float dist = length(position - origin);
895
+ return ( dist - near ) / ( far - near );
896
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:n}}();var ii=class extends ae{constructor(e,r,o,n){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=n}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Dl=(e=>(e.NOISE="noise",e.MAP="map",e))(Dl||{}),Bl=class extends ae{constructor(e,r,o,n,s){super("v3");this.displacementTypeIndex=new he(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(Dl)[this.displacementTypeIndex.value]==="map"&&(this.mat=new on(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=n,this.noiseFunctionIndex=s}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(Dl)[this.displacementTypeIndex.value]){case"map":{o=e.include(Bl.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let a=Object.values(Jn)[this.noiseFunctionIndex.value],l=new X(`vec3 orthogonal(vec3 v) {
897
+ return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
898
+ }`),c=new X(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
899
+ return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
900
+ }`,[ot.simplex,ot.simplexFractal,ot.simplexAshima,ot.fbm,ot.perlin]),u=new X(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
901
+ vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
902
+ vec3 tangent1 = orthogonal(normal);
903
+ vec3 tangent2 = normalize(cross(normal, tangent1));
904
+
905
+ // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
906
+ // This caused some small oval/circular visual artifacts in the lighting.
907
+ // For now, simply using neighbors further away betters the problem,
908
+ // but we should figure out the underlying cause when we have some time.
909
+ // Maybe its related to how we calculate the tangent and bitangent?
910
+ vec3 nearby1 = position + tangent1;
911
+ vec3 nearby2 = position + tangent2;
912
+ vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement);
913
+ vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
914
+ displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
915
+ return displaced_position;
916
+ }`,[c,l]);o=e.include(u),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},si=Bl;si.Nodes=function(){let e=new X(`vec3 orthogonal(vec3 v) {
917
+ return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
918
+ }`),r=new X(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
919
+ vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
920
+ vec4 tmp = texture2D(tex, uvs);
921
+ vec3 col = tmp.rgb;
922
+ if (crop > 0.5) {
923
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
924
+ return 0.0;
925
+ }
926
+ }
927
+ return col.r;
928
+ }`);return{map:new X(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
929
+ vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
930
+ vec3 tangent1 = normalize(orthogonal(normal));
931
+ vec3 tangent2 = normalize(cross(normal, tangent1));
932
+ vec3 nearby1 = position + tangent1 * 0.1;
933
+ vec3 nearby2 = position + tangent2 * 0.1;
934
+ vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
935
+ vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
936
+ displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
937
+ return displaced_position;
938
+ }`,[e,r])}}();var El=class extends ae{constructor(e,r,o,n,s,a,l,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=n,this.offset=s,this.morph=a,this.angle=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(El.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ai=El;ai.Nodes=function(){return{gradient:new X(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
785
939
  vec4 color = colors[0];
786
940
  vec2 m = morph / vUv.xy;
787
941
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -823,508 +977,353 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
823
977
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
824
978
 
825
979
  return color.xyz;
826
- }`)}}();var Rl=(e=>(e.NOISE="noise",e.MAP="map",e))(Rl||{}),zl=class extends ae{constructor(e=new fe(0),r,o,n,s,a){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=r,this.movementOrTexture=o,Object.values(Rl)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Yo(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=s,this.noiseFunctionIndex=a}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(Rl)[this.displacementTypeIndex.value]){case"map":{o=e.include(zl.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let a=Object.values(Yn)[this.noiseFunctionIndex.value],l=new K(`vec3 orthogonal(vec3 v) {
827
- return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
828
- }`),c=new K(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
829
- return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
830
- }`,[nt.simplex,nt.simplexFractal,nt.simplexAshima,nt.fbm,nt.perlin]),h=new K(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
831
- vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
832
- vec3 tangent1 = orthogonal(normal);
833
- vec3 tangent2 = normalize(cross(normal, tangent1));
980
+ }`)}}();var ci=class extends ae{constructor(e,r,o,n,s,a,l,c,u,m){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=o,this.projection=n,this.axis=s,this.side=a,this.size=l,this.mat=c,this.alpha=u,this.mode=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,n;switch(this.projection.value){case 3:n=e.include(ci.Nodes.cylindrical);break;case 2:n=e.include(ci.Nodes.spherical);break;case 1:let a=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=new X(`
981
+ vec3 ${o}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
982
+
983
+ vec2 uvs = ( mat * vec3( (${o}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
984
+
985
+ vec4 tmp = texture2D( tex, uvs );
834
986
 
835
- // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
836
- // This caused some small oval/circular visual artifacts in the lighting.
837
- // For now, simply using neighbors further away betters the problem,
838
- // but we should figure out the underlying cause when we have some time.
839
- // Maybe its related to how we calculate the tangent and bitangent?
840
- vec3 nearby1 = position + tangent1;
841
- vec3 nearby2 = position + tangent2;
842
- vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement);
843
- vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
844
- displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
845
- return displaced_position;
846
- }`,[c,l]);o=e.include(h),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.noiseFunctionIndex=e.noiseFunctionIndex?.clone(),this.scale=e.scale?.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},Jo=zl;Jo.Nodes=function(){let e=new K(`vec3 orthogonal(vec3 v) {
847
- return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
848
- }`),r=new K(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
849
- vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
850
- vec4 tmp = texture2D(tex, uvs);
851
987
  vec3 col = tmp.rgb;
852
- if (crop > 0.5) {
988
+ float lalpha = alpha * tmp.a;
989
+ ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${a}));`}
990
+
991
+ if ( crop > 0.5 ) {
853
992
  if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
854
- return 0.0;
993
+ lalpha = 0.0;
855
994
  }
856
995
  }
857
- return col.r;
858
- }`);return{map:new K(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
859
- vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
860
- vec3 tangent1 = normalize(orthogonal(normal));
861
- vec3 tangent2 = normalize(cross(normal, tangent1));
862
- vec3 nearby1 = position + tangent1 * 0.1;
863
- vec3 nearby2 = position + tangent2 * 0.1;
864
- vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
865
- vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
866
- displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
867
- return displaced_position;
868
- }`,[e,r])}}();var oi=class extends ae{constructor(e=new ce,r=new ce,o=new ce,n=new ce,s=new ce,a=new ce,l=new ce,c=new ce,h=new ce,p=new ce,u=new ce,d=new ce){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=n,this.fB=s,this.distortion=a,this.colorA=l,this.colorB=c,this.colorC=h,this.colorD=p,this.alpha=u,this.noiseType=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,n,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(Yn)[this.noiseType.value],l=new K(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
869
- vec3 st = position / size;
870
- st /= scale;
871
- vec3 q = vec3(${a}(st),
872
- ${a}(st + vec3(1.0)),
873
- ${a}(st + vec3(1.0)));
874
- vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
875
- ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
876
- ${a}(st * q));
877
- float f = ${a}(st + r);
878
- vec4 color;
879
- color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
880
- color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
881
- color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
996
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
997
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
998
+ return col;
999
+ }`);n=e.include(l);break;default:n=e.include(ci.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let a=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${a})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+s.join(",")+")",this.getType(e),r)}},li=ci;li.Nodes=function(){let e=new X(`
1000
+ vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1001
+ vec3 posN = normalize(position);
1002
+ float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
1003
+ float scaledHeight = position.y / (size.y * 0.5);
1004
+ float v = (scaledHeight / 2.) + .5;
1005
+
1006
+ vec2 calculatedUv = vec2(u,v);
1007
+ vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
1008
+
1009
+ vec2 df = fwidth(uvs);
1010
+ if(df.x > 0.5) df.x = 0.;
1011
+
1012
+ #ifdef GL_EXT_shader_texture_lod
1013
+ vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
1014
+ #else
1015
+ vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
1016
+ #endif
1017
+
1018
+ vec3 col = tmp.rgb;
1019
+ float lalpha = alpha * tmp.a;
1020
+ if ( crop > 0.5 ) {
1021
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
1022
+ lalpha = 0.0;
1023
+ }
1024
+ }
1025
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1026
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1027
+ return col;
1028
+ }
1029
+ `),r=new X(`
1030
+ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1031
+ vec3 posN = normalize(vPosition);
1032
+ float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
1033
+ float v = 0.5 + asin(posN.y) / 3.1415;
1034
+
1035
+ vec2 calculatedUv = vec2(u,v);
1036
+ vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
1037
+
1038
+ vec2 df = fwidth(uvs);
1039
+ if(df.x > 0.5) df.x = 0.;
1040
+ #ifdef GL_EXT_shader_texture_lod
1041
+ vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
1042
+ #else
1043
+ vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
1044
+ #endif
1045
+
1046
+ vec3 col = tmp.rgb;
1047
+ float lalpha = alpha * tmp.a;
1048
+ if ( crop > 0.5 ) {
1049
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
1050
+ lalpha = 0.0;
1051
+ }
1052
+ }
1053
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1054
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1055
+ return col;
1056
+ }
1057
+ `),o=new X(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1058
+
1059
+ vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
1060
+ vec4 tmp = texture2D( tex, uvs );
1061
+
1062
+ vec3 col = tmp.rgb;
1063
+
1064
+ float lalpha = alpha * tmp.a;
1065
+ if ( crop > 0.5 ) {
1066
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
1067
+ lalpha = 0.0;
1068
+ }
1069
+ }
1070
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1071
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1072
+ return col;
1073
+ }`);return{cylindrical:e,spherical:r,uv:o}}();var Gl=class extends ae{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r}generate(e,r){if(e.isShader("fragment")){let o=e.include(Gl.Nodes.customNormal),n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.alpha.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ui=Gl;ui.Nodes=function(){return{customNormal:new X(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
1074
+ vec3 normal = packNormalToRGB( norm ).rgb;
1075
+ normal *= step( vec3(0.5), cnormal );
1076
+
1077
+ accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1078
+
1079
+ return normal;
1080
+ }`)}}();import{Vector2 as pi,Vector3 as wr,Vector4 as Rl}from"three";function Sd(i,t){switch(i.type){case"fresnel":return PS(i,t);case"gradient":return MS(i);case"depth":return OS(i);case"normal":return _S(i);case"noise":return DS(i,t);case"rainbow":return BS(i);case"toon":return ES(i,t);case"outline":return GS(i,t);case"transmission":return RS(i,t);case"color":return AS(i,t)}}function IS(i){return{type:i.type}}function nr(i){let{alpha:t,mode:e}=i;return{...IS(i),alpha:t,mode:e}}function AS(i,t){return{...nr(i),color:Ve(i.color,t)}}function PS(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:s}=i;return{...nr(i),color:Ve(s,t),bias:e,scale:r,intensity:o,factor:n}}function MS(i){let{gradientType:t,smooth:e,colors:r,steps:o,angle:n,offset:s,morph:a}=i;return{...nr(i),gradientType:t,smooth:e,colors:r.map(l=>new Rl(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new pi(...s),morph:new pi(...a),angle:n}}function OS(i){let{gradientType:t,near:e,far:r,isVector:o,isWorldSpace:n,origin:s,direction:a,colors:l,steps:c,smooth:u,num:m}=i;return{...nr(i),gradientType:t,near:e,far:r,isVector:o,isWorldSpace:n,origin:new wr(...s),direction:a?new wr(...a):new wr(1,0,0),num:m,colors:l.map(p=>new Rl(p[0],p[1],p[2],p[3])),steps:c,smooth:u}}function _S(i){let{cnormal:t}=i;return{...nr(i),cnormal:new wr(t[0],t[1],t[2])}}function DS(i,t){return{...nr(i),scale:i.scale,move:i.move,fA:new pi(...i.fA),fB:new pi(...i.fB),size:new wr(...i.size),distortion:new pi(...i.distortion),colorA:Ve(i.colorA,t),colorB:Ve(i.colorB,t),colorC:Ve(i.colorC,t),colorD:Ve(i.colorD,t),noiseType:i.noiseType}}function BS(i){return{...nr(i),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new wr(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new wr(...i.offset)}}function ES(i,t){return{...nr(i),positioning:i.positioning,colors:i.colors.map(e=>new Rl(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new wr(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:Ve(i.shadowColor,t),offset:new wr(...i.offset)}}function GS(i,t){return{...nr(i),outlineColor:Ve(i.outlineColor,t),contourColor:Ve(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:i.contourDirection,positionalLines:i.positionalLines,compensation:i.compensation,resolution:t.resolutionNode,normalMap:t.normalMap,depthMap:t.normalRenderTarget.depthTexture,pixelRatio:t.pixelRatioNode}}function RS(i,t){return{...nr(i),thickness:i.thickness,ior:i.ior,roughness:i.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap}}var kr=class extends Qe{};import{Texture as VS}from"three";var Vl=new Map,mi={url:"head",time:0,data:null,next:null,prev:null},sn={url:"tail",time:1/0,data:null,next:null,prev:null};mi.next=sn;sn.prev=mi;var wd=0;function Td(i){if(typeof i=="string")return i;let t=Date.now(),e=Vl.get(i);return e===void 0?(e={url:URL.createObjectURL(new Blob([i])),data:i,time:t,next:null,prev:null},Vl.set(i,e)):(e.time=t,e.prev.next=e.next,e.next.prev=e.prev),e.prev=sn.prev,e.next=sn,sn.prev.next=e,sn.prev=e,t-wd>1e3*10&&(wd=t+1e3,setTimeout(()=>{let r=Date.now(),o=mi.next;for(;o.time<r-1e3*10;)URL.revokeObjectURL(o.url),Vl.delete(o.data),o=o.next,o.prev=mi,mi.next=o},900)),e.url}var an=class{constructor(t,e){this.data=t;this.onImageLoad=e;this.loaded=!1;this.updateSrc(t.data)}updateSrc(t){this.dispose(),this.loaded=!1,this.img=new Image,this.img.src=Td(t),this.img.onload=()=>{this.loaded=!0;let e=[1e3,1001,1002];for(let r of e){let o=this[r];o&&(o.image=this.img,o.needsUpdate=!0)}this.onImageLoad&&this.onImageLoad()}}getTexture(t){let e=this[t];if(e)return e;{let r=new VS(this.img,void 0,t,t);return this.loaded&&(r.needsUpdate=!0),this[t]=r,r}}dispose(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}};1e3,1001,1002;var no=class extends an{};var Hr=class extends Ce{};function zS(i,t){switch(i.type){case"noise":return t==="noiseType";case"texture":return t==="projection"||t==="axis"||t==="side";case"displace":return t==="noiseType";case"depth":return t==="num"||t==="smooth"||t==="isWorldSpace"||t==="gradientType"||t==="isVector";default:return!1}}function zl(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let s=n.image,a=t.image(s),l=r;l instanceof no||l.image.dispose(),l.image=a}if("wrapping"in n){let s=r;s.wrap=n.wrapping}if("repeat"in n||"offset"in n){let s="mat",a=e.uniforms[`f${e.id}_${s}`];"repeat"in n&&(a.repeat=n.repeat),"offset"in n&&(a.offset=n.offset),a.updateMatrix()}return o}function Nd(i,t,e,r){let o=!1;for(let[n,s]of Object.entries(i)){if(!n||s===void 0||Fl(n,e,r))continue;e.visible=r.visible;let a=e.uniforms[`f${e.id}_${n}`];if(!!a&&!(a instanceof Hr))switch(a.constructor){case we:if(typeof s=="string"){let l=t.getColor(s);l&&(a.value=l);break}else{let l=s;a.value instanceof kr?a.value=new Qe(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case At:if(typeof s=="string"){let l=t.getColor(s);l&&(a.value=l);break}else{let l=s;a.value instanceof kr?a.value=new Qe(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case ke:{let l=s;a.value.setX(l[0]),a.value.setY(l[1]);break}case Je:{let l=s;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case mt:{zl(s,t,e);break}case Et:{s.forEach((l,c)=>{a.value[c].setX(l[0]),a.value[c].setY(l[1]),a.value[c].setZ(l[2]),a.value[c].setW(l[3])});break}default:{o=o||zS(e,n),a.value=s;break}}}return o}var Ul=class extends ae{constructor(e,r,o){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Ul.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.generate(e,"t")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},di=Ul;di.Nodes=function(){return{matcap:new X(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
1081
+ vec3 viewDir = normalize( vViewPosition );
1082
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
1083
+ vec3 y = cross( viewDir, x );
1084
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
1085
+ vec4 matcapColor = texture2D( matcapTex, uv );
1086
+
1087
+ calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );
1088
+ accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1089
+
1090
+ return matcapColor.rgb;
1091
+ }
1092
+ `)}}();var fi=class extends Hr{constructor(e,r){super("t");this.image=e;this.wrap=r}get value(){return this.image.getTexture(this.wrap)}};import{Vector3 as FS}from"three";var Ks=class extends Hr{constructor(e){super("v3");this.image=e;this._value=new FS}get value(){return this._value.x=this.image.img.width,this._value.y=this.image.img.height,this._value}};var jl=class extends ae{constructor(e,r,o,n,s,a,l,c,u,m){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=n,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(jl.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},hi=jl;hi.Nodes=function(){let e=new X(`float rand(float n) {
1093
+ return fract(sin(n) * 43758.5453123);
1094
+ }`),r=new X(`float hash1(float p) {
1095
+ p = fract(p * 0.011);
1096
+ p *= p + 7.5;
1097
+ p *= p + p;
1098
+ return fract(p);
1099
+ }`),o=new X(`float valueNoise(vec3 x) {
1100
+ const vec3 step = vec3(110, 241, 171);
1101
+
1102
+ vec3 i = floor(x);
1103
+ vec3 f = fract(x);
1104
+
1105
+ // For performance, compute the base input to a 1D hash from the integer part of the argument and the
1106
+ // incremental change to the 1D based on the 3D -> 1D wrapping
1107
+ float n = dot(i, step);
1108
+
1109
+ vec3 u = f * f * (3.0 - 2.0 * f);
1110
+ return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
1111
+ mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
1112
+ mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
1113
+ mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
1114
+ }`,[r]),n=new X(`vec3 hash3(vec3 x) {
1115
+ x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
1116
+ dot(x,vec3(269.5, 183.3, 246.1)),
1117
+ dot(x,vec3(113.5, 271.9, 124.6)));
1118
+
1119
+ return fract(sin(x)*43758.5453123);
1120
+ }`),s=new X(`vec3 voronoiNoise(in vec3 x)
1121
+ {
1122
+ vec3 p = floor(x);
1123
+ vec3 f = fract(x);
1124
+
1125
+ float id = 0.0;
1126
+ vec2 res = vec2(100.0);
1127
+
1128
+ for(int k=-1; k<=1; k++)
1129
+ for(int j=-1; j<=1; j++)
1130
+ for(int i=-1; i<=1; i++)
1131
+ {
1132
+ vec3 b = vec3(float(i), float(j), float(k));
1133
+
1134
+ // Comment out the "+ hash(p + b);" part below to get "square" cells
1135
+ vec3 r = vec3(b) - f + hash3(p + b);
1136
+ float d = dot(r, r);
1137
+
1138
+ if (d < res.x)
1139
+ {
1140
+ id = dot(p + b, vec3(1.0, 57.0, 113.0));
1141
+ res = vec2(d, res.x);
1142
+ }
1143
+ else if (d < res.y)
1144
+ {
1145
+ res.y = d;
1146
+ }
1147
+ }
1148
+
1149
+ return vec3(sqrt(res), abs(id));
1150
+ }
1151
+ `,[n]);return{toon:new X(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float alpha, out float calpha) {
1152
+ float t = 0.0;
1153
+ float shadow = 1.0;
1154
+
1155
+ if (positioning == 0) {
1156
+
1157
+ // Can't do this mode if lighting is "none"
1158
+ #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
1159
+
1160
+ // Algorithm from Chapter 10 of Graphics Shaders
1161
+ const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
1162
+ vec3 lpos;
1163
+ vec3 l;
1164
+ float dproduct;
1165
+
1166
+ #if (NUM_POINT_LIGHTS > 0)
1167
+
1168
+ #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
1169
+ PointLightShadow pointLightShadow;
1170
+ #endif
1171
+
1172
+ #pragma unroll_loop_start
1173
+ for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
1174
+ // Light positions are in view-space for some reason?
1175
+ lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
1176
+ l = normalize(lpos - worldPosition);
1177
+
1178
+ dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
1179
+
1180
+ // TODO: we want to use "intensity" but it isn't available in the shader code
1181
+ //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
882
1182
 
883
- float lalpha = alpha * color.a;
884
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1183
+ t = max(t, dproduct);
885
1184
 
886
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
887
- return clamp(color, 0.0, 1.0).rgb;
888
- }`,[nt.simplex,nt.simplexFractal,nt.simplexAshima,nt.fbm,nt.perlin]),c=e.include(l),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(c+"("+h.join(",")+")",this.getType(e),r)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};oi.numOctaves=5;var Vl=class extends ae{constructor(e=new ce,r=new ce,o=Vl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),s=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+s+" )",o,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},dt=Vl;dt.ADD="+",dt.SUB="-",dt.MUL="*",dt.DIV="/";var ni=class extends ae{constructor(e=new ce,r=new ce,o=new ce,n=new ce){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=n}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var Qo=class extends ae{constructor(e,r,o,n,s,a,l,c,h,p,u,d){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=n,this.isVector=s,this.isWorldSpace=a,this.origin=l,this.direction=c,this.colors=h,this.steps=p,this.num=u,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,n=new K(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], float alpha, out float calpha) {
889
- vec4 color = colors[0];
890
- #ifdef ${o}_IS_VECTOR
891
- #ifdef ${o}_LINEAR
892
- #ifdef ${o}_WORLDSPACE
893
- float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
894
- #else
895
- float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
896
- #endif
897
- #else
898
- #ifdef ${o}_WORLDSPACE
899
- float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
900
- #else
901
- float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
902
- #endif
903
- #endif
904
- #else
905
- float dist = length(vWPosition - cameraPosition);
906
- float depth = ( dist - near ) / ( far - near );
907
- #endif
1185
+ // Accumulate shadow contribution
1186
+ #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
1187
+ pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
1188
+ shadow *= getPointShadow(
1189
+ pointShadowMap[UNROLLED_LOOP_INDEX],
1190
+ pointLightShadow.shadowMapSize,
1191
+ pointLightShadow.shadowBias,
1192
+ pointLightShadow.shadowRadius,
1193
+ vPointShadowCoord[UNROLLED_LOOP_INDEX],
1194
+ pointLightShadow.shadowCameraNear,
1195
+ pointLightShadow.shadowCameraFar);
1196
+ #endif
1197
+ }
1198
+ #pragma unroll_loop_end
908
1199
 
1200
+ #endif
909
1201
 
910
- float p;
911
- #ifdef ${o}_SMOOTH
912
- for ( int i = 1; i < ${o}_MAX_COLORS; i++ ) {
913
- p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
914
- color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
915
- }
916
- #else
917
- for ( int i = 1; i < ${o}_MAX_COLORS; i++ ) {
918
- p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
919
- color = mix(color, colors[i], p);
920
- }
921
- #endif
1202
+ #if NUM_DIR_LIGHTS > 0
1203
+
1204
+ #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
1205
+ DirectionalLightShadow directionalLightShadow;
1206
+ #endif
922
1207
 
923
- float lalpha = alpha * color.a;
924
- calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1208
+ #pragma unroll_loop_start
1209
+ for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
1210
+ // Use the direction vector for directional lights instead
1211
+ l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
1212
+
1213
+ dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
1214
+ t = max(t, dproduct);
925
1215
 
926
- accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
927
- return color.rgb;
928
- }`,[Qo.Nodes.vectorLinearWorldSpaceDepth,Qo.Nodes.vectorLinearObjectSpaceDepth,Qo.Nodes.vectorSphericalObjectSpaceDepth,Qo.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(n),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.direction=e.direction.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ii=Qo;ii.Nodes=function(){let e=new K(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
929
- vec3 n = normalize(direction);
930
- float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
931
- return ( dist - near ) / ( far - near );
932
- }`),r=new K(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
933
- vec3 n = normalize(direction);
934
- float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
935
- return ( dist - near ) / ( far - near );
936
- }`),o=new K(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
937
- float dist = length(vWPosition - origin);
938
- return ( dist - near ) / ( far - near );
939
- }`),n=new K(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
940
- float dist = length(position - origin);
941
- return ( dist - near ) / ( far - near );
942
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:n}}();var Fl=class extends ae{constructor(e,r,o){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Fl.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.getTexture(e,"t")),n.push("normal"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},si=Fl;si.Nodes=function(){return{matcap:new K(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
943
- vec3 viewDir = normalize( vViewPosition );
944
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
945
- vec3 y = cross( viewDir, x );
946
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
947
- vec4 matcapColor = texture2D( matcapTex, uv );
1216
+ // Accumulate shadow contribution
1217
+ #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
1218
+ directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
1219
+ shadow *= getShadow(
1220
+ UNROLLED_LOOP_INDEX,
1221
+ directionalShadowMap[UNROLLED_LOOP_INDEX],
1222
+ directionalLightShadow.shadowMapSize,
1223
+ directionalLightShadow.shadowBias,
1224
+ directionalLightShadow.shadowRadius,
1225
+ vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
1226
+ #endif
1227
+ }
1228
+ #pragma unroll_loop_end
948
1229
 
949
- calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );
950
- accumAlpha += ( 1.0 - accumAlpha ) * alpha;
951
-
952
- return matcapColor.rgb;
953
- }
954
- `)}}();var en=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=Sr.generateUUID(),this.needsUpdate=!1,this._material=t,this._layerNodes=[];let e=this._createLayer({id:0,type:"color"});this._material.color=e.color,this._material.alpha===void 0&&(this._material.alpha=new X(1));let r=new X(1),o=new fe(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=o),this._layerNodes.push({id:0,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),this._layerNodes.push({id:1,type:"light",alpha:r,mode:o}),this.head=e.layer,this.head.next=new Oe(1,void 0,{type:"light",alpha:r,mode:o}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){this._material=t;let e,r,o=this.head;for(;o!==void 0;){if(o.type==="light"){e=o.uniforms[`f${o.id}_alpha`],r=o.uniforms[`f${o.id}_mode`];break}o=o.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=e,this._material.shadingBlend=r),this.attachLightNodes(t.userData.layers?.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(t){let e=[],r=this.head;for(;r;)r.type===t&&e.push(r),r=r.next;return e}addLayer(t){if(t.id=t.id??++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}let e=this._createLayer(t),r=e.layer;if(this.head===void 0)this.head=r;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=r}return e.color&&this._layerNodes.push({id:r.id,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),e.position&&this._layerNodes.push({id:r.id,type:"position",position:e.position}),this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){let r=this.head;t.id=t.id??++this.id,this.layerCount++;let o=this._createLayer(t),n=o.layer;n.next=e;let s=0;if(r===e)this.head=n,o.color&&this._layerNodes.splice(0,0,{id:n.id,type:"color",color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(0,0,{id:n.id,type:"position",position:o.position});else{for(s=1;r?.next!==e;)r=r?.next,s++;r.next=n,o.color&&this._layerNodes.splice(s,0,{id:n.id,type:"color",color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(s,0,{id:n.id,type:"position",position:o.position})}return this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerAt(t,e){e.id=e.id??++this.id,this.layerCount++;let r=this._createLayer(e),o=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:o.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:o.id,type:"position",position:r.position}),t==0)o.next=this.head,this.head=o;else{let n=this.head,s=this.head.next;for(let a=0;a<t-1;a++)n=s,s=s.next;o.next=s,n.next=o}return this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}removeLayer(t){let e=this.head,r,o=0;if(e?.id==t)this.head=e.next;else for(o=1,r=e,e=e?.next;e!=null;){if(e.id==t){r.next=e.next;break}o++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Sr.generateUUID(),this.layerCount--,o}changeLayer(t,e){let r,o=this.head,n;if(o?.id==t){let s=this._createLayer({id:t,uuid:o.uuid,...e});n=s.layer,n.next=o.next,this.head=n,s.color&&(this._layerNodes[0]={id:n.id,type:"color",color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:n.id,type:"position",position:s.position}),n.uniforms[`f${t}_mode`].value=o.uniforms[`f${t}_mode`].value,n.uniforms[`f${t}_alpha`].value=o.uniforms[`f${t}_alpha`].value}else{r=o,o=o.next;let s=1;for(;o!=null;){if(o.id==t){let a=this._createLayer({id:t,uuid:o.uuid,...e});n=a.layer,r.next=n,n.next=o.next,a.color&&(this._layerNodes[s]={id:t,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:t,type:"position",position:a.position}),n.uniforms[`f${t}_mode`].value=o.uniforms[`f${t}_mode`].value,n.uniforms[`f${t}_alpha`].value=o.uniforms[`f${t}_alpha`].value;break}r=o,o=o.next,s++}}return this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}getLayer(t){let e=this.head;for(;e!=null&&e.id!=t;)e=e.next;return e}getLayerByUuid(t){let e=this.head;for(;e!==void 0;){if(e.uuid===t)return e;e=e.next}}getLayers(){let t=[],e=this.head;for(;e!=null;)t.push(e),e=e.next;return t}getLayerPosition(t){let e=this.head,r=0;for(;e!==void 0&&e.id!=t;)r++,e=e.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(t,e){let r,o=this.head,n;if(t==0)r=this.head,this.head=r.next;else{for(let a=0;a<t;a++)n=o,o=o.next;n.next=o.next,r=o}if(o=this.head,n=void 0,e==0)r.next=this.head,this.head=r;else{for(let a=0;a<e-1;a++)o=o.next;r.next=o?.next,o.next=r}let s=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,s),this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Sr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(t){this.needsUpdate=!1,this.layerCount=t.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,t.head);let e=t.head,r=this.head;for(;e.next!=null;)this.rebuildLayerNodes(r,e.next),r=r.next,e=e.next;return this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(t){let e=new X(t.alpha),r=new fe(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let o=new Oe(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=o;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=o}return this.attachLightNodes(this.getLightLayer()),o}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let o=r?e.uniforms[`f${e.id}_alpha`]:new X(e.uniforms[`f${e.id}_alpha`].value),n=r?e.uniforms[`f${e.id}_mode`]:new fe(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=o,this._material.shadingBlend=n,this._layerNodes.push({id:e.id,type:"light",alpha:o,mode:n}),this.head===void 0?this.head=new Oe(e.id,e.uuid,{type:"light",alpha:o,mode:n}):t&&(t.next=new Oe(e.id,e.uuid,{type:"light",alpha:o,mode:n})),this.attachLightNodes(e)}else{let o={type:e.type,id:e.id};for(let n in e.uniforms){let s=e.getName(n);if(!s)continue;let a=`f${e.id}_${s}`;if(Array.isArray(e.uniforms[a].value))o[s]=e.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=e.uniforms[a].value;if(s==="transmissionDepthMap"){o[s]=l;continue}l!=null&&(o[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(o)}}attachLightNodes(t){let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new Ne(t?.getValue("emissive")?.clone()??0);break;case"Phong":e.shininess=new X(t?.getValue("shininess")??30),e.specular=new Ne(t?.getValue("specular")?.clone()??1118481);break;case"Toon":e.shininess=new X(t?.getValue("shininess")??30),e.specular=new Ne(t?.getValue("specular")?.clone()??1118481);break;case"Physical":e.roughness=new X(t?.getValue("roughness")??.3),e.metalness=new X(t?.getValue("metalness")??0),e.reflectivity=new X(t?.getValue("reflectivity")??.5);break;default:break}Object.keys(e).forEach(o=>{this._material[o]=e[o],r.uniforms[`f${r.id}_${o}`]=e[o]})}clone(t){return new en(t).copy(this)}getLightLayer(){let t=this.head;for(;t!==void 0&&t.type!=="light";)t=t.next??t;return t}dispose(){let t=this.head;for(this._layerNodes=[],this.layerCount=0;t!==void 0;)t.hasOwnProperty("dispose")===!0&&t.dispose(),t=t.next;this.head=void 0}_createLayer(t){let e=t.type;switch(e){case"color":{let r=new Ne(t.color??5855577),o=new X(t.alpha??1),n=new Ce("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");n.keywords.alpha=o;let s=new fe(t.mode??0);return r.alpha=o,{layer:new Oe(t.id,t.uuid,{type:e,color:r,alpha:o,calpha:n,mode:s}),color:r,alpha:n,mode:s}}case"texture":{let r=t.texture??new Dt,o=r.matrix;t.mat&&o.copy(t.mat),r.needsUpdate=!0;let n=new X(t.crop??0),s=new fe(t.projection??0),a=new fe(t.axis??0),l=new fe(t.side??0),c=new Ye(t.size?new wr(t.size[0],t.size[1]):new wr(100,100)),h=new X(t.alpha??1),p=new fe(t.mode??0),u=new Je(r),d=new ot(t.textureSize??new Rt(r.image?r.image.width:0,r.image?r.image.height:0)),m=new $n(u,d,n,s,a,l,c,h,p),g=new Ce(m.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,texture:u,textureSize:d,crop:n,projection:s,axis:a,side:l,size:c,mat:m.mat,alpha:h,calpha:g,mode:p}),color:m,alpha:g,mode:p}}case"matcap":{let r=t.texture??new Dt;r.needsUpdate=!0;let o=new X(t.alpha??1),n=new Je(r),s=new fe(t.mode??0),a=new si(n,o,s),l=new Ce(a.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,texture:n,alpha:o,calpha:l,mode:s}),color:a,alpha:l,mode:s}}case"fresnel":{let r=new Ne(t.color??16777215),o=new X(t.bias??.1),n=new X(t.scale??1),s=new X(t.intensity??2),a=new X(t.factor??1),l=new X(t.alpha??1),c=new fe(t.mode??0),h=new Kn(r,o,n,s,a,l,c),p=new Ce(h.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,color:r,bias:o,scale:n,intensity:s,factor:a,alpha:l,calpha:p,mode:c}),color:h,alpha:p,mode:c}}case"rainbow":{let r=new X(t.filmThickness??30),o=new X(t.movement??0),n=new ot(t.wavelengths??new Rt(0,0,0)),s=new X(t.noiseStrength??0),a=new X(t.noiseScale??1),l=new ot(t.offset??new Rt(0,0,0)),c=new X(t.alpha??1),h=new Jn(r,o,n,s,a,l,c),p=new Ce(h.calpha,"f"),u=new fe(t.mode??0);return{layer:new Oe(t.id,t.uuid,{type:e,filmThickness:r,movement:o,wavelengths:n,noiseStrength:s,noiseScale:a,offset:l,alpha:c,calpha:p,mode:u}),color:h,alpha:p,mode:u}}case"toon":{let r=new fe(t.positioning??0),o;t.colors?o=new br(t.colors.length,t.colors):(o=new br(10,new Zo(0,0,0,1)),o.value[1]=new Zo(1,1,1,1));let n;t.steps?n=new ke(t.steps.length,t.steps):(n=new ke(10,1),n.value[0]=0);let s=new ot(t.source??new Rt(0,0,0)),a=new Fr(t.isWorldSpace??!0),l=new X(t.noiseStrength??0),c=new X(t.noiseScale??1),h=new nr(t.shadowColor),p=new ot(t.offset??new Rt(0,0,0)),u=new X(t.alpha??1),d=new Qn(r,o,n,s,a,l,c,h,p,u),m=new Ce(d.calpha,"f"),g=new fe(t.mode??0);return{layer:new Oe(t.id,t.uuid,{type:e,positioning:r,colors:o,steps:n,source:s,isWorldSpace:a,noiseStrength:l,noiseScale:c,shadowColor:h,offset:p,alpha:u,calpha:m,mode:g}),color:d,alpha:m,mode:g}}case"outline":{let r=new Ne(t.outlineColor??16777215),o=new Ne(t.contourColor??16777215),n=new X(t.outlineWidth??.1),s=new X(t.contourWidth??.1),a=new X(t.outlineThreshold??.1),l=new X(t.contourThreshold??.1),c=new X(t.outlineSmoothing??.1),h=new X(t.contourFrequency??.1),p=new ot(t.contourDirections??new Rt(0,1,0)),u=new Fr(t.positionalLines??!1),d=new Fr(t.compensation??!0),m=t.normalMap??new Dt,g=new Je(m),x=t.depthMap??new Dt,y=new Je(x),v=t.pixelRatio??new X(window.devicePixelRatio),P=t.resolution??new Ye(new wr(1,1)),S=new X(t.alpha??1),b=new Zn(r,o,n,s,a,l,c,h,p,u,d,P,g,y,v,S),B=new Ce(b.calpha,"f"),w=new fe(t.mode??0);return{layer:new Oe(t.id,t.uuid,{type:e,outlineColor:r,contourColor:o,outlineWidth:n,contourWidth:s,outlineThreshold:a,contourThreshold:l,outlineSmoothing:c,contourFrequency:h,contourDirection:p,positionalLines:u,compensation:d,resolution:P,normalMap:g,depthMap:y,pixelRatio:v,alpha:S,calpha:B,mode:w}),color:b,alpha:B,mode:w}}case"transmission":{let r=new X(t.thickness??10),o=new X(t.ior??1.5),n=new X(t.roughness??.5),s=new Ye(t.transmissionSamplerSize??new wr(2048,2048)),a=t.transmissionSamplerMap??new Dt,l=t.transmissionDepthMap??new Dt,c=new Je(a),h=new Je(l),p=window.innerWidth,u=window.innerHeight,d=p>=u?new Ye(u/p,1):new Ye(1,p/u),m=new X(t.alpha??1),g=new ei(r,o,n,s,c,h,d,m),x=new Ce(g.calpha,"f"),y=new fe(t.mode??0);return{layer:new Oe(t.id,t.uuid,{type:e,thickness:r,ior:o,roughness:n,transmissionSamplerSize:s,transmissionSamplerMap:c,transmissionDepthMap:h,aspectRatio:d,alpha:m,calpha:x,mode:y}),color:g,alpha:x,mode:y}}case"depth":{let r=new fe(t.gradientType??0),o=new Fr(t.smooth??!1),n=new X(t.near??50),s=new X(t.far??200),a=new X(t.isVector??1),l=new X(t.isWorldSpace??0),c=new ot(t.origin??new Rt),h=new ot(t.direction??new Rt),p=new fe(t.num??0),u;t.colors?u=new br(p.value+1,t.colors):(u=new br(p.value+1,new Zo(0,0,0,1)),u.value[1]=new Zo(1,1,1,1));let d;t.steps?d=new ke(p.value+1,t.steps):(d=new ke(p.value+1,1),d.value[0]=0);let m=new X(t.alpha??1),g=new fe(t.mode??0),x=new ii(r,o,n,s,a,l,c,h,u,d,p,m),y=new Ce(x.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,gradientType:r,smooth:o,near:n,far:s,isVector:a,isWorldSpace:l,origin:c,direction:h,colors:u,steps:d,num:p,alpha:m,calpha:y,mode:g}),color:x,alpha:y,mode:g}}case"noise":{let r=new X(t.scale??1),o=new ot(t.size??new Rt(100,100,100)),n=new X(t.move??1),s=new Ye(t.fA??new wr(1.7,9.2)),a=new Ye(t.fB??new wr(8.3,2.8)),l=new Ye(t.distortion??new wr(1,1)),c=new nr(t.colorA),h=new nr(t.colorB),p=new nr(t.colorC),u=new nr(t.colorD),d=new X(t.alpha??1),m=new fe(t.mode??0),g=new fe(t.noiseType??0),x=new oi(r,o,n,s,a,l,c,h,p,u,d,g),y=new Ce(x.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,scale:r,size:o,move:n,fA:s,fB:a,distortion:l,colorA:c,colorB:h,colorC:p,colorD:u,alpha:d,calpha:y,mode:m,noiseType:g}),color:x,alpha:y,mode:m}}case"normal":{let r=new ot(t.cnormal??new Rt(1,1,1)),o=new X(t.alpha??1),n=new fe(t.mode??0),s=new ti(r,o),a=new Ce("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return a.keywords.alpha=o,{layer:new Oe(t.id,t.uuid,{type:e,cnormal:r,alpha:o,calpha:a,mode:n}),color:s,alpha:a,mode:n}}case"gradient":{let r=new fe(t.gradientType??0),o=new Fr(t.smooth??!1),n;t.colors?n=new br(t.colors.length,t.colors):(n=new br(10,new Zo(0,0,0,1)),n.value[1]=new Zo(1,1,1,1));let s;t.steps?s=new ke(t.steps.length,t.steps):(s=new ke(10,1),s.value[0]=0);let a=new Ye(t.offset??new wr(0,0)),l=new Ye(t.morph??new wr(0,0)),c=new X(t.angle??0),h=new X(t.alpha??1),p=new fe(t.mode??0),u=new ri(r,o,n,s,a,l,c,h),d=new Ce(u.calpha,"f");return{layer:new Oe(t.id,t.uuid,{type:e,gradientType:r,smooth:o,colors:n,steps:s,offset:a,morph:l,angle:c,alpha:h,calpha:d,mode:p}),color:u,alpha:d,mode:p}}case"displace":{let r=new fe(t.displacementType??0);if(r.value===0){let o=new ot(t.offset??new Rt(0,0,0)),n=new X(t.scale??10),s=new X(t.intensity??8),a=new X(t.movement??1),l=new X(t.alpha??1),c=new fe(t.mode??0),h=new fe(t.noiseType??0),p=new Jo(r,s,a,o,n,h);return{layer:new Oe(t.id,t.uuid,{displacementType:r,type:e,offset:o,scale:n,intensity:s,movement:a,alpha:l,mode:c,noiseType:h}),position:p}}else if(r.value===1){let o=t.texture??new Dt,n=o.matrix;t.mat&&n.copy(t.mat),o.needsUpdate=!0;let s=new X(t.intensity??8),a=new Je(o),l=new X(t.crop??0),c=new X(t.alpha??1),h=new fe(t.mode??0),p=new Jo(r,s,a,l);return{layer:new Oe(t.id,t.uuid,{displacementType:r,type:e,intensity:s,texture:a,crop:l,mat:p.mat,alpha:c,mode:h}),position:p}}return{}}}return{}}blendColors(){let t=this._layerNodes.findIndex(r=>r.type==="color"),e=this._layerNodes.findIndex(r=>r.type==="light");if(t!==-1&&t<e){let r=this._layerNodes[t].color;for(let o=t+1;o<e;++o){let n=this._layerNodes[o];n.type==="color"&&(r=new ni(r,n.color,n.alpha,n.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new Ce("outgoingLight","f"),e=this._layerNodes.findIndex(r=>r.type==="light");if(this._layerNodes.length>e+1){for(let r=e+1;r<this._layerNodes.length;++r){let o=this._layerNodes[r];o.type==="color"&&(t=new ni(t,o.color,o.alpha,o.mode))}"afterColor"in this._material&&(this._material.afterColor=t)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let t=this._layerNodes.filter(e=>e.type==="position");if(t.length>0){let e=t[0].position;for(let r=1;r<t.length;++r)t[r]&&(e=new dt(e,t[r].position,dt.ADD),e=new dt(e,new X(.5).setReadonly(!0),dt.MUL));this._material.position=e}else this._material.position=void 0}cleanupChangedLayer(t){switch(this._layerNodes=this._layerNodes.filter(e=>e.id!==t.id),t.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};import{NormalBlending as _S,ShaderMaterial as BS}from"three";import{CubeReflectionMapping as LS,CubeRefractionMapping as IS,CubeUVReflectionMapping as PS,LinearEncoding as Cd,sRGBEncoding as MS}from"three";var ai=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var NS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
955
- )*?)}`,"gim"),CS=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),tn=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,s){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=NS.exec(e);if(r){let o=r[2],n;for(;n=CS.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var li=class extends ae{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,n,s){n=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let h=0;h<a.inputs.length;h++){let p=a.inputs[h],u=this.inputs[h]||this.inputs[p.name];c.push(u.build(e,e.getTypeByFormat(p.type)))}l+=c.join(", ")+" )"}return e.format(l,n,r)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(r=>r.clone()),this}};var Te=class extends ae{constructor(e=new ce,r=Te.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:n=r,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Te.MIX:case Te.CLAMP:case Te.REFRACT:case Te.SMOOTHSTEP:case Te.FACEFORWARD:return 3;case Te.MIN:case Te.MAX:case Te.MOD:case Te.STEP:case Te.REFLECT:case Te.DISTANCE:case Te.DOT:case Te.CROSS:case Te.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Te.LENGTH:case Te.DISTANCE:case Te.DOT:return"f";case Te.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,n,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,h=this.getInputType(e),p=this.getType(e);switch(this.type=p,this.method){case Te.NEGATE:return e.format("( -"+this.a.build(e,h)+" )",h,r);case Te.INVERT:return e.format("( 1.0 - "+this.a.build(e,h)+" )",h,r);case Te.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case Te.STEP:o=this.a.build(e,a===1?"f":h),n=this.b.build(e,h);break;case Te.MIN:case Te.MAX:case Te.MOD:o=this.a.build(e,h),n=this.b.build(e,l===1?"f":h);break;case Te.REFRACT:o=this.a.build(e,h),n=this.b.build(e,h),s=this.c.build(e,"f");break;case Te.MIX:o=this.a.build(e,h),n=this.b.build(e,h),s=this.c.build(e,c===1?"f":h);break;default:o=this.a.build(e,h),this.b&&(n=this.b.build(e,h)),this.c&&(s=this.c.build(e,h));break}let u=[];u.push(o),n&&u.push(n),s&&u.push(s);let d=this.getNumInputs(e);if(u.length!==d)throw Error(`Arguments not match used in "${this.method}". Require ${d}, currently ${u.length}.`);return e.format(this.method+"( "+u.join(", ")+" )",p,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof ce?e.b.clone():e.b,this.c=e.c instanceof ce?e.c.clone():e.c,this.method=e.method,this}},de=Te;de.RAD="radians",de.DEG="degrees",de.EXP="exp",de.EXP2="exp2",de.LOG="log",de.LOG2="log2",de.SQRT="sqrt",de.INV_SQRT="inversesqrt",de.FLOOR="floor",de.CEIL="ceil",de.NORMALIZE="normalize",de.FRACT="fract",de.SATURATE="saturate",de.SIN="sin",de.COS="cos",de.TAN="tan",de.ASIN="asin",de.ACOS="acos",de.ARCTAN="atan",de.ABS="abs",de.SIGN="sign",de.LENGTH="length",de.NEGATE="negate",de.INVERT="invert",de.MIN="min",de.MAX="max",de.MOD="mod",de.STEP="step",de.REFLECT="reflect",de.DISTANCE="distance",de.DOT="dot",de.CROSS="cross",de.POW="pow",de.MIX="mix",de.CLAMP="clamp",de.REFRACT="refract",de.SMOOTHSTEP="smoothstep",de.FACEFORWARD="faceforward";var rn=class extends ae{constructor(e=new ce,r=new ce,o=new ce){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,n){let s=new li(rn.Nodes.bilinearCubeUV,[r,o,n]);this.colorSpaceTL=this.colorSpaceTL??new at(new Ce("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new at(new Ce("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new at(new Ce("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new at(new Ce("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new Ce(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ce(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ce(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ce(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Ce("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=s,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,s=new li(rn.Nodes.roughnessToMip,[n]),a=new de(s,rn.Nodes.m0,rn.Nodes.cubeUV_maxMipLevel,de.CLAMP),l=new de(a,de.FLOOR),c=new de(a,de.FRACT),h=this.bilinearCubeUV(e,this.value,o,l),p=this.bilinearCubeUV(e,this.value,o,new dt(l,new X(1).setReadonly(!0),dt.ADD)),u=new de(h,p,c,de.MIX);return e.format(u.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},on=rn;on.Nodes=function(){let e=new tn(`struct TextureCubeUVData {
956
- vec4 tl;
957
- vec4 tr;
958
- vec4 br;
959
- vec4 bl;
960
- vec2 f;
961
- }`),r=new xe("float cubeUV_maxMipLevel 8.0",!0),o=new xe("float cubeUV_minMipLevel 4.0",!0),n=new xe("float cubeUV_maxTileSize 256.0",!0),s=new xe("float cubeUV_minTileSize 16.0",!0),a=new K(`float getFace(vec3 direction) {
962
- vec3 absDirection = abs(direction);
963
- float face = -1.0;
964
- if (absDirection.x > absDirection.z) {
965
- if (absDirection.x > absDirection.y)
966
- face = direction.x > 0.0 ? 0.0 : 3.0;
967
- else
968
- face = direction.y > 0.0 ? 1.0 : 4.0;
969
- } else {
970
- if (absDirection.z > absDirection.y)
971
- face = direction.z > 0.0 ? 2.0 : 5.0;
972
- else
973
- face = direction.y > 0.0 ? 1.0 : 4.0;
974
- }
975
- return face;
976
- }`);a.useKeywords=!1;let l=new K(`vec2 getUV(vec3 direction, float face) {
977
- vec2 uv;
978
- if (face == 0.0) {
979
- uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
980
- } else if (face == 1.0) {
981
- uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
982
- } else if (face == 2.0) {
983
- uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
984
- } else if (face == 3.0) {
985
- uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
986
- } else if (face == 4.0) {
987
- uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
988
- } else {
989
- uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
990
- }
991
- return 0.5 * (uv + 1.0);
992
- }`);l.useKeywords=!1;let c=new K(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
993
- float face = getFace(direction);
994
- float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
995
- mipInt = max(mipInt, cubeUV_minMipLevel);
996
- float faceSize = exp2(mipInt);
997
- float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
998
- vec2 uv = getUV(direction, face) * (faceSize - 1.0);
999
- vec2 f = fract(uv);
1000
- uv += 0.5 - f;
1001
- if (face > 2.0) {
1002
- uv.y += faceSize;
1003
- face -= 3.0;
1004
- }
1005
- uv.x += face * faceSize;
1006
- if(mipInt < cubeUV_maxMipLevel){
1007
- uv.y += 2.0 * cubeUV_maxTileSize;
1008
- }
1009
- uv.y += filterInt * 2.0 * cubeUV_minTileSize;
1010
- uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
1011
- uv *= texelSize;
1012
- vec4 tl = texture2D(envMap, uv);
1013
- uv.x += texelSize;
1014
- vec4 tr = texture2D(envMap, uv);
1015
- uv.y += texelSize;
1016
- vec4 br = texture2D(envMap, uv);
1017
- uv.x -= texelSize;
1018
- vec4 bl = texture2D(envMap, uv);
1019
- return TextureCubeUVData( tl, tr, br, bl, f );
1020
- }`,[e,a,l,r,o,n,s]);c.useKeywords=!1;let h=new xe("float r0 1.0",!0),p=new xe("float v0 0.339",!0),u=new xe("float m0 -2.0",!0),d=new xe("float r1 0.8",!0),m=new xe("float v1 0.276",!0),g=new xe("float m1 -1.0",!0),x=new xe("float r4 0.4",!0),y=new xe("float v4 0.046",!0),v=new xe("float m4 2.0",!0),P=new xe("float r5 0.305",!0),S=new xe("float v5 0.016",!0),b=new xe("float m5 3.0",!0),B=new xe("float r6 0.21",!0),w=new xe("float v6 0.0038",!0),f=new xe("float m6 4.0",!0),D=[h,p,u,d,m,g,x,y,v,P,S,b,B,w,f],C=new K(`float roughnessToMip(float roughness) {
1021
- float mip = 0.0;
1022
- if (roughness >= r1) {
1023
- mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
1024
- } else if (roughness >= r4) {
1025
- mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
1026
- } else if (roughness >= r5) {
1027
- mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
1028
- } else if (roughness >= r6) {
1029
- mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
1030
- } else {
1031
- mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
1032
- }
1033
- return mip;
1034
- }`,D);return{bilinearCubeUV:c,roughnessToMip:C,m0:u,cubeUV_maxMipLevel:r}}();var ro=class extends ae{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ro.VIEW}getShared(){return this.scope===ro.WORLD}build(e,r,o,n){let s=e.context[this.scope+"Normal"];return s?s.build(e,r,o,n):super.build(e,r,o)}generate(e,r,o,n,s){let a;switch(this.scope){case ro.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case ro.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case ro.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}copy(e){return super.copy(e),this.scope=e.scope,this}},$e=ro;$e.LOCAL="local",$e.WORLD="world",$e.VIEW="view",$e.NORMAL="normal";He.addKeyword("viewNormal",function(){return new $e($e.VIEW)});He.addKeyword("localNormal",function(){return new $e($e.NORMAL)});He.addKeyword("worldNormal",function(){return new $e($e.WORLD)});var ir=class extends ae{constructor(e){super("v3");this.nodeType="Position";this.scope=e??ir.LOCAL}getType(){switch(this.scope){case ir.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case ir.LOCAL:case ir.WORLD:return!1}return!0}generate(e,r,o,n,s){let a;switch(this.scope){case ir.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case ir.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case ir.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ir.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}copy(e){return super.copy(e),this.scope=e.scope,this}},Qe=ir;Qe.LOCAL="local",Qe.WORLD="world",Qe.VIEW="view",Qe.PROJECTION="projection";He.addKeyword("position",function(){return new Qe});He.addKeyword("worldPosition",function(){return new Qe(Qe.WORLD)});He.addKeyword("viewPosition",function(){return new Qe(Qe.VIEW)});var Vt=class extends ae{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Vt.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Vt.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case Vt.VECTOR:{let s=new $e($e.VIEW),a=e.context.roughness,l=s.build(e,"v3"),c=new Qe(Qe.VIEW).build(e,"v3"),h=a?a.build(e,"f"):void 0,p=`reflect( -normalize( ${c} ), ${l} )`;h&&(p=`normalize( mix( ${p}, ${l}, ${h} * ${h} ) )`);let u=`inverseTransformDirection( ${p}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${u};`),n="reflectVec"):n=u;break}case Vt.CUBE:{let s=new Vt(Vt.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),n="reflectCubeVec"):n=a;break}case Vt.SPHERE:{let s=new Vt(Vt.VECTOR).build(e,"v3"),a="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),n="reflectSphereVec"):n=a;break}}return e.format(n,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}copy(e){return super.copy(e),this.scope=e.scope,this}},sr=Vt;sr.CUBE="cube",sr.SPHERE="sphere",sr.VECTOR="vector";var Vs=class extends ae{constructor(e=new Je,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new on(this.value,r??new sr(sr.VECTOR),o),this.irradianceNode=new on(this.value,new $e($e.WORLD),new X(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as TS}from"three";var Fs=class extends Ie{constructor(e=new TS,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new sr,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv?.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+o+", "+n+", "+s+" )":a="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new at(new Ce("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,r)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var Td=["x","y","z","w"],AS=["float","vec2","vec3","vec4"],OS={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},DS={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Us=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let s="";n=n.sort(t);for(let a=0;a<n.length;a++)n[a].src&&(s+=n[a].src+`
1035
- `);return s}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
1036
- // NOTE: Include Spline's blending modes. This could be part of BlendNode
1037
- #define SPE_BLENDING_NORMAL 0
1038
- #define SPE_BLENDING_MULTIPLY 1
1039
- #define SPE_BLENDING_SCREEN 2
1040
- #define SPE_BLENDING_OVERLAY 3
1230
+ #endif
1041
1231
 
1042
- vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
1043
- return mix( a, b, alpha );
1044
- }
1232
+ #if NUM_SPOT_LIGHTS > 0
1233
+
1234
+ #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
1235
+ SpotLightShadow spotLightShadow;
1236
+ #endif
1045
1237
 
1046
- vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
1047
- return mix( a, a * b, alpha );
1048
- }
1238
+ #pragma unroll_loop_start
1239
+ for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
1240
+ lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
1241
+ l = normalize(lpos - worldPosition);
1242
+
1243
+ dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
1244
+ t = max(t, dproduct);
1049
1245
 
1050
- vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
1051
- vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
1052
- return mix( a, tmp, alpha );
1053
- }
1246
+ // Accumulate shadow contribution
1247
+ #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
1248
+ spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
1249
+ shadow *= getShadow(
1250
+ UNROLLED_LOOP_INDEX,
1251
+ spotShadowMap[UNROLLED_LOOP_INDEX],
1252
+ spotLightShadow.shadowMapSize,
1253
+ spotLightShadow.shadowBias,
1254
+ spotLightShadow.shadowRadius,
1255
+ vSpotShadowCoord[UNROLLED_LOOP_INDEX]);
1256
+ #endif
1257
+ }
1258
+ #pragma unroll_loop_end
1054
1259
 
1055
- vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
1056
- vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
1057
- return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
1058
- }
1260
+ #endif
1059
1261
 
1060
- vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
1061
- if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
1062
- else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
1063
- else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
1064
- else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
1065
- return vec3( 1.0 );
1066
- }
1067
- `,"#include <packing>","#include <common>"].join(`
1068
- `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
1069
- `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
1070
- accumAlpha += (1.0 - accumAlpha) * alpha;
1071
- }`,""].join(`
1072
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.material=t,this.renderer=e,this.requires.lights=t.lights,this.requires.fog=t.fog,this.mergeDefines(t.defines),this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
1073
- `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
1074
- `}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
1075
- `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
1076
- `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,o="varying",n="V",s=""){let a=this.getVars(o),l=a[t];if(!l){let c=a.length;l={name:r||"node"+n+c+(s?"_"+s:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,o){return this.getVar(t,e,r,this.shader,"T",o)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
1077
- `)}getVarListCode(t,e){e=e??"";let r="";for(let o=0,n=t.length;o<n;++o){let s=t[o],a=s.type,l=s.name,c=s.size,h=this.getFormatByType(a);if(h===void 0)throw new Error("Node pars "+h+" not found.");h.includes("[]")?r+=e+" "+h.substring(0,h.length-2)+" "+l+`[${c}];
1078
- `:r+=e+" "+h+" "+l+`;
1079
- `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof ce?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,n,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new ai({type:e,size:r.size,name:o||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new ai({type:e,name:o||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,o,n){return this.createUniform("vertex",t,e,r,o,n)}createFragmentUniform(t,e,r,o,n){return this.createUniform("fragment",t,e,r,o,n)}include(t,e,r){let o;if(t=typeof t=="string"?He.get(t):t,this.context.include===!1)return t.name;t instanceof K?o=this.includes.functions:t instanceof xe?o=this.includes.consts:t instanceof tn&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(t){let s=n[t.name];if(s||(s=n[t.name]={node:t,deps:[]},n.push(s),s.src=t.build(this,"source")),t instanceof K&&e&&n[e.name]&&n[e.name].deps.indexOf(t)===-1&&(n[e.name].deps.push(t),t.includes?.length)){let a=0;do this.include(t.includes[a++],e);while(a<t.includes.length)}return r&&(s.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return AS[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case LS:case IS:return new Fs(r);case PS:return new Vs(new Je(r));default:return new Je(r)}else{if(r.isVector2)return new Ye(r);if(r.isVector3)return new ot(r);if(r.isVector4)return new nr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return OS[t]||t}getFormatByType(t){return DS[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Td[t]}getIndexByElement(t){return Td.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=Cd,e===Cd&&this.context.gamma&&(e=MS),e}};var ci=class extends ce{constructor(e=new ce){super("v4");this.nodeType="Raw";this.value=e}generate(e){let r=this.value.analyzeAndFlow(e,this.type),o=r.code+`
1080
- `;return e.isShader("vertex")?o+="gl_Position = "+r.result+";":o+="gl_FragColor = "+r.result+";",o}copy(e){return super.copy(e),this.value.copy(e.value),this}};var bt=class extends BS{constructor(e,r,o){super(o);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e??new ci(new Qe(Qe.PROJECTION)),this.fragment=r??new ci(new Ne(5855577)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let r=new en(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(o=>requestAnimationFrame(o));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let o=(n,s,a)=>Math.min(Math.max(n,s),a);if(this.userData.layers){for(let n of this.userData.layers.getLayers())if(n.type=="displace"){this.uniformsBackup[`f${n.id}_intensity`]=n.uniforms[`f${n.id}_intensity`].value;let s=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type=="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){e=e??{};let r=e.builder??new Us;return r.setMaterial(this,e.renderer),r.build(this.vertex,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.fog=r.requires.fog,this.lights=r.requires.lights,this.transparent=r.requires.transparent||this.blending>_S,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}get penumbraSizeNode(){return this.fragment.penumbraSize}set penumbraSizeNode(e){this.fragment.penumbraSize=e}};Object.defineProperties(bt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as ES,UniformsUtils as GS}from"three";var js=class extends ce{constructor(){super("basic");this.nodeType="Basic";this.color=new Ne(5855577)}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(GS.merge([ES.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1081
- `));let n=["#include <beginnormal_vertex>",`
1082
- #if !defined( USE_LAYER_DISPLACE )
1083
- #include <defaultnormal_vertex>
1084
- #endif
1262
+ t = clamp(t, 0.0, 1.0);
1263
+
1264
+ #endif
1265
+
1266
+ } else if (positioning == 1) {
1267
+
1268
+ vec3 origin = mix(position, worldPosition, float(isWorldSpace));
1269
+ vec3 direction = normalize(source - origin);
1270
+ t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
1085
1271
 
1086
- vec3 displaced_position = position;
1087
- vec3 displaced_normal = normal;
1272
+ } else {
1088
1273
 
1089
- #if defined( USE_LAYER_DISPLACE )
1090
- vec3 transformed;
1091
- vec3 transformedNormal;
1092
- #endif
1093
- `,"#include <normal_vertex>",`
1094
- #if !defined( USE_LAYER_DISPLACE )
1095
- #include <begin_vertex>
1096
- #endif /* !USE_LAYER_DISPLACE */
1097
- `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1098
- `)}else{this.color===void 0&&(this.color=new Ne(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1099
- `));let a=["#include <normal_fragment_begin>",o.code];n&&a.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?a.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):a.push(`vec3 finalColor = ${o.result};`),n?a.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} );`):a.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a.push("#include <fog_fragment>","#include <dithering_fragment>"),r=a.join(`
1100
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var ks=class extends bt{constructor(e=new js,r){super(e,e,r);this.type="BasicNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}};var Ft=class extends ks{constructor(t,e,r){super(e,t),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r??this._getLayerStack(t?.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}static fromMaterial(t){let e=new Ft(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}};import{UniformsLib as Ld,UniformsUtils as RS}from"three";var Hs=class extends ce{constructor(){super("phong");this.nodeType="Phong";this.color=new Ne(5855577),this.specular=new Ne(1118481),this.shininess=new X(30),this.penumbraSize=new ke(5,.5),this.shadingAlpha=new X(1),this.shadingBlend=new fe(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(RS.merge([Ld.fog,Ld.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1101
- `));let n=["#include <beginnormal_vertex>",`
1102
- #ifndef USE_LAYER_DISPLACE
1103
- #include <defaultnormal_vertex>
1104
- #endif
1274
+ vec3 origin = worldPosition;
1275
+ vec3 source = cameraPosition - offset;
1276
+ vec3 direction = normalize(source - origin);
1277
+ t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
1278
+
1279
+ }
1105
1280
 
1281
+ if (noiseStrength > 0.0) {
1282
+ // Distort with noise
1283
+ vec3 st = position / noiseScale;
1284
+
1285
+ // Voronoi "smooth" noise
1286
+ float noise = 1.0 - voronoiNoise(st).x;
1106
1287
 
1107
- vec3 displaced_position = position;
1108
- vec3 displaced_normal = normal;
1288
+ // Voronoi cellular noise
1289
+ //float noise = 1.0 - rand(voronoiNoise(st).z);
1109
1290
 
1110
- #ifdef USE_LAYER_DISPLACE
1111
- vec3 transformed;
1112
- vec3 transformedNormal;
1113
- #endif
1114
- `,"#include <normal_vertex>",`
1115
- #ifndef USE_LAYER_DISPLACE
1116
- #include <begin_vertex>
1117
- #endif
1118
- `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1119
- `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new Ne(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1120
- `));let p=["#include <normal_fragment_begin>",`
1121
- // NOTE: gl_FrontFacing alternative using face normal estimation.
1122
- vec3 viewdx = dFdx(vViewPosition);
1123
- vec3 viewdy = dFdy(vViewPosition);
1124
- vec3 faceNormal = normalize(cross(viewdx,viewdy));
1125
- if (dot(normal, faceNormal) < 0.0) {
1126
- normal *= -1.0;
1127
- }
1128
- `," BlinnPhongMaterial material;"];p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),h&&p.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),p.push("material.diffuseColor = diffuseColor;"),p.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),p.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),p.push(`
1129
- if (outgoingLight != diffuseColor) {
1130
- float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1131
- accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
1132
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
1291
+ // Position warp noise
1292
+ // vec3 offset = vec3(
1293
+ // simplex3d(st),
1294
+ // simplex3d(st + vec3(111.1, 143.89, 217.19)),
1295
+ // simplex3d(st + vec3(171.1, 247.89, 117.23))
1296
+ // );
1297
+ // st += offset;
1298
+ // float noise = valueNoise(st);
1299
+
1300
+ t += noise * noiseStrength;
1133
1301
  }
1134
- `),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
1135
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Ws=class extends bt{constructor(e=new Hs,r){super(e,e,r);this.type="PhongNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var nn=class extends Ws{constructor(t,e,r){super(e,t),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r??this._getLayerStack(t?.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}static fromMaterial(t){let e=new nn(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}};import{UniformsLib as Id,UniformsUtils as zS}from"three";var qs=class extends ce{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ne(5855577),this.emissive=new Ne(0),this.emissiveIntensity=new X(1),this.penumbraSize=new ke(5,.5),this.shadingAlpha=new X(1),this.shadingBlend=new fe(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(zS.merge([Id.fog,Id.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1136
- `));let n=["#include <beginnormal_vertex>",`
1137
- #ifndef USE_LAYER_DISPLACE
1138
- #include <defaultnormal_vertex>
1139
- #endif
1140
1302
 
1141
- vec3 displaced_position = position;
1142
- vec3 displaced_normal = normal;
1303
+ t = clamp(t, 0.0, 1.0);
1143
1304
 
1144
- #ifdef USE_LAYER_DISPLACE
1145
- vec3 transformed;
1146
- vec3 transformedNormal;
1147
- #endif
1148
- `,"#include <normal_vertex>",`
1149
- #ifndef USE_LAYER_DISPLACE
1150
- #include <begin_vertex>
1151
- #endif
1152
- `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
1153
- vec3 diffuse = vec3( 1.0 );
1154
- GeometricContext geometry;
1155
- geometry.position = mvPosition.xyz;
1156
- geometry.normal = normalize( transformedNormal );
1157
- geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
1158
- GeometricContext backGeometry;
1159
- backGeometry.position = geometry.position;
1160
- backGeometry.normal = -geometry.normal;
1161
- backGeometry.viewDir = geometry.viewDir;
1162
- vLightFront = vec3( 0.0 );
1163
- vIndirectFront = vec3( 0.0 );
1164
- #ifdef DOUBLE_SIDED
1165
- vLightBack = vec3( 0.0 );
1166
- vIndirectBack = vec3( 0.0 );
1167
- #endif
1168
- IncidentLight directLight;
1169
- float dotNL;
1170
- vec3 directLightColor_Diffuse;
1171
- vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
1172
- vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
1173
- #ifdef DOUBLE_SIDED
1174
- vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
1175
- vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
1176
- #endif
1177
- #if NUM_POINT_LIGHTS > 0
1178
- #pragma unroll_loop_start
1179
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1180
- getPointLightInfo( pointLights[ i ], geometry, directLight );
1181
- dotNL = dot( geometry.normal, directLight.direction );
1182
- directLightColor_Diffuse = directLight.color;
1183
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
1184
- #ifdef DOUBLE_SIDED
1185
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
1186
- #endif
1187
- }
1188
- #pragma unroll_loop_end
1189
- #endif
1190
- #if NUM_SPOT_LIGHTS > 0
1191
- #pragma unroll_loop_start
1192
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1193
- getSpotLightInfo( spotLights[ i ], geometry, directLight );
1194
- dotNL = dot( geometry.normal, directLight.direction );
1195
- directLightColor_Diffuse = directLight.color;
1196
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
1197
- #ifdef DOUBLE_SIDED
1198
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
1199
- #endif
1200
- }
1201
- #pragma unroll_loop_end
1202
- #endif
1203
- #if NUM_DIR_LIGHTS > 0
1204
- #pragma unroll_loop_start
1205
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1206
- getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
1207
- dotNL = dot( geometry.normal, directLight.direction );
1208
- directLightColor_Diffuse = directLight.color;
1209
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
1210
- #ifdef DOUBLE_SIDED
1211
- vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
1212
- #endif
1213
- }
1214
- #pragma unroll_loop_end
1215
- #endif
1216
- #if NUM_HEMI_LIGHTS > 0
1217
- #pragma unroll_loop_start
1218
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1219
- vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
1220
- #ifdef DOUBLE_SIDED
1221
- vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
1222
- #endif
1223
- }
1224
- #pragma unroll_loop_end
1225
- #endif
1226
- `," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1227
- `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new Ne(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1228
- `));let p=["#include <normal_fragment_begin>",`
1229
- // NOTE: gl_FrontFacing alternative using face normal estimation.
1230
- vec3 viewdx = dFdx(vViewPosition);
1231
- vec3 viewdy = dFdy(vViewPosition);
1232
- vec3 faceNormal = normalize(cross(viewdx, viewdy));
1233
- bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
1234
- `,"#include <clipping_planes_fragment>"];p.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&p.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),p.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),n&&p.push(n.code,"reflectedLight.directDiffuse += "+n.result+" * "+s.result+";"),p.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),p.push(`
1235
- if (outgoingLight != diffuseColor) {
1236
- float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1237
- accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
1238
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
1305
+ // Compute ramp color
1306
+ float p;
1307
+ vec4 color = colors[0];
1308
+ for (int i = 1; i < COLORS_MAX; i++) {
1309
+ p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
1310
+ color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
1239
1311
  }
1240
- `),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
1241
- `)}return r}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var $s=class extends bt{constructor(e=new qs,r){super(e,e,r);this.type="LambertNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}};var Xs=class extends $s{constructor(t,e,r){super(e,t),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r??this._getLayerStack(t?.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}};import{UniformsLib as Pd,UniformsUtils as VS}from"three";var Ks=class extends ce{constructor(){super("toon");this.nodeType="Toon";this.color=new Ne(5855577),this.specular=new Ne(1118481),this.shininess=new X(30),this.penumbraSize=new ke(5,.5),this.shadingAlpha=new X(1),this.shadingBlend=new fe(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(VS.merge([Pd.fog,Pd.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1242
- `));let n=["#include <beginnormal_vertex>",`
1243
- #ifndef USE_LAYER_DISPLACE
1244
- #include <defaultnormal_vertex>
1245
- #endif
1246
1312
 
1247
- vec3 displaced_position = position;
1248
- vec3 displaced_normal = normal;
1313
+ // Incorporate custom shadow color
1314
+ if (positioning == 0) {
1249
1315
 
1250
- #ifdef USE_LAYER_DISPLACE
1251
- vec3 transformed;
1252
- vec3 transformedNormal;
1253
- #endif
1254
- `,"#include <normal_vertex>",`
1255
- #ifndef USE_LAYER_DISPLACE
1256
- #include <begin_vertex>
1257
- #endif
1258
- `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1259
- `)}else{e.mergeUniform({penumbraSize:this.penumbraSize}),this.color===void 0&&(this.color=new Ne(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
1260
- varying vec3 vViewPosition;
1261
- struct ToonMaterial {
1262
- vec3 diffuseColor;
1263
- vec3 specularColor;
1264
- float specularShininess;
1265
- float specularStrength;
1266
- };
1267
- void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
1268
- vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
1269
-
1270
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1271
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
1272
- }
1273
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
1274
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1275
- }
1276
- #define RE_Direct RE_Direct_Toon
1277
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
1278
- #define Material_LightProbeLOD( material ) (0)
1279
- `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
1280
- `));let p=["#include <normal_fragment_begin>",`
1281
- // NOTE: gl_FrontFacing alternative using face normal estimation.
1282
- vec3 viewdx = dFdx(vViewPosition);
1283
- vec3 viewdy = dFdy(vViewPosition);
1284
- vec3 faceNormal = normalize(cross(viewdx,viewdy));
1285
- if (dot(normal, faceNormal) < 0.0) {
1286
- normal *= -1.0;
1287
- }
1288
- `," ToonMaterial material;"];p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," vec3 specular = "+n.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),h&&p.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),p.push("material.diffuseColor = diffuseColor;"),p.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),p.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),p.push(`
1289
- if (outgoingLight != diffuseColor) {
1290
- float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1291
- accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
1292
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
1316
+ vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
1317
+ color.rgb = mix(blendedShadow, color.rgb, shadow);
1318
+
1293
1319
  }
1294
- `),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
1295
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Ys=class extends bt{constructor(e=new Ks,r){super(e,e,r);this.type="ToonNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Js=class extends Ys{constructor(t,e,r){super(e,t),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r??this._getLayerStack(t?.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}};import{UniformsLib as Ul,UniformsUtils as FS}from"three";var Qs=class extends ce{constructor(){super("standard");this.nodeType="Standard";this.color=new Ne(5855577),this.roughness=new X(.3),this.metalness=new X(0),this.reflectivity=new X(.5),this.penumbraSize=new ke(5,.5),this.shadingAlpha=new X(1),this.shadingBlend=new fe(0)}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(FS.merge([Ul.fog,Ul.lights])),Ul.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1296
- `));let n=["#include <beginnormal_vertex>",`
1297
- #if !defined( USE_LAYER_DISPLACE )
1298
- #include <defaultnormal_vertex>
1299
- #endif
1300
1320
 
1301
- vec3 displaced_position = position;
1302
- vec3 displaced_normal = normal;
1321
+ // Accumulate alpha as usual
1322
+ float lalpha = alpha * color.a;
1323
+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
1324
+ accumAlpha += (1.0 - accumAlpha) * lalpha;
1303
1325
 
1304
- #if defined( USE_LAYER_DISPLACE )
1305
- vec3 transformed;
1306
- vec3 transformedNormal;
1307
- #endif
1308
- `,"#include <normal_vertex>",`
1309
- #if !defined( USE_LAYER_DISPLACE )
1310
- #include <begin_vertex>
1311
- #endif /* !USE_LAYER_DISPLACE */
1312
- `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1313
- `)}else{e.mergeUniform({penumbraSize:this.penumbraSize});let o={gamma:!0};this.color===void 0&&(this.color=new Ne(5855577)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let n=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),a=this.metalness.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
1314
- `));let d=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
1315
- // NOTE: gl_FrontFacing alternative using face normal estimation.
1316
- vec3 viewdx = dFdx(vViewPosition);
1317
- vec3 viewdy = dFdy(vViewPosition);
1318
- vec3 faceNormal = normalize(cross(viewdx,viewdy));
1319
- if (dot(normal, faceNormal) < 0.0) {
1320
- normal *= -1.0;
1321
- }
1322
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];d.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",a.code," float metalnessFactor = "+a.result+";"),p&&d.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),d.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),d.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),u?d.push(u.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+u.result+" ) ), diffuseColor, metalnessFactor );"):d.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),d.push("#include <lights_fragment_begin>"),d.push("#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),d.push(`
1323
- if (outgoingLight != diffuseColor) {
1324
- float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1325
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * lightAccu;
1326
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
1327
- }
1328
- `),h&&d.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),p?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
1329
- `)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Zs=class extends bt{constructor(e=new Qs,r){super(e,e,r);this.type="StandardNodeMaterial",this.fragment=e}get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}};var ea=class extends Zs{constructor(t,e,r){super(e,t),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r??this._getLayerStack(t?.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}};import{Color as Hl}from"three";import{Matrix3 as Md,Texture as jl,Vector2 as hi,Vector3 as ar,Vector4 as kl}from"three";function Ad(i,t){switch(i.data.type){case"light":return St(i);case"fresnel":return jS(i,t);case"gradient":return kS(i);case"depth":return HS(i);case"normal":return WS(i);case"noise":return qS(i,t);case"texture":return $S(i,t);case"rainbow":return XS(i);case"toon":return KS(i,t);case"outline":return YS(i,t);case"transmission":return JS(i,t);case"matcap":return QS(i,t);case"displace":return ZS(i);case"color":default:return US(i,t)}}function Od(i){return{type:i.data.type}}function St(i){let{alpha:t,mode:e}=i.data;return{...Od(i),alpha:t,mode:e}}function US(i,t){return{...St(i),color:Ae(i.data.color,t)}}function jS(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:s}=i.data;return{...St(i),color:Ae(s,t),bias:e,scale:r,intensity:o,factor:n}}function kS(i){let{gradientType:t,smooth:e,colors:r,steps:o,angle:n,offset:s,morph:a}=i.data;return{...St(i),gradientType:t,smooth:e,colors:r.map(l=>new kl(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new hi(...s),morph:new hi(...a),angle:n}}function HS(i){let{gradientType:t,near:e,far:r,isVector:o,isWorldSpace:n,origin:s,direction:a,colors:l,steps:c,smooth:h,num:p}=i.data;return{...St(i),gradientType:t,near:e,far:r,isVector:o,isWorldSpace:n,origin:new ar(...s),direction:a?new ar(...a):new ar(1,0,0),num:p,colors:l.map(u=>new kl(u[0],u[1],u[2],u[3])),steps:c,smooth:h}}function WS(i){let{cnormal:t}=i.data;return{...St(i),cnormal:new ar(t[0],t[1],t[2])}}function qS(i,t){let{data:e}=i;return{...St(i),scale:e.scale,move:e.move,fA:new hi(...e.fA),fB:new hi(...e.fB),size:new ar(...e.size),distortion:new hi(...e.distortion),colorA:Ae(e.colorA,t),colorB:Ae(e.colorB,t),colorC:Ae(e.colorC,t),colorD:Ae(e.colorD,t),noiseType:e.noiseType}}function $S(i,t){let{projection:e,axis:r,side:o,crop:n,size:s}=i.data,{image:a,wrapping:l,repeat:c,offset:h}=i.data.texture,p=new jl,u;if(typeof a=="string")u=t?.getImage(a);else{let d=new Image;d.src=sn(a.data),d.onload=()=>{t?.onImageLoad&&t?.onImageLoad()},u=d}return p.image=u,p.repeat.set(c[0],c[1]),p.offset.set(h[0],h[1]),p.wrapS=p.wrapT=l,{...St(i),texture:p,mat:new Md().setUvTransform(h[0],h[1],c[0],c[1],0,0,0),crop:n,projection:e,axis:["x","y","z"].indexOf(r),side:[2,0,1].indexOf(o),size:s}}function XS(i){let{data:t}=i;return{...St(i),filmThickness:t.filmThickness,movement:t.movement,wavelengths:new ar(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new ar(...t.offset)}}function KS(i,t){let{data:e}=i;return{...St(i),positioning:e.positioning,colors:e.colors.map(r=>new kl(r[0],r[1],r[2],r[3])),num:e.colors.length,steps:e.steps,source:new ar(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:Ae(e.shadowColor,t),offset:new ar(...e.offset)}}function YS(i,t){let{data:e}=i;return{...St(i),outlineColor:Ae(e.outlineColor,t),contourColor:Ae(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:e.contourDirection,positionalLines:e.positionalLines,compensation:e.compensation,resolution:t.resolutionNode,normalMap:t.normalMap,depthMap:t.normalRenderTarget.depthTexture,pixelRatio:t.pixelRatioNode}}function JS(i,t){let{data:e}=i;return{...St(i),thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap}}function QS(i,t){let e=new jl,{image:r}=i.data.texture,o;if(typeof r=="string")o=t?.getImage(r);else{let s=new Image;s.src=sn(r.data),s.onload=()=>{t?.onImageLoad&&t?.onImageLoad()},o=s}e.image=o;let n=16777215;return{...St(i),color:n,texture:e}}function ZS(i){let{data:t}=i,e={...Od(i),intensity:t.intensity};if(t.displacementType==="noise")return{...e,offset:new ar(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType};{let r=new jl,o=new Md().setUvTransform(0,0,1,1,0,0,0);return{...e,texture:r,mat:o,crop:t.crop}}}function Dd(i,t,e){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=e.alpha*(e.visible?1:0),e.type==="outline"&&i=="visible"){let o=t.uniforms[`f${t.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return r}}import{Color as Ed,Vector4 as ew}from"three";var an;(t=>{function i(e){return new Ed(e.x,e.y,e.z).getHex()}t.getHex=i})(an||(an={}));var _d;(t=>{function i(e){return new ew(e.r,e.g,e.b,e.a)}t.getThreeVector4=i})(_d||(_d={}));var Bd;(e=>{function i(r,o){r.setRGB(o.r,o.g,o.b)}e.setThreeColor=i;function t(r){return new Ed(r.r,r.g,r.b).getHex()}e.getHex=t})(Bd||(Bd={}));function pi(i,t){return typeof i=="string"?t.getMaterialOrDeletedPlaceholder(i):Wl(i,t)}function Gd(i,t){return i.map(e=>pi(e,t))}function Wl(i,t){let e=i.layers??Qr.defaultTwoLayerData("phong").layers,r=tw(e),o;switch(r.category){case"basic":o=new Ft;break;case"lambert":{o=new Xs;break}case"toon":{o=new Js;break}case"physical":o=new ea;break;case"phong":default:{o=new nn;break}}o.name=i.name??"Untitled Material";let n=o.userData.layers;rw(n);for(let s=e.length-1;s>=0;s--)ow(n,e[s],t);switch(r.category){case"basic":break;case"lambert":{let l=o,h=Ae(r.emissive,t);h instanceof Hl?l.emissive.value=h:l.emissive.value.setHex(an.getHex(h));break}case"toon":{let l=o,c=r;l.shininess.value=c.shininess;let h=Ae(c.specular,t);h instanceof Hl?l.specular.value=h:l.specular.value.setHex(an.getHex(h));break}case"physical":let s=o,a=r;s.metalness.value=a.metalness,s.roughness.value=a.roughness,s.reflectivity.value=a.reflectivity;break;case"phong":default:{let l=o,c=r;l.shininess.value=c.shininess;let h=Ae(c.specular,t);h instanceof Hl?l.specular.value=h:l.specular.value.setHex(an.getHex(h));break}}return o.penumbraSizeNode=t.penumbraSizeNode,n.blendColors(),n.blendAfterColors(),n.blendPositions(),o}function tw(i){for(let t of i)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function rw(i){for(let t of i.getLayers())i.removeLayer(t.id)}function ow(i,t,e){let r=Ad(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e?.transmissionSamplerMap,r.transmissionDepthMap=e?.transmissionDepthMap),r.type==="outline"&&(r.normalMap=e?.normalMap,r.depthMap=e?.normalRenderTarget.depthTexture);let o=i.addLayer(r);o.uuid=t.id;for(let n in t.data)Dd(n,o,t.data)}function aw(i,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=i.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=i.depthTexture}function lw(i,t){t.uniforms[`f${t.id}_normalMap`].value=i.texture,t.uniforms[`f${t.id}_depthMap`].value=i.depthTexture}function cw(i){if(i.geometry.attributes.extrudeNormals)return;let t=new Map,e=i.geometry.attributes.position.array,r=i.geometry.attributes.normal.array,o=new Float32Array(e.length);for(let n=0;n<e.length;n+=3){let s=`${e[n]}_${e[n+1]}_${e[n+2]}`,a=new $l(r[n],r[n+1],r[n+2]);t.has(s)?t.get(s)?.normals.push(a):t.set(s,{normals:[a],result:new $l})}t.forEach((n,s)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<e.length;n+=3){let s=`${e[n]}_${e[n+1]}_${e[n+2]}`,a=t.get(s)?.result;a&&(o[n]=a.x,o[n+1]=a.y,o[n+2]=a.z)}i.geometry.setAttribute("extrudeNormal",new Fd(o,3))}function hw(i){if(i.geometry.attributes.extrudeNormals)return;let t=i.geometry.attributes.position.array,e=new Float32Array(t.length),r=new $l;for(let o=0;o<t.length;o+=3)r.set(t[o],t[o+1],t[o+2]).normalize(),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z;i.geometry.setAttribute("extrudeNormal",new Fd(e,3))}function ui(i){i.objectType==="Mesh2D"?hw(i):cw(i)}function Xl(i){let t=i.geometry.attributes.position.array,e=new Float32Array(t.length),r=parseInt(i.uuid.replace(/\D/g,"")),o=[ql.seededRandom(r),ql.seededRandom(r+1e4),ql.seededRandom(r+2e4)];for(let n=0;n<t.length;n++)e[n]=o[n%3];i.geometry.setAttribute("randomColor",new sw(e,3))}function Rd(i,t,e){if(!e.userData.layers)return!1;let r=!1,o=e.userData.layers.getLayersOfType("transmission"),n=e.userData.layers.getLayersOfType("outline");return n.length>0&&(t.layers.set(8),o.length===0&&t.layers.enable(3),t.cloner?.refreshClonerMasks(),r=!0,i!==void 0&&n.forEach(s=>lw(i,s)),Xl(t),ui(t)),o.length===0&&n.length===0&&(t.layers.set(0),t.cloner?.refreshClonerMasks()),r}function zd(i,t,e){if(!e.userData.layers)return!1;let r=!1,o=e.userData.layers.getLayersOfType("transmission"),n=e.userData.layers.getLayersOfType("outline");return o.length>0&&(t.layers.set(3),n.length>0&&t.layers.enable(8),t.cloner?.refreshClonerMasks(),r=!0,i!==void 0&&o.forEach(s=>aw(i,s))),o.length===0&&n.length===0&&(t.layers.set(0),t.cloner?.refreshClonerMasks()),r}function Ud(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof Vd)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Rd(i,r,r.material[o])&&(e=!0);else Rd(i,r,r.material)&&(e=!0)}),e}function jd(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof Vd)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)zd(i,r,r.material[o])&&(e=!0);else zd(i,r,r.material)&&(e=!0)}),e}function kd(i,t){"material"in i&&pw(i.material,t),"geometry"in i&&i.geometry.dispose()}function pw(i,t){gc(i).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var Xe=class extends Ot(uw){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new dw;this.booleanExclude=null;Array.isArray(r)&&e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0)}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}updateGeometry(e){let r=this.geometry,o=Kl[r.userData.type],n=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=o.build(o.normalizeInputs(e,n)),a=r.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),ui(this),r.getAttribute("randomColor")&&Xl(this),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=di(r),n=this.material;return new this.constructor(o,n).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new eo(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?(this.cloner?.onRemoved(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new eo(this)),this.cloner.fromClonerState(e))}fromState(e,r){return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=e.castShadow??!0,this.receiveShadow=e.receiveShadow??!0,this.booleanExclude=e.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ut.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),tr(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)er(e)&&(e.freeBooleanPointer(),tr(e)&&e.invalidateUpstreamBooleanData())}};var gw=new Yl(0,0,1),Hd=new Yl,Wd=new Yl,qd=new fw,jr=class extends Xe{constructor(e=Ke.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new mw;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=e,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),qd.getNormalMatrix(this.matrixWorld),Hd.copy(gw).applyMatrix3(qd).normalize(),Wd.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Hd,Wd)}clone(e){let r=this.shape.clone(),o=this.material,n=this.geometry.userData,s=Ke.create(Object.assign({},n,{shape:r})),a=new jr(s,o).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){Xe.prototype.raycast.call(this,e,r)}};function ta(i,t){return xw(i)}function xw(i){let t={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=ve.createFromState(i.shape,i.width,i.height);t.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),t.geometry=new yw().parse(i));let e;try{e=di(t)}catch(r){console.error(r)}if(!e){let r=ve.createFromState(Eo.defaultData(),100,100);t.shape=r,e=di(t)}return e}var ue;Rs.then(i=>{ue=i});var Kd=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Yd=new Uint32Array([0,1,2,3]),Jd=new Uint8Array([4]),_t=class{static build(i,t,e,r,o){let n,s,a,l=i?.phongAngle??t?.phongAngle??35;if(r===!1&&(l=-1),i.positionWASM!==void 0){e&&e!==0&&(ue.free_bvh(e),ue.free_subdivision_surface(e));try{n=_t.allocate(i,o)}catch(c){console.error(c,i),n=_t.allocate({positionWASM:Kd,indexWASM:Yd,verticesPerFaceWASM:Jd},o)}ue.set_destination_refinement_level(n,0),s=_t.buildLevel(n,!0,l)}else n=e,i.phongAngle!==void 0&&(s=_t.buildLevel(n,!0,l));return i.subdivisions!==void 0&&(ue.set_destination_refinement_level(n,i.subdivisions),i.subdivisions>0?a=_t.buildLevel(n,!1,l):a=null),{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}}static primitiveToQuads(i,t){i.widthSegments>16&&(i.widthSegments=16),i.heightSegments>16&&(i.heightSegments=16),i.depthSegments>16&&(i.depthSegments=16),i.radialSegments>16&&(i.radialSegments=16),i.type==="DodecahedronGeometry"&&(i.detail=0);let e=i.shape!==void 0?t.geometry:ta(i),r,o,n,s;return{positions:r,triIndices:s}=rc(e.getAttribute("position"),e.getIndex()),{indices:o,verticesPerFace:n}=oc(r,s,e),{positions:r,indices:o,verticesPerFace:n}}static allocate(i,t){let e,r,o,n=[],s=[];i.positionWASM&&i.positionWASM.length>0?(e=i.positionWASM,r=i.indexWASM,o=i.verticesPerFaceWASM):(e=Kd,r=Yd,o=Jd);let a=e.length,l=r.length,c=o.length,h=e.length+n.length+s.length,p=r.length+o.length,u=h*Float32Array.BYTES_PER_ELEMENT+p*Uint32Array.BYTES_PER_ELEMENT,d=h*Float32Array.BYTES_PER_ELEMENT,m=p*Uint32Array.BYTES_PER_ELEMENT,g=ue._malloc(u),x=new Float32Array(ue.HEAPF32.buffer,g,h),y=new Uint32Array(ue.HEAPU32.buffer,g+d,p);x.set(e,0),x.set(n,e.length),x.set(s,e.length+n.length),y.set(r,0),y.set(o,r.length);let v;i?.scaleBaked?.some(S=>S!==1)&&(v=new vw().makeScale(...i.scaleBaked)),t&&(v?v.premultiply(t):v=t);let P=v?ue.alloc_subdivision_surface2(g,a,g+d,l,g+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):ue.alloc_subdivision_surface(g,a,g+d,l,g+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return ue._free(g),P}static buildLevel(i,t,e,r,o){let n=o?ue.get_mesh_data2(i,t?ue.Level.CONTROL:ue.Level.REFINED,e,o.elements):ue.get_mesh_data(i,t?ue.Level.CONTROL:ue.Level.REFINED,e),s=8,a=ue.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(4,4+4),c=0,h=ue.HEAPU32[a[c]>>2],p=ue.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let u=ue.HEAPU32[a[c]>>2],d=ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let m=ue.HEAPU32[a[c]>>2],g=ue.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let x=ue.HEAPU32[a[c]>>2],y=ue.HEAPU32.subarray(x>>2,(x>>2)+l[c]);if(c++,r===void 0){let v=new $d;if(v.setIndex(new Jl(y,1)),v.setAttribute("position",new Ql(p,3)),v.setAttribute("normal",new Ql(d,3)),t){v.setAttribute("faceMap",new Jl(g,1));let P=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new Xd(P,4))}return ue.free_mesh_data(n),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(p),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,ue.free_mesh_data(n)}static buildControlCageWireframe(i,t,e){let r=ue.get_wireframe_data_for_base_level(i),o=4,n=ue.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(2,2+2),a=0,l=ue.HEAPU32[n[a]>>2],c=ue.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let h=ue.HEAPU32[n[a]>>2],p=ue.HEAPU32.subarray(h>>2,(h>>2)+s[a]);if(t===void 0){let u=new $d;u.setAttribute("position",new Ql(c,3));let d=new Float32Array(c.length);for(let m=0,g=c.length;m<g;)d[m++]=e.r,d[m++]=e.g,d[m++]=e.b;return u.setAttribute("color",new Xd(d,3)),u.setIndex(new Jl(p,1)),ue.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(c),t.attributes.position.needsUpdate=!0,ue.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,t,e){t||ue.set_destination_refinement_level(i,1);let r=e?ue.get_topological_data2(i,t?ue.Level.CONTROL:ue.Level.REFINED,e.elements):ue.get_topological_data(i,t?ue.Level.CONTROL:ue.Level.REFINED),o=6,n=ue.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=ue.HEAPU32[n[a]>>2],c=new Float32Array(ue.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let h=ue.HEAPU32[n[a]>>2],p=new Uint32Array(ue.HEAPU32.subarray(h>>2,(h>>2)+s[a]));a++;let u=ue.HEAPU32[n[a]>>2],d=new Uint8Array(ue.HEAPU32.subarray(u>>2,(u>>2)+s[a]));return ue.free_topological_data(r),{positions:c,indices:p,verticesPerFace:d}}};var Qd=["getX","getY","getZ"];function rc(i,t){let e={},r=t?t.count:i.count,o=0,n=[],s=[],a=1e4;for(let c=0;c<r;c++){let h=t?t.getX(c):c,p="";for(let u=0;u<3;u++)p+=`${~~(i[Qd[u]](h)*a)},`;if(p in e)n.push(e[p]);else{for(let u=0;u<3;u++)s.push(i[Qd[u]](h));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:s,triIndices:l}}var ra=new oa,Zl=new oa,ec=new oa,tc=new oa;function oc(i,t,e){let r=[],o=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let n=e.userData.shape.extractShapePointsToFlatArray([]),s=0;for(let l=0;l<n.length;l+=2)s+=(n[l]-n[(l===0?n.length:l)-2])*(n[l+1]+n[(l===0?n.length:l)-1]);i.length=0;let a=0;if(s<0)for(let l=0;l<n.length;l+=2)i.push(n[l],n[l+1],0),r.push(a++);else for(let l=n.length-2;l>=0;l-=2)i.push(n[l],n[l+1],0),r.push(a++);return o.push(a),{indices:r,verticesPerFace:o}}for(let n=0,s=e.capStartIndex??t.length;n<s;)if(t[n+1]===t[n+3]&&t[n+2]===t[n+5]||t[n+0]===t[n+3]&&t[n+2]===t[n+4]){ra.set(i[t[n]*3],i[t[n]*3+1],i[t[n]*3+2]),Zl.set(i[t[n+1]*3],i[t[n+1]*3+1],i[t[n+1]*3+2]),ec.set(i[t[n+4]*3],i[t[n+4]*3+1],i[t[n+4]*3+2]),tc.set(i[t[n+5]*3],i[t[n+5]*3+1],i[t[n+5]*3+2]),Zl.sub(ra).normalize(),ec.sub(ra).normalize(),tc.sub(ra).normalize();let a=Zl.cross(ec).dot(tc);Math.abs(a)>.005?(r.push(t[n],t[n+1],t[n+2]),o.push(3),n+=3):(r.push(t[n],t[n+1],t[n+4],t[n+5]),o.push(4),n+=6)}else r.push(t[n],t[n+1],t[n+2]),o.push(3),n+=3;if(e.capStartIndex!==void 0){let n=[],s=[],a=0;for(let l=0,c=0;l<i.length;l+=3,c++)i[l+2]===0&&(n.push(c),a++),i[l+2]===e.userData.parameters.depth&&s.push(c);if(e.userData.parameters.extrudeBevelSize===0){let l=s[0];s[0]=s[1],s[1]=l}n.reverse(),r.push(...n,...s),o.push(a,a)}return{indices:r,verticesPerFace:o}}var Ut={};ef(Ut,{calcBoolean:()=>Cw,calcBooleanTopological:()=>Nw,freeMeshSet:()=>Iw,getMeshSet:()=>Tw,transformMeshSet:()=>Lw});var bw,Zd=new Promise(i=>{bw=i});import{Float32BufferAttribute as em,Sphere as Sw}from"three";var ye,ln;Zd.then(i=>ye=i);function ww(i,t){let e,{positions:r,triIndices:o}=rc(i.getAttribute("position"),i.getIndex()),n;if(t){let{indices:s,verticesPerFace:a}=oc(r,o,i);n=a.length,e=[];for(let l=0,c=0;l<n;l++){e.push(a[l]);for(let h=0;h<a[l];h++)e.push(s[c++])}}else{let s=o.length;e=Array(s+s/3),n=0;for(let a=0,l=0;l<e.length;)e[l++]=3,n++,e[l++]=o[a++],e[l++]=o[a++],e[l++]=o[a++]}return{positions:r,faceIndices:e,nFaces:n}}function tm(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ye._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ye.HEAPU32.buffer,n,t):new Float32Array(ye.HEAPF32.buffer,n,t)).set(i,0),n}function rm(i){switch(i){case 0:return ye.OP.UNION;case 1:return ye.OP.INTERSECTION;case 2:return ye.OP.A_MINUS_B;case 3:return ye.OP.B_MINUS_A;case 4:return ye.OP.SYMMETRIC_DIFFERENCE;case 5:return ye.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function Nw(i,t){ln===void 0&&(ln=ye.init_csg());let e=tm(i),r=ye.csg_calc_topological(ln,e,i.length,rm(t));ye._free(e);let o=6,n=ye.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=ye.HEAPU32[n[a]>>2],c=new Float32Array(ye.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let h=ye.HEAPU32[n[a]>>2],p=new Uint32Array(ye.HEAPU32.subarray(h>>2,(h>>2)+s[a]));a++;let u=ye.HEAPU32[n[a]>>2],d=new Uint8Array(ye.HEAPU32.subarray(u>>2,(u>>2)+s[a]));return ye.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:d}}function Cw(i,t,e,r){ln===void 0&&(ln=ye.init_csg());let o=tm(i),n=ye.csg_calc(ln,o,i.length,r,rm(t));ye._free(o);let s=5,a=ye.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(2,2+3),c=0,h=ye.HEAPU32[a[c]>>2],p=ye.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let u=ye.HEAPU32[a[c]>>2],d=ye.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let m=l[c];e.setAttribute("position",new em(p,3)),e.setAttribute("normal",new em(d,3));let g=ye.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Sw),e.boundingSphere.center.set(g[0],g[1],g[2]),e.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,e.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},ye.free_mesh_data(n),m}function Tw(i,t){if(ye===void 0)return-1;let e,r,o;if(t&&i.userData.positions!==void 0){let g=i.userData;o=g.verticesPerFace.length,e=g.positions,r=Array(g.verticesPerFace.reduce((x,y)=>x+y,0)+o);for(let x=0,y=0,v=0;x<g.verticesPerFace.length;x++){r[v++]=g.verticesPerFace[x];for(let P=0;P<g.verticesPerFace[x];P++)r[v++]=g.indices[y++]}}else({positions:e,faceIndices:r,nFaces:o}=ww(i,t));let n=e.length,s=r.length,a=e.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,p=l*Uint32Array.BYTES_PER_ELEMENT,u=ye._malloc(c),d=new Float32Array(ye.HEAPF32.buffer,u,a),m=new Uint32Array(ye.HEAPU32.buffer,u+h,l);return d.set(e,0),m.set(r,0),ye.get_csg_mesh(u,n,u+h,s,o)}function Lw(i,t){ye.transform_csg_mesh(i,t.elements)}function Iw(i){ye.free_csg_mesh(i)}var Kl={ConeGeometry:au,CubeGeometry:lu,CylinderGeometry:su,DodecahedronGeometry:cu,EllipseGeometry:Gu,HelixGeometry:Uu,IcosahedronGeometry:ju,LatheGeometry:ku,NonParametricGeometry:Ju,PolygonGeometry:Qu,PyramidGeometry:Zu,RectangleGeometry:ed,SphereGeometry:td,PlaneGeometry:rd,BackdropGeometry:od,StarGeometry:nd,TextFrameGeometry:Gs,TorusGeometry:id,TorusKnotGeometry:sd,TriangleGeometry:ad,VectorGeometry:Ke},di=i=>Kl[i.type].create(i);import{BufferGeometry as om,Matrix4 as Pw}from"three";var nm=new Pw;var na=class extends Xe{constructor(e=new om,r){super(e,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(e){if(this.booleanMeshSetAddress!==-1)return;for(let o=0;o<this.children.length;o++){let n=this.children[o];tr(n)&&n.recomputeBoolean(e===!0)}this.meshSetAddresses=[];for(let o=0;o<this.children.length;o++){let n=this.children[o];if(gd(n)&&n.booleanExclude===!1&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0){if(n.booleanMeshSetAddress===-1){if(n.booleanMeshSetAddress=Ut.getMeshSet(n.geometry,e===!0),n.booleanMeshSetAddress===-1)return;Ut.transformMeshSet(n.booleanMeshSetAddress,n.matrix),n.booleanMatrixInvOld.copy(n.matrix).invert(),n.booleanWasTransformed=!1}else tr(n)&&n.needsTransformForDownstream===!0?(Ut.transformMeshSet(n.booleanMeshSetAddress,n.matrix),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(nm.multiplyMatrices(n.matrix,n.booleanMatrixInvOld),Ut.transformMeshSet(n.booleanMeshSetAddress,nm),n.booleanMatrixInvOld.copy(n.matrix).invert(),n.booleanWasTransformed=!1);this.meshSetAddresses.push(n.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return Ut.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new om,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Ut.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(o){this.booleanMeshSetAddress=0,console.error(o)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}updateGeometry(e){let r=e.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};import{Camera as Hw,OrthographicCamera as Ww,PerspectiveCamera as qw,Vector3 as kt,Object3D as am,Quaternion as $w}from"three";import{BoxBufferGeometry as Mw}from"three";var lr=i=>{var t;return t=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new Mw(30,30,30),t};import{Camera as Bw,LineSegments as Ew,BufferGeometry as Gw,LineBasicMaterial as Rw,Color as ic,Vector3 as zw,Float32BufferAttribute as sm}from"three";import{Ray as Aw,Sphere as Ow,Matrix4 as Dw,Vector3 as Nr}from"three";var ia=new Aw,nc=new Ow,im=new Dw,cr=(i,t,e,r,o=!1)=>{let n=t,s=i.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),nc.copy(n.boundingSphere),nc.applyMatrix4(s),e.ray.intersectsSphere(nc)===!1||(im.copy(s).invert(),ia.copy(e.ray).applyMatrix4(im),n.boundingBox!==null&&ia.intersectsBox(n.boundingBox)===!1))return;let a,l,c,h,p=n.index,u=n.attributes.position,d=n.drawRange,m,g;if(o===!1){let y=Math.max(0,d.start),v=Math.min(p.count,d.start+d.count);for(m=y,g=v;m<g;m+=3)if(l=p.getX(m),c=p.getX(m+1),h=p.getX(m+2),a=x(i,e,ia,u,l,c,h),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let v=n.attributes.position,P=new Nr,S=new Nr,b=new Nr,B=new Nr,w=2,D=1/((i.scale.x+i.scale.y+i.scale.z)/3),C=D*D,I=Math.max(0,d.start),L=Math.min(v.count,d.start+d.count);for(let M=I,k=L-1;M<k;M+=w){if(P.fromBufferAttribute(v,M),S.fromBufferAttribute(v,M+1),ia.distanceSqToSegment(P,S,B,b)>C)continue;B.applyMatrix4(i.matrixWorld);let oe=e.ray.origin.distanceTo(B);oe<e.near||oe>e.far||r.push({distance:oe,point:b.clone().applyMatrix4(i.matrixWorld),object:i})}}function x(y,v,P,S,b,B,w){let f=new Nr,D=new Nr,C=new Nr,I=new Nr,L=new Nr;if(f.fromBufferAttribute(S,b),D.fromBufferAttribute(S,B),C.fromBufferAttribute(S,w),P.intersectTriangle(f,D,C,!1,I)===null)return null;L.copy(I),L.applyMatrix4(y.matrixWorld);let k=v.ray.origin.distanceTo(L);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:L.clone(),object:y}}};var sa=new zw,Bt=new Bw,sc=class extends Ew{constructor(e){let r=new Gw,o=new Rw({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],a={},l=new ic(15711266),c=new ic(15711266),h=new ic(2857471);p("n1","n2",l),p("n2","n4",l),p("n4","n3",l),p("n3","n1",l),p("f1","f2",l),p("f2","f4",l),p("f4","f3",l),p("f3","f1",l),p("n1","f1",l),p("n2","f2",l),p("n3","f3",l),p("n4","f4",l),p("p","n1",c),p("p","n2",c),p("p","n3",c),p("p","n4",c),p("u1","u2",h),p("u2","u3",h),p("u3","u1",h);function p(d,m,g){u(d,g),u(m,g)}function u(d,m){n.push(0,0,0),s.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(n.length/3-1)}r.setAttribute("position",new sm(n,3)),r.setAttribute("color",new sm(s,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Bt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,a=o?.8:1e-4;jt("n1",r,e,Bt,-n,-s,a),jt("n2",r,e,Bt,n,-s,a),jt("n3",r,e,Bt,-n,s,a),jt("n4",r,e,Bt,n,s,a);let l=a;jt("f1",r,e,Bt,-n,-s,l),jt("f2",r,e,Bt,n,-s,l),jt("f3",r,e,Bt,-n,s,l),jt("f4",r,e,Bt,n,s,l);let c=l,h=.5;jt("u1",r,e,Bt,n*.7*h,s*1.1,c),jt("u2",r,e,Bt,-n*.7*h,s*1.1,c),jt("u3",r,e,Bt,0,s*(1.1+.9*h),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function jt(i,t,e,r,o,n,s){sa.set(o,n,s).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],sa.x,sa.y,sa.z)}}var aa=class extends lr(sc){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){cr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as Vw}from"three";var cn=class extends lr(Vw){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,cn.geometryHelper,e,r)}};import{AxesHelper as Fw}from"three";var hn=class extends lr(Fw){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){cr(this.object,hn.geometryHelper,e,r)}update(){}};import{PointLightHelper as Uw}from"three";var pn=class extends lr(Uw){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,pn.geometryHelper,e,r)}};import{SpotLightHelper as jw,Vector3 as kw}from"three";var la=class extends lr(jw){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,la.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=la._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},mi=la;mi._vector=new kw;var hr=(i,t)=>class extends i{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(o){this.visible=o,this.setHelperVisibility(o),this.setHelperChildrenVisibility(o)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(o){this.objectHelper.visible=o}setHelperChildrenVisibility(o){for(let n of this.children)At(n)&&n.traverseEntity(s=>{vr(s)&&s.visible&&(s.objectHelper.visible=o)})}raycast(o,n){this.objectHelper.raycast(o,n)}fromLightState(o,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;o.color!==void 0&&(s.color=Ae(o.color,n)),o.intensity!==void 0&&(s.intensity=o.intensity),o.depth!==void 0&&(s.shadow.camera.far=o.depth,s.shadow.needsUpdate=!0),o.shadows!==void 0&&(this.castShadow=o.shadows),o.helper!==void 0&&(this.enableHelper=o.helper,s.gizmos.shadowmap.visible=o.helper)}return this}};var un=new kt,ac=new kt,Cr=class extends hr(Ot(Hw),aa){constructor(e=window.innerWidth,r=window.innerHeight,o=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Xr.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new Ww(e*-.5,e*.5,r*.5,r*-.5,n??-5e4,s),this.perspCamera=new qw(o,e/r,n??50,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,r){let o=new Cr().fromState(r);return o.enableHelper=!0,o.objectHelper.update(),o.uuid=e,o}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(un),this.targetOffset=un.distanceTo(e)}getTarget(e=new kt){return this.getWorldDirection(ac),this.getWorldPosition(un),ac.multiplyScalar(this.targetOffset),e.copy(un).add(ac),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(un),un.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new $w),r=new kt(0,0,1).applyQuaternion(e),o=new kt().copy(am.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let n=new kt().copy(am.DefaultUp).projectOnPlane(r),s=new kt().crossVectors(n,o).dot(r)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(o)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new kt),n=e.getWorldDirection(new kt).multiplyScalar(this.targetOffset);return{position:r.clone().add(n),target:r}}getViewToObject(e){let r=e.getWorldPosition(new kt),n=this.getWorldDirection(new kt).multiplyScalar(this.targetOffset);return{position:r.clone().sub(n),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,n,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,n,s,a):this.orthoCamera.setViewOffset(e,r,o,n,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Io(r,e)}fromCameraState(e){let{orthographic:r,perspective:o}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as Xw}from"three";var Tr=class extends hr(Ot(Xw),hn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new Tr().fromState(r);return o.uuid=e,o.enableHelper=!0,o.objectHelper.update(),o}};import{DirectionalLight as Kw,CameraHelper as ca}from"three";var dn=class extends hr(Ot(Kw),cn){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let o=this.shadow.camera;o.top=1250,o.bottom=-1250,o.right=1250,o.left=-1250,o.near=-1e4,o.far=2500;let n=new ca(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,r,o){let n=new dn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ca&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ca&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ca&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromDirectionalLightState(e,r){let o=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&pd(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),o&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as Yw,Vector3 as ha,Box3 as Jw,Box3Helper as pa,Color as Qw}from"three";var mn=class extends hr(Ot(Yw),pn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let n=new ha(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ha(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),a=new Jw(n,s),l=new pa(a,new Qw(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(e,r,o){let n=new mn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof pa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof pa&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof pa){let o=this.shadow.camera,n=new ha(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ha(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z);r.box.set(n,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as Zw,CameraHelper as ua,MathUtils as e1,Vector3 as pm,Quaternion as t1}from"three";var lm=new pm,cm=new pm,hm=new t1,fn=class extends hr(Ot(Zw),mi){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let o=this.shadow.camera;o.fov=e1.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let n=new ua(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,r,o){let n=new fn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),cm.setFromMatrixPosition(this.matrixWorld),hm.setFromRotationMatrix(this.matrixWorld),lm.copy(this.up).applyQuaternion(hm).negate().multiplyScalar(this.distance),this.target.position.copy(cm).add(lm),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var um=i=>i.tagName==="VIDEO",gn=class{static resize(t,e,r){let o=t/e,n;if(!r.image)return;let s=r.image;um(s)?n=s.videoWidth/s.videoHeight:n=s.width/s.height,o>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/o):r.repeat.set(1,1*n/o)),o<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/n*-1,1):r.repeat.set(1*o/n,1)),o==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let o=t/e,n=r.image!==void 0?r.image.width/r.image.height:1,s;o>n?s={x:1,y:n/o}:o<n?s={x:o/n,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let o=r.userData.layers,n=o.getLayers();for(let s=0;s<n.length;s++){let a=n[s];xd(a)&&(gn.resizeTextureLayer(t,e,a.uniforms[`f${a.id}_texture`].value),o.updateLayerUniform())}}static resizeComplex(t,e,r,o){let n=t/e,s,a=r.image;um(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,o.geometry.type.includes("Shape")?(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/n):r.repeat.set(1/t,1/e*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*n/s*-1,1/e):r.repeat.set(1/t*n/s,1/e)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var da=class extends Xe{constructor(e,r){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&gn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var yn=class extends Xe{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var xn=class extends yn{constructor(e,r){super(e,r);this.objectType="NonParametric"}};import{DoubleSide as r1,Mesh as o1,MeshBasicMaterial as n1,ShapeBufferGeometry as i1,Vector2 as s1,Vector3 as a1}from"three";import{FontLoader as l1}from"three/examples/jsm/loaders/FontLoader.js";var Re=class extends o1{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:n,fontSize:s,LOD:a=16},l=new n1({color:0,opacity:1,visible:!0,transparent:!0,side:r1})){let c=Re.loadChar(e,o,a);super(c.geometry,l);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=n,this.fontSize=s,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new s1,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Re._fontPath}static set FONTS_PATH(e){Re._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let o=new a1(this.localPosition.x,-this.localPosition.y,0);this.position.copy(o).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Re.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let r=Re.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=Re.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Re(e).copy(this)}static loadFont(e){return new Promise(function(r,o){Re.fontCache[e]?r(Re.fontCache[e]):new l1().load(Re.FONTS_PATH+e+".json",s=>{Re.fontCache[e]=s,r(s)},void 0,o)})}static loadChar(e,r,o){if(Re.charCache[e]){if(Re.charCache[e][o]&&Re.charCache[e][o].fontFamily===r)return Re.charCache[e][o]}else Re.charCache[e]={};let n=Re.fontCache[r],s=n.generateShapes(e,1);return Re.charCache[e][o]={geometry:new i1(s,o),fontFamily:r,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Re.charCache[e][o]}},wt=Re;wt.charCache={},wt.fontCache={},wt._fontPath="/_assets/_fonts/";import{DoubleSide as lc,MeshBasicMaterial as c1,Vector3 as h1,Object3D as p1}from"three";import{Vector2 as dm}from"three";var ma=new dm,oo=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new dm(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,o;for(o=t;o>=0;o-=1)if(this.message[o].char===" "){r=!1,e.length===0&&(o-=1,e.splice(0,0,this.message[o]));break}else e.splice(0,0,this.message[o]);return r?e=[]:this.message.splice(o+1,e.length),e}getWord(t=0,e=1){let r=[],o=t;for(o=t;;o+=e){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}e>0?(r.push(this.message[o]),this.message.splice(o,1),o-=e):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,o=t;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=e}return(o<0||o>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let o=e;o<=r;o+=1)this.message[o].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,o,n){switch(r){case 1:this.leftAlign(t,n);break;case 3:this.centerAlign(this.spaceLeft(e),t,n);break;case 2:this.rightAlign(this.spaceLeft(e),t,n);break;case 4:this.justifyAlign(this.spaceLeft(e),t,n);break}}offsetCharacters(t,e,r){ma.set(e,r);let o=this.message.length;for(let n=0;n<o;n++)this.message[n].updatePosition(this.message[n].localPosition.add(ma),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(e,0,r);return}let n=t/o,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=n),ma.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ma),e)}clone(){let t=new oo(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var cc=class extends Xe{constructor(e){super(e,new Ft({transparent:!0,opacity:1,visible:!1,side:lc}));this.objectType="TextFrame";this.charContainer=new p1,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new h1(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let n=Gs.create({parameters:{width:r.width,height:r.height}}),s=new cc(n).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await wt.loadFont(o),r.text=e;let n=r.textOrigin,s=new c1({visible:r.visible,transparent:!0,side:lc}),a=e.split(`
1330
- `),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let p=new oo(l,r.lineHeight,r.fontSize);return p.message=c.split("").map(u=>{let d={char:u,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},m=s.clone();m.color=r.hexColor,m.opacity=r.opacity;let g=new wt(d,m);return p.addChar3D(g,n),this.charContainer.add(g),g}),l+=p.maxCharSize*p.lineHeight,p}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let n=[];for(let s=0,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof wt&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,r.push(n[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,n=o.parameters.width,s=o.parameters.height,a=e.parameters?.width??n,l=e.parameters?.height??s,c=r.textFrame;super.updateGeometry(e),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==s?(this.checkOverFlow(),this.checkCapacity()):a!==n&&(n<a?this.checkCapacity():n>a&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,n=r.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(o);let a=[];for(;n[s].checkOverFlow(r.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?a.unshift(n[s].getWord(n[s].message.length-1,-1)):a.unshift(n[s].popChar());if(a.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)n[s+1].addChar3D(a[c][h],o,l),l+=1;n[s+1].fullUpdate(o)}n[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,n=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let l,c=s[a-1].spaceLeft(n);if(s[a].wordSize(0,1)<=c){s[a].containSpace()?l=s[a].getWord(0,1):l=s[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&s[a-1].addChar3D(l[h],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new oo(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,n=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<n.length;a++)n[a].updateYLinePos(this.getNewLinePosition(a)),n[a].fullUpdate(o.textOrigin),n[a].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let o=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=o[s].maxCharSize*o[s].lineHeight;return n}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.color?.isColor&&(l.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.visible=e}}}async updateFontFamily(e){await wt.loadFont(e);let o=this.userData.textFrame,n=o.textLines;o.fontFamily=e;for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,n=o.textLines,s=o.fontSize;o.fontSize=e;for(let a=0;a<n.length;a++)n[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await wt.loadFont(o.fontFamily);let n=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)s[a].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let n=0;n<o.length;n++)o[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Ae(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}convertToVector(){let{fontFamily:e,hexColor:r}=this.userData.textFrame,o=new Tr;o.name="Text Shape";let n=wt.fontCache[e];for(let s of this.charContainer.children)s instanceof wt&&n.generateShapes(s.char,1).forEach(a=>{let l=new ve().fromShape(a);l.applyScale(s.scale.x,s.scale.y);let c=Ke.create({shape:l}),h=new Ft({side:lc});h.color=r;let p=new jr(c,h);p.name=s.char,p.position.copy(s.position),p.rotation.copy(s.rotation),o.attach(p)});return o}},no=cc;no.VerticalAlign=qa,no.HorizontalAlign=Wa,no.TextTransform=$a;import{DRACOLoader as u1}from"three/examples/jsm/loaders/DRACOLoader.js";var kr;function d1(){return kr||(kr=new u1,kr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),kr.decoderPending}async function m1(i){if(kr){let t={attributeIDs:kr.defaultAttributeIDs,attributeTypes:kr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await kr.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function mm(i,t){let[e,r]=Pa(ms.deserialize(new Uint8Array(i))),o=[];e.scene.objects.traverse((n,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await d1();for(let n of o){let s=await m1(Aa(n.geometry.data.draco));if(s){s.index&&(n.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:l,array:c,itemSize:h})=>{a[l]={array:c,itemSize:h,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var hc=new Map,fi={url:"head",time:0,data:null,next:null,prev:null},vn={url:"tail",time:1/0,data:null,next:null,prev:null};fi.next=vn;vn.prev=fi;var fm=0;function sn(i){if(typeof i=="string")return i;let t=Date.now(),e=hc.get(i);return e===void 0?(e={url:URL.createObjectURL(new Blob([i])),data:i,time:t,next:null,prev:null},hc.set(i,e)):(e.time=t,e.prev.next=e.next,e.next.prev=e.prev),e.prev=vn.prev,e.next=vn,vn.prev.next=e,vn.prev=e,t-fm>1e3*10&&(fm=t+1e3,setTimeout(()=>{let r=Date.now(),o=fi.next;for(;o.time<r-1e3*10;)URL.revokeObjectURL(o.url),hc.delete(o.data),o=o.next,o.prev=fi,fi.next=o},900)),e.url}import{WebGLRenderTarget as gm,LinearMipmapLinearFilter as f1,LinearFilter as g1,ClampToEdgeWrapping as ym,DepthTexture as xm,NearestFilter as vm,FloatType as y1}from"three";var bm=new Ft,fa=class extends ut{},ga=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new gm(2048,2048,{generateMipmaps:!0,minFilter:f1,magFilter:g1,wrapS:ym,wrapT:ym}),this.transmissionRenderTarget.depthTexture=new xm(2048,2048),this.normalRenderTarget=new gm(1024,1024,{generateMipmaps:!1,minFilter:vm,magFilter:vm,type:y1}),this.normalRenderTarget.depthTexture=new xm(1024,1024),this.penumbraSizeNode=new ke(5,t.penumbraSize),this.resolutionNode=new Ye(1,1),this.pixelRatioNode=new X(window.devicePixelRatio),this.reset(t)}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.data);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,Wl(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}get normalMap(){return this.normalRenderTarget.texture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}isSharedMaterial(t){return t.uuid in this.materials||t===bm}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??bm}getMaterials(){return this.materials}addImage(t,e){if(this.images[t])return this.images[t].onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[t].src=sn(e),!0;{let r=new Image;return r.src=sn(e),r.onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[t]=r,!1}}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new fa(e.r,e.g,e.b,e.a):this.colors[t]=new fa(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{HemisphereLight as M1,Scene as A1,Vector3 as O1,Color as Am,Fog as D1,Box3 as _1}from"three";import{Box3 as x1,Matrix4 as io,Sphere as Nm,Vector3 as v1}from"three";var Tm=rf(wm());var pc;Rs.then(i=>{pc=i});var Lm=new io,b1=new io,S1=new io,Ht=new x1,Hr=new v1,w1=new io,N1=new io,bn=class extends Xe{constructor(e,r,o,n){super(o??r,n);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new io;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new io;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}=_t.build(r.geometry,void 0,void 0,!r.flatShading),l=pi(r.material,o),c=new bn(n,s,a||void 0,l);return r.geometry.phongAngle!==void 0&&(c.phongAngle=r.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=e,c.fromState(r),c}shallowClone(e){return new xn(this.geometry,this.material).shallowCopy(this,e)}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:n,subdivPointer:s}=_t.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);if(e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,ui(this),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){_t.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&_t.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=_t.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=_t.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,Xe.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:n,q:s}=(0,Tm.SVD)(r),a=Lm.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=b1.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=S1.copy(l).transpose();this.shearScale=w1.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(l),this.shearScaleInv=N1.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),s.every(h=>Math.abs(s[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Nm);let r=e.attributes.position,o=e.boundingSphere.center;Ht.setFromBufferAttribute(r),Ht.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Hr);let n={width:Hr.x,height:Hr.y,depth:Hr.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let r=this.originalGeometry;Ht.min.set(e[0],e[2],e[4]),Ht.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ht.min.applyMatrix4(this.shearScaleInv),Ht.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Nm);let o=r.boundingSphere.center;Ht.getCenter(o),r.boundingSphere.radius=o.distanceTo(Ht.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ht.getSize(Hr);let n={width:Hr.x,height:Hr.y,depth:Hr.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(pc.free_bvh(this.subdivPointer),pc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Cm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Cm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function Cm(i,t,e,r){let o=i.position.array,n=i.normal.array,s=Lm.makeScale(t,e,r).invert().elements,a,l,c;for(var h=0,p=o.length;h<p;h+=3)o[h]*=t,o[h+1]*=e,o[h+2]*=r,a=n[h],l=n[h+1],c=n[h+2],n[h]=s[0]*a+s[4]*l+s[8]*c,n[h+1]=s[1]*a+s[5]*l+s[9]*c,n[h+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as C1,BufferGeometry as T1,DoubleSide as L1,FrontSide as I1}from"three";function Im(i,t){t.flatShading!==void 0&&(i.flatShading=t.flatShading,i.needsUpdate=!0),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?i.side=I1:t.side===1?i.side=C1:i.side=L1)}function P1(i,t){if(Array.isArray(i.material))for(let e of i.material)Im(e,t);else{let e=i.material;Im(e,t)}i.objectType==="SubdivObject"&&t.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!t.flatShading,i.updateMesh())}function Pm(i,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=bn.createFromState(i,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new T1:ta(t.geometry,e),n="materials"in t?Gd(t.materials,e):pi(t.material,e);vs.is2DParametricMesh(o.userData.type)?r=new da(o,n):o?.userData.type==="VectorGeometry"?r=new jr(o,n):t.geometry.type==="NonParametricGeometry"?r=new xn(o,n):t.geometry.type==="BooleanGeometry"?(r=new na(void 0,n),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new yn(o,n),r.uuid=i,r.fromState(t,e)}return P1(r,t),r}function Mm(i,t,e){return t.type==="Mesh"?Pm(i,t,e):t.type==="TextFrame"?no.createFromState(i,t,e):t.type==="Empty"?Tr.createFromState(i,t):t.type==="PointLight"?mn.createFromState(i,t,e):t.type==="SpotLight"?fn.createFromState(i,t,e):t.type==="DirectionalLight"?dn.createFromState(i,t,e):Po.is(t.type)?Cr.createFromState(i,t):(console.error(t),new Tr)}var Om=new O1,uc=class extends zs(A1){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new D1(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this._color=new Am(1,0,0);this.bgColor=new Am(1,1,1);this.entityByUuid={};this.ambientLight=new M1(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=jd(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}needsNormal(e){return this.needsNormalDirty&&(this._needsNormal=Ud(e,this),e!==void 0&&(this.needsNormalDirty=!1)),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ae(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Cr&&this.switchActiveCamera(o)}this.traverse(o=>{tr(o)&&o.recomputeBoolean()})}clearScene(e){this.traverseEntity(r=>{kd(r,e)});for(let r of this.children)At(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Cr.createFromState(uc.PERSONAL_CAMERA_ID,{...Ss.defaultData,name:"Personal Camera"});return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=n=>{for(let s of n.children){let a=Il(s),l=Ll(s);(At(s)&&!s.raycastLock&&s.visible||a||l)&&((a||er(s)||!a&&!l&&vr(s)&&s.objectHelper.parent)&&e.intersectObject(s,!1,r),a||o(s))}};o(this);for(let n=0,s=r.length;n<s;n++)Il(r[n].object)&&(r[n].object=r[n].object.parent.object);return r}traverseEntity(e){for(let r of this.children)At(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ae(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,r){hd(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ae(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,r,o){for(let n of e)this.createChildObject(n.id,n.data,n.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,n,s){let a=Mm(e,r,s);return a&&(this.entityByUuid[e]=a,n.add(a),tr(n)&&er(a)&&(a.prevBooleanObjectParent=n),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let n=0,s=e.length;n<s;++n){let{id:a,recursive:l}=e[n],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;r.push(...h.vertices)}let o=new _1;return o.setFromPoints(r),o.getCenter(Om),Om}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Xe)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)e(r.material[o]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,n;e>=r?(o=r/e,n=1):(o=1,n=e/r),this.traverseMaterial(s=>{s.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=o,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},gi=uc;gi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as sH}from"three";import{mergeBufferGeometries as cH}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Dm(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as _m,ShaderLib as B1}from"three";function Bm(i){let t=new Set;return i.traverse(e=>{if(er(e))if(Fe(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);E1(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new _m,specularColor:new _m}),e.onBeforeCompile=(o,n)=>{r&&r(o,n),o.uniforms=Object.assign(B1.physical.uniforms,o.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):G1(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function E1(i){return i.userData.layers.getLayersOfType("transmission").length>0}function G1(i){let t=i.userData.layers.head,e=0;for(;t!==void 0;){if(t.type!=="light"&&t.type!=="fresnel"){let r=t.uniforms["f"+t.id+"_alpha"];r&&(e+=(1-e)*r.value)}t=t.next}return e<1}function Em(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function Gm(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,n)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as R1}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Rm(i){let t=[];return i.traverse(e=>{e instanceof eo&&t.push(e)}),t.forEach(e=>{let r=e.object,o=e.children,n=o.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Dm(l),l}),s=R1(e.parameters.hideBase?n:[r.geometry,...n]);r.geometry=s,r.material=o[0].material,r.remove(e)}),i}function zm(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function Vm(i){Object.values(i.shared.materials).forEach(t=>{dc(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?dc(e.material):"materials"in e&&e.materials.forEach(r=>{dc(r)})})}function dc(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var Fm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",mc=class extends V1{load(t,e,r,o=console.error){let n=new z1(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(Fm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(Fm),n.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await mm(t,Vm),r=new ga(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new gi(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let n=e.scene.publish.playCamera;if(n){let s=o.find(n);s&&cd(s)&&Object.assign(s,{makeDefault:!0})}return o=Rm(o),o=Bm(o),o=Em(o),o=Gm(o),o=zm(o),o}};export{mc as default};
1326
+ return color.xyz;
1327
+
1328
+ }`,[ot.simplex,e,o,s])}}();import{Matrix3 as US}from"three";function Cd(i,t,e){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Qs=class extends on{constructor(e,r){super(new US);this.repeat=e;this.offset=r;Cd(this.value,e,r)}updateMatrix(){Cd(this.value,this.repeat,this.offset)}};var sr=class{constructor(t,e,r,o){this.type=t;this.id=e;this.uuid=r;this.uniforms={};for(let n in o)this.uniforms[`f${this.id}_${n}`]=o[n]}static create(t,e,r,o){if(r.type==="light")return ar.createLigherLayer(t,e,r,o);if(r.type==="texture"){let n=o.image(r.texture.image),s=new fi(n,r.texture.wrapping),a=new Ks(n),l=new Qs(r.texture.repeat,r.texture.offset),c=new Y(r.crop?1:0),u=new he(r.projection??0),m=new he(["x","y","z"].indexOf(r.axis)??0),p=new he(r.side??0),d=new ke(r.size?new Tr(r.size[0],r.size[1]):new Tr(100,100)),f=new Y(r.alpha??1),g=new he(r.mode??0),x=new li(s,a,c,u,m,p,d,l,f,g),y=new ve(x.calpha,"f");return new We("texture",t,e,{texture:s,textureSize:a,crop:c,projection:u,axis:m,side:p,size:d,mat:l,alpha:f,mode:g},x,g,y)}else if(r.type==="matcap"){let n=o.image(r.texture.image),s=new fi(n,r.texture.wrapping),a=new Y(r.alpha??1),l=new he(r.mode??0),c=new di(s,a,l),u=new ve(c.calpha,"f");return new We("matcap",t,e,{texture:s,alpha:a,mode:l},c,l,u)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new Je(new ir(...r.offset)),s=new Y(r.scale??10),a=new Y(r.intensity??8),l=new Y(r.movement??1),c=new he(r.noiseType??0),u=new si(a,l,n,s,c);return new gi(r.type,t,e,{offset:n,scale:s,intensity:a,movement:l,noiseType:c},u)}else throw new Error;else{let n=kS(t,e,r,o);for(let s in r)Fl(s,n,r);return n}}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props?!0:Nd(o.props,r,this,e)}else if(o.path[0]==="texture")return"texture"in e?zl(o.props,r,this):!0;return!1}dispose(){}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},We=class extends sr{constructor(e,r,o,n,s,a,l){super(e,r,o,n);this.color=s;this.mode=a;this.alpha=l}},gi=class extends sr{constructor(e,r,o,n,s){super(e,r,o,n);this.position=s}},ar=class extends sr{constructor(e,r,o,n,s){super("light",e,r,s);this.data=o;this.node=n}static createLigherLayer(e,r,o,n){let s,a=new Y(o.alpha),l=new he(o.mode),c;if(o.category==="lambert"){s=new Yn;let u=new we(n.color(o.emissive)??0);c={emissive:u},s.emissive=u}else if(o.category==="phong"){s=new Ys;let u=new Y(o.shininess??30),m=new we(n.color(o.specular)??1118481);c={shininess:u,specular:m},s.shininess=u,s.specular=m}else if(o.category==="toon"){s=new Qn;let u=new Y(o.shininess??30),m=new we(n.color(o.specular)??1118481);c={shininess:u,specular:m},s.shininess=u,s.specular=m}else if(o.category==="physical"){s=new Kn;let u=new Y(o.roughness??.3),m=new Y(o.metalness??0),p=new Y(o.reflectivity??.5);c={roughness:u,metalness:m,reflectivity:p},s.roughness=u,s.metalness=m,s.reflectivity=p}else s=new Ur,c={};return s.alpha=new Y(1),s.shadingAlpha=a,s.shadingBlend=l,c.alpha=s.shadingAlpha,c.mode=s.shadingBlend,new ar(e,r,o,s,c)}};function Ld(i){let t=i instanceof sr?i.type:i;return t==="texture"||t==="displace_map"||t==="matcap"}function jS(i,t,e,r){switch(i){case"color":{let o=new we(r.color??5855577),n=new Y(r.alpha??1),s=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=n;let a=new he(r.mode??0);return o.alpha=n,new We(i,t,e,{color:o,alpha:n,mode:a},o,a,s)}case"fresnel":{let o=new we(r.color??16777215),n=new Y(r.bias??.1),s=new Y(r.scale??1),a=new Y(r.intensity??2),l=new Y(r.factor??1),c=new Y(r.alpha??1),u=new he(r.mode??0),m=new ei(o,n,s,a,l,c,u),p=new ve(m.calpha,"f");return new We(i,t,e,{color:o,bias:n,scale:s,intensity:a,factor:l,alpha:c,mode:u},m,u,p)}case"rainbow":{let o=new Y(r.filmThickness??30),n=new Y(r.movement??0),s=new Je(r.wavelengths??new ir(0,0,0)),a=new Y(r.noiseStrength??0),l=new Y(r.noiseScale??1),c=new Je(r.offset??new ir(0,0,0)),u=new Y(r.alpha??1),m=new ti(o,n,s,a,l,c,u),p=new ve(m.calpha,"f"),d=new he(r.mode??0);return new We(i,t,e,{filmThickness:o,movement:n,wavelengths:s,noiseStrength:a,noiseScale:l,offset:c,alpha:u,mode:d},m,d,p)}case"transmission":{let o=new Y(r.thickness??10),n=new Y(r.ior??1.5),s=new Y(r.roughness??.5),a=new ke(r.transmissionSamplerSize??new Tr(2048,2048)),l=r.transmissionSamplerMap??new Js,c=r.transmissionDepthMap??new Js,u=new mt(l),m=new mt(c),p=window.innerWidth,d=window.innerHeight,f=p>=d?new ke(d/p,1):new ke(1,p/d),g=new Y(r.alpha??1),x=new oi(o,n,s,a,u,m,f,g),y=new ve(x.calpha,"f"),v=new he(r.mode??0);return new We(i,t,e,{thickness:o,ior:n,roughness:s,transmissionSamplerSize:a,transmissionSamplerMap:u,transmissionDepthMap:m,aspectRatio:f,alpha:g,mode:v},x,v,y)}case"toon":{let o=new he(r.positioning??0),n;r.colors?n=new Et(r.colors.length,r.colors):(n=new Et(10,new ln(0,0,0,1)),n.value[1]=new ln(1,1,1,1));let s;r.steps?s=new He(r.steps.length,r.steps):(s=new He(10,1),s.value[0]=0);let a=new Je(r.source??new ir(0,0,0)),l=new jr(r.isWorldSpace??!0),c=new Y(r.noiseStrength??0),u=new Y(r.noiseScale??1),m=new At(r.shadowColor),p=new Je(r.offset??new ir(0,0,0)),d=new Y(r.alpha??1),f=new hi(o,n,s,a,l,c,u,m,p,d),g=new ve(f.calpha,"f"),x=new he(r.mode??0);return new We(i,t,e,{positioning:o,colors:n,steps:s,source:a,isWorldSpace:l,noiseStrength:c,noiseScale:u,shadowColor:m,offset:p,alpha:d,mode:x},f,x,g)}case"outline":{let o=new we(r.outlineColor??16777215),n=new we(r.contourColor??16777215),s=new Y(r.outlineWidth??.1),a=new Y(r.contourWidth??.1),l=new Y(r.outlineThreshold??.1),c=new Y(r.contourThreshold??.1),u=new Y(r.outlineSmoothing??.1),m=new Y(r.contourFrequency??.1),p=new Je(r.contourDirections??new ir(0,1,0)),d=new jr(r.positionalLines??!1),f=new jr(r.compensation??!0),g=r.normalMap??new Js,x=new mt(g),y=r.depthMap??new Js,v=new mt(y),A=r.pixelRatio??new Y(window.devicePixelRatio),S=r.resolution??new ke(new Tr(1,1)),b=new Y(r.alpha??1),B=new ri(o,n,s,a,l,c,u,m,p,d,f,S,x,v,A,b),w=new ve(B.calpha,"f"),h=new he(r.mode??0);return new We(i,t,e,{outlineColor:o,contourColor:n,outlineWidth:s,contourWidth:a,outlineThreshold:l,contourThreshold:c,outlineSmoothing:u,contourFrequency:m,contourDirection:p,positionalLines:d,compensation:f,resolution:S,normalMap:x,depthMap:v,pixelRatio:A,alpha:b,mode:h},B,h,w)}case"depth":{let o=new he(r.gradientType??0),n=new jr(r.smooth??!1),s=new Y(r.near??50),a=new Y(r.far??200),l=new Y(r.isVector??1),c=new Y(r.isWorldSpace??0),u=new Je(r.origin??new ir),m=new Je(r.direction??new ir),p=new he(r.num??0),d;r.colors?d=new Et(p.value+1,r.colors):(d=new Et(p.value+1,new ln(0,0,0,1)),d.value[1]=new ln(1,1,1,1));let f;r.steps?f=new He(p.value+1,r.steps):(f=new He(p.value+1,1),f.value[0]=0);let g=new Y(r.alpha??1),x=new he(r.mode??0),y=new ni(o,n,s,a,l,c,u,m,d,f,p,g),v=new ve(y.calpha,"f");return new We(i,t,e,{gradientType:o,smooth:n,near:s,far:a,isVector:l,isWorldSpace:c,origin:u,direction:m,colors:d,steps:f,num:p,alpha:g,mode:x},y,x,v)}case"noise":{let o=new Y(r.scale??1),n=new Je(r.size??new ir(100,100,100)),s=new Y(r.move??1),a=new ke(r.fA??new Tr(1.7,9.2)),l=new ke(r.fB??new Tr(8.3,2.8)),c=new ke(r.distortion??new Tr(1,1)),u=new At(r.colorA),m=new At(r.colorB),p=new At(r.colorC),d=new At(r.colorD),f=new Y(r.alpha??1),g=new he(r.mode??0),x=new he(r.noiseType??0),y=new Zn(o,n,s,a,l,c,u,m,p,d,f,x),v=new ve(y.calpha,"f");return new We(i,t,e,{scale:o,size:n,move:s,fA:a,fB:l,distortion:c,colorA:u,colorB:m,colorC:p,colorD:d,alpha:f,mode:g,noiseType:x},y,g,v)}case"normal":{let o=new Je(r.cnormal??new ir(1,1,1)),n=new Y(r.alpha??1),s=new he(r.mode??0),a=new ui(o,n),l=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return l.keywords.alpha=n,new We(i,t,e,{cnormal:o,alpha:n,mode:s},a,s,l)}case"gradient":{let o=new he(r.gradientType??0),n=new jr(r.smooth??!1),s;r.colors?s=new Et(r.colors.length,r.colors):(s=new Et(10,new ln(0,0,0,1)),s.value[1]=new ln(1,1,1,1));let a;r.steps?a=new He(r.steps.length,r.steps):(a=new He(10,1),a.value[0]=0);let l=new ke(r.offset??new Tr(0,0)),c=new ke(r.morph??new Tr(0,0)),u=new Y(r.angle??0),m=new Y(r.alpha??1),p=new he(r.mode??0),d=new ai(o,n,s,a,l,c,u,m),f=new ve(d.calpha,"f");return new We(i,t,e,{gradientType:o,smooth:n,colors:s,steps:a,offset:l,morph:c,angle:u,alpha:m,mode:p},d,p,f)}default:{let o=new we(1,0,0,1),n=new Y(1),s=new ve("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=n;let a=new he(0);return o.alpha=n,new We(i,t,e,{color:o,alpha:n,mode:a},o,a,s)}}}function kS(i,t,e,r){let o=Sd(e,r);return jS(e.type,i,t,o)}function Fl(i,t,e){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=e.alpha*(e.visible?1:0),e.type==="outline"&&i=="visible"){let o=t.uniforms[`f${t.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return r}}var Gt=class extends WS{constructor(e,r){super(void 0);this.data=e;this.layerIdGen=0;this.type="NodeMaterial";this.uniformsBackup={};this.fog=!0,this.updaters=[],this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile;let o=e.layers??gr.defaultTwoLayerData("phong").layers;this.layers=o.map(n=>sr.create(this.layerIdGen++,n.id,n.data,r)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r)}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.data.category}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof ar),this.lightLayer===void 0&&(this.lightLayer=new ar(0,"",Er.defaultData("light","basic"),new Ur,{})),this.lightLayer.node instanceof Ur||(this.lightLayer.node.penumbraSize=e.penumbraSizeNode),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,r,o){if(this.data=r,e.path[0]==="layers"){let n=e.path[1];if(n===void 0){if(this.layers.reverse(),e.type===4){let s=sr.create(this.layerIdGen++,e.id,e.data,o);this.layers.splice(e.localIndex,0,s)}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose();else if(e.type===6){let s=this.layers.findIndex(l=>l.uuid===e.id),a=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,a)}this.layers.reverse(),this.onUpdate(o)}else{let s=this.layers.find(a=>a.uuid===n);if(s){let a=r.layers.data(n);if(s.updateByOp({...e,path:e.path.slice(2)},a,o)){let c=sr.create(this.layerIdGen++,n,a,o);this.layers.splice(this.layers.findIndex(u=>u.uuid===n),1,c),this.onUpdate(o)}}}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof We),r=this.layers.findIndex(o=>o instanceof ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let s=this.layers[n];s instanceof We&&(o=new ii(o,s.color,s.alpha,s.mode))}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new ve("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];n instanceof We&&(e=new ii(e,n.color,n.alpha,n.mode))}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof gi);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new dt(r,e[o].position,dt.ADD),r=new dt(r,new Y(.5).setReadonly(!0),dt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,r){this.build({renderer:r}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(n,s,a)=>Math.min(Math.max(n,s),a);for(let n of this.layers)if(n.type==="displace"){this.uniformsBackup[`f${n.id}_intensity`]=n.uniforms[`f${n.id}_intensity`].value;let s=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=s}}restoreClampedUniforms(){for(let e of this.layers)e.type==="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){e=e??{};let r=e.builder??new Xs;return this.lights=this.lightLayer.data.category!=="basic",r.setMaterial(this,e.renderer),r.build(this.fragment,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.transparent=r.requires.transparent||this.blending>HS,this}dispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Gt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});var io=class extends Gt{};import{MathUtils as kl,BufferAttribute as XS,Mesh as Pd,Vector3 as Hl,Float32BufferAttribute as Md,Ray as YS,Matrix4 as KS,Raycaster as QS}from"three";function JS(i,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=i.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=i.depthTexture}function ZS(i,t){t.uniforms[`f${t.id}_normalMap`].value=i.texture,t.uniforms[`f${t.id}_depthMap`].value=i.depthTexture}function ew(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let t=new Map,e=i.geometry.attributes.position.array,r=i.geometry.attributes.normal.array,o=new Float32Array(e.length);for(let n=0;n<e.length;n+=3){let s=`${e[n]}_${e[n+1]}_${e[n+2]}`,a=new Hl(r[n],r[n+1],r[n+2]);t.has(s)?t.get(s)?.normals.push(a):t.set(s,{normals:[a],result:new Hl})}t.forEach((n,s)=>{for(let a of n.normals)n.result.add(a);n.result.divideScalar(n.normals.length)});for(let n=0;n<e.length;n+=3){let s=`${e[n]}_${e[n+1]}_${e[n+2]}`,a=t.get(s)?.result;a&&(o[n]=a.x,o[n+1]=a.y,o[n+2]=a.z)}i.geometry.setAttribute("extrudeNormal",new Md(o,3))}function tw(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let t=i.geometry.attributes.position.array,e=new Float32Array(t.length),r=new Hl;for(let o=0;o<t.length;o+=3)r.set(t[o],t[o+1],t[o+2]).normalize(),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z;i.geometry.setAttribute("extrudeNormal",new Md(e,3))}function so(i){if(i.objectType!=="TextFrame"){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(i.material.getLayersOfType("outline").length===0)return;i.objectType==="Mesh2D"?tw(i):ew(i)}}function ao(i){if(!i.geometry.attributes.position)return;let t=i.geometry.attributes.position.array,e=new Float32Array(t.length),r=parseInt(i.uuid.replace(/\D/g,"")),o=[kl.seededRandom(r),kl.seededRandom(r+1e4),kl.seededRandom(r+2e4)];for(let n=0;n<t.length;n++)e[n]=o[n%3];i.geometry.setAttribute("randomColor",new XS(e,3))}function Id(i,t,e){let r=!1,o=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline");return n.length>0&&(t.layers.set(8),o.length===0&&t.layers.enable(3),r=!0,i!==void 0&&n.forEach(s=>ZS(i,s)),ao(t),so(t)),o.length===0&&n.length===0&&t.layers.set(0),r}function Ad(i,t,e){if(!e.layers)return!1;let r=!1,o=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline");return o.length>0&&(t.layers.set(3),n.length>0&&t.layers.enable(8),r=!0,i!==void 0&&o.forEach(s=>JS(i,s))),o.length===0&&n.length===0&&t.layers.set(0),r}function Od(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof Pd&&r.objectType!=="TextFrame")if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Id(i,r,r.material[o])&&(e=!0);else Id(i,r,r.material)&&(e=!0)}),e}function _d(i,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof Pd)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Ad(i,r,r.material[o])&&(e=!0);else Ad(i,r,r.material)&&(e=!0)}),e}function Dd(i){"material"in i&&rw(i.material),"geometry"in i&&i.geometry.dispose()}function rw(i){uc(i).forEach(t=>{t instanceof io||t.dispose()})}var ow=new QS,nw=new KS,iw=new YS;function Bd(i,t,e){let r=i.cloner;if(r)for(let o of r.children){let n=nw.copy(o.matrixWorld).invert(),s=iw.copy(t.ray).applyMatrix4(n),a=i.matrixWorld;s.applyMatrix4(a);let l=ow;l.set(s.origin,s.direction),l.near=t.near,l.far=t.far,l.intersectObject(i,!1).length>0&&e.push({object:i})}}var Ke=class extends It(sw){constructor(e,r){super(e,r);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new aw;this.booleanExclude=null;Array.isArray(r)&&e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0)}get isGroup(){return this._cloner?.parameters.hideBase===!0}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}updateGeometry(e){let r=this.geometry,o=Wl[r.userData.type],n=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=o.build(o.normalizeInputs(e,n)),a=r.uuid;this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),so(this),r.getAttribute("randomColor")&&ao(this)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,o=yi(r),n=this.material;return new this.constructor(o,n).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new to(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new to(this)),this.cloner.fromClonerState(e))}fromState(e,r){return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=e.castShadow??!0,this.receiveShadow=e.receiveShadow??!0,this.booleanExclude=e.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Rt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Jt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)Qt(e)&&(e.freeBooleanPointer(),Jt(e)&&e.invalidateUpstreamBooleanData())}};var uw=new ql(0,0,1),Ed=new ql,Gd=new ql,Rd=new cw,cn=class extends Ke{constructor(e=st.create({}),r){super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new lw;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=e,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Rd.getNormalMatrix(this.matrixWorld),Ed.copy(uw).applyMatrix3(Rd).normalize(),Gd.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Ed,Gd)}clone(e){let r=this.shape.clone(),o=this.material,n=this.geometry.userData,s=st.create(Object.assign({},n,{shape:r})),a=new cn(s,o).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){Ke.prototype.raycast.call(this,e,r)}};function Zs(i,t){return mw(i)}function mw(i){let t={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=Se.createFromState(i.shape,i.width,i.height);t.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>r.materialIndex=Math.max(r.materialIndex??0,0)),t.geometry=new pw().parse(i));let e;try{e=yi(t)}catch(r){console.error(r)}if(!e){let r=Se.createFromState(Fo.defaultData(),100,100);t.shape=r,e=yi(t)}return e}var pe;ks.then(i=>{pe=i});var Fd=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ud=new Uint32Array([0,1,2,3]),jd=new Uint8Array([4]),Pt=class{static build(i,t,e,r,o){let n,s,a,l=i?.phongAngle??t?.phongAngle??35;if(r===!1&&(l=-1),i.positionWASM!==void 0){e&&e!==0&&(pe.free_bvh(e),pe.free_subdivision_surface(e));try{n=Pt.allocate(i,o)}catch(c){console.error(c,i),n=Pt.allocate({positionWASM:Fd,indexWASM:Ud,verticesPerFaceWASM:jd},o)}pe.set_destination_refinement_level(n,0),s=Pt.buildLevel(n,!0,l)}else n=e,i.phongAngle!==void 0&&(s=Pt.buildLevel(n,!0,l));return i.subdivisions!==void 0&&(pe.set_destination_refinement_level(n,i.subdivisions),i.subdivisions>0?a=Pt.buildLevel(n,!1,l):a=null),{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}}static primitiveToQuads(i,t){i.widthSegments>16&&(i.widthSegments=16),i.heightSegments>16&&(i.heightSegments=16),i.depthSegments>16&&(i.depthSegments=16),i.radialSegments>16&&(i.radialSegments=16),i.type==="DodecahedronGeometry"&&(i.detail=0);let e=i.shape!==void 0?t.geometry:Zs(i),r,o,n,s;return{positions:r,triIndices:s}=Jl(e.getAttribute("position"),e.getIndex()),{indices:o,verticesPerFace:n}=Zl(r,s,e),{positions:r,indices:o,verticesPerFace:n}}static allocate(i,t){let e,r,o,n=[],s=[];i.positionWASM&&i.positionWASM.length>0?(e=i.positionWASM,r=i.indexWASM,o=i.verticesPerFaceWASM):(e=Fd,r=Ud,o=jd);let a=e.length,l=r.length,c=o.length,u=e.length+n.length+s.length,m=r.length+o.length,p=u*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,d=u*Float32Array.BYTES_PER_ELEMENT,f=m*Uint32Array.BYTES_PER_ELEMENT,g=pe._malloc(p),x=new Float32Array(pe.HEAPF32.buffer,g,u),y=new Uint32Array(pe.HEAPU32.buffer,g+d,m);x.set(e,0),x.set(n,e.length),x.set(s,e.length+n.length),y.set(r,0),y.set(o,r.length);let v;i?.scaleBaked?.some(S=>S!==1)&&(v=new dw().makeScale(...i.scaleBaked)),t&&(v?v.premultiply(t):v=t);let A=v?pe.alloc_subdivision_surface2(g,a,g+d,l,g+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):pe.alloc_subdivision_surface(g,a,g+d,l,g+d+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return pe._free(g),A}static buildLevel(i,t,e,r,o){let n=o?pe.get_mesh_data2(i,t?pe.Level.CONTROL:pe.Level.REFINED,e,o.elements):pe.get_mesh_data(i,t?pe.Level.CONTROL:pe.Level.REFINED,e),s=8,a=pe.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(4,4+4),c=0,u=pe.HEAPU32[a[c]>>2],m=pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=pe.HEAPU32[a[c]>>2],d=pe.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let f=pe.HEAPU32[a[c]>>2],g=pe.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let x=pe.HEAPU32[a[c]>>2],y=pe.HEAPU32.subarray(x>>2,(x>>2)+l[c]);if(c++,r===void 0){let v=new Vd;if(v.setIndex(new $l(y,1)),v.setAttribute("position",new Xl(m,3)),v.setAttribute("normal",new Xl(d,3)),t){v.setAttribute("faceMap",new $l(g,1));let A=new Float32Array(d.length/3*4).fill(0);v.setAttribute("color",new zd(A,4))}return pe.free_mesh_data(n),v.userData.type="SubdivGeometry",v}r.getAttribute("position").copyArray(m),r.getAttribute("normal").copyArray(d),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,pe.free_mesh_data(n)}static buildControlCageWireframe(i,t,e){let r=pe.get_wireframe_data_for_base_level(i),o=4,n=pe.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(2,2+2),a=0,l=pe.HEAPU32[n[a]>>2],c=pe.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let u=pe.HEAPU32[n[a]>>2],m=pe.HEAPU32.subarray(u>>2,(u>>2)+s[a]);if(t===void 0){let p=new Vd;p.setAttribute("position",new Xl(c,3));let d=new Float32Array(c.length);for(let f=0,g=c.length;f<g;)d[f++]=e.r,d[f++]=e.g,d[f++]=e.b;return p.setAttribute("color",new zd(d,3)),p.setIndex(new $l(m,1)),pe.free_wireframe_data_for_base_level(r),p}t.getAttribute("position").copyArray(c),t.attributes.position.needsUpdate=!0,pe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,t,e){t||pe.set_destination_refinement_level(i,1);let r=e?pe.get_topological_data2(i,t?pe.Level.CONTROL:pe.Level.REFINED,e.elements):pe.get_topological_data(i,t?pe.Level.CONTROL:pe.Level.REFINED),o=6,n=pe.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=pe.HEAPU32[n[a]>>2],c=new Float32Array(pe.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let u=pe.HEAPU32[n[a]>>2],m=new Uint32Array(pe.HEAPU32.subarray(u>>2,(u>>2)+s[a]));a++;let p=pe.HEAPU32[n[a]>>2],d=new Uint8Array(pe.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return pe.free_topological_data(r),{positions:c,indices:m,verticesPerFace:d}}};var kd=["getX","getY","getZ"];function Jl(i,t){let e={},r=t?t.count:i.count,o=0,n=[],s=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,m="";for(let p=0;p<3;p++)m+=`${~~(i[kd[p]](u)*a)},`;if(m in e)n.push(e[m]);else{for(let p=0;p<3;p++)s.push(i[kd[p]](u));e[m]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:s,triIndices:l}}var ea=new ta,Yl=new ta,Kl=new ta,Ql=new ta;function Zl(i,t,e){let r=[],o=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let n=e.userData.shape.extractShapePointsToFlatArray([]),s=0;for(let l=0;l<n.length;l+=2)s+=(n[l]-n[(l===0?n.length:l)-2])*(n[l+1]+n[(l===0?n.length:l)-1]);i.length=0;let a=0;if(s<0)for(let l=0;l<n.length;l+=2)i.push(n[l],n[l+1],0),r.push(a++);else for(let l=n.length-2;l>=0;l-=2)i.push(n[l],n[l+1],0),r.push(a++);return o.push(a),{indices:r,verticesPerFace:o}}for(let n=0,s=e.capStartIndex??t.length;n<s;)if(t[n+1]===t[n+3]&&t[n+2]===t[n+5]||t[n+0]===t[n+3]&&t[n+2]===t[n+4]){ea.set(i[t[n]*3],i[t[n]*3+1],i[t[n]*3+2]),Yl.set(i[t[n+1]*3],i[t[n+1]*3+1],i[t[n+1]*3+2]),Kl.set(i[t[n+4]*3],i[t[n+4]*3+1],i[t[n+4]*3+2]),Ql.set(i[t[n+5]*3],i[t[n+5]*3+1],i[t[n+5]*3+2]),Yl.sub(ea).normalize(),Kl.sub(ea).normalize(),Ql.sub(ea).normalize();let a=Yl.cross(Kl).dot(Ql);Math.abs(a)>.005?(r.push(t[n],t[n+1],t[n+2]),o.push(3),n+=3):(r.push(t[n],t[n+1],t[n+4],t[n+5]),o.push(4),n+=6)}else r.push(t[n],t[n+1],t[n+2]),o.push(3),n+=3;if(e.capStartIndex!==void 0){let n=[],s=[],a=0;for(let l=0,c=0;l<i.length;l+=3,c++)i[l+2]===0&&(n.push(c),a++),i[l+2]===e.userData.parameters.depth&&s.push(c);if(e.userData.parameters.extrudeBevelSize===0){let l=s[0];s[0]=s[1],s[1]=l}n.reverse(),r.push(...n,...s),o.push(a,a)}return{indices:r,verticesPerFace:o}}var Rt={};qf(Rt,{calcBoolean:()=>xw,calcBooleanTopological:()=>yw,freeMeshSet:()=>Sw,getMeshSet:()=>vw,transformMeshSet:()=>bw});var fw,Hd=new Promise(i=>{fw=i});import{Float32BufferAttribute as Wd,Sphere as hw}from"three";var ge,un;Hd.then(i=>ge=i);function gw(i,t){let e,{positions:r,triIndices:o}=Jl(i.getAttribute("position"),i.getIndex()),n;if(t){let{indices:s,verticesPerFace:a}=Zl(r,o,i);n=a.length,e=[];for(let l=0,c=0;l<n;l++){e.push(a[l]);for(let u=0;u<a[l];u++)e.push(s[c++])}}else{let s=o.length;e=Array(s+s/3),n=0;for(let a=0,l=0;l<e.length;)e[l++]=3,n++,e[l++]=o[a++],e[l++]=o[a++],e[l++]=o[a++]}return{positions:r,faceIndices:e,nFaces:n}}function qd(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=ge._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ge.HEAPU32.buffer,n,t):new Float32Array(ge.HEAPF32.buffer,n,t)).set(i,0),n}function $d(i){switch(i){case 0:return ge.OP.UNION;case 1:return ge.OP.INTERSECTION;case 2:return ge.OP.A_MINUS_B;case 3:return ge.OP.B_MINUS_A;case 4:return ge.OP.SYMMETRIC_DIFFERENCE;case 5:return ge.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function yw(i,t){un===void 0&&(un=ge.init_csg());let e=qd(i),r=ge.csg_calc_topological(un,e,i.length,$d(t));ge._free(e);let o=6,n=ge.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=ge.HEAPU32[n[a]>>2],c=new Float32Array(ge.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let u=ge.HEAPU32[n[a]>>2],m=new Uint32Array(ge.HEAPU32.subarray(u>>2,(u>>2)+s[a]));a++;let p=ge.HEAPU32[n[a]>>2],d=new Uint8Array(ge.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return ge.free_mesh_data(r),{positions:c,indices:m,verticesPerFace:d}}function xw(i,t,e,r){un===void 0&&(un=ge.init_csg());let o=qd(i),n=ge.csg_calc(un,o,i.length,r,$d(t));ge._free(o);let s=5,a=ge.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(2,2+3),c=0,u=ge.HEAPU32[a[c]>>2],m=ge.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ge.HEAPU32[a[c]>>2],d=ge.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let f=l[c];e.setAttribute("position",new Wd(m,3)),e.setAttribute("normal",new Wd(d,3));let g=ge.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new hw),e.boundingSphere.center.set(g[0],g[1],g[2]),e.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,e.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},ge.free_mesh_data(n),f}function vw(i,t){if(ge===void 0)return-1;let e,r,o;if(t&&i.userData.positions!==void 0){let g=i.userData;o=g.verticesPerFace.length,e=g.positions,r=Array(g.verticesPerFace.reduce((x,y)=>x+y,0)+o);for(let x=0,y=0,v=0;x<g.verticesPerFace.length;x++){r[v++]=g.verticesPerFace[x];for(let A=0;A<g.verticesPerFace[x];A++)r[v++]=g.indices[y++]}}else({positions:e,faceIndices:r,nFaces:o}=gw(i,t));let n=e.length,s=r.length,a=e.length,l=r.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,u=a*Float32Array.BYTES_PER_ELEMENT,m=l*Uint32Array.BYTES_PER_ELEMENT,p=ge._malloc(c),d=new Float32Array(ge.HEAPF32.buffer,p,a),f=new Uint32Array(ge.HEAPU32.buffer,p+u,l);return d.set(e,0),f.set(r,0),ge.get_csg_mesh(p,n,p+u,s,o)}function bw(i,t){ge.transform_csg_mesh(i,t.elements)}function Sw(i){ge.free_csg_mesh(i)}var Wl={ConeGeometry:tm,CubeGeometry:rm,CylinderGeometry:em,DodecahedronGeometry:om,EllipseGeometry:Mm,HelixGeometry:Em,IcosahedronGeometry:Gm,LatheGeometry:Rm,NonParametricGeometry:Wm,PolygonGeometry:qm,PyramidGeometry:$m,RectangleGeometry:Xm,SphereGeometry:Ym,PlaneGeometry:Km,BackdropGeometry:Qm,StarGeometry:Jm,TextFrameGeometry:js,TorusGeometry:Zm,TorusKnotGeometry:ed,TriangleGeometry:td,VectorGeometry:st},yi=i=>Wl[i.type].create(i);import{BufferGeometry as Xd,Matrix4 as ww}from"three";var Yd=new ww;var ra=class extends Ke{constructor(e=new Xd,r){super(e,r);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(e){if(this.booleanMeshSetAddress!==-1)return;for(let o=0;o<this.children.length;o++){let n=this.children[o];Jt(n)&&n.recomputeBoolean(e===!0)}this.meshSetAddresses=[];for(let o=0;o<this.children.length;o++){let n=this.children[o];if(ud(n)&&n.booleanExclude===!1&&n.geometry.attributes.position?.count>0&&n.geometry.drawRange.count>0){if(n.booleanMeshSetAddress===-1){if(n.booleanMeshSetAddress=Rt.getMeshSet(n.geometry,e===!0),n.booleanMeshSetAddress===-1)return;Rt.transformMeshSet(n.booleanMeshSetAddress,n.matrix),n.booleanMatrixInvOld.copy(n.matrix).invert(),n.booleanWasTransformed=!1}else Jt(n)&&n.needsTransformForDownstream===!0?(Rt.transformMeshSet(n.booleanMeshSetAddress,n.matrix),n.needsTransformForDownstream=!1):n.booleanWasTransformed===!0&&(Yd.multiplyMatrices(n.matrix,n.booleanMatrixInvOld),Rt.transformMeshSet(n.booleanMeshSetAddress,Yd),n.booleanMatrixInvOld.copy(n.matrix).invert(),n.booleanWasTransformed=!1);this.meshSetAddresses.push(n.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(e===!0)return Rt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let r=this.geometry;r.dispose(),this.geometry=new Xd,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere;try{this.booleanMeshSetAddress=Rt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(o){this.booleanMeshSetAddress=0,console.error(o)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,so(this),ao(this)}updateGeometry(e){let r=e.parameters;r.operation!==void 0&&(this.booleanOp=r.operation),r.phongAngle!==void 0&&(this.phongAngle=r.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};import{Camera as Vw,OrthographicCamera as zw,PerspectiveCamera as Fw,Vector3 as zt,Object3D as Jd,Quaternion as Uw}from"three";import{BoxBufferGeometry as Tw}from"three";var lr=i=>{var t;return t=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new Tw(30,30,30),t};import{Camera as Aw,LineSegments as Pw,BufferGeometry as Mw,LineBasicMaterial as Ow,Color as tc,Vector3 as _w,Float32BufferAttribute as Qd}from"three";import{Ray as Nw,Sphere as Cw,Matrix4 as Lw,Vector3 as Nr}from"three";var oa=new Nw,ec=new Cw,Kd=new Lw,cr=(i,t,e,r,o=!1)=>{let n=t,s=i.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),ec.copy(n.boundingSphere),ec.applyMatrix4(s),e.ray.intersectsSphere(ec)===!1||(Kd.copy(s).invert(),oa.copy(e.ray).applyMatrix4(Kd),n.boundingBox!==null&&oa.intersectsBox(n.boundingBox)===!1))return;let a,l,c,u,m=n.index,p=n.attributes.position,d=n.drawRange,f,g;if(o===!1){let y=Math.max(0,d.start),v=Math.min(m.count,d.start+d.count);for(f=y,g=v;f<g;f+=3)if(l=m.getX(f),c=m.getX(f+1),u=m.getX(f+2),a=x(i,e,oa,p,l,c,u),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let v=n.attributes.position,A=new Nr,S=new Nr,b=new Nr,B=new Nr,w=2,_=1/((i.scale.x+i.scale.y+i.scale.z)/3),N=_*_,I=Math.max(0,d.start),L=Math.min(v.count,d.start+d.count);for(let P=I,k=L-1;P<k;P+=w){if(A.fromBufferAttribute(v,P),S.fromBufferAttribute(v,P+1),oa.distanceSqToSegment(A,S,B,b)>N)continue;B.applyMatrix4(i.matrixWorld);let oe=e.ray.origin.distanceTo(B);oe<e.near||oe>e.far||r.push({distance:oe,point:b.clone().applyMatrix4(i.matrixWorld),object:i})}}function x(y,v,A,S,b,B,w){let h=new Nr,_=new Nr,N=new Nr,I=new Nr,L=new Nr;if(h.fromBufferAttribute(S,b),_.fromBufferAttribute(S,B),N.fromBufferAttribute(S,w),A.intersectTriangle(h,_,N,!1,I)===null)return null;L.copy(I),L.applyMatrix4(y.matrixWorld);let k=v.ray.origin.distanceTo(L);return k<v.near||k>v.far?null:{faceIndex:1,distance:k,point:L.clone(),object:y}}};var na=new _w,Mt=new Aw,rc=class extends Pw{constructor(e){let r=new Mw,o=new Ow({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],a={},l=new tc(15711266),c=new tc(15711266),u=new tc(2857471);m("n1","n2",l),m("n2","n4",l),m("n4","n3",l),m("n3","n1",l),m("f1","f2",l),m("f2","f4",l),m("f4","f3",l),m("f3","f1",l),m("n1","f1",l),m("n2","f2",l),m("n3","f3",l),m("n4","f4",l),m("p","n1",c),m("p","n2",c),m("p","n3",c),m("p","n4",c),m("u1","u2",u),m("u2","u3",u),m("u3","u1",u);function m(d,f,g){p(d,g),p(f,g)}function p(d,f){n.push(0,0,0),s.push(f.r,f.g,f.b),a[d]===void 0&&(a[d]=[]),a[d].push(n.length/3-1)}r.setAttribute("position",new Qd(n,3)),r.setAttribute("color",new Qd(s,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Mt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,s=1,a=o?.8:1e-4;Vt("n1",r,e,Mt,-n,-s,a),Vt("n2",r,e,Mt,n,-s,a),Vt("n3",r,e,Mt,-n,s,a),Vt("n4",r,e,Mt,n,s,a);let l=a;Vt("f1",r,e,Mt,-n,-s,l),Vt("f2",r,e,Mt,n,-s,l),Vt("f3",r,e,Mt,-n,s,l),Vt("f4",r,e,Mt,n,s,l);let c=l,u=.5;Vt("u1",r,e,Mt,n*.7*u,s*1.1,c),Vt("u2",r,e,Mt,-n*.7*u,s*1.1,c),Vt("u3",r,e,Mt,0,s*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Vt(i,t,e,r,o,n,s){na.set(o,n,s).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],na.x,na.y,na.z)}}var ia=class extends lr(rc){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){cr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as Dw}from"three";var pn=class extends lr(Dw){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,pn.geometryHelper,e,r)}};import{AxesHelper as Bw}from"three";var mn=class extends lr(Bw){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){cr(this.object,mn.geometryHelper,e,r)}update(){}};import{PointLightHelper as Ew}from"three";var dn=class extends lr(Ew){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,dn.geometryHelper,e,r)}};import{SpotLightHelper as Gw,Vector3 as Rw}from"three";var sa=class extends lr(Gw){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){cr(this.object,sa.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=sa._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(n);else this.cone.material.color.set(n)}}},xi=sa;xi._vector=new Rw;var ur=(i,t)=>class extends i{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(o){this.visible=o,this.setHelperVisibility(o),this.setHelperChildrenVisibility(o)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(o){this.objectHelper.visible=o}setHelperChildrenVisibility(o){for(let n of this.children)Dt(n)&&n.traverseEntity(s=>{Sr(s)&&s.visible&&(s.objectHelper.visible=o)})}raycast(o,n){this.objectHelper.raycast(o,n)}fromLightState(o,n){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;o.color!==void 0&&(s.color=Ve(o.color,n)),o.intensity!==void 0&&(s.intensity=o.intensity),o.depth!==void 0&&(s.shadow.camera.far=o.depth,s.shadow.needsUpdate=!0),o.shadows!==void 0&&(this.castShadow=o.shadows),o.helper!==void 0&&(this.enableHelper=o.helper,s.gizmos.shadowmap.visible=o.helper)}return this}};var fn=new zt,oc=new zt,Cr=class extends ur(It(Vw),ia){constructor(e=window.innerWidth,r=window.innerHeight,o=45,n,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=Kr.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new zw(e*-.5,e*.5,r*.5,r*-.5,n??-5e4,s),this.perspCamera=new Fw(o,e/r,n??50,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,r){let o=new Cr().fromState(r);return o.enableHelper=!0,o.objectHelper.update(),o.uuid=e,o}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(fn),this.targetOffset=fn.distanceTo(e)}getTarget(e=new zt){return this.getWorldDirection(oc),this.getWorldPosition(fn),oc.multiplyScalar(this.targetOffset),e.copy(fn).add(oc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(fn),fn.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new Uw),r=new zt(0,0,1).applyQuaternion(e),o=new zt().copy(Jd.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let n=new zt().copy(Jd.DefaultUp).projectOnPlane(r),s=new zt().crossVectors(n,o).dot(r)>=0?1:-1;this.angleOffsetFromUp=n.angleTo(o)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new zt),n=e.getWorldDirection(new zt).multiplyScalar(this.targetOffset);return{position:r.clone().add(n),target:r}}getViewToObject(e){let r=e.getWorldPosition(new zt),n=this.getWorldDirection(new zt).multiplyScalar(this.targetOffset);return{position:r.clone().sub(n),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,n,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,n,s,a):this.orthoCamera.setViewOffset(e,r,o,n,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Do(r,e)}fromCameraState(e){let{orthographic:r,perspective:o}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),o!==void 0&&(o.near!==void 0&&(this.perspCamera.near=o.near),o.fov!==void 0&&(this.perspCamera.fov=o.fov),o.zoom!==void 0&&(this.perspCamera.zoom=o.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as jw}from"three";var lo=class extends ur(It(jw),mn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let o=new lo().fromState(r);return o.uuid=e,o.enableHelper=!0,o.objectHelper.update(),o}};import{DirectionalLight as kw,CameraHelper as aa}from"three";var hn=class extends ur(It(kw),pn){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let o=this.shadow.camera;o.top=1250,o.bottom=-1250,o.right=1250,o.left=-1250,o.near=-1e4,o.far=2500;let n=new aa(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,r,o){let n=new hn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof aa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof aa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof aa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromDirectionalLightState(e,r){let o=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,r),e.size!==void 0&&id(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),o&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as Hw,Vector3 as la,Box3 as Ww,Box3Helper as ca,Color as qw}from"three";var gn=class extends ur(It(Hw),dn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let n=new la(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new la(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),a=new Ww(n,s),l=new ca(a,new qw(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(e,r,o){let n=new gn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ca&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ca&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof ca){let o=this.shadow.camera,n=new la(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new la(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z);r.box.set(n,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromPointLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as $w,CameraHelper as ua,MathUtils as Xw,Vector3 as rf,Quaternion as Yw}from"three";var Zd=new rf,ef=new rf,tf=new Yw,yn=class extends ur(It($w),xi){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let o=this.shadow.camera;o.fov=Xw.RAD2DEG*2*this.angle,o.aspect=1,o.near=100,o.far=2500;let n=new ua(this.shadow.camera);n.visible=!1,this._gizmos.shadowmap=n,this.update()}static createFromState(e,r,o){let n=new yn().fromState(r,o);return n.uuid=e,n}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ua&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),ef.setFromMatrixPosition(this.matrixWorld),tf.setFromRotationMatrix(this.matrixWorld),Zd.copy(this.up).applyQuaternion(tf).negate().multiplyScalar(this.distance),this.target.position.copy(ef).add(Zd),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromSpotLightState(e,r){return super.fromLightState(e,r),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var of=i=>i.tagName==="VIDEO",xn=class{static resize(t,e,r){let o=t/e,n;if(!r.image)return;let s=r.image;of(s)?n=s.videoWidth/s.videoHeight:n=s.width/s.height,o>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/o):r.repeat.set(1,1*n/o)),o<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/n*-1,1):r.repeat.set(1*o/n,1)),o==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let o=t/e,n=r.image!==void 0?r.image.width/r.image.height:1,s;o>n?s={x:1,y:n/o}:o<n?s={x:o/n,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let o=r.layers;for(let n=0;n<o.length;n++){let s=o[n];Ld(s)&&xn.resizeTextureLayer(t,e,s.uniforms[`f${s.id}_texture`].value)}}static resizeComplex(t,e,r,o){let n=t/e,s,a=r.image;of(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,o.geometry.type.includes("Shape")?(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/n):r.repeat.set(1/t,1/e*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*n/s*-1,1/e):r.repeat.set(1/t*n/s,1/e)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var pa=class extends Ke{constructor(e,r){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.layers&&xn.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var vn=class extends Ke{constructor(e,r){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var ma=class extends vn{constructor(e,r){super(e,r);this.objectType="NonParametric"}};import{DoubleSide as Kw,Mesh as Qw,MeshBasicMaterial as Jw,ShapeBufferGeometry as Zw,Vector2 as e1,Vector3 as t1}from"three";import{FontLoader as r1}from"three/examples/jsm/loaders/FontLoader.js";var Be=class extends Qw{constructor({char:e,originalChar:r,fontFamily:o,letterSpacing:n,fontSize:s,LOD:a=16},l=new Jw({color:0,opacity:1,visible:!0,transparent:!0,side:Kw})){let c=Be.loadChar(e,o,a);super(c.geometry,l);this.char=e,this.originalChar=r??e,this.fontFamily=o,this.letterSpacing=n,this.fontSize=s,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new e1,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Be._fontPath}static set FONTS_PATH(e){Be._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let o=new t1(this.localPosition.x,-this.localPosition.y,0);this.position.copy(o).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Be.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let r=Be.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let r=Be.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Be(e).copy(this)}static loadFont(e){return new Promise(function(r,o){Be.fontCache[e]?r(Be.fontCache[e]):new r1().load(Be.FONTS_PATH+e+".json",s=>{Be.fontCache[e]=s,r(s)},void 0,o)})}static loadChar(e,r,o){if(Be.charCache[e]){if(Be.charCache[e][o]&&Be.charCache[e][o].fontFamily===r)return Be.charCache[e][o]}else Be.charCache[e]={};let n=Be.fontCache[r],s=n.generateShapes(e,1);return Be.charCache[e][o]={geometry:new Zw(s,o),fontFamily:r,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Be.charCache[e][o]}},Ft=Be;Ft.charCache={},Ft.fontCache={},Ft._fontPath="/_assets/_fonts/";import{DoubleSide as sf,MeshBasicMaterial as af,Vector3 as o1,Object3D as n1}from"three";import{Vector2 as nf}from"three";var da=new nf,co=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new nf(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,o;for(o=t;o>=0;o-=1)if(this.message[o].char===" "){r=!1,e.length===0&&(o-=1,e.splice(0,0,this.message[o]));break}else e.splice(0,0,this.message[o]);return r?e=[]:this.message.splice(o+1,e.length),e}getWord(t=0,e=1){let r=[],o=t;for(o=t;;o+=e){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}e>0?(r.push(this.message[o]),this.message.splice(o,1),o-=e):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,o=t;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=e}return(o<0||o>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let o=e;o<=r;o+=1)this.message[o].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,o,n){switch(r){case 1:this.leftAlign(t,n);break;case 3:this.centerAlign(this.spaceLeft(e),t,n);break;case 2:this.rightAlign(this.spaceLeft(e),t,n);break;case 4:this.justifyAlign(this.spaceLeft(e),t,n);break}}offsetCharacters(t,e,r){da.set(e,r);let o=this.message.length;for(let n=0;n<o;n++)this.message[n].updatePosition(this.message[n].localPosition.add(da),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(e,0,r);return}let n=t/o,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=n),da.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(da),e)}clone(){let t=new co(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var nc=class extends Ke{constructor(e){super(e,new af({transparent:!0,opacity:1,visible:!1,side:sf}));this.objectType="TextFrame";this.charContainer=new n1,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new o1(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,o){let n=js.create({parameters:{width:r.width,height:r.height}}),s=new nc(n).fromState(r,o);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,o=r.fontFamily;await Ft.loadFont(o),r.text=e;let n=r.textOrigin,s=new af({visible:r.visible,transparent:!0,side:sf}),a=e.split(`
1329
+ `),l=0;this.userData.textFrame.textLines=a.map((c,u)=>{let m=new co(l,r.lineHeight,r.fontSize);return m.message=c.split("").map(p=>{let d={char:p,fontFamily:o,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},f=s.clone();f.color=r.hexColor,f.opacity=r.opacity;let g=new Ft(d,f);return m.addChar3D(g,n),this.charContainer.add(g),g}),l+=m.maxCharSize*m.lineHeight,m}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let o=[];if(super.raycast(e,o),o.length>0){r.push(o[0]);return}let n=[];for(let s=0,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof Ft&&(e.intersectObject(this.charContainer.children[s],!1,n),n.length>0)){n[0].object=this,r.push(n[0]);return}}updateGeometry(e){let r=this.userData,o=this.geometry.userData,n=o.parameters.width,s=o.parameters.height,a=e.parameters?.width??n,l=e.parameters?.height??s,c=r.textFrame;super.updateGeometry(e),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==s?(this.checkOverFlow(),this.checkCapacity()):a!==n&&(n<a?this.checkCapacity():n>a&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,o=r.textFrame.textOrigin,n=r.textFrame.textLines;for(let s=e;s<n.length;s++){n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(o);let a=[];for(;n[s].checkOverFlow(r.textFrame.maxLineSize);)n[s].containSpaceOverFlow()?a.unshift(n[s].getWord(n[s].message.length-1,-1)):a.unshift(n[s].popChar());if(a.length>0){n[s+1]===void 0?(n[s].isEndLine(!1),this.createTextLine()):n[s].endLine&&(this.createTextLine(s+1),n[s].isEndLine(!1),n[s+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let u=0;u<a[c].length;u+=1)n[s+1].addChar3D(a[c][u],o,l),l+=1;n[s+1].fullUpdate(o)}n[s].fullUpdate(o)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,o=r.textFrame.textOrigin,n=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o),!!s[a-1])for(;!s[a-1].endLine;){let l,c=s[a-1].spaceLeft(n);if(s[a].wordSize(0,1)<=c){s[a].containSpace()?l=s[a].getWord(0,1):l=s[a].popChar(0);for(let u=0;u<l.length;u+=1)l[u]&&s[a-1].addChar3D(l[u],o)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(o));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let o=this.userData.textFrame;o.textLines.splice(e,0,new co(this.getNewLinePosition(e),o.lineHeight,o.fontSize))}textFullUpdate(e=0){let o=this.userData.textFrame,n=o.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<n.length;a++)n[a].updateYLinePos(this.getNewLinePosition(a)),n[a].fullUpdate(o.textOrigin),n[a].alignText(o.textOrigin,o.maxLineSize,o.horizontalAlignment,o.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let o=this.userData.textFrame.textLines,n=0;for(let s=0;s<e;s+=1)n+=o[s].maxCharSize*o[s].lineHeight;return n}updateColor(e){let r=this.userData;r.textFrame.hexColor=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.color?.isColor&&(l.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.visible=e}}}async updateFontFamily(e){await Ft.loadFont(e);let o=this.userData.textFrame,n=o.textLines;o.fontFamily=e;for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let o=this.userData.textFrame,n=o.textLines,s=o.fontSize;o.fontSize=e;for(let a=0;a<n.length;a++)n[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let o=this.userData.textFrame;await Ft.loadFont(o.fontFamily);let n=o.textLines;switch(o.textTransform=e,e){case 2:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let s=0;s<n.length;s++){let a=n[s].message;for(let l=0;l<a.length;l++)n[s].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)s[a].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let o=r.textFrame.textLines;for(let n=0;n<o.length;n++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,o=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let n=0;n<o.length;n++)o[n].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}fromTextFrameData(e,r){if(e.color!==void 0){let o=Ve(e.color,r);this.updateColor(o),this.updateOpacity(o.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,r){return super.fromState(e),this.fromTextFrameData(e,r),this}},uo=nc;uo.VerticalAlign=Ha,uo.HorizontalAlign=ka,uo.TextTransform=Wa;import{WebGLRenderTarget as lf,LinearMipmapLinearFilter as i1,LinearFilter as s1,ClampToEdgeWrapping as cf,DepthTexture as uf,NearestFilter as pf,FloatType as a1}from"three";var vi=class{constructor(t){this.deletedMaterial=new io(gr.defaultTwoLayerData("basic"),this);this.deletedImage=new no(Is.emptyImage);this.materials={};this.images={};this.colors={};this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};this.transmissionRenderTarget=new lf(2048,2048,{generateMipmaps:!0,minFilter:i1,magFilter:s1,wrapS:cf,wrapT:cf}),this.transmissionRenderTarget.depthTexture=new uf(2048,2048),this.normalRenderTarget=new lf(1024,1024,{generateMipmaps:!1,minFilter:pf,magFilter:pf,type:a1}),this.normalRenderTarget.depthTexture=new uf(1024,1024),this.penumbraSizeNode=new He(5,t.penumbraSize),this.resolutionNode=new ke(1,1),this.pixelRatioNode=new Y(window.devicePixelRatio),this.reset(t)}setOnImageLoad(t){this._onImageLoad=t}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,new io(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}get normalMap(){return this.normalRenderTarget.texture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):new Gt(t,this)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.images[t].updateSrc(e.data),!0):(this.images[t]=new no(e,this.onImageLoad),!1)}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):new an(t,this.onImageLoad)}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new kr(e.r,e.g,e.b,e.a):this.colors[t]=new kr(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Qe(0,0,0,0))}else return"a"in t?new Qe(t.r,t.g,t.b,t.a):new Qe(t.r,t.g,t.b,1);return e}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this._onImageLoad=void 0}},G4=new vi(Ls.emptyData());import{DRACOLoader as l1}from"three/examples/jsm/loaders/DRACOLoader.js";var Wr;function c1(){return Wr||(Wr=new l1,Wr.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wr.decoderPending}async function u1(i){if(Wr){let t={attributeIDs:Wr.defaultAttributeIDs,attributeTypes:Wr.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Wr.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function mf(i,t){let[e,r]=La(xs.deserialize(new Uint8Array(i))),o=[];e.scene.objects.traverse((n,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await c1();for(let n of o){let s=await u1(Aa(n.geometry.data.draco));if(s){s.index&&(n.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:l,array:c,itemSize:u})=>{a[l]={array:c,itemSize:u,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=a,n.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{HemisphereLight as w1,Scene as T1,Vector3 as N1,Color as wf,Fog as C1,Box3 as L1}from"three";import{Box3 as p1,Matrix4 as po,Sphere as hf,Vector3 as m1}from"three";var yf=Xf(ff());var ic;ks.then(i=>{ic=i});var xf=new po,d1=new po,f1=new po,Ut=new p1,qr=new m1,h1=new po,g1=new po,bn=class extends Ke{constructor(e,r,o,n){super(o??r,n);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=o;this.objectType="SubdivObject";this.hiddenMatrixOld=new po;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new po;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,o){let{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}=Pt.build(r.geometry,void 0,void 0,!r.flatShading),l=o.material(r.material),c=new bn(n,s,a||void 0,l);return r.geometry.phongAngle!==void 0&&(c.phongAngle=r.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=e,c.fromState(r),c}buildFromStore(e,r){let{originalGeometry:o,subdividedGeometry:n,subdivPointer:s}=Pt.build(e,r,this.subdivPointer,this.smoothShading,this.shearScale);e.phongAngle!==void 0&&(this.phongAngle=e.phongAngle),this.subdivPointer=s,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,so(this),ao(this),e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Pt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Pt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Pt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Pt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){this.geometry=this.originalGeometry,Ke.prototype.raycast.call(this,e,r),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:o,v:n,q:s}=(0,yf.SVD)(r),a=xf.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=d1.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=f1.copy(l).transpose();this.shearScale=h1.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(l),this.shearScaleInv=g1.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),s.every(u=>Math.abs(s[0]-u)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new hf);let r=e.attributes.position,o=e.boundingSphere.center;Ut.setFromBufferAttribute(r),Ut.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ut.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ut.getSize(qr);let n={width:qr.x,height:qr.y,depth:qr.z};return this.geometry.userData.parameters=n,n}updateBoundingBox(e){let r=this.originalGeometry;Ut.min.set(e[0],e[2],e[4]),Ut.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(Ut.min.applyMatrix4(this.shearScaleInv),Ut.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new hf);let o=r.boundingSphere.center;Ut.getCenter(o),r.boundingSphere.radius=o.distanceTo(Ut.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ut.getSize(qr);let n={width:qr.x,height:qr.y,depth:qr.z};return this.geometry.userData.parameters=n,n}freeSubdivPointer(){this.subdivPointer&&(ic.free_bvh(this.subdivPointer),ic.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,gf(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(gf(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...e.parameters}}};function gf(i,t,e,r){let o=i.position.array,n=i.normal.array,s=xf.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,m=o.length;u<m;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,a=n[u],l=n[u+1],c=n[u+2],n[u]=s[0]*a+s[4]*l+s[8]*c,n[u+1]=s[1]*a+s[5]*l+s[9]*c,n[u+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as y1,BufferGeometry as x1,DoubleSide as v1,FrontSide as b1}from"three";function vf(i,t){t.flatShading!==void 0&&(i.flatShading=t.flatShading,i.needsUpdate=!0),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?i.side=b1:t.side===1?i.side=y1:i.side=v1)}function S1(i,t){if(Array.isArray(i.material))for(let e of i.material)vf(e,t);else{let e=i.material;vf(e,t)}i.objectType==="SubdivObject"&&t.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!t.flatShading,i.updateMesh())}function bf(i,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=bn.createFromState(i,t,e);else{let o=t.geometry.type==="BooleanGeometry"?new x1:Zs(t.geometry,e),n="materials"in t?t.materials.map(s=>e.material(s)):e.material(t.material);Ts.is2DParametricMesh(o.userData.type)?r=new pa(o,n):o?.userData.type==="VectorGeometry"?r=new cn(o,n):t.geometry.type==="NonParametricGeometry"?r=new ma(o,n):t.geometry.type==="BooleanGeometry"?(r=new ra(void 0,n),r.booleanOp=t.geometry.operation,t.geometry.phongAngle!==void 0&&(r.phongAngle=t.geometry.phongAngle)):r=new vn(o,n),r.uuid=i,r.fromState(t,e)}return S1(r,t),r}function Sf(i,t,e){return t.type==="Mesh"?bf(i,t,e):t.type==="TextFrame"?uo.createFromState(i,t,e):t.type==="Empty"?lo.createFromState(i,t):t.type==="PointLight"?gn.createFromState(i,t,e):t.type==="SpotLight"?yn.createFromState(i,t,e):t.type==="DirectionalLight"?hn.createFromState(i,t,e):Bo.is(t.type)?Cr.createFromState(i,t):(console.error(t),new lo)}var Tf=new N1,sc=class extends Hs(T1){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new C1(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this._color=new wf(1,0,0);this.bgColor=new wf(1,1,1);this.entityByUuid={};this.ambientLight=new w1(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=_d(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}needsNormal(e){return this.needsNormalDirty&&(this._needsNormal=Od(e,this),e!==void 0&&(this.needsNormalDirty=!1)),this._needsNormal}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ve(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Cr&&this.switchActiveCamera(o)}this.traverse(o=>{Jt(o)&&o.recomputeBoolean()})}clearScene(){this.traverseEntity(e=>{Dd(e)});for(let e of this.children)Dt(e)&&e.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Cr.createFromState(sc.PERSONAL_CAMERA_ID,{...Cs.defaultData,name:"Personal Camera"});return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],o=n=>{for(let s of n.children)Dt(s)&&!s.raycastLock&&s.visible&&((Qt(s)||Sr(s)&&s.enableHelper&&s.objectHelper.parent)&&(e.intersectObject(s,!1,r),Bd(s,e,r)),o(s))};return o(this),r}traverseEntity(e){for(let r of this.children)Dt(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ve(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,r){nd(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ve(e.groundColor,r)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,r,o){for(let n of e)this.createChildObject(n.id,n.data,n.children,r,o)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,o,n,s){let a=Sf(e,r,s);return a&&(this.entityByUuid[e]=a,n.add(a),Jt(n)&&Qt(a)&&(a.prevBooleanObjectParent=n),this.createChildrenObjects(o,a,s)),a}getCenter(e){let r=[];for(let n=0,s=e.length;n<s;++n){let{id:a,recursive:l}=e[n],c=this.find(a),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new L1;return o.setFromPoints(r),o.getCenter(Tf),Tf}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Ke)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Gt&&e(r.material[o]);else r.material instanceof Gt&&e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let o,n;e>=r?(o=r/e,n=1):(o=1,n=e/r),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=o,l.uniforms[`f${l.id}_aspectRatio`].value.y=n})})}},bi=sc;bi.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{Mesh as $k}from"three";import{mergeBufferGeometries as Kk}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Nf(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}import{Color as Cf,ShaderLib as I1}from"three";function Lf(i){let t=new Set;return i.traverse(e=>{if(Qt(e))if(Re(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);A1(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Cf,specularColor:new Cf}),e.onBeforeCompile=(o,n)=>{r&&r(o,n),o.uniforms=Object.assign(I1.physical.uniforms,o.uniforms),e.getLayersOfType("transmission").forEach(s=>{o.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=o.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=o.uniforms.transmissionSamplerSize.value)})}):P1(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function A1(i){return i.getLayersOfType("transmission").length>0}function P1(i){let t=0;return i.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let r=e.uniforms["f"+e.id+"_alpha"];r&&(t+=(1-t)*r.value)}}),t<1}function If(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function Af(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,n)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,n))}}t.push(r.name)}),i}import{mergeBufferGeometries as M1}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Pf(i){let t=[];return i.traverse(e=>{e instanceof to&&t.push(e)}),t.forEach(e=>{let r=e.object,o=e.children,n=o.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&Nf(l),l}),s=M1(e.parameters.hideBase?n:[r.geometry,...n]);r.geometry=s,r.material=o[0].material,r.remove(e)}),i}function Mf(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function Of(i){Object.values(i.shared.materials).forEach(t=>{ac(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?ac(e.material):"materials"in e&&e.materials.forEach(r=>{ac(r)})})}function ac(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var _f="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",lc=class extends _1{load(t,e,r,o=console.error){let n=new O1(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(_f+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(_f),n.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},r,o)}async parse(t){let e=await mf(t,Of),r=new vi(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new bi(e.scene,r);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let n=e.scene.publish.playCamera;if(n){let s=o.find(n);s&&od(s)&&Object.assign(s,{makeDefault:!0})}return o=Pf(o),o=Lf(o),o=If(o),o=Af(o),o=Mf(o),o}};export{lc as default};