| Server IP : 5.129.245.98 / Your IP : 216.73.216.246 Web Server : Apache/2.4.66 (Debian) System : Linux 1b8c17c336b9 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/greenshiftgsap/libs/splinetool/ |
Upload File : |
"use strict";var wN=Object.create;var Uf=Object.defineProperty;var AN=Object.getOwnPropertyDescriptor;var EN=Object.getOwnPropertyNames;var MN=Object.getPrototypeOf,TN=Object.prototype.hasOwnProperty;var CN=(n,t,e)=>t in n?Uf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Qo=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),jM=(n,t)=>{for(var e in t)Uf(n,e,{get:t[e],enumerable:!0})},HM=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of EN(t))!TN.call(n,i)&&i!==e&&Uf(n,i,{get:()=>t[i],enumerable:!(r=AN(t,i))||r.enumerable});return n};var Ko=(n,t,e)=>(e=n!=null?wN(MN(n)):{},HM(t||!n||!n.__esModule?Uf(e,"default",{value:n,enumerable:!0}):e,n)),PN=n=>HM(Uf({},"__esModule",{value:!0}),n);var tc=(n,t,e)=>(CN(n,typeof t!="symbol"?t+"":t,e),e);var mO=Qo((F1,pO)=>{(function(n,t){typeof F1=="object"?pO.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(F1,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,i=0,s=0,o=1;e.length==0&&(e=[+new Date]);var a=t();r=a(" "),i=a(" "),s=a(" ");for(var l=0;l<e.length;l++)r-=a(e[l]),r<0&&(r+=1),i-=a(e[l]),i<0&&(i+=1),s-=a(e[l]),s<0&&(s+=1);a=null;var c=function(){var u=2091639*r+o*23283064365386963e-26;return r=i,i=s,s=u-(o=u|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[r,i,s,o]},c.importState=function(u){r=+u[0]||0,i=+u[1]||0,s=+u[2]||0,o=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(i){i=i.toString();for(var s=0;s<i.length;s++){e+=i.charCodeAt(s);var o=.02519603282416938*e;e=o>>>0,o-=e,o*=e,e=o>>>0,o-=e,e+=o*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var z1=Qo((l0,xO)=>{(function(n,t){typeof l0=="object"&&typeof xO<"u"?t(l0):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(l0,function(n){"use strict";n.SVD=function(t,e,r,i,s){if(e=e===void 0||e,r=r===void 0||r,s=1e-64/(i=i||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var o,a,l,c,u,h,d,f,p,m,g,y,v=t[0].length,x=t.length;if(x<v)throw new TypeError("Invalid matrix: m < n");for(var S=[],w=[],A=[],M=e==="f"?x:v,b=m=d=0;b<x;b++)w[b]=new Array(M).fill(0);for(b=0;b<v;b++)A[b]=new Array(v).fill(0);var T,C=new Array(v).fill(0);for(b=0;b<x;b++)for(o=0;o<v;o++)w[b][o]=t[b][o];for(b=0;b<v;b++){for(S[b]=d,p=0,l=b+1,o=b;o<x;o++)p+=Math.pow(w[o][b],2);if(p<s)d=0;else for(f=(h=w[b][b])*(d=h<0?Math.sqrt(p):-Math.sqrt(p))-p,w[b][b]=h-d,o=l;o<v;o++){for(p=0,a=b;a<x;a++)p+=w[a][b]*w[a][o];for(h=p/f,a=b;a<x;a++)w[a][o]=w[a][o]+h*w[a][b]}for(C[b]=d,p=0,o=l;o<v;o++)p+=Math.pow(w[b][o],2);if(p<s)d=0;else{for(f=(h=w[b][b+1])*(d=h<0?Math.sqrt(p):-Math.sqrt(p))-p,w[b][b+1]=h-d,o=l;o<v;o++)S[o]=w[b][o]/f;for(o=l;o<x;o++){for(p=0,a=l;a<v;a++)p+=w[o][a]*w[b][a];for(a=l;a<v;a++)w[o][a]=w[o][a]+p*S[a]}}m<(g=Math.abs(C[b])+Math.abs(S[b]))&&(m=g)}if(r)for(b=v-1;0<=b;b--){if(d!==0){for(f=w[b][b+1]*d,o=l;o<v;o++)A[o][b]=w[b][o]/f;for(o=l;o<v;o++){for(p=0,a=l;a<v;a++)p+=w[b][a]*A[a][o];for(a=l;a<v;a++)A[a][o]=A[a][o]+p*A[a][b]}}for(o=l;o<v;o++)A[b][o]=0,A[o][b]=0;A[b][b]=1,d=S[b],l=b}if(e){if(e==="f")for(b=v;b<x;b++){for(o=v;o<x;o++)w[b][o]=0;w[b][b]=1}for(b=v-1;0<=b;b--){for(l=b+1,d=C[b],o=l;o<M;o++)w[b][o]=0;if(d!==0){for(f=w[b][b]*d,o=l;o<M;o++){for(p=0,a=l;a<x;a++)p+=w[a][b]*w[a][o];for(h=p/f,a=b;a<x;a++)w[a][o]=w[a][o]+h*w[a][b]}for(o=b;o<x;o++)w[o][b]=w[o][b]/d}else for(o=b;o<x;o++)w[o][b]=0;w[b][b]=w[b][b]+1}}for(i*=m,a=v-1;0<=a;a--)for(var P=0;P<50;P++){for(T=!1,l=a;0<=l;l--){if(Math.abs(S[l])<=i){T=!0;break}if(Math.abs(C[l-1])<=i)break}if(!T){for(u=0,c=l-(p=1),b=l;b<a+1&&(h=p*S[b],S[b]=u*S[b],!(Math.abs(h)<=i));b++)if(d=C[b],C[b]=Math.sqrt(h*h+d*d),u=d/(f=C[b]),p=-h/f,e)for(o=0;o<x;o++)g=w[o][c],y=w[o][b],w[o][c]=g*u+y*p,w[o][b]=-g*p+y*u}if(y=C[a],l===a){if(y<0&&(C[a]=-y,r))for(o=0;o<v;o++)A[o][a]=-A[o][a];break}for(m=C[l],h=(((g=C[a-1])-y)*(g+y)+((d=S[a-1])-(f=S[a]))*(d+f))/(2*f*g),d=Math.sqrt(h*h+1),h=((m-y)*(m+y)+f*(g/(h<0?h-d:h+d)-f))/m,b=l+(p=u=1);b<a+1;b++){if(d=S[b],g=C[b],f=p*d,d*=u,y=Math.sqrt(h*h+f*f),h=m*(u=h/(S[b-1]=y))+d*(p=f/y),d=-m*p+d*u,f=g*p,g*=u,r)for(o=0;o<v;o++)m=A[o][b-1],y=A[o][b],A[o][b-1]=m*u+y*p,A[o][b]=-m*p+y*u;if(y=Math.sqrt(h*h+f*f),h=(u=h/(C[b-1]=y))*d+(p=f/y)*g,m=-p*d+u*g,e)for(o=0;o<x;o++)g=w[o][b-1],y=w[o][b],w[o][b-1]=g*u+y*p,w[o][b]=-g*p+y*u}S[l]=0,S[a]=h,C[a]=m}for(b=0;b<v;b++)C[b]<i&&(C[b]=0);return{u:w,q:C,v:A}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var qO=Qo((iA,nA)=>{(function(n,t){typeof iA=="object"&&typeof nA<"u"?nA.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(iA,function(){"use strict";var n=function(r,i){if(r===void 0&&(r=[]),i===void 0&&(i=t),this.data=r,this.length=this.data.length,this.compare=i,this.length>0)for(var s=(this.length>>1)-1;s>=0;s--)this._down(s)};n.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var i=this,s=i.data,o=i.compare,a=s[r];r>0;){var l=r-1>>1,c=s[l];if(o(a,c)>=0)break;s[r]=c,r=l}s[r]=a},n.prototype._down=function(r){for(var i=this,s=i.data,o=i.compare,a=this.length>>1,l=s[r];r<a;){var c=(r<<1)+1,u=s[c],h=c+1;if(h<this.length&&o(s[h],u)<0&&(c=h,u=s[h]),o(u,l)>=0)break;s[r]=u,r=c}s[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return n})});var XO=Qo((Jme,sA)=>{"use strict";var p0=qO();p0.default&&(p0=p0.default);sA.exports=YO;sA.exports.default=YO;function YO(n,t,e){t=t||1;for(var r,i,s,o,a=0;a<n[0].length;a++){var l=n[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<i)&&(i=l[1]),(!a||l[0]>s)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var c=s-r,u=o-i,h=Math.min(c,u),d=h/2;if(h===0){var f=[r,i];return f.distance=0,f}for(var p=new p0(void 0,H9),m=r;m<s;m+=h)for(var g=i;g<o;g+=h)p.push(new Dl(m+d,g+d,d,n));var y=q9(n),v=new Dl(r+c/2,i+u/2,0,n);v.d>y.d&&(y=v);for(var x=p.length;p.length;){var S=p.pop();S.d>y.d&&(y=S,e&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,x)),!(S.max-y.d<=t)&&(d=S.h/2,p.push(new Dl(S.x-d,S.y-d,d,n)),p.push(new Dl(S.x+d,S.y-d,d,n)),p.push(new Dl(S.x-d,S.y+d,d,n)),p.push(new Dl(S.x+d,S.y+d,d,n)),x+=4)}e&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var w=[y.x,y.y];return w.distance=y.d,w}function H9(n,t){return t.max-n.max}function Dl(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=W9(n,t,r),this.max=this.d+this.h*Math.SQRT2}function W9(n,t,e){for(var r=!1,i=1/0,s=0;s<e.length;s++)for(var o=e[s],a=0,l=o.length,c=l-1;a<l;c=a++){var u=o[a],h=o[c];u[1]>t!=h[1]>t&&n<(h[0]-u[0])*(t-u[1])/(h[1]-u[1])+u[0]&&(r=!r),i=Math.min(i,Y9(n,t,u,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function q9(n){for(var t=0,e=0,r=0,i=n[0],s=0,o=i.length,a=o-1;s<o;a=s++){var l=i[s],c=i[a],u=l[0]*c[1]-c[0]*l[1];e+=(l[0]+c[0])*u,r+=(l[1]+c[1])*u,t+=u*3}return t===0?new Dl(i[0][0],i[0][1],0,n):new Dl(e/t,r/t,0,n)}function Y9(n,t,e,r){var i=e[0],s=e[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){var l=((n-i)*o+(t-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=t-s,o*o+a*a}});var YI=Qo((z0,qI)=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});z0.default=q7;function q7(n){if(n===null||n===!0||n===!1)return NaN;var t=Number(n);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}qI.exports=z0.default});var QI=Qo((U0,XI)=>{"use strict";Object.defineProperty(U0,"__esModule",{value:!0});U0.default=Y7;function Y7(n){var t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return t.setUTCFullYear(n.getFullYear()),n.getTime()-t.getTime()}XI.exports=U0.default});var k3=Qo((mLe,U3)=>{"use strict";function PQ(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Qc(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Qc)}PQ(Qc,Error);Qc.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var u="",h;for(h=0;h<c.parts.length;h++)u+=c.parts[h]instanceof Array?s(c.parts[h][0])+"-"+s(c.parts[h][1]):s(c.parts[h]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(u)})}function s(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(u)})}function o(c){return e[c.type](c)}function a(c){var u=new Array(c.length),h,d;for(h=0;h<c.length;h++)u[h]=o(c[h]);if(u.sort(),u.length>0){for(h=1,d=1;h<u.length;h++)u[h-1]!==u[h]&&(u[d]=u[h],d++);u.length=d}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(n)+" but "+l(t)+" found."};function _Q(n,t){t=t!==void 0?t:{};var e={},r={svg_path:je},i=je,s=function(I){if(!I)return[];for(var R=[],X=0;X<I.length;X++)R=R.concat.apply(R,I[X]);var z=R[0];return z&&z.code=="m"&&(delete z.relative,z.code="M"),R},o=function(I,R){return gi(I,R)},a=/^[Mm]/,l=Be(["M","m"],!1,!1),c=function(I,R,X){var z=ai(I,[R]);return X&&(z=z.concat(ai(I=="M"?"L":"l",X[1]))),z},u=/^[Zz]/,h=Be(["Z","z"],!1,!1),d=function(){return ai("Z")},f=/^[Ll]/,p=Be(["L","l"],!1,!1),m=function(I,R){return ai(I,R)},g=/^[Hh]/,y=Be(["H","h"],!1,!1),v=function(I,R){return ai(I,R.map(function(X){return{x:X}}))},x=/^[Vv]/,S=Be(["V","v"],!1,!1),w=function(I,R){return ai(I,R.map(function(X){return{y:X}}))},A=/^[Cc]/,M=Be(["C","c"],!1,!1),b=function(I,R,X){return{x1:I.x,y1:I.y,x2:R.x,y2:R.y,x:X.x,y:X.y}},T=/^[Ss]/,C=Be(["S","s"],!1,!1),P=function(I,R){return{x2:I.x,y2:I.y,x:R.x,y:R.y}},D=/^[Qq]/,_=Be(["Q","q"],!1,!1),O=function(I,R){return{x1:I.x,y1:I.y,x:R.x,y:R.y}},L=/^[Tt]/,j=Be(["T","t"],!1,!1),V=/^[Aa]/,H=Be(["A","a"],!1,!1),W=function(I,R,X,z,ee,Pe){return{rx:I,ry:R,xAxisRotation:X,largeArc:z,sweep:ee,x:Pe.x,y:Pe.y}},q=function(I,R){return{x:I,y:R}},K=function(I){return I*1},G=function(I){return I.join("")*1},Z=/^[01]/,te=Be(["0","1"],!1,!1),$=function(I){return I=="1"},Y=function(){return""},oe=",",ie=Ge(",",!1),re=function(I){return I.join("")},J=".",Ae=Ge(".",!1),xe=/^[eE]/,de=Be(["e","E"],!1,!1),Oe=/^[+\-]/,Ce=Be(["+","-"],!1,!1),Ue=/^[0-9]/,ze=Be([["0","9"]],!1,!1),Ve=function(I){return I.join("")},Ie=/^[ \t\n\r]/,Ye=Be([" "," ",`
`,"\r"],!1,!1),F=0,N=0,B=[{line:1,column:1}],ae=0,ge=[],me=0,Le;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');i=r[t.startRule]}function Ne(){return n.substring(N,F)}function Re(){return Ar(N,F)}function pe(I,R){throw R=R!==void 0?R:Ar(N,F),Me([Bt(I)],n.substring(N,F),R)}function rt(I,R){throw R=R!==void 0?R:Ar(N,F),ye(I,R)}function Ge(I,R){return{type:"literal",text:I,ignoreCase:R}}function Be(I,R,X){return{type:"class",parts:I,inverted:R,ignoreCase:X}}function Je(){return{type:"any"}}function nt(){return{type:"end"}}function Bt(I){return{type:"other",description:I}}function ur(I){var R=B[I],X;if(R)return R;for(X=I-1;!B[X];)X--;for(R=B[X],R={line:R.line,column:R.column};X<I;)n.charCodeAt(X)===10?(R.line++,R.column=1):R.column++,X++;return B[I]=R,R}function Ar(I,R){var X=ur(I),z=ur(R);return{start:{offset:I,line:X.line,column:X.column},end:{offset:R,line:z.line,column:z.column}}}function Q(I){F<ae||(F>ae&&(ae=F,ge=[]),ge.push(I))}function ye(I,R){return new Qc(I,null,null,R)}function Me(I,R,X){return new Qc(Qc.buildMessage(I,R),I,R,X)}function je(){var I,R,X,z,ee;for(I=F,R=[],X=At();X!==e;)R.push(X),X=At();if(R!==e)if(X=He(),X===e&&(X=null),X!==e){for(z=[],ee=At();ee!==e;)z.push(ee),ee=At();z!==e?(N=I,R=s(X),I=R):(F=I,I=e)}else F=I,I=e;else F=I,I=e;return I}function He(){var I,R,X,z,ee,Pe;if(I=F,R=_t(),R!==e){for(X=[],z=F,ee=[],Pe=At();Pe!==e;)ee.push(Pe),Pe=At();for(ee!==e?(Pe=_t(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;){for(X.push(z),z=F,ee=[],Pe=At();Pe!==e;)ee.push(Pe),Pe=At();ee!==e?(Pe=_t(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e)}X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function _t(){var I,R,X,z,ee,Pe;if(I=F,R=Nr(),R!==e){for(X=[],z=F,ee=[],Pe=At();Pe!==e;)ee.push(Pe),Pe=At();for(ee!==e?(Pe=Br(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;){for(X.push(z),z=F,ee=[],Pe=At();Pe!==e;)ee.push(Pe),Pe=At();ee!==e?(Pe=Br(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e)}X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function Br(){var I;return I=Xo(),I===e&&(I=Er(),I===e&&(I=An(),I===e&&(I=Rb(),I===e&&(I=Lb(),I===e&&(I=le(),I===e&&(I=be(),I===e&&(I=wt(),I===e&&(I=kt())))))))),I}function Nr(){var I,R,X,z,ee,Pe,au;if(I=F,a.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(l)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=Ft(),z!==e?(ee=F,Pe=gt(),Pe===e&&(Pe=null),Pe!==e?(au=es(),au!==e?(Pe=[Pe,au],ee=Pe):(F=ee,ee=e)):(F=ee,ee=e),ee===e&&(ee=null),ee!==e?(N=I,R=c(R,z,ee),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function Xo(){var I,R;return I=F,u.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(h)),R!==e&&(N=I,R=d()),I=R,I}function Er(){var I,R,X,z;if(I=F,f.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(p)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=es(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function es(){var I,R,X,z,ee,Pe;if(I=F,R=Ft(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function An(){var I,R,X,z;if(I=F,g.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(y)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=zf(),z!==e?(N=I,R=v(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function zf(){var I,R,X,z,ee,Pe;if(I=F,R=$i(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=$i(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=$i(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function Rb(){var I,R,X,z;if(I=F,x.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(S)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=zf(),z!==e?(N=I,R=w(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function Lb(){var I,R,X,z;if(I=F,A.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(M)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=Bb(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function Bb(){var I,R,X,z,ee,Pe;if(I=F,R=k(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=k(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=k(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function k(){var I,R,X,z,ee,Pe;return I=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Ft(),z!==e?(ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(N=I,R=b(R,z,Pe),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e),I}function le(){var I,R,X,z;if(I=F,T.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(C)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=ve(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function ve(){var I,R,X,z,ee,Pe;if(I=F,R=se(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=se(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=se(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function se(){var I,R,X,z;return I=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Ft(),z!==e?(N=I,R=P(R,z),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e),I}function be(){var I,R,X,z;if(I=F,D.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(_)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=ct(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function ct(){var I,R,X,z,ee,Pe;if(I=F,R=mt(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=mt(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=mt(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function mt(){var I,R,X,z;return I=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Ft(),z!==e?(N=I,R=O(R,z),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e),I}function wt(){var I,R,X,z;if(I=F,L.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(j)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=Tt(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function Tt(){var I,R,X,z,ee,Pe;if(I=F,R=Ft(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function kt(){var I,R,X,z;if(I=F,V.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(H)),R!==e){for(X=[],z=At();z!==e;)X.push(z),z=At();X!==e?(z=Nt(),z!==e?(N=I,R=m(R,z),I=R):(F=I,I=e)):(F=I,I=e)}else F=I,I=e;return I}function Nt(){var I,R,X,z,ee,Pe;if(I=F,R=Dt(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Dt(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);z!==e;)X.push(z),z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Dt(),Pe!==e?(ee=[ee,Pe],z=ee):(F=z,z=e)):(F=z,z=e);X!==e?(N=I,R=o(R,X),I=R):(F=I,I=e)}else F=I,I=e;return I}function Dt(){var I,R,X,z,ee,Pe,au,Nb,pg,Fb,mg,Vb;return I=F,R=Ji(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Ji(),z!==e?(ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=$i(),Pe!==e?(au=gt(),au!==e?(Nb=oo(),Nb!==e?(pg=gt(),pg===e&&(pg=null),pg!==e?(Fb=oo(),Fb!==e?(mg=gt(),mg===e&&(mg=null),mg!==e?(Vb=Ft(),Vb!==e?(N=I,R=W(R,z,Pe,Nb,Fb,Vb),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e)):(F=I,I=e),I}function Ft(){var I,R,X,z;return I=F,R=$i(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=$i(),z!==e?(N=I,R=q(R,z),I=R):(F=I,I=e)):(F=I,I=e)):(F=I,I=e),I}function Ji(){var I,R;return I=F,R=nu(),R===e&&(R=zn()),R!==e&&(N=I,R=K(R)),I=R,I}function $i(){var I,R,X,z;return I=F,R=F,X=su(),X===e&&(X=null),X!==e?(z=nu(),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=su(),X===e&&(X=null),X!==e?(z=zn(),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=I,R=G(R)),I=R,I}function oo(){var I,R;return I=F,Z.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(te)),R!==e&&(N=I,R=$(R)),I=R,I}function gt(){var I,R,X,z,ee;if(I=F,R=[],X=At(),X!==e)for(;X!==e;)R.push(X),X=At();else R=e;if(R!==e)if(X=Rt(),X===e&&(X=null),X!==e){for(z=[],ee=At();ee!==e;)z.push(ee),ee=At();z!==e?(R=[R,X,z],I=R):(F=I,I=e)}else F=I,I=e;else F=I,I=e;if(I===e){if(I=F,R=F,X=Rt(),X!==e){for(z=[],ee=At();ee!==e;)z.push(ee),ee=At();z!==e?(X=[X,z],R=X):(F=R,R=e)}else F=R,R=e;R!==e&&(N=I,R=Y()),I=R}return I}function Rt(){var I;return n.charCodeAt(F)===44?(I=oe,F++):(I=e,me===0&&Q(ie)),I}function nu(){var I,R,X,z;return I=F,R=F,X=oi(),X!==e?(z=ao(),z===e&&(z=null),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=zn(),X!==e?(z=ao(),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=I,R=re(R)),I=R,I}function oi(){var I,R,X,z,ee;return I=F,R=F,X=zn(),X===e&&(X=null),X!==e?(n.charCodeAt(F)===46?(z=J,F++):(z=e,me===0&&Q(Ae)),z!==e?(ee=zn(),ee!==e?(X=[X,z,ee],R=X):(F=R,R=e)):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=zn(),X!==e?(n.charCodeAt(F)===46?(z=J,F++):(z=e,me===0&&Q(Ae)),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=I,R=re(R)),I=R,I}function ao(){var I,R,X,z,ee;return I=F,R=F,xe.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&Q(de)),X!==e?(z=su(),z===e&&(z=null),z!==e?(ee=zn(),ee!==e?(X=[X,z,ee],R=X):(F=R,R=e)):(F=R,R=e)):(F=R,R=e),R!==e&&(N=I,R=re(R)),I=R,I}function su(){var I;return Oe.test(n.charAt(F))?(I=n.charAt(F),F++):(I=e,me===0&&Q(Ce)),I}function zn(){var I,R,X;if(I=F,R=[],Ue.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&Q(ze)),X!==e)for(;X!==e;)R.push(X),Ue.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&Q(ze));else R=e;return R!==e&&(N=I,R=Ve(R)),I=R,I}function At(){var I,R;return I=F,Ie.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&Q(Ye)),R!==e&&(N=I,R=Y()),I=R,I}function gi(I,R){if(!R)return[I];for(var X=[I],z=0,ee=R.length;z<ee;z++)X[z+1]=R[z][1];return X}var ts={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var ou in ts)ts[ou.toUpperCase()]=ts[ou];function ai(I,R){R||(R=[{}]);for(var X=R.length;X--;){var z={code:I,command:ts[I]};I==I.toLowerCase()&&(z.relative=!0);for(var ee in R[X])z[ee]=R[X][ee];R[X]=z}return R}if(Le=i(),Le!==e&&F===n.length)return Le;throw Le!==e&&F<n.length&&Q(nt()),Me(ge,ae<n.length?n.charAt(ae):null,ae<n.length?Ar(ae,ae+1):Ar(ae,ae))}U3.exports={SyntaxError:Qc,parse:_Q}});var CE=Qo((gLe,G3)=>{var Tx=k3().parse;Tx.parseSVG=Tx;Tx.makeAbsolute=DQ;G3.exports=Tx;function DQ(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(i){i.command==="moveto"&&(t=i),i.x0=e.x,i.y0=e.y;for(var s in r)s in i&&(i[s]+=i.relative?i[r[s]]:0);"x"in i||(i.x=e.x),"y"in i||(i.y=e.y),i.relative=!1,i.code=i.code.toUpperCase(),i.command=="closepath"&&(i.x=t.x,i.y=t.y),e=i}),n}});var bN=Qo((J6e,xN)=>{xN.exports=function(t,e){for(var r=t.split("."),i=e.split("."),s=0;s<3;s++){var o=Number(r[s]),a=Number(i[s]);if(o>a)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!isNaN(a))return-1}return 0}});var iJ={};jM(iJ,{Application:()=>GM});module.exports=PN(iJ);var oa="149";var Yn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},_N=0,WM=1,DN=2;var by=1,ON=2,Kf=3,Gn=0,ui=1,ji=2;var Zt=0,Wa=1,qM=2,YM=3,XM=4,IN=5,wu=100,RN=101,LN=102,QM=103,KM=104,BN=200,NN=201,FN=202,VN=203,AC=204,EC=205,zN=206,UN=207,kN=208,GN=209,jN=210,HN=0,WN=1,qN=2,wS=3,YN=4,XN=5,QN=6,KN=7,MC=0,ZN=1,JN=2,Os=0,$N=1,eF=2,tF=3,rF=4,iF=5,TC=300,Ya=301,Xa=302,AS=303,ES=304,Yu=306,Is=1e3,Yt=1001,MS=1002,Vt=1003,ZM=1004;var zb=1005;var tt=1006,nF=1007;var cc=1008;var Cr=1009,sF=1010,oF=1011,CC=1012,aF=1013,Ds=1014,yr=1015,jn=1016,lF=1017,cF=1018,qa=1020,uF=1021,jr=1023,hF=1024,dF=1025,ac=1026,Qa=1027,fF=1028,pF=1029,Xu=1030,mF=1031,nw=1033,Ub=33776,kb=33777,Gb=33778,jb=33779,JM=35840,$M=35841,eT=35842,tT=35843,gF=36196,rT=37492,iT=37496,nT=37808,sT=37809,oT=37810,aT=37811,lT=37812,cT=37813,uT=37814,hT=37815,dT=37816,fT=37817,pT=37818,mT=37819,gT=37820,yT=37821,Hb=36492,yF=36283,vT=36284,xT=36285,bT=36286,sw=2200,ow=2201,xp=2202,Wg=2300,qg=2301,Wb=2302,Au=2400,Eu=2401,Yg=2402,aw=2500,vF=2501;var un=3e3,at=3001,Ii=3200,lw=3201,xF=0,bF=1;var lo="srgb",ip="srgb-linear";var qb=7680;var SF=519,TS=35044,PC=35048;var ST="300 es",CS=1035,hr=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let r=this._listeners;return r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let i=this._listeners[t];if(i!==void 0){let s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let r=this._listeners[t.type];if(r!==void 0){t.target=this;let i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}},en=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],wT=1234567,Jf=Math.PI/180,np=180/Math.PI;function is(){let n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(en[n&255]+en[n>>8&255]+en[n>>16&255]+en[n>>24&255]+"-"+en[t&255]+en[t>>8&255]+"-"+en[t>>16&15|64]+en[t>>24&255]+"-"+en[e&63|128]+en[e>>8&255]+"-"+en[e>>16&255]+en[e>>24&255]+en[r&255]+en[r>>8&255]+en[r>>16&255]+en[r>>24&255]).toLowerCase()}function ci(n,t,e){return Math.max(t,Math.min(e,n))}function cw(n,t){return(n%t+t)%t}function wF(n,t,e,r,i){return r+(n-t)*(i-r)/(e-t)}function AF(n,t,e){return n!==t?(e-n)/(t-n):0}function $f(n,t,e){return(1-e)*n+e*t}function EF(n,t,e,r){return $f(n,t,1-Math.exp(-e*r))}function MF(n,t=1){return t-Math.abs(cw(n,t*2)-t)}function TF(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function CF(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function PF(n,t){return n+Math.floor(Math.random()*(t-n+1))}function _F(n,t){return n+Math.random()*(t-n)}function DF(n){return n*(.5-Math.random())}function OF(n){n!==void 0&&(wT=n);let t=wT+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function IF(n){return n*Jf}function RF(n){return n*np}function PS(n){return(n&n-1)===0&&n!==0}function _C(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Xg(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function LF(n,t,e,r,i){let s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+r)/2),u=o((t+r)/2),h=s((t-r)/2),d=o((t-r)/2),f=s((r-t)/2),p=o((r-t)/2);switch(i){case"XYX":n.set(a*u,l*h,l*d,a*c);break;case"YZY":n.set(l*d,a*u,l*h,a*c);break;case"ZXZ":n.set(l*h,l*d,a*u,a*c);break;case"XZX":n.set(a*u,l*p,l*f,a*c);break;case"YXY":n.set(l*f,a*u,l*p,a*c);break;case"ZYZ":n.set(l*p,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function na(n,t){switch(t.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function gr(n,t){switch(t.constructor){case Float32Array:return n;case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var we=Object.freeze({__proto__:null,DEG2RAD:Jf,RAD2DEG:np,ceilPowerOfTwo:_C,clamp:ci,damp:EF,degToRad:IF,denormalize:na,euclideanModulo:cw,floorPowerOfTwo:Xg,generateUUID:is,inverseLerp:AF,isPowerOfTwo:PS,lerp:$f,mapLinear:wF,normalize:gr,pingpong:MF,radToDeg:RF,randFloat:_F,randFloatSpread:DF,randInt:PF,seededRandom:OF,setQuaternionFromProperEuler:LF,smootherstep:CF,smoothstep:TF}),U=class{constructor(t=0,e=0){U.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},vr=class{constructor(){vr.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,r,i,s,o,a,l,c){let u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=s,u[5]=l,u[6]=r,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],u=r[4],h=r[7],d=r[2],f=r[5],p=r[8],m=i[0],g=i[3],y=i[6],v=i[1],x=i[4],S=i[7],w=i[2],A=i[5],M=i[8];return s[0]=o*m+a*v+l*w,s[3]=o*g+a*x+l*A,s[6]=o*y+a*S+l*M,s[1]=c*m+u*v+h*w,s[4]=c*g+u*x+h*A,s[7]=c*y+u*S+h*M,s[2]=d*m+f*v+p*w,s[5]=d*g+f*x+p*A,s[8]=d*y+f*S+p*M,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-r*s*u+r*a*l+i*s*c-i*o*l}invert(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=a*l-u*s,f=c*s-o*l,p=e*h+r*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return t[0]=h*m,t[1]=(i*c-u*r)*m,t[2]=(a*r-i*o)*m,t[3]=d*m,t[4]=(u*e-i*l)*m,t[5]=(i*s-a*e)*m,t[6]=f*m,t[7]=(r*l-c*e)*m,t[8]=(o*e-r*s)*m,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Yb.makeScale(t,e)),this}rotate(t){return this.premultiply(Yb.makeRotation(-t)),this}translate(t,e){return this.premultiply(Yb.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}},Yb=new vr;function DC(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}var BF={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function gg(n,t){return new BF[n](t)}function sp(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function lc(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Hg(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Xb={[lo]:{[ip]:lc},[ip]:{[lo]:Hg}},an={legacyMode:!0,get workingColorSpace(){return ip},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,t,e){if(this.legacyMode||t===e||!t||!e)return n;if(Xb[t]&&Xb[t][e]!==void 0){let r=Xb[t][e];return n.r=r(n.r),n.g=r(n.g),n.b=r(n.b),n}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(n,t){return this.convert(n,this.workingColorSpace,t)},toWorkingColorSpace:function(n,t){return this.convert(n,t,this.workingColorSpace)}},OC={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},yi={r:0,g:0,b:0},Cs={h:0,s:0,l:0},yg={h:0,s:0,l:0};function Qb(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}function vg(n,t){return t.r=n.r,t.g=n.g,t.b=n.b,t}var We=class{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,e===void 0&&r===void 0?this.set(t):this.setRGB(t,e,r)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=lo){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,an.toWorkingColorSpace(this,e),this}setRGB(t,e,r,i=an.workingColorSpace){return this.r=t,this.g=e,this.b=r,an.toWorkingColorSpace(this,i),this}setHSL(t,e,r,i=an.workingColorSpace){if(t=cw(t,1),e=ci(e,0,1),r=ci(r,0,1),e===0)this.r=this.g=this.b=r;else{let s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=Qb(o,s,t+1/3),this.g=Qb(o,s,t),this.b=Qb(o,s,t-1/3)}return an.toWorkingColorSpace(this,i),this}setStyle(t,e=lo){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,an.toWorkingColorSpace(this,e),r(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,an.toWorkingColorSpace(this,e),r(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,c=parseFloat(s[2])/100,u=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,c,u,e)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,an.toWorkingColorSpace(this,e),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,an.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=lo){let r=OC[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=lc(t.r),this.g=lc(t.g),this.b=lc(t.b),this}copyLinearToSRGB(t){return this.r=Hg(t.r),this.g=Hg(t.g),this.b=Hg(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=lo){return an.fromWorkingColorSpace(vg(this,yi),t),ci(yi.r*255,0,255)<<16^ci(yi.g*255,0,255)<<8^ci(yi.b*255,0,255)<<0}getHexString(t=lo){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=an.workingColorSpace){an.fromWorkingColorSpace(vg(this,yi),e);let r=yi.r,i=yi.g,s=yi.b,o=Math.max(r,i,s),a=Math.min(r,i,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return t.h=l,t.s=c,t.l=u,t}getRGB(t,e=an.workingColorSpace){return an.fromWorkingColorSpace(vg(this,yi),e),t.r=yi.r,t.g=yi.g,t.b=yi.b,t}getStyle(t=lo){return an.fromWorkingColorSpace(vg(this,yi),t),t!==lo?`color(${t} ${yi.r} ${yi.g} ${yi.b})`:`rgb(${yi.r*255|0},${yi.g*255|0},${yi.b*255|0})`}offsetHSL(t,e,r){return this.getHSL(Cs),Cs.h+=t,Cs.s+=e,Cs.l+=r,this.setHSL(Cs.h,Cs.s,Cs.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(Cs),t.getHSL(yg);let r=$f(Cs.h,yg.h,e),i=$f(Cs.s,yg.s,e),s=$f(Cs.l,yg.l,e);return this.setHSL(r,i,s),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};We.NAMES=OC;var lu,Qg=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{lu===void 0&&(lu=sp("canvas")),lu.width=t.width,lu.height=t.height;let r=lu.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=lu}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=sp("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);let i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=lc(s[o]/255)*255;return r.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(lc(e[r]/255)*255):e[r]=lc(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Kg=class{constructor(t=null){this.isSource=!0,this.uuid=is(),this.data=t,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Kb(i[o].image)):s.push(Kb(i[o]))}else s=Kb(i);r.url=s}return e||(t.images[this.uuid]=r),r}};function Kb(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Qg.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var NF=0,Jt=class extends hr{constructor(t=Jt.DEFAULT_IMAGE,e=Jt.DEFAULT_MAPPING,r=Yt,i=Yt,s=tt,o=cc,a=jr,l=Cr,c=Jt.DEFAULT_ANISOTROPY,u=un){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:NF++}),this.uuid=is(),this.name="",this.source=new Kg(t),this.mipmaps=[],this.mapping=e,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new U(0,0),this.repeat=new U(1,1),this.center=new U(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==TC)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Is:t.x=t.x-Math.floor(t.x);break;case Yt:t.x=t.x<0?0:1;break;case MS:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Is:t.y=t.y-Math.floor(t.y);break;case Yt:t.y=t.y<0?0:1;break;case MS:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}};Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=TC;Jt.DEFAULT_ANISOTROPY=1;var Ke=class{constructor(t=0,e=0,r=0,i=1){Ke.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s,l=t.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],p=l[9],m=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let x=(c+1)/2,S=(f+1)/2,w=(y+1)/2,A=(u+d)/4,M=(h+m)/4,b=(p+g)/4;return x>S&&x>w?x<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(x),i=A/r,s=M/r):S>w?S<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),r=A/i,s=b/i):w<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),r=M/s,i=b/s),this.set(r,i,s,e),this}let v=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(h-m)/v,this.z=(d-u)/v,this.w=Math.acos((c+f+y-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},dt=class extends hr{constructor(t=1,e=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ke(0,0,t,e),this.scissorTest=!1,this.viewport=new Ke(0,0,t,e);let i={width:t,height:e,depth:1};this.texture=new Jt(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:tt,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(t,e,r=1){(this.width!==t||this.height!==e||this.depth!==r)&&(this.width=t,this.height=e,this.depth=r,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new Kg(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Zg=class extends Jt{constructor(t=null,e=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:r,depth:i},this.magFilter=Vt,this.minFilter=Vt,this.wrapR=Yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Jg=class extends Jt{constructor(t=null,e=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:r,depth:i},this.magFilter=Vt,this.minFilter=Vt,this.wrapR=Yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var $g=class extends dt{constructor(t=1,e=1,r=1,i={}){super(t,e,i),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let o=0;o<r;o++)this.texture[o]=s.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(t,e,r=1){if(this.width!==t||this.height!==e||this.depth!==r){this.width=t,this.height=e,this.depth=r;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=t,this.texture[i].image.height=e,this.texture[i].image.depth=r;this.dispose()}return this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e),this}copy(t){this.dispose(),this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,r=t.texture.length;e<r;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}},Qe=class{constructor(t=0,e=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=i}static slerpFlat(t,e,r,i,s,o,a){let l=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3],d=s[o+0],f=s[o+1],p=s[o+2],m=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=m;return}if(h!==m||l!==d||c!==f||u!==p){let g=1-a,y=l*d+c*f+u*p+h*m,v=y>=0?1:-1,x=1-y*y;if(x>Number.EPSILON){let w=Math.sqrt(x),A=Math.atan2(w,y*v);g=Math.sin(g*A)/w,a=Math.sin(a*A)/w}let S=a*v;if(l=l*g+d*S,c=c*g+f*S,u=u*g+p*S,h=h*g+m*S,g===1-a){let w=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=w,c*=w,u*=w,h*=w}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,i,s,o){let a=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+l*f-c*d,t[e+1]=l*p+u*d+c*h-a*f,t[e+2]=c*p+u*f+a*d-l*h,t[e+3]=u*p-a*h-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),u=a(i/2),h=a(s/2),d=l(r/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],h=e[10],d=r+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(r>a&&r>h){let f=2*Math.sqrt(1+r-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>h){let f=2*Math.sqrt(1+a-r-h);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+h-r-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<Number.EPSILON?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ci(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=r*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-r*c,this._z=s*u+o*c+r*l-i*a,this._w=o*u-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,i=this._y,s=this._z,o=this._w,a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-e;return this._w=f*o+e*this._w,this._x=f*r+e*this._x,this._y=f*i+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-e)*u)/c,d=Math.sin(e*u)/c;return this._w=o*h+this._w*d,this._x=r*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){let t=Math.random(),e=Math.sqrt(1-t),r=Math.sqrt(t),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(i),r*Math.sin(s),r*Math.cos(s),e*Math.sin(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},E=class{constructor(t=0,e=0,r=0){E.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(AT.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(AT.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){let e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=l*e+o*i-a*r,u=l*r+a*e-s*i,h=l*i+s*r-o*e,d=-s*e-o*r-a*i;return this.x=c*l+d*-s+u*-a-h*-o,this.y=u*l+d*-o+h*-s-c*-a,this.z=h*l+d*-a+c*-o-u*-s,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Zb.copy(this).projectOnVector(t),this.sub(Zb)}reflect(t){return this.sub(Zb.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let r=this.dot(t)/e;return Math.acos(ci(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){let i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,r=Math.sqrt(1-t**2);return this.x=r*Math.cos(e),this.y=r*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Zb=new E,AT=new Qe,Gt=class{constructor(t=new E(1/0,1/0,1/0),e=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=t.length;l<c;l+=3){let u=t[l],h=t[l+1],d=t[l+2];u<e&&(e=u),h<r&&(r=h),d<i&&(i=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,i),this.max.set(s,o,a),this}setFromBufferAttribute(t){let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=t.count;l<c;l++){let u=t.getX(l),h=t.getY(l),d=t.getZ(l);u<e&&(e=u),h<r&&(r=h),d<i&&(i=d),u>s&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,i),this.max.set(s,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=rc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let r=t.geometry;if(r!==void 0)if(e&&r.attributes!=null&&r.attributes.position!==void 0){let s=r.attributes.position;for(let o=0,a=s.count;o<a;o++)rc.fromBufferAttribute(s,o).applyMatrix4(t.matrixWorld),this.expandByPoint(rc)}else r.boundingBox===null&&r.computeBoundingBox(),Jb.copy(r.boundingBox),Jb.applyMatrix4(t.matrixWorld),this.union(Jb);let i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,rc),rc.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(kf),xg.subVectors(this.max,kf),cu.subVectors(t.a,kf),uu.subVectors(t.b,kf),hu.subVectors(t.c,kf),Ua.subVectors(uu,cu),ka.subVectors(hu,uu),ic.subVectors(cu,hu);let e=[0,-Ua.z,Ua.y,0,-ka.z,ka.y,0,-ic.z,ic.y,Ua.z,0,-Ua.x,ka.z,0,-ka.x,ic.z,0,-ic.x,-Ua.y,Ua.x,0,-ka.y,ka.x,0,-ic.y,ic.x,0];return!$b(e,cu,uu,hu,xg)||(e=[1,0,0,0,1,0,0,0,1],!$b(e,cu,uu,hu,xg))?!1:(bg.crossVectors(Ua,ka),e=[bg.x,bg.y,bg.z],$b(e,cu,uu,hu,xg))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return rc.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=this.getSize(rc).length()*.5,t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Zo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Zo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Zo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Zo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Zo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Zo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Zo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Zo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Zo),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Zo=[new E,new E,new E,new E,new E,new E,new E,new E],rc=new E,Jb=new Gt,cu=new E,uu=new E,hu=new E,Ua=new E,ka=new E,ic=new E,kf=new E,xg=new E,bg=new E,nc=new E;function $b(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){nc.fromArray(n,s);let a=i.x*Math.abs(nc.x)+i.y*Math.abs(nc.y)+i.z*Math.abs(nc.z),l=t.dot(nc),c=e.dot(nc),u=r.dot(nc);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var FF=new Gt,Gf=new E,eS=new E,Dr=class{constructor(t=new E,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let r=this.center;e!==void 0?r.copy(e):FF.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Gf.subVectors(t,this.center);let e=Gf.lengthSq();if(e>this.radius*this.radius){let r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Gf,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(eS.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gf.copy(t.center).add(eS)),this.expandByPoint(Gf.copy(t.center).sub(eS))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Jo=new E,tS=new E,Sg=new E,Ga=new E,rS=new E,wg=new E,iS=new E,Rs=class{constructor(t=new E,e=new E(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Jo)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Jo.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Jo.copy(this.direction).multiplyScalar(e).add(this.origin),Jo.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){tS.copy(t).add(e).multiplyScalar(.5),Sg.copy(e).sub(t).normalize(),Ga.copy(this.origin).sub(tS);let s=t.distanceTo(e)*.5,o=-this.direction.dot(Sg),a=Ga.dot(this.direction),l=-Ga.dot(Sg),c=Ga.lengthSq(),u=Math.abs(1-o*o),h,d,f,p;if(u>0)if(h=o*l-a,d=o*a-l,p=s*u,h>=0)if(d>=-p)if(d<=p){let m=1/u;h*=m,d*=m,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d<=-p?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c):d<=p?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;return r&&r.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(Sg).multiplyScalar(d).add(tS),f}intersectSphere(t,e){Jo.subVectors(t.center,this.origin);let r=Jo.dot(this.direction),i=Jo.dot(Jo)-r*r,s=t.radius*t.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=r-o,l=r+o;return a<0&&l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){let r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(r=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(r=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),u>=0?(s=(t.min.y-d.y)*u,o=(t.max.y-d.y)*u):(s=(t.max.y-d.y)*u,o=(t.min.y-d.y)*u),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(t.min.z-d.z)*h,l=(t.max.z-d.z)*h):(a=(t.max.z-d.z)*h,l=(t.min.z-d.z)*h),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,Jo)!==null}intersectTriangle(t,e,r,i,s){rS.subVectors(e,t),wg.subVectors(r,t),iS.crossVectors(rS,wg);let o=this.direction.dot(iS),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ga.subVectors(this.origin,t);let l=a*this.direction.dot(wg.crossVectors(Ga,wg));if(l<0)return null;let c=a*this.direction.dot(rS.cross(Ga));if(c<0||l+c>o)return null;let u=-a*Ga.dot(iS);return u<0?null:this.at(u/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ce=class{constructor(){ce.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m,g){let y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=i,y[1]=s,y[5]=o,y[9]=a,y[13]=l,y[2]=c,y[6]=u,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ce().fromArray(this.elements)}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){let e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,r=t.elements,i=1/du.setFromMatrixColumn(t,0).length(),s=1/du.setFromMatrixColumn(t,1).length(),o=1/du.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*u,f=o*h,p=a*u,m=a*h;e[0]=l*u,e[4]=-l*h,e[8]=c,e[1]=f+p*c,e[5]=d-m*c,e[9]=-a*l,e[2]=m-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){let d=l*u,f=l*h,p=c*u,m=c*h;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=o*l}else if(t.order==="ZXY"){let d=l*u,f=l*h,p=c*u,m=c*h;e[0]=d-m*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*u,e[9]=m-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){let d=o*u,f=o*h,p=a*u,m=a*h;e[0]=l*u,e[4]=p*c-f,e[8]=d*c+m,e[1]=l*h,e[5]=m*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){let d=o*l,f=o*c,p=a*l,m=a*c;e[0]=l*u,e[4]=m-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=f*h+p,e[10]=d-m*h}else if(t.order==="XZY"){let d=o*l,f=o*c,p=a*l,m=a*c;e[0]=l*u,e[4]=-h,e[8]=c*u,e[1]=d*h+m,e[5]=o*u,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*u,e[10]=m*h+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(VF,t,zF)}lookAt(t,e,r){let i=this.elements;return Un.subVectors(t,e),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),ja.crossVectors(r,Un),ja.lengthSq()===0&&(Math.abs(r.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),ja.crossVectors(r,Un)),ja.normalize(),Ag.crossVectors(Un,ja),i[0]=ja.x,i[4]=Ag.x,i[8]=Un.x,i[1]=ja.y,i[5]=Ag.y,i[9]=Un.y,i[2]=ja.z,i[6]=Ag.z,i[10]=Un.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],u=r[1],h=r[5],d=r[9],f=r[13],p=r[2],m=r[6],g=r[10],y=r[14],v=r[3],x=r[7],S=r[11],w=r[15],A=i[0],M=i[4],b=i[8],T=i[12],C=i[1],P=i[5],D=i[9],_=i[13],O=i[2],L=i[6],j=i[10],V=i[14],H=i[3],W=i[7],q=i[11],K=i[15];return s[0]=o*A+a*C+l*O+c*H,s[4]=o*M+a*P+l*L+c*W,s[8]=o*b+a*D+l*j+c*q,s[12]=o*T+a*_+l*V+c*K,s[1]=u*A+h*C+d*O+f*H,s[5]=u*M+h*P+d*L+f*W,s[9]=u*b+h*D+d*j+f*q,s[13]=u*T+h*_+d*V+f*K,s[2]=p*A+m*C+g*O+y*H,s[6]=p*M+m*P+g*L+y*W,s[10]=p*b+m*D+g*j+y*q,s[14]=p*T+m*_+g*V+y*K,s[3]=v*A+x*C+S*O+w*H,s[7]=v*M+x*P+S*L+w*W,s[11]=v*b+x*D+S*j+w*q,s[15]=v*T+x*_+S*V+w*K,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],m=t[7],g=t[11],y=t[15];return p*(+s*l*h-i*c*h-s*a*d+r*c*d+i*a*f-r*l*f)+m*(+e*l*f-e*c*d+s*o*d-i*o*f+i*c*u-s*l*u)+g*(+e*c*h-e*a*f-s*o*h+r*o*f+s*a*u-r*c*u)+y*(-i*a*u-e*l*h+e*a*d+i*o*h-r*o*d+r*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],y=t[15],v=h*g*c-m*d*c+m*l*f-a*g*f-h*l*y+a*d*y,x=p*d*c-u*g*c-p*l*f+o*g*f+u*l*y-o*d*y,S=u*m*c-p*h*c+p*a*f-o*m*f-u*a*y+o*h*y,w=p*h*l-u*m*l-p*a*d+o*m*d+u*a*g-o*h*g,A=e*v+r*x+i*S+s*w;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/A;return t[0]=v*M,t[1]=(m*d*s-h*g*s-m*i*f+r*g*f+h*i*y-r*d*y)*M,t[2]=(a*g*s-m*l*s+m*i*c-r*g*c-a*i*y+r*l*y)*M,t[3]=(h*l*s-a*d*s-h*i*c+r*d*c+a*i*f-r*l*f)*M,t[4]=x*M,t[5]=(u*g*s-p*d*s+p*i*f-e*g*f-u*i*y+e*d*y)*M,t[6]=(p*l*s-o*g*s-p*i*c+e*g*c+o*i*y-e*l*y)*M,t[7]=(o*d*s-u*l*s+u*i*c-e*d*c-o*i*f+e*l*f)*M,t[8]=S*M,t[9]=(p*h*s-u*m*s-p*r*f+e*m*f+u*r*y-e*h*y)*M,t[10]=(o*m*s-p*a*s+p*r*c-e*m*c-o*r*y+e*a*y)*M,t[11]=(u*a*s-o*h*s-u*r*c+e*h*c+o*r*f-e*a*f)*M,t[12]=w*M,t[13]=(u*m*i-p*h*i+p*r*d-e*m*d-u*r*g+e*h*g)*M,t[14]=(p*a*i-o*m*i-p*r*l+e*m*l+o*r*g-e*a*g)*M,t[15]=(o*h*i-u*a*i+u*r*l-e*h*l-o*r*d+e*a*d)*M,this}scale(t){let e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,u=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+r,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){let i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,u=o+o,h=a+a,d=s*c,f=s*u,p=s*h,m=o*u,g=o*h,y=a*h,v=l*c,x=l*u,S=l*h,w=r.x,A=r.y,M=r.z;return i[0]=(1-(m+y))*w,i[1]=(f+S)*w,i[2]=(p-x)*w,i[3]=0,i[4]=(f-S)*A,i[5]=(1-(d+y))*A,i[6]=(g+v)*A,i[7]=0,i[8]=(p+x)*M,i[9]=(g-v)*M,i[10]=(1-(d+m))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){let i=this.elements,s=du.set(i[0],i[1],i[2]).length(),o=du.set(i[4],i[5],i[6]).length(),a=du.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],Ps.copy(this);let c=1/s,u=1/o,h=1/a;return Ps.elements[0]*=c,Ps.elements[1]*=c,Ps.elements[2]*=c,Ps.elements[4]*=u,Ps.elements[5]*=u,Ps.elements[6]*=u,Ps.elements[8]*=h,Ps.elements[9]*=h,Ps.elements[10]*=h,e.setFromRotationMatrix(Ps),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o){let a=this.elements,l=2*s/(e-t),c=2*s/(r-i),u=(e+t)/(e-t),h=(r+i)/(r-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,r,i,s,o){let a=this.elements,l=1/(e-t),c=1/(r-i),u=1/(o-s),h=(e+t)*l,d=(r+i)*c,f=(o+s)*u;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){let e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}},du=new E,Ps=new ce,VF=new E(0,0,0),zF=new E(1,1,1),ja=new E,Ag=new E,Un=new E,ET=new ce,MT=new Qe,rr=class{constructor(t=0,e=0,r=0,i=rr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){let i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(ci(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ci(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(ci(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ci(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(ci(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-ci(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return ET.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ET,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return MT.setFromEuler(this),this.setFromQuaternion(MT,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};rr.DEFAULT_ORDER="XYZ";var op=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},UF=0,TT=new E,fu=new Qe,$o=new ce,Eg=new E,jf=new E,kF=new E,GF=new Qe,CT=new E(1,0,0),PT=new E(0,1,0),_T=new E(0,0,1),jF={type:"added"},DT={type:"removed"},Et=class extends hr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:UF++}),this.uuid=is(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Et.DEFAULT_UP.clone();let t=new E,e=new rr,r=new Qe,i=new E(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ce},normalMatrix:{value:new vr}}),this.matrix=new ce,this.matrixWorld=new ce,this.matrixAutoUpdate=Et.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new op,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return fu.setFromAxisAngle(t,e),this.quaternion.multiply(fu),this}rotateOnWorldAxis(t,e){return fu.setFromAxisAngle(t,e),this.quaternion.premultiply(fu),this}rotateX(t){return this.rotateOnAxis(CT,t)}rotateY(t){return this.rotateOnAxis(PT,t)}rotateZ(t){return this.rotateOnAxis(_T,t)}translateOnAxis(t,e){return TT.copy(t).applyQuaternion(this.quaternion),this.position.add(TT.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(CT,t)}translateY(t){return this.translateOnAxis(PT,t)}translateZ(t){return this.translateOnAxis(_T,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4($o.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?Eg.copy(t):Eg.set(t,e,r);let i=this.parent;this.updateWorldMatrix(!0,!1),jf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$o.lookAt(jf,Eg,this.up):$o.lookAt(Eg,jf,this.up),this.quaternion.setFromRotationMatrix($o),i&&($o.extractRotation(i.matrixWorld),fu.setFromRotationMatrix($o),this.quaternion.premultiply(fu.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(jF)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(DT)),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){let e=this.children[t];e.parent=null,e.dispatchEvent(DT)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),$o.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),$o.multiply(t.parent.matrixWorld)),t.applyMatrix4($o),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,i=this.children.length;r<i;r++){let o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e){let r=[];this[t]===e&&r.push(this);for(let i=0,s=this.children.length;i<s;i++){let o=this.children[i].getObjectsByProperty(t,e);o.length>0&&(r=r.concat(o))}return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jf,t,kF),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(jf,GF,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let r=0,i=e.length;r<i;r++){let s=e[r];(s.matrixWorldAutoUpdate===!0||t===!0)&&s.updateMatrixWorld(t)}}updateWorldMatrix(t,e){let r=this.parent;if(t===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++){let a=i[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){let e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let h=l[c];s(t.shapes,h)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){let a=o(t.geometries),l=o(t.materials),c=o(t.textures),u=o(t.images),h=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),d.length>0&&(r.skeletons=d),f.length>0&&(r.animations=f),p.length>0&&(r.nodes=p)}return r.object=i,r;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){let i=t.children[r];this.add(i.clone())}return this}};Et.DEFAULT_UP=new E(0,1,0);Et.DEFAULT_MATRIX_AUTO_UPDATE=!0;Et.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var _s=new E,ea=new E,nS=new E,ta=new E,pu=new E,mu=new E,OT=new E,sS=new E,oS=new E,aS=new E,Mr=class{constructor(t=new E,e=new E,r=new E){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,i){i.subVectors(r,e),_s.subVectors(t,e),i.cross(_s);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){_s.subVectors(i,e),ea.subVectors(r,e),nS.subVectors(t,e);let o=_s.dot(_s),a=_s.dot(ea),l=_s.dot(nS),c=ea.dot(ea),u=ea.dot(nS),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(c*l-a*u)*d,p=(o*u-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,ta),ta.x>=0&&ta.y>=0&&ta.x+ta.y<=1}static getUV(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,ta),l.set(0,0),l.addScaledVector(s,ta.x),l.addScaledVector(o,ta.y),l.addScaledVector(a,ta.z),l}static isFrontFacing(t,e,r,i){return _s.subVectors(r,e),ea.subVectors(t,e),_s.cross(ea).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return _s.subVectors(this.c,this.b),ea.subVectors(this.a,this.b),_s.cross(ea).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Mr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Mr.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,i,s){return Mr.getUV(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Mr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Mr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let r=this.a,i=this.b,s=this.c,o,a;pu.subVectors(i,r),mu.subVectors(s,r),sS.subVectors(t,r);let l=pu.dot(sS),c=mu.dot(sS);if(l<=0&&c<=0)return e.copy(r);oS.subVectors(t,i);let u=pu.dot(oS),h=mu.dot(oS);if(u>=0&&h<=u)return e.copy(i);let d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),e.copy(r).addScaledVector(pu,o);aS.subVectors(t,s);let f=pu.dot(aS),p=mu.dot(aS);if(p>=0&&f<=p)return e.copy(s);let m=f*c-l*p;if(m<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(r).addScaledVector(mu,a);let g=u*p-f*h;if(g<=0&&h-u>=0&&f-p>=0)return OT.subVectors(s,i),a=(h-u)/(h-u+(f-p)),e.copy(i).addScaledVector(OT,a);let y=1/(g+m+d);return o=m*y,a=d*y,e.copy(r).addScaledVector(pu,o).addScaledVector(mu,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},HF=0,uc=class extends hr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:HF++}),this.uuid=is(),this.name="",this.type="Material",this.blending=Wa,this.side=Gn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=AC,this.blendDst=EC,this.blendEquation=wu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=wS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=SF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qb,this.stencilZFail=qb,this.stencilZPass=qb,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let r=t[e];if(r===void 0){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}let i=this[e];if(i===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Wa&&(r.blending=this.blending),this.side!==Gn&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(r.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(e){let s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,r=null;if(e!==null){let i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Hn=class extends uc{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MC,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},li=new E,Mg=new U,Xe=class{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=TS,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)Mg.fromBufferAttribute(this,e),Mg.applyMatrix3(t),this.setXY(e,Mg.x,Mg.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)li.fromBufferAttribute(this,e),li.applyMatrix3(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)li.fromBufferAttribute(this,e),li.applyMatrix4(t),this.setXYZ(e,li.x,li.y,li.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)li.fromBufferAttribute(this,e),li.applyNormalMatrix(t),this.setXYZ(e,li.x,li.y,li.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)li.fromBufferAttribute(this,e),li.transformDirection(t),this.setXYZ(e,li.x,li.y,li.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=na(e,this.array)),e}setX(t,e){return this.normalized&&(e=gr(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=na(e,this.array)),e}setY(t,e){return this.normalized&&(e=gr(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=na(e,this.array)),e}setZ(t,e){return this.normalized&&(e=gr(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=na(e,this.array)),e}setW(t,e){return this.normalized&&(e=gr(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array),i=gr(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array),i=gr(i,this.array),s=gr(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==TS&&(t.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(t.updateRange=this.updateRange),t}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}};var ey=class extends Xe{constructor(t,e,r){super(new Uint16Array(t),e,r)}};var uo=class extends Xe{constructor(t,e,r){super(new Uint32Array(t),e,r)}};var Te=class extends Xe{constructor(t,e,r){super(new Float32Array(t),e,r)}};var WF=0,rs=new ce,lS=new Et,gu=new E,kn=new Gt,Hf=new Gt,Oi=new E,_e=class extends hr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:WF++}),this.uuid=is(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(DC(t)?uo:ey)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let r=this.attributes.normal;if(r!==void 0){let s=new vr().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return rs.makeRotationFromQuaternion(t),this.applyMatrix4(rs),this}rotateX(t){return rs.makeRotationX(t),this.applyMatrix4(rs),this}rotateY(t){return rs.makeRotationY(t),this.applyMatrix4(rs),this}rotateZ(t){return rs.makeRotationZ(t),this.applyMatrix4(rs),this}translate(t,e,r){return rs.makeTranslation(t,e,r),this.applyMatrix4(rs),this}scale(t,e,r){return rs.makeScale(t,e,r),this.applyMatrix4(rs),this}lookAt(t){return lS.lookAt(t),lS.updateMatrix(),this.applyMatrix4(lS.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(gu).negate(),this.translate(gu.x,gu.y,gu.z),this}setFromPoints(t){let e=[];for(let r=0,i=t.length;r<i;r++){let s=t[r];e.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Te(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gt);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new E(-1/0,-1/0,-1/0),new E(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,i=e.length;r<i;r++){let s=e[r];kn.setFromBufferAttribute(s),this.morphTargetsRelative?(Oi.addVectors(this.boundingBox.min,kn.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,kn.max),this.boundingBox.expandByPoint(Oi)):(this.boundingBox.expandByPoint(kn.min),this.boundingBox.expandByPoint(kn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dr);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new E,1/0);return}if(t){let r=this.boundingSphere.center;if(kn.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){let a=e[s];Hf.setFromBufferAttribute(a),this.morphTargetsRelative?(Oi.addVectors(kn.min,Hf.min),kn.expandByPoint(Oi),Oi.addVectors(kn.max,Hf.max),kn.expandByPoint(Oi)):(kn.expandByPoint(Hf.min),kn.expandByPoint(Hf.max))}kn.getCenter(r);let i=0;for(let s=0,o=t.count;s<o;s++)Oi.fromBufferAttribute(t,s),i=Math.max(i,r.distanceToSquared(Oi));if(e)for(let s=0,o=e.length;s<o;s++){let a=e[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Oi.fromBufferAttribute(a,c),l&&(gu.fromBufferAttribute(t,c),Oi.add(gu)),i=Math.max(i,r.distanceToSquared(Oi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let r=t.array,i=e.position.array,s=e.normal.array,o=e.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Xe(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,c=[],u=[];for(let C=0;C<a;C++)c[C]=new E,u[C]=new E;let h=new E,d=new E,f=new E,p=new U,m=new U,g=new U,y=new E,v=new E;function x(C,P,D){h.fromArray(i,C*3),d.fromArray(i,P*3),f.fromArray(i,D*3),p.fromArray(o,C*2),m.fromArray(o,P*2),g.fromArray(o,D*2),d.sub(h),f.sub(h),m.sub(p),g.sub(p);let _=1/(m.x*g.y-g.x*m.y);!isFinite(_)||(y.copy(d).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(_),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-g.x).multiplyScalar(_),c[C].add(y),c[P].add(y),c[D].add(y),u[C].add(v),u[P].add(v),u[D].add(v))}let S=this.groups;S.length===0&&(S=[{start:0,count:r.length}]);for(let C=0,P=S.length;C<P;++C){let D=S[C],_=D.start,O=D.count;for(let L=_,j=_+O;L<j;L+=3)x(r[L+0],r[L+1],r[L+2])}let w=new E,A=new E,M=new E,b=new E;function T(C){M.fromArray(s,C*3),b.copy(M);let P=c[C];w.copy(P),w.sub(M.multiplyScalar(M.dot(P))).normalize(),A.crossVectors(b,P);let _=A.dot(u[C])<0?-1:1;l[C*4]=w.x,l[C*4+1]=w.y,l[C*4+2]=w.z,l[C*4+3]=_}for(let C=0,P=S.length;C<P;++C){let D=S[C],_=D.start,O=D.count;for(let L=_,j=_+O;L<j;L+=3)T(r[L+0]),T(r[L+1]),T(r[L+2])}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Xe(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let d=0,f=r.count;d<f;d++)r.setXYZ(d,0,0,0);let i=new E,s=new E,o=new E,a=new E,l=new E,c=new E,u=new E,h=new E;if(t)for(let d=0,f=t.count;d<f;d+=3){let p=t.getX(d+0),m=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),o.fromBufferAttribute(e,g),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(r,p),l.fromBufferAttribute(r,m),c.fromBufferAttribute(r,g),a.add(u),l.add(u),c.add(u),r.setXYZ(p,a.x,a.y,a.z),r.setXYZ(m,l.x,l.y,l.z),r.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),r.setXYZ(d+0,u.x,u.y,u.z),r.setXYZ(d+1,u.x,u.y,u.z),r.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){let t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)Oi.fromBufferAttribute(t,e),Oi.normalize(),t.setXYZ(e,Oi.x,Oi.y,Oi.z)}toNonIndexed(){function t(a,l){let c=a.array,u=a.itemSize,h=a.normalized,d=new c.constructor(l.length*u),f=0,p=0;for(let m=0,g=l.length;m<g;m++){a.isInterleavedBufferAttribute?f=l[m]*a.data.stride+a.offset:f=l[m]*u;for(let y=0;y<u;y++)d[p++]=c[f++]}return new Xe(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new _e,r=this.index.array,i=this.attributes;for(let a in i){let l=i[a],c=t(l,r);e.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){let d=c[u],f=t(d,r);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){let t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let r=this.attributes;for(let l in r){let c=r[l];t.data.attributes[l]=c.toJSON(t.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){let f=c[h];u.push(f.toJSON(t.data))}u.length>0&&(i[l]=u,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let r=t.index;r!==null&&this.setIndex(r.clone(e));let i=t.attributes;for(let c in i){let u=i[c];this.setAttribute(c,u.clone(e))}let s=t.morphAttributes;for(let c in s){let u=[],h=s[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(e));this.morphAttributes[c]=u}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let c=0,u=o.length;c<u;c++){let h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,t.parameters!==void 0&&(this.parameters=Object.assign({},t.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},IT=new ce,yu=new Rs,cS=new Dr,Wf=new E,qf=new E,Yf=new E,uS=new E,Tg=new E,Cg=new U,Pg=new U,_g=new U,hS=new E,Dg=new E,Xt=class extends Et{constructor(t=new _e,e=new Hn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){let r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(s&&a){Tg.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let u=a[l],h=s[l];u!==0&&(uS.fromBufferAttribute(h,t),o?Tg.addScaledVector(uS,u):Tg.addScaledVector(uS.sub(e),u))}e.add(Tg)}return this.isSkinnedMesh&&this.boneTransform(t,e),e}raycast(t,e){let r=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(r.boundingSphere===null&&r.computeBoundingSphere(),cS.copy(r.boundingSphere),cS.applyMatrix4(s),t.ray.intersectsSphere(cS)===!1)||(IT.copy(s).invert(),yu.copy(t.ray).applyMatrix4(IT),r.boundingBox!==null&&yu.intersectsBox(r.boundingBox)===!1))return;let o,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv2,h=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(i))for(let f=0,p=h.length;f<p;f++){let m=h[f],g=i[m.materialIndex],y=Math.max(m.start,d.start),v=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let x=y,S=v;x<S;x+=3){let w=a.getX(x),A=a.getX(x+1),M=a.getX(x+2);o=Og(this,g,t,yu,c,u,w,A,M),o&&(o.faceIndex=Math.floor(x/3),o.face.materialIndex=m.materialIndex,e.push(o))}}else{let f=Math.max(0,d.start),p=Math.min(a.count,d.start+d.count);for(let m=f,g=p;m<g;m+=3){let y=a.getX(m),v=a.getX(m+1),x=a.getX(m+2);o=Og(this,i,t,yu,c,u,y,v,x),o&&(o.faceIndex=Math.floor(m/3),e.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let f=0,p=h.length;f<p;f++){let m=h[f],g=i[m.materialIndex],y=Math.max(m.start,d.start),v=Math.min(l.count,Math.min(m.start+m.count,d.start+d.count));for(let x=y,S=v;x<S;x+=3){let w=x,A=x+1,M=x+2;o=Og(this,g,t,yu,c,u,w,A,M),o&&(o.faceIndex=Math.floor(x/3),o.face.materialIndex=m.materialIndex,e.push(o))}}else{let f=Math.max(0,d.start),p=Math.min(l.count,d.start+d.count);for(let m=f,g=p;m<g;m+=3){let y=m,v=m+1,x=m+2;o=Og(this,i,t,yu,c,u,y,v,x),o&&(o.faceIndex=Math.floor(m/3),e.push(o))}}}};function qF(n,t,e,r,i,s,o,a){let l;if(t.side===ui?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,t.side===Gn,a),l===null)return null;Dg.copy(a),Dg.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(Dg);return c<e.near||c>e.far?null:{distance:c,point:Dg.clone(),object:n}}function Og(n,t,e,r,i,s,o,a,l){n.getVertexPosition(o,Wf),n.getVertexPosition(a,qf),n.getVertexPosition(l,Yf);let c=qF(n,t,e,r,Wf,qf,Yf,hS);if(c){i&&(Cg.fromBufferAttribute(i,o),Pg.fromBufferAttribute(i,a),_g.fromBufferAttribute(i,l),c.uv=Mr.getUV(hS,Wf,qf,Yf,Cg,Pg,_g,new U)),s&&(Cg.fromBufferAttribute(s,o),Pg.fromBufferAttribute(s,a),_g.fromBufferAttribute(s,l),c.uv2=Mr.getUV(hS,Wf,qf,Yf,Cg,Pg,_g,new U));let u={a:o,b:a,c:l,normal:new E,materialIndex:0};Mr.getNormal(Wf,qf,Yf,u.normal),c.face=u}return c}var hi=class extends _e{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],d=0,f=0;p("z","y","x",-1,-1,r,e,t,o,s,0),p("z","y","x",1,-1,r,e,-t,o,s,1),p("x","z","y",1,1,t,r,e,i,o,2),p("x","z","y",1,-1,t,r,-e,i,o,3),p("x","y","z",1,-1,t,e,r,i,s,4),p("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(h,2));function p(m,g,y,v,x,S,w,A,M,b,T){let C=S/M,P=w/b,D=S/2,_=w/2,O=A/2,L=M+1,j=b+1,V=0,H=0,W=new E;for(let q=0;q<j;q++){let K=q*P-_;for(let G=0;G<L;G++){let Z=G*C-D;W[m]=Z*v,W[g]=K*x,W[y]=O,c.push(W.x,W.y,W.z),W[m]=0,W[g]=0,W[y]=A>0?1:-1,u.push(W.x,W.y,W.z),h.push(G/M),h.push(1-q/b),V+=1}}for(let q=0;q<b;q++)for(let K=0;K<M;K++){let G=d+K+L*q,Z=d+K+L*(q+1),te=d+(K+1)+L*(q+1),$=d+(K+1)+L*q;l.push(G,Z,$),l.push(Z,te,$),H+=6}a.addGroup(f,H,T),f+=H,d+=V}}static fromJSON(t){return new hi(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function Pu(n){let t={};for(let e in n){t[e]={};for(let r in n[e]){let i=n[e][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?t[e][r]=i.clone():Array.isArray(i)?t[e][r]=i.slice():t[e][r]=i}}return t}function cn(n){let t={};for(let e=0;e<n.length;e++){let r=Pu(n[e]);for(let i in r)t[i]=r[i]}return t}function YF(n){let t=[];for(let e=0;e<n.length;e++)t.push(n[e].clone());return t}function IC(n){return n.getRenderTarget()===null&&n.outputEncoding===at?lo:ip}var Bs={clone:Pu,merge:cn},XF=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,QF=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,st=class extends uc{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=XF,this.fragmentShader=QF,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Pu(t.uniforms),this.uniformsGroups=YF(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let i in this.uniforms){let o=this.uniforms[i].value;o&&o.isTexture?e.uniforms[i]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[i]={type:"m4",value:o.toArray()}:e.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let r={};for(let i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}},Wn=class extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ce,this.projectionMatrix=new ce,this.projectionMatrixInverse=new ce}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Kr=class extends Wn{constructor(t=50,e=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=np*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Jf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return np*2*Math.atan(Math.tan(Jf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,r,i,s,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Jf*.5*this.fov)/this.zoom,r=2*e,i=this.aspect*r,s=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*r/c,i*=o.width/l,r*=o.height/c}let a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-r,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},vu=-90,xu=1,_S=class extends Et{constructor(t,e,r){super(),this.type="CubeCamera",this.renderTarget=r;let i=new Kr(vu,xu,t,e);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i);let s=new Kr(vu,xu,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let o=new Kr(vu,xu,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new Kr(vu,xu,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new Kr(vu,xu,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let c=new Kr(vu,xu,t,e);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,-1),this.add(c)}update(t,e){this.parent===null&&this.updateMatrixWorld();let r=this.renderTarget,[i,s,o,a,l,c]=this.children,u=t.getRenderTarget(),h=t.toneMapping,d=t.xr.enabled;t.toneMapping=Os,t.xr.enabled=!1;let f=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,s),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,a),t.setRenderTarget(r,4),t.render(e,l),r.texture.generateMipmaps=f,t.setRenderTarget(r,5),t.render(e,c),t.setRenderTarget(u),t.toneMapping=h,t.xr.enabled=d,r.texture.needsPMREMUpdate=!0}},_u=class extends Jt{constructor(t,e,r,i,s,o,a,l,c,u){t=t!==void 0?t:[],e=e!==void 0?e:Ya,super(t,e,r,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},DS=class extends dt{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let r={width:t,height:t,depth:1},i=[r,r,r,r,r,r];this.texture=new _u(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:tt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let r={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},i=new hi(5,5,5),s=new st({name:"CubemapFromEquirect",uniforms:Pu(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ui,blending:Zt});s.uniforms.tEquirect.value=e;let o=new Xt(i,s),a=e.minFilter;return e.minFilter===cc&&(e.minFilter=tt),new _S(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,r,i){let s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,r,i);t.setRenderTarget(s)}},dS=new E,KF=new E,ZF=new vr,Zr=class{constructor(t=new E(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,r,i){return this.normal.set(t,e,r),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){let i=dS.subVectors(r,e).cross(KF.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){let r=t.delta(dS),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(r).multiplyScalar(s).add(t.start)}intersectsLine(t){let e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let r=e||ZF.getNormalMatrix(t),i=this.coplanarPoint(dS).applyMatrix4(t),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},bu=new Dr,Ig=new E,ap=class{constructor(t=new Zr,e=new Zr,r=new Zr,i=new Zr,s=new Zr,o=new Zr){this.planes=[t,e,r,i,s,o]}set(t,e,r,i,s,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){let e=this.planes;for(let r=0;r<6;r++)e[r].copy(t.planes[r]);return this}setFromProjectionMatrix(t){let e=this.planes,r=t.elements,i=r[0],s=r[1],o=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8],f=r[9],p=r[10],m=r[11],g=r[12],y=r[13],v=r[14],x=r[15];return e[0].setComponents(a-i,h-l,m-d,x-g).normalize(),e[1].setComponents(a+i,h+l,m+d,x+g).normalize(),e[2].setComponents(a+s,h+c,m+f,x+y).normalize(),e[3].setComponents(a-s,h-c,m-f,x-y).normalize(),e[4].setComponents(a-o,h-u,m-p,x-v).normalize(),e[5].setComponents(a+o,h+u,m+p,x+v).normalize(),this}intersectsObject(t){let e=t.geometry;return e.boundingSphere===null&&e.computeBoundingSphere(),bu.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(bu)}intersectsSprite(t){return bu.center.set(0,0,0),bu.radius=.7071067811865476,bu.applyMatrix4(t.matrixWorld),this.intersectsSphere(bu)}intersectsSphere(t){let e=this.planes,r=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let r=0;r<6;r++){let i=e[r];if(Ig.x=i.normal.x>0?t.max.x:t.min.x,Ig.y=i.normal.y>0?t.max.y:t.min.y,Ig.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Ig)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function RC(){let n=null,t=!1,e=null,r=null;function i(s,o){e(s,o),r=n.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(r=n.requestAnimationFrame(i),t=!0)},stop:function(){n.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){n=s}}}function JF(n,t){let e=t.isWebGL2,r=new WeakMap;function i(c,u){let h=c.array,d=c.usage,f=n.createBuffer();n.bindBuffer(u,f),n.bufferData(u,h,d),c.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(e)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:f,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,f=u.updateRange;n.bindBuffer(h,c),f.count===-1?n.bufferSubData(h,0,d):(e?n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=r.get(c);u&&(n.deleteBuffer(u.buffer),r.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=r.get(c);(!d||d.version<c.version)&&r.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);let h=r.get(c);h===void 0?r.set(c,i(c,u)):h.version<c.version&&(s(h.buffer,c,u),h.version=c.version)}return{get:o,remove:a,update:l}}var hn=class extends _e{constructor(t=1,e=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:i};let s=t/2,o=e/2,a=Math.floor(r),l=Math.floor(i),c=a+1,u=l+1,h=t/a,d=e/l,f=[],p=[],m=[],g=[];for(let y=0;y<u;y++){let v=y*d-o;for(let x=0;x<c;x++){let S=x*h-s;p.push(S,-v,0),m.push(0,0,1),g.push(x/a),g.push(1-y/l)}}for(let y=0;y<l;y++)for(let v=0;v<a;v++){let x=v+c*y,S=v+c*(y+1),w=v+1+c*(y+1),A=v+1+c*y;f.push(x,S,A),f.push(S,w,A)}this.setIndex(f),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2))}static fromJSON(t){return new hn(t.width,t.height,t.widthSegments,t.heightSegments)}},$F=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif`,eV=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,tV=`#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
#endif`,rV=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,iV=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,nV=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,sV="vec3 transformed = vec3( position );",oV=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,aV=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#ifdef USE_IRIDESCENCE
vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif`,lV=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float R21 = R12;
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,cV=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vUv );
vec2 dSTdy = dFdy( vUv );
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = dFdx( surf_pos.xyz );
vec3 vSigmaY = dFdy( surf_pos.xyz );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,uV=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif`,hV=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,dV=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,fV=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,pV=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,mV=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,gV=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
varying vec3 vColor;
#endif`,yV=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif`,vV=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
struct GeometricContext {
vec3 position;
vec3 normal;
vec3 viewDir;
#ifdef USE_CLEARCOAT
vec3 clearcoatNormal;
#endif
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
float luminance( const in vec3 rgb ) {
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
return dot( weights, rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}`,xV=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_v0 0.339
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_v1 0.276
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_v4 0.046
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_v5 0.016
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_v6 0.0038
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,bV=`vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
mat3 m = mat3( instanceMatrix );
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
transformedNormal = m * transformedNormal;
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,SV=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,wV=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif`,AV=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vUv );
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,EV=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,MV="gl_FragColor = linearToOutputTexel( gl_FragColor );",TV=`vec4 LinearToLinear( in vec4 value ) {
return value;
}
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.a );
}`,CV=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif`,PV=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,_V=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,DV=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,OV=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,IV=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,RV=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,LV=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,BV=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,NV=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,FV=`#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`,VV=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,zV=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,UV=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,kV=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
#else
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
}
return 1.0;
#endif
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometry.position;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometry.position;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif`,GV=`#if defined( USE_ENVMAP )
vec3 getIBLIrradiance( const in vec3 normal ) {
#if defined( ENVMAP_TYPE_CUBE_UV )
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#if defined( ENVMAP_TYPE_CUBE_UV )
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#endif`,jV=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,HV=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,WV=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,qV=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,YV=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULARINTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
#endif
#ifdef USE_SPECULARCOLORMAP
specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEENCOLORMAP
material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEENROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
#endif
#endif`,XV=`struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
};
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
vec4 r = roughness * c0 + c1;
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
vec2 fab = DFGApprox( normal, viewDir, roughness );
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometry.normal;
vec3 viewDir = geometry.viewDir;
vec3 position = geometry.position;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
#endif
#ifdef USE_IRIDESCENCE
reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
#else
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
#endif
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,QV=`
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef USE_CLEARCOAT
geometry.clearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometry, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometry, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, geometry, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,KV=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometry.normal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,ZV=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif`,JV=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,$V=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,ez=`#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
varying float vIsPerspective;
#else
uniform float logDepthBufFC;
#endif
#endif`,tz=`#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#else
if ( isPerspectiveMatrix( projectionMatrix ) ) {
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
gl_Position.z *= gl_Position.w;
}
#endif
#endif`,rz=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,iz=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,nz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,sz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,oz=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vUv );
metalnessFactor *= texelMetalness.b;
#endif`,az=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,lz=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,cz=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#else
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
#endif
#endif`,uz=`#ifdef USE_MORPHTARGETS
uniform float morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#else
#ifndef USE_MORPHNORMALS
uniform float morphTargetInfluences[ 8 ];
#else
uniform float morphTargetInfluences[ 4 ];
#endif
#endif
#endif`,hz=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#else
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
#ifndef USE_MORPHNORMALS
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
#endif
#endif
#endif`,dz=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
#ifdef USE_TANGENT
vec3 tangent = normalize( vTangent );
vec3 bitangent = normalize( vBitangent );
#ifdef DOUBLE_SIDED
tangent = tangent * faceDirection;
bitangent = bitangent * faceDirection;
#endif
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
mat3 vTBN = mat3( tangent, bitangent, normal );
#endif
#endif
#endif
vec3 geometryNormal = normal;`,fz=`#ifdef OBJECTSPACE_NORMALMAP
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( TANGENTSPACE_NORMALMAP )
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
#ifdef USE_TANGENT
normal = normalize( vTBN * mapN );
#else
normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
#endif
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,pz=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,mz=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,gz=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,yz=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef OBJECTSPACE_NORMALMAP
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( vUv.st );
vec2 st1 = dFdy( vUv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
}
#endif`,vz=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = geometryNormal;
#endif`,xz=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
#ifdef USE_TANGENT
clearcoatNormal = normalize( vTBN * clearcoatMapN );
#else
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
#endif
#endif`,bz=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif`,Sz=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,wz=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha + 0.1;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Az=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
vec4 r = vec4( fract( v * PackFactors ), v );
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors );
}
vec2 packDepthToRG( in highp float v ) {
return packDepthToRGBA( v ).yx;
}
float unpackRGToDepth( const in highp vec2 v ) {
return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
}
vec4 pack2HalfToRGBA( vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
return linearClipZ * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * invClipZ - far );
}`,Ez=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,Mz=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,Tz=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Cz=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,Pz=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vUv );
roughnessFactor *= texelRoughness.g;
#endif`,_z=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Dz=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
float hard_shadow = step( compare , distribution.x );
if (hard_shadow != 1.0 ) {
float distance = compare - distribution.x ;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return shadow;
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
vec3 lightToPosition = shadowCoord.xyz;
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
return (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
#endif`,Oz=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,Iz=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,Rz=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,Lz=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Bz=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
uniform int boneTextureSize;
mat4 getBoneMatrix( const in float i ) {
float j = i * 4.0;
float x = mod( j, float( boneTextureSize ) );
float y = floor( j / float( boneTextureSize ) );
float dx = 1.0 / float( boneTextureSize );
float dy = 1.0 / float( boneTextureSize );
y = dy * ( y + 0.5 );
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
mat4 bone = mat4( v1, v2, v3, v4 );
return bone;
}
#endif`,Nz=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,Fz=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,Vz=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,zz=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,Uz=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,kz=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return toneMappingExposure * color;
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,Gz=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmission = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );
#endif`,jz=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
#ifdef texture2DLodEXT
return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
#else
return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
#endif
}
vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return radiance;
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
}
#endif`,Hz=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
varying vec2 vUv;
#endif`,Wz=`#ifdef USE_UV
#ifdef UVS_VERTEX_ONLY
vec2 vUv;
#else
varying vec2 vUv;
#endif
uniform mat3 uvTransform;
#endif`,qz=`#ifdef USE_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif`,Yz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
varying vec2 vUv2;
#endif`,Xz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
#endif`,Qz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif`,Kz=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`,Zz=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,Jz=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <encodings_fragment>
}`,$z=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,eU=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <encodings_fragment>
}`,tU=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,rU=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <encodings_fragment>
}`,iU=`#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,nU=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <logdepthbuf_fragment>
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#endif
}`,sU=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <skinbase_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,oU=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( 1.0 );
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
}`,aU=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,lU=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <encodings_fragment>
}`,cU=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <color_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,uU=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,hU=`#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,dU=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,fU=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,pU=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,mU=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,gU=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,yU=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
varying vec3 vViewPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
vViewPosition = - mvPosition.xyz;
#endif
}`,vU=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,xU=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,bU=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,SU=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,wU=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULARINTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#ifdef USE_SPECULARCOLORMAP
uniform sampler2D specularColorMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEENCOLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEENROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <bsdfs>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
#endif
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,AU=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,EU=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,MU=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <color_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,TU=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
outgoingLight = diffuseColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,CU=`#include <common>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,PU=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
}`,_U=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
vec2 scale;
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,DU=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
vec4 diffuseColor = vec4( diffuse, opacity );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
outgoingLight = diffuseColor.rgb;
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
}`,xt={alphamap_fragment:$F,alphamap_pars_fragment:eV,alphatest_fragment:tV,alphatest_pars_fragment:rV,aomap_fragment:iV,aomap_pars_fragment:nV,begin_vertex:sV,beginnormal_vertex:oV,bsdfs:aV,iridescence_fragment:lV,bumpmap_pars_fragment:cV,clipping_planes_fragment:uV,clipping_planes_pars_fragment:hV,clipping_planes_pars_vertex:dV,clipping_planes_vertex:fV,color_fragment:pV,color_pars_fragment:mV,color_pars_vertex:gV,color_vertex:yV,common:vV,cube_uv_reflection_fragment:xV,defaultnormal_vertex:bV,displacementmap_pars_vertex:SV,displacementmap_vertex:wV,emissivemap_fragment:AV,emissivemap_pars_fragment:EV,encodings_fragment:MV,encodings_pars_fragment:TV,envmap_fragment:CV,envmap_common_pars_fragment:PV,envmap_pars_fragment:_V,envmap_pars_vertex:DV,envmap_physical_pars_fragment:GV,envmap_vertex:OV,fog_vertex:IV,fog_pars_vertex:RV,fog_fragment:LV,fog_pars_fragment:BV,gradientmap_pars_fragment:NV,lightmap_fragment:FV,lightmap_pars_fragment:VV,lights_lambert_fragment:zV,lights_lambert_pars_fragment:UV,lights_pars_begin:kV,lights_toon_fragment:jV,lights_toon_pars_fragment:HV,lights_phong_fragment:WV,lights_phong_pars_fragment:qV,lights_physical_fragment:YV,lights_physical_pars_fragment:XV,lights_fragment_begin:QV,lights_fragment_maps:KV,lights_fragment_end:ZV,logdepthbuf_fragment:JV,logdepthbuf_pars_fragment:$V,logdepthbuf_pars_vertex:ez,logdepthbuf_vertex:tz,map_fragment:rz,map_pars_fragment:iz,map_particle_fragment:nz,map_particle_pars_fragment:sz,metalnessmap_fragment:oz,metalnessmap_pars_fragment:az,morphcolor_vertex:lz,morphnormal_vertex:cz,morphtarget_pars_vertex:uz,morphtarget_vertex:hz,normal_fragment_begin:dz,normal_fragment_maps:fz,normal_pars_fragment:pz,normal_pars_vertex:mz,normal_vertex:gz,normalmap_pars_fragment:yz,clearcoat_normal_fragment_begin:vz,clearcoat_normal_fragment_maps:xz,clearcoat_pars_fragment:bz,iridescence_pars_fragment:Sz,output_fragment:wz,packing:Az,premultiplied_alpha_fragment:Ez,project_vertex:Mz,dithering_fragment:Tz,dithering_pars_fragment:Cz,roughnessmap_fragment:Pz,roughnessmap_pars_fragment:_z,shadowmap_pars_fragment:Dz,shadowmap_pars_vertex:Oz,shadowmap_vertex:Iz,shadowmask_pars_fragment:Rz,skinbase_vertex:Lz,skinning_pars_vertex:Bz,skinning_vertex:Nz,skinnormal_vertex:Fz,specularmap_fragment:Vz,specularmap_pars_fragment:zz,tonemapping_fragment:Uz,tonemapping_pars_fragment:kz,transmission_fragment:Gz,transmission_pars_fragment:jz,uv_pars_fragment:Hz,uv_pars_vertex:Wz,uv_vertex:qz,uv2_pars_fragment:Yz,uv2_pars_vertex:Xz,uv2_vertex:Qz,worldpos_vertex:Kz,background_vert:Zz,background_frag:Jz,backgroundCube_vert:$z,backgroundCube_frag:eU,cube_vert:tU,cube_frag:rU,depth_vert:iU,depth_frag:nU,distanceRGBA_vert:sU,distanceRGBA_frag:oU,equirect_vert:aU,equirect_frag:lU,linedashed_vert:cU,linedashed_frag:uU,meshbasic_vert:hU,meshbasic_frag:dU,meshlambert_vert:fU,meshlambert_frag:pU,meshmatcap_vert:mU,meshmatcap_frag:gU,meshnormal_vert:yU,meshnormal_frag:vU,meshphong_vert:xU,meshphong_frag:bU,meshphysical_vert:SU,meshphysical_frag:wU,meshtoon_vert:AU,meshtoon_frag:EU,points_vert:MU,points_frag:TU,shadow_vert:CU,shadow_frag:PU,sprite_vert:_U,sprite_frag:DU},De={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new vr},uv2Transform:{value:new vr},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new U(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new vr}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new U(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new vr}}},co={basic:{uniforms:cn([De.common,De.specularmap,De.envmap,De.aomap,De.lightmap,De.fog]),vertexShader:xt.meshbasic_vert,fragmentShader:xt.meshbasic_frag},lambert:{uniforms:cn([De.common,De.specularmap,De.envmap,De.aomap,De.lightmap,De.emissivemap,De.bumpmap,De.normalmap,De.displacementmap,De.fog,De.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshlambert_vert,fragmentShader:xt.meshlambert_frag},phong:{uniforms:cn([De.common,De.specularmap,De.envmap,De.aomap,De.lightmap,De.emissivemap,De.bumpmap,De.normalmap,De.displacementmap,De.fog,De.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30}}]),vertexShader:xt.meshphong_vert,fragmentShader:xt.meshphong_frag},standard:{uniforms:cn([De.common,De.envmap,De.aomap,De.lightmap,De.emissivemap,De.bumpmap,De.normalmap,De.displacementmap,De.roughnessmap,De.metalnessmap,De.fog,De.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag},toon:{uniforms:cn([De.common,De.aomap,De.lightmap,De.emissivemap,De.bumpmap,De.normalmap,De.displacementmap,De.gradientmap,De.fog,De.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshtoon_vert,fragmentShader:xt.meshtoon_frag},matcap:{uniforms:cn([De.common,De.bumpmap,De.normalmap,De.displacementmap,De.fog,{matcap:{value:null}}]),vertexShader:xt.meshmatcap_vert,fragmentShader:xt.meshmatcap_frag},points:{uniforms:cn([De.points,De.fog]),vertexShader:xt.points_vert,fragmentShader:xt.points_frag},dashed:{uniforms:cn([De.common,De.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xt.linedashed_vert,fragmentShader:xt.linedashed_frag},depth:{uniforms:cn([De.common,De.displacementmap]),vertexShader:xt.depth_vert,fragmentShader:xt.depth_frag},normal:{uniforms:cn([De.common,De.bumpmap,De.normalmap,De.displacementmap,{opacity:{value:1}}]),vertexShader:xt.meshnormal_vert,fragmentShader:xt.meshnormal_frag},sprite:{uniforms:cn([De.sprite,De.fog]),vertexShader:xt.sprite_vert,fragmentShader:xt.sprite_frag},background:{uniforms:{uvTransform:{value:new vr},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:xt.background_vert,fragmentShader:xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:xt.backgroundCube_vert,fragmentShader:xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xt.cube_vert,fragmentShader:xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xt.equirect_vert,fragmentShader:xt.equirect_frag},distanceRGBA:{uniforms:cn([De.common,De.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xt.distanceRGBA_vert,fragmentShader:xt.distanceRGBA_frag},shadow:{uniforms:cn([De.lights,De.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:xt.shadow_vert,fragmentShader:xt.shadow_frag}};co.physical={uniforms:cn([co.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new U(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new U},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag};var Rg={r:0,b:0,g:0};function OU(n,t,e,r,i,s,o){let a=new We(0),l=s===!0?0:1,c,u,h=null,d=0,f=null;function p(g,y){let v=!1,x=y.isScene===!0?y.background:null;x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x));let S=n.xr,w=S.getSession&&S.getSession();w&&w.environmentBlendMode==="additive"&&(x=null),x===null?m(a,l):x&&x.isColor&&(m(x,1),v=!0),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),x&&(x.isCubeTexture||x.mapping===Yu)?(u===void 0&&(u=new Xt(new hi(1,1,1),new st({name:"BackgroundCubeMaterial",uniforms:Pu(co.backgroundCube.uniforms),vertexShader:co.backgroundCube.vertexShader,fragmentShader:co.backgroundCube.fragmentShader,side:ui,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(A,M,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=x,u.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=x.encoding!==at,(h!==x||d!==x.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,h=x,d=x.version,f=n.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new Xt(new hn(2,2),new st({name:"BackgroundMaterial",uniforms:Pu(co.background.uniforms),vertexShader:co.background.vertexShader,fragmentShader:co.background.fragmentShader,side:Gn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=x.encoding!==at,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,f=n.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null))}function m(g,y){g.getRGB(Rg,IC(n)),r.buffers.color.setClear(Rg.r,Rg.g,Rg.b,y,o)}return{getClearColor:function(){return a},setClearColor:function(g,y=1){a.set(g),l=y,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,m(a,l)},render:p}}function IU(n,t,e,r){let i=n.getParameter(34921),s=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=g(null),c=l,u=!1;function h(O,L,j,V,H){let W=!1;if(o){let q=m(V,j,L);c!==q&&(c=q,f(c.object)),W=y(O,V,j,H),W&&v(O,V,j,H)}else{let q=L.wireframe===!0;(c.geometry!==V.id||c.program!==j.id||c.wireframe!==q)&&(c.geometry=V.id,c.program=j.id,c.wireframe=q,W=!0)}H!==null&&e.update(H,34963),(W||u)&&(u=!1,b(O,L,j,V),H!==null&&n.bindBuffer(34963,e.get(H).buffer))}function d(){return r.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function f(O){return r.isWebGL2?n.bindVertexArray(O):s.bindVertexArrayOES(O)}function p(O){return r.isWebGL2?n.deleteVertexArray(O):s.deleteVertexArrayOES(O)}function m(O,L,j){let V=j.wireframe===!0,H=a[O.id];H===void 0&&(H={},a[O.id]=H);let W=H[L.id];W===void 0&&(W={},H[L.id]=W);let q=W[V];return q===void 0&&(q=g(d()),W[V]=q),q}function g(O){let L=[],j=[],V=[];for(let H=0;H<i;H++)L[H]=0,j[H]=0,V[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:j,attributeDivisors:V,object:O,attributes:{},index:null}}function y(O,L,j,V){let H=c.attributes,W=L.attributes,q=0,K=j.getAttributes();for(let G in K)if(K[G].location>=0){let te=H[G],$=W[G];if($===void 0&&(G==="instanceMatrix"&&O.instanceMatrix&&($=O.instanceMatrix),G==="instanceColor"&&O.instanceColor&&($=O.instanceColor)),te===void 0||te.attribute!==$||$&&te.data!==$.data)return!0;q++}return c.attributesNum!==q||c.index!==V}function v(O,L,j,V){let H={},W=L.attributes,q=0,K=j.getAttributes();for(let G in K)if(K[G].location>=0){let te=W[G];te===void 0&&(G==="instanceMatrix"&&O.instanceMatrix&&(te=O.instanceMatrix),G==="instanceColor"&&O.instanceColor&&(te=O.instanceColor));let $={};$.attribute=te,te&&te.data&&($.data=te.data),H[G]=$,q++}c.attributes=H,c.attributesNum=q,c.index=V}function x(){let O=c.newAttributes;for(let L=0,j=O.length;L<j;L++)O[L]=0}function S(O){w(O,0)}function w(O,L){let j=c.newAttributes,V=c.enabledAttributes,H=c.attributeDivisors;j[O]=1,V[O]===0&&(n.enableVertexAttribArray(O),V[O]=1),H[O]!==L&&((r.isWebGL2?n:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](O,L),H[O]=L)}function A(){let O=c.newAttributes,L=c.enabledAttributes;for(let j=0,V=L.length;j<V;j++)L[j]!==O[j]&&(n.disableVertexAttribArray(j),L[j]=0)}function M(O,L,j,V,H,W){r.isWebGL2===!0&&(j===5124||j===5125)?n.vertexAttribIPointer(O,L,j,H,W):n.vertexAttribPointer(O,L,j,V,H,W)}function b(O,L,j,V){if(r.isWebGL2===!1&&(O.isInstancedMesh||V.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;x();let H=V.attributes,W=j.getAttributes(),q=L.defaultAttributeValues;for(let K in W){let G=W[K];if(G.location>=0){let Z=H[K];if(Z===void 0&&(K==="instanceMatrix"&&O.instanceMatrix&&(Z=O.instanceMatrix),K==="instanceColor"&&O.instanceColor&&(Z=O.instanceColor)),Z!==void 0){let te=Z.normalized,$=Z.itemSize,Y=e.get(Z);if(Y===void 0)continue;let oe=Y.buffer,ie=Y.type,re=Y.bytesPerElement;if(Z.isInterleavedBufferAttribute){let J=Z.data,Ae=J.stride,xe=Z.offset;if(J.isInstancedInterleavedBuffer){for(let de=0;de<G.locationSize;de++)w(G.location+de,J.meshPerAttribute);O.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let de=0;de<G.locationSize;de++)S(G.location+de);n.bindBuffer(34962,oe);for(let de=0;de<G.locationSize;de++)M(G.location+de,$/G.locationSize,ie,te,Ae*re,(xe+$/G.locationSize*de)*re)}else{if(Z.isInstancedBufferAttribute){for(let J=0;J<G.locationSize;J++)w(G.location+J,Z.meshPerAttribute);O.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let J=0;J<G.locationSize;J++)S(G.location+J);n.bindBuffer(34962,oe);for(let J=0;J<G.locationSize;J++)M(G.location+J,$/G.locationSize,ie,te,$*re,$/G.locationSize*J*re)}}else if(q!==void 0){let te=q[K];if(te!==void 0)switch(te.length){case 2:n.vertexAttrib2fv(G.location,te);break;case 3:n.vertexAttrib3fv(G.location,te);break;case 4:n.vertexAttrib4fv(G.location,te);break;default:n.vertexAttrib1fv(G.location,te)}}}}A()}function T(){D();for(let O in a){let L=a[O];for(let j in L){let V=L[j];for(let H in V)p(V[H].object),delete V[H];delete L[j]}delete a[O]}}function C(O){if(a[O.id]===void 0)return;let L=a[O.id];for(let j in L){let V=L[j];for(let H in V)p(V[H].object),delete V[H];delete L[j]}delete a[O.id]}function P(O){for(let L in a){let j=a[L];if(j[O.id]===void 0)continue;let V=j[O.id];for(let H in V)p(V[H].object),delete V[H];delete j[O.id]}}function D(){_(),u=!0,c!==l&&(c=l,f(c.object))}function _(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:D,resetDefaultState:_,dispose:T,releaseStatesOfGeometry:C,releaseStatesOfProgram:P,initAttributes:x,enableAttribute:S,disableUnusedAttributes:A}}function RU(n,t,e,r){let i=r.isWebGL2,s;function o(c){s=c}function a(c,u){n.drawArrays(s,c,u),e.update(u,s,1)}function l(c,u,h){if(h===0)return;let d,f;if(i)d=n,f="drawArraysInstanced";else if(d=t.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,c,u,h),e.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function LU(n,t,e){let r;function i(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let M=t.get("EXT_texture_filter_anisotropic");r=n.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(M){if(M==="highp"){if(n.getShaderPrecisionFormat(35633,36338).precision>0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext,a=e.precision!==void 0?e.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||t.has("WEBGL_draw_buffers"),u=e.logarithmicDepthBuffer===!0,h=n.getParameter(34930),d=n.getParameter(35660),f=n.getParameter(3379),p=n.getParameter(34076),m=n.getParameter(34921),g=n.getParameter(36347),y=n.getParameter(36348),v=n.getParameter(36349),x=d>0,S=o||t.has("OES_texture_float"),w=x&&S,A=o?n.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:v,vertexTextures:x,floatFragmentTextures:S,floatVertexTextures:w,maxSamples:A}}function BU(n){let t=this,e=null,r=0,i=!1,s=!1,o=new Zr,a=new vr,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||r!==0||i;return i=d,r=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){e=u(h,d,0)},this.setState=function(h,d,f){let p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,y=n.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):c();else{let v=s?0:r,x=v*4,S=y.clippingState||null;l.value=S,S=u(p,d,x,f);for(let w=0;w!==x;++w)S[w]=e[w];y.clippingState=S,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(h,d,f,p){let m=h!==null?h.length:0,g=null;if(m!==0){if(g=l.value,p!==!0||g===null){let y=f+m*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<y)&&(g=new Float32Array(y));for(let x=0,S=f;x!==m;++x,S+=4)o.copy(h[x]).applyMatrix4(v,a),o.normal.toArray(g,S),g[S+3]=o.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}function NU(n){let t=new WeakMap;function e(o,a){return a===AS?o.mapping=Ya:a===ES&&(o.mapping=Xa),o}function r(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===AS||a===ES)if(t.has(o)){let l=t.get(o).texture;return e(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new DS(l.height/2);return c.fromEquirectangularTexture(n,o),t.set(o,c),o.addEventListener("dispose",i),e(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function s(){t=new WeakMap}return{get:r,dispose:s}}var Ka=class extends Wn{constructor(t=-1,e=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=r-t,o=r+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},Mu=4,RT=[.125,.215,.35,.446,.526,.582],oc=20,fS=new Ka,LT=new We,pS=null,sc=(1+Math.sqrt(5))/2,Su=1/sc,BT=[new E(1,1,1),new E(-1,1,1),new E(1,1,-1),new E(-1,1,-1),new E(0,sc,Su),new E(0,sc,-Su),new E(Su,0,sc),new E(-Su,0,sc),new E(sc,Su,0),new E(-sc,Su,0)],ty=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,r=.1,i=100){pS=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,r,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=VT(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=FT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(pS),t.scissorTest=!1,Lg(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ya||t.mapping===Xa?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),pS=this._renderer.getRenderTarget();let r=e||this._allocateTargets();return this._textureToCubeUV(t,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,r={magFilter:tt,minFilter:tt,generateMipmaps:!1,type:jn,format:jr,encoding:un,depthBuffer:!1},i=NT(t,e,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=NT(t,e,r);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=FU(s)),this._blurMaterial=VU(s,t,e)}return i}_compileMaterial(t){let e=new Xt(this._lodPlanes[0],t);this._renderer.compile(e,fS)}_sceneToCubeUV(t,e,r,i){let a=new Kr(90,1,e,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(LT),u.toneMapping=Os,u.autoClear=!1;let f=new Hn({name:"PMREM.Background",side:ui,depthWrite:!1,depthTest:!1}),p=new Xt(new hi,f),m=!1,g=t.background;g?g.isColor&&(f.color.copy(g),t.background=null,m=!0):(f.color.copy(LT),m=!0);for(let y=0;y<6;y++){let v=y%3;v===0?(a.up.set(0,l[y],0),a.lookAt(c[y],0,0)):v===1?(a.up.set(0,0,l[y]),a.lookAt(0,c[y],0)):(a.up.set(0,l[y],0),a.lookAt(0,0,c[y]));let x=this._cubeSize;Lg(i,v*x,y>2?x:0,x,x),u.setRenderTarget(i),m&&u.render(p,a),u.render(t,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=d,u.autoClear=h,t.background=g}_textureToCubeUV(t,e){let r=this._renderer,i=t.mapping===Ya||t.mapping===Xa;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=VT()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=FT());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Xt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;let l=this._cubeSize;Lg(e,0,0,3*l,2*l),r.setRenderTarget(e),r.render(o,fS)}_applyPMREM(t){let e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=BT[(i-1)%BT.length];this._blur(t,i-1,i,s,o)}e.autoClear=r}_blur(t,e,r,i,s){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,r,i,"latitudinal",s),this._halfBlur(o,t,r,r,i,"longitudinal",s)}_halfBlur(t,e,r,i,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new Xt(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[r]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*oc-1),m=s/p,g=isFinite(s)?1+Math.floor(u*m):oc;g>oc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${oc}`);let y=[],v=0;for(let M=0;M<oc;++M){let b=M/m,T=Math.exp(-b*b/2);y.push(T),M===0?v+=T:M<g&&(v+=2*T)}for(let M=0;M<y.length;M++)y[M]=y[M]/v;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=y,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:x}=this;d.dTheta.value=p,d.mipInt.value=x-r;let S=this._sizeLods[i],w=3*S*(i>x-Mu?i-x+Mu:0),A=4*(this._cubeSize-S);Lg(e,w,A,3*S,2*S),l.setRenderTarget(e),l.render(h,fS)}};function FU(n){let t=[],e=[],r=[],i=n,s=n-Mu+1+RT.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);e.push(a);let l=1/a;o>n-Mu?l=RT[o-n+Mu-1]:o===0&&(l=0),r.push(l);let c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,p=6,m=3,g=2,y=1,v=new Float32Array(m*p*f),x=new Float32Array(g*p*f),S=new Float32Array(y*p*f);for(let A=0;A<f;A++){let M=A%3*2/3-1,b=A>2?0:-1,T=[M,b,0,M+2/3,b,0,M+2/3,b+1,0,M,b,0,M+2/3,b+1,0,M,b+1,0];v.set(T,m*p*A),x.set(d,g*p*A);let C=[A,A,A,A,A,A];S.set(C,y*p*A)}let w=new _e;w.setAttribute("position",new Xe(v,m)),w.setAttribute("uv",new Xe(x,g)),w.setAttribute("faceIndex",new Xe(S,y)),t.push(w),i>Mu&&i--}return{lodPlanes:t,sizeLods:e,sigmas:r}}function NT(n,t,e){let r=new dt(n,t,e);return r.texture.mapping=Yu,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Lg(n,t,e,r,i){n.viewport.set(t,e,r,i),n.scissor.set(t,e,r,i)}function VU(n,t,e){let r=new Float32Array(oc),i=new E(0,1,0);return new st({name:"SphericalGaussianBlur",defines:{n:oc,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:uw(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:Zt,depthTest:!1,depthWrite:!1})}function FT(){return new st({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uw(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:Zt,depthTest:!1,depthWrite:!1})}function VT(){return new st({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uw(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:Zt,depthTest:!1,depthWrite:!1})}function uw(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}function zU(n){let t=new WeakMap,e=null;function r(a){if(a&&a.isTexture){let l=a.mapping,c=l===AS||l===ES,u=l===Ya||l===Xa;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=t.get(a);return e===null&&(e=new ty(n)),h=c?e.fromEquirectangular(a,h):e.fromCubemap(a,h),t.set(a,h),h.texture}else{if(t.has(a))return t.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&i(h)){e===null&&(e=new ty(n));let d=c?e.fromEquirectangular(a):e.fromCubemap(a);return t.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:r,dispose:o}}function UU(n){let t={};function e(r){if(t[r]!==void 0)return t[r];let i;switch(r){case"WEBGL_depth_texture":i=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=n.getExtension(r)}return t[r]=i,i}return{has:function(r){return e(r)!==null},init:function(r){r.isWebGL2?e("EXT_color_buffer_float"):(e("WEBGL_depth_texture"),e("OES_texture_float"),e("OES_texture_half_float"),e("OES_texture_half_float_linear"),e("OES_standard_derivatives"),e("OES_element_index_uint"),e("OES_vertex_array_object"),e("ANGLE_instanced_arrays")),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture")},get:function(r){let i=e(r);return i===null&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),i}}}function kU(n,t,e,r){let i={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&t.remove(d.index);for(let p in d.attributes)t.remove(d.attributes[p]);d.removeEventListener("dispose",o),delete i[d.id];let f=s.get(d);f&&(t.remove(f),s.delete(d)),r.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,e.memory.geometries++),d}function l(h){let d=h.attributes;for(let p in d)t.update(d[p],34962);let f=h.morphAttributes;for(let p in f){let m=f[p];for(let g=0,y=m.length;g<y;g++)t.update(m[g],34962)}}function c(h){let d=[],f=h.index,p=h.attributes.position,m=0;if(f!==null){let v=f.array;m=f.version;for(let x=0,S=v.length;x<S;x+=3){let w=v[x+0],A=v[x+1],M=v[x+2];d.push(w,A,A,M,M,w)}}else{let v=p.array;m=p.version;for(let x=0,S=v.length/3-1;x<S;x+=3){let w=x+0,A=x+1,M=x+2;d.push(w,A,A,M,M,w)}}let g=new(DC(d)?uo:ey)(d,1);g.version=m;let y=s.get(h);y&&t.remove(y),s.set(h,g)}function u(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function GU(n,t,e,r){let i=r.isWebGL2,s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function u(d,f){n.drawElements(s,f,a,d*l),e.update(f,s,1)}function h(d,f,p){if(p===0)return;let m,g;if(i)m=n,g="drawElementsInstanced";else if(m=t.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",m===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[g](s,f,a,d*l,p),e.update(f,s,p)}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=h}function jU(n){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,a){switch(e.calls++,o){case 4:e.triangles+=a*(s/3);break;case 1:e.lines+=a*(s/2);break;case 3:e.lines+=a*(s-1);break;case 2:e.lines+=a*s;break;case 0:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:r}}function HU(n,t){return n[0]-t[0]}function WU(n,t){return Math.abs(t[1])-Math.abs(n[1])}function qU(n,t,e){let r={},i=new Float32Array(8),s=new WeakMap,o=new Ke,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,h,d){let f=c.morphTargetInfluences;if(t.isWebGL2===!0){let p=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,m=p!==void 0?p.length:0,g=s.get(u);if(g===void 0||g.count!==m){let L=function(){_.dispose(),s.delete(u),u.removeEventListener("dispose",L)};g!==void 0&&g.texture.dispose();let x=u.morphAttributes.position!==void 0,S=u.morphAttributes.normal!==void 0,w=u.morphAttributes.color!==void 0,A=u.morphAttributes.position||[],M=u.morphAttributes.normal||[],b=u.morphAttributes.color||[],T=0;x===!0&&(T=1),S===!0&&(T=2),w===!0&&(T=3);let C=u.attributes.position.count*T,P=1;C>t.maxTextureSize&&(P=Math.ceil(C/t.maxTextureSize),C=t.maxTextureSize);let D=new Float32Array(C*P*4*m),_=new Zg(D,C,P,m);_.type=yr,_.needsUpdate=!0;let O=T*4;for(let j=0;j<m;j++){let V=A[j],H=M[j],W=b[j],q=C*P*4*j;for(let K=0;K<V.count;K++){let G=K*O;x===!0&&(o.fromBufferAttribute(V,K),D[q+G+0]=o.x,D[q+G+1]=o.y,D[q+G+2]=o.z,D[q+G+3]=0),S===!0&&(o.fromBufferAttribute(H,K),D[q+G+4]=o.x,D[q+G+5]=o.y,D[q+G+6]=o.z,D[q+G+7]=0),w===!0&&(o.fromBufferAttribute(W,K),D[q+G+8]=o.x,D[q+G+9]=o.y,D[q+G+10]=o.z,D[q+G+11]=W.itemSize===4?o.w:1)}}g={count:m,texture:_,size:new U(C,P)},s.set(u,g),u.addEventListener("dispose",L)}let y=0;for(let x=0;x<f.length;x++)y+=f[x];let v=u.morphTargetsRelative?1:1-y;d.getUniforms().setValue(n,"morphTargetBaseInfluence",v),d.getUniforms().setValue(n,"morphTargetInfluences",f),d.getUniforms().setValue(n,"morphTargetsTexture",g.texture,e),d.getUniforms().setValue(n,"morphTargetsTextureSize",g.size)}else{let p=f===void 0?0:f.length,m=r[u.id];if(m===void 0||m.length!==p){m=[];for(let S=0;S<p;S++)m[S]=[S,0];r[u.id]=m}for(let S=0;S<p;S++){let w=m[S];w[0]=S,w[1]=f[S]}m.sort(WU);for(let S=0;S<8;S++)S<p&&m[S][1]?(a[S][0]=m[S][0],a[S][1]=m[S][1]):(a[S][0]=Number.MAX_SAFE_INTEGER,a[S][1]=0);a.sort(HU);let g=u.morphAttributes.position,y=u.morphAttributes.normal,v=0;for(let S=0;S<8;S++){let w=a[S],A=w[0],M=w[1];A!==Number.MAX_SAFE_INTEGER&&M?(g&&u.getAttribute("morphTarget"+S)!==g[A]&&u.setAttribute("morphTarget"+S,g[A]),y&&u.getAttribute("morphNormal"+S)!==y[A]&&u.setAttribute("morphNormal"+S,y[A]),i[S]=M,v+=M):(g&&u.hasAttribute("morphTarget"+S)===!0&&u.deleteAttribute("morphTarget"+S),y&&u.hasAttribute("morphNormal"+S)===!0&&u.deleteAttribute("morphNormal"+S),i[S]=0)}let x=u.morphTargetsRelative?1:1-v;d.getUniforms().setValue(n,"morphTargetBaseInfluence",x),d.getUniforms().setValue(n,"morphTargetInfluences",i)}}return{update:l}}function YU(n,t,e,r){let i=new WeakMap;function s(l){let c=r.render.frame,u=l.geometry,h=t.get(l,u);return i.get(h)!==c&&(t.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),e.update(l.instanceMatrix,34962),l.instanceColor!==null&&e.update(l.instanceColor,34962)),h}function o(){i=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:s,dispose:o}}var LC=new Jt,BC=new Zg,NC=new Jg,FC=new _u,zT=[],UT=[],kT=new Float32Array(16),GT=new Float32Array(9),jT=new Float32Array(4);function Qu(n,t,e){let r=n[0];if(r<=0||r>0)return n;let i=t*e,s=zT[i];if(s===void 0&&(s=new Float32Array(i),zT[i]=s),t!==0){r.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,n[o].toArray(s,a)}return s}function vi(n,t){if(n.length!==t.length)return!1;for(let e=0,r=n.length;e<r;e++)if(n[e]!==t[e])return!1;return!0}function xi(n,t){for(let e=0,r=t.length;e<r;e++)n[e]=t[e]}function Sy(n,t){let e=UT[t];e===void 0&&(e=new Int32Array(t),UT[t]=e);for(let r=0;r!==t;++r)e[r]=n.allocateTextureUnit();return e}function XU(n,t){let e=this.cache;e[0]!==t&&(n.uniform1f(this.addr,t),e[0]=t)}function QU(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(n.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(vi(e,t))return;n.uniform2fv(this.addr,t),xi(e,t)}}function KU(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(n.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(n.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(vi(e,t))return;n.uniform3fv(this.addr,t),xi(e,t)}}function ZU(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(n.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(vi(e,t))return;n.uniform4fv(this.addr,t),xi(e,t)}}function JU(n,t){let e=this.cache,r=t.elements;if(r===void 0){if(vi(e,t))return;n.uniformMatrix2fv(this.addr,!1,t),xi(e,t)}else{if(vi(e,r))return;jT.set(r),n.uniformMatrix2fv(this.addr,!1,jT),xi(e,r)}}function $U(n,t){let e=this.cache,r=t.elements;if(r===void 0){if(vi(e,t))return;n.uniformMatrix3fv(this.addr,!1,t),xi(e,t)}else{if(vi(e,r))return;GT.set(r),n.uniformMatrix3fv(this.addr,!1,GT),xi(e,r)}}function ek(n,t){let e=this.cache,r=t.elements;if(r===void 0){if(vi(e,t))return;n.uniformMatrix4fv(this.addr,!1,t),xi(e,t)}else{if(vi(e,r))return;kT.set(r),n.uniformMatrix4fv(this.addr,!1,kT),xi(e,r)}}function tk(n,t){let e=this.cache;e[0]!==t&&(n.uniform1i(this.addr,t),e[0]=t)}function rk(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(n.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(vi(e,t))return;n.uniform2iv(this.addr,t),xi(e,t)}}function ik(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(n.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(vi(e,t))return;n.uniform3iv(this.addr,t),xi(e,t)}}function nk(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(n.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(vi(e,t))return;n.uniform4iv(this.addr,t),xi(e,t)}}function sk(n,t){let e=this.cache;e[0]!==t&&(n.uniform1ui(this.addr,t),e[0]=t)}function ok(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(n.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(vi(e,t))return;n.uniform2uiv(this.addr,t),xi(e,t)}}function ak(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(n.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(vi(e,t))return;n.uniform3uiv(this.addr,t),xi(e,t)}}function lk(n,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(n.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(vi(e,t))return;n.uniform4uiv(this.addr,t),xi(e,t)}}function ck(n,t,e){let r=this.cache,i=e.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),e.setTexture2D(t||LC,i)}function uk(n,t,e){let r=this.cache,i=e.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),e.setTexture3D(t||NC,i)}function hk(n,t,e){let r=this.cache,i=e.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),e.setTextureCube(t||FC,i)}function dk(n,t,e){let r=this.cache,i=e.allocateTextureUnit();r[0]!==i&&(n.uniform1i(this.addr,i),r[0]=i),e.setTexture2DArray(t||BC,i)}function fk(n){switch(n){case 5126:return XU;case 35664:return QU;case 35665:return KU;case 35666:return ZU;case 35674:return JU;case 35675:return $U;case 35676:return ek;case 5124:case 35670:return tk;case 35667:case 35671:return rk;case 35668:case 35672:return ik;case 35669:case 35673:return nk;case 5125:return sk;case 36294:return ok;case 36295:return ak;case 36296:return lk;case 35678:case 36198:case 36298:case 36306:case 35682:return ck;case 35679:case 36299:case 36307:return uk;case 35680:case 36300:case 36308:case 36293:return hk;case 36289:case 36303:case 36311:case 36292:return dk}}function pk(n,t){n.uniform1fv(this.addr,t)}function mk(n,t){let e=Qu(t,this.size,2);n.uniform2fv(this.addr,e)}function gk(n,t){let e=Qu(t,this.size,3);n.uniform3fv(this.addr,e)}function yk(n,t){let e=Qu(t,this.size,4);n.uniform4fv(this.addr,e)}function vk(n,t){let e=Qu(t,this.size,4);n.uniformMatrix2fv(this.addr,!1,e)}function xk(n,t){let e=Qu(t,this.size,9);n.uniformMatrix3fv(this.addr,!1,e)}function bk(n,t){let e=Qu(t,this.size,16);n.uniformMatrix4fv(this.addr,!1,e)}function Sk(n,t){n.uniform1iv(this.addr,t)}function wk(n,t){n.uniform2iv(this.addr,t)}function Ak(n,t){n.uniform3iv(this.addr,t)}function Ek(n,t){n.uniform4iv(this.addr,t)}function Mk(n,t){n.uniform1uiv(this.addr,t)}function Tk(n,t){n.uniform2uiv(this.addr,t)}function Ck(n,t){n.uniform3uiv(this.addr,t)}function Pk(n,t){n.uniform4uiv(this.addr,t)}function _k(n,t,e){let r=this.cache,i=t.length,s=Sy(e,i);vi(r,s)||(n.uniform1iv(this.addr,s),xi(r,s));for(let o=0;o!==i;++o)e.setTexture2D(t[o]||LC,s[o])}function Dk(n,t,e){let r=this.cache,i=t.length,s=Sy(e,i);vi(r,s)||(n.uniform1iv(this.addr,s),xi(r,s));for(let o=0;o!==i;++o)e.setTexture3D(t[o]||NC,s[o])}function Ok(n,t,e){let r=this.cache,i=t.length,s=Sy(e,i);vi(r,s)||(n.uniform1iv(this.addr,s),xi(r,s));for(let o=0;o!==i;++o)e.setTextureCube(t[o]||FC,s[o])}function Ik(n,t,e){let r=this.cache,i=t.length,s=Sy(e,i);vi(r,s)||(n.uniform1iv(this.addr,s),xi(r,s));for(let o=0;o!==i;++o)e.setTexture2DArray(t[o]||BC,s[o])}function Rk(n){switch(n){case 5126:return pk;case 35664:return mk;case 35665:return gk;case 35666:return yk;case 35674:return vk;case 35675:return xk;case 35676:return bk;case 5124:case 35670:return Sk;case 35667:case 35671:return wk;case 35668:case 35672:return Ak;case 35669:case 35673:return Ek;case 5125:return Mk;case 36294:return Tk;case 36295:return Ck;case 36296:return Pk;case 35678:case 36198:case 36298:case 36306:case 35682:return _k;case 35679:case 36299:case 36307:return Dk;case 35680:case 36300:case 36308:case 36293:return Ok;case 36289:case 36303:case 36311:case 36292:return Ik}}var OS=class{constructor(t,e,r){this.id=t,this.addr=r,this.cache=[],this.setValue=fk(e.type)}},IS=class{constructor(t,e,r){this.id=t,this.addr=r,this.cache=[],this.size=e.size,this.setValue=Rk(e.type)}},RS=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,r){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(t,e[a.id],r)}}},mS=/(\w+)(\])?(\[|\.)?/g;function HT(n,t){n.seq.push(t),n.map[t.id]=t}function Lk(n,t,e){let r=n.name,i=r.length;for(mS.lastIndex=0;;){let s=mS.exec(r),o=mS.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){HT(e,c===void 0?new OS(a,n,t):new IS(a,n,t));break}else{let h=e.map[a];h===void 0&&(h=new RS(a),HT(e,h)),e=h}}}var Cu=class{constructor(t,e){this.seq=[],this.map={};let r=t.getProgramParameter(e,35718);for(let i=0;i<r;++i){let s=t.getActiveUniform(e,i),o=t.getUniformLocation(e,s.name);Lk(s,o,this)}}setValue(t,e,r,i){let s=this.map[e];s!==void 0&&s.setValue(t,r,i)}setOptional(t,e,r){let i=e[r];i!==void 0&&this.setValue(t,r,i)}static upload(t,e,r,i){for(let s=0,o=e.length;s!==o;++s){let a=e[s],l=r[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,i)}}static seqWithValue(t,e){let r=[];for(let i=0,s=t.length;i!==s;++i){let o=t[i];o.id in e&&r.push(o)}return r}};function WT(n,t,e){let r=n.createShader(t);return n.shaderSource(r,e),n.compileShader(r),r}var Bk=0;function Nk(n,t){let e=n.split(`
`),r=[],i=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=i;o<s;o++){let a=o+1;r.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return r.join(`
`)}function Fk(n){switch(n){case un:return["Linear","( value )"];case at:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function qT(n,t,e){let r=n.getShaderParameter(t,35713),i=n.getShaderInfoLog(t).trim();if(r&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return e.toUpperCase()+`
`+i+`
`+Nk(n.getShaderSource(t),o)}else return i}function Vk(n,t){let e=Fk(t);return"vec4 "+n+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function zk(n,t){let e;switch(t){case $N:e="Linear";break;case eF:e="Reinhard";break;case tF:e="OptimizedCineon";break;case rF:e="ACESFilmic";break;case iF:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+n+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function Uk(n){return[n.extensionDerivatives||!!n.envMapCubeUVHeight||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Zf).join(`
`)}function kk(n){let t=[];for(let e in n){let r=n[e];r!==!1&&t.push("#define "+e+" "+r)}return t.join(`
`)}function Gk(n,t){let e={},r=n.getProgramParameter(t,35721);for(let i=0;i<r;i++){let s=n.getActiveAttrib(t,i),o=s.name,a=1;s.type===35674&&(a=2),s.type===35675&&(a=3),s.type===35676&&(a=4),e[o]={type:s.type,location:n.getAttribLocation(t,o),locationSize:a}}return e}function Zf(n){return n!==""}function YT(n,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function XT(n,t){return n.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var jk=/^[ \t]*#include +<([\w\d./]+)>/gm;function LS(n){return n.replace(jk,Hk)}function Hk(n,t){let e=xt[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return LS(e)}var Wk=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function QT(n){return n.replace(Wk,qk)}function qk(n,t,e,r){let i="";for(let s=parseInt(t);s<parseInt(e);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function KT(n){let t="precision "+n.precision+` float;
precision `+n.precision+" int;";return n.precision==="highp"?t+=`
#define HIGH_PRECISION`:n.precision==="mediump"?t+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(t+=`
#define LOW_PRECISION`),t}function Yk(n){let t="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===by?t="SHADOWMAP_TYPE_PCF":n.shadowMapType===ON?t="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Kf&&(t="SHADOWMAP_TYPE_VSM"),t}function Xk(n){let t="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Ya:case Xa:t="ENVMAP_TYPE_CUBE";break;case Yu:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Qk(n){let t="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Xa:t="ENVMAP_MODE_REFRACTION";break}return t}function Kk(n){let t="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case MC:t="ENVMAP_BLENDING_MULTIPLY";break;case ZN:t="ENVMAP_BLENDING_MIX";break;case JN:t="ENVMAP_BLENDING_ADD";break}return t}function Zk(n){let t=n.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:r,maxMip:e}}function Jk(n,t,e,r){let i=n.getContext(),s=e.defines,o=e.vertexShader,a=e.fragmentShader,l=Yk(e),c=Xk(e),u=Qk(e),h=Kk(e),d=Zk(e),f=e.isWebGL2?"":Uk(e),p=kk(s),m=i.createProgram(),g,y,v=e.glslVersion?"#version "+e.glslVersion+`
`:"";e.isRawShaderMaterial?(g=[p].filter(Zf).join(`
`),g.length>0&&(g+=`
`),y=[f,p].filter(Zf).join(`
`),y.length>0&&(y+=`
`)):(g=[KT(e),"#define SHADER_NAME "+e.shaderName,p,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.supportsVertexTextures?"#define VERTEX_TEXTURES":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.displacementMap&&e.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(Zf).join(`
`),y=[f,KT(e),"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Os?"#define TONE_MAPPING":"",e.toneMapping!==Os?xt.tonemapping_pars_fragment:"",e.toneMapping!==Os?zk("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",xt.encodings_pars_fragment,Vk("linearToOutputTexel",e.outputEncoding),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
`].filter(Zf).join(`
`)),o=LS(o),o=YT(o,e),o=XT(o,e),a=LS(a),a=YT(a,e),a=XT(a,e),o=QT(o),a=QT(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+g,y=["#define varying in",e.glslVersion===ST?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===ST?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+y);let x=v+g+o,S=v+y+a,w=WT(i,35633,x),A=WT(i,35632,S);if(i.attachShader(m,w),i.attachShader(m,A),e.index0AttributeName!==void 0?i.bindAttribLocation(m,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),n.debug.checkShaderErrors){let T=i.getProgramInfoLog(m).trim(),C=i.getShaderInfoLog(w).trim(),P=i.getShaderInfoLog(A).trim(),D=!0,_=!0;if(i.getProgramParameter(m,35714)===!1){D=!1;let O=qT(i,w,"vertex"),L=qT(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+`
Program Info Log: `+T+`
`+O+`
`+L)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(C===""||P==="")&&(_=!1);_&&(this.diagnostics={runnable:D,programLog:T,vertexShader:{log:C,prefix:g},fragmentShader:{log:P,prefix:y}})}i.deleteShader(w),i.deleteShader(A);let M;this.getUniforms=function(){return M===void 0&&(M=new Cu(i,m)),M};let b;return this.getAttributes=function(){return b===void 0&&(b=Gk(i,m)),b},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=e.shaderName,this.id=Bk++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=A,this}var $k=0,BS=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,r=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let r of e)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,r=e.get(t);return r===void 0&&(r=new Set,e.set(t,r)),r}_getShaderStage(t){let e=this.shaderCache,r=e.get(t);return r===void 0&&(r=new NS(t),e.set(t,r)),r}},NS=class{constructor(t){this.id=$k++,this.code=t,this.usedTimes=0}};function eG(n,t,e,r,i,s,o){let a=new op,l=new BS,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(b,T,C,P,D){let _=P.fog,O=D.geometry,L=b.isMeshStandardMaterial?P.environment:null,j=(b.isMeshStandardMaterial?e:t).get(b.envMap||L),V=!!j&&j.mapping===Yu?j.image.height:null,H=p[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let W=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,q=W!==void 0?W.length:0,K=0;O.morphAttributes.position!==void 0&&(K=1),O.morphAttributes.normal!==void 0&&(K=2),O.morphAttributes.color!==void 0&&(K=3);let G,Z,te,$;if(H){let Ae=co[H];G=Ae.vertexShader,Z=Ae.fragmentShader}else G=b.vertexShader,Z=b.fragmentShader,l.update(b),te=l.getVertexShaderID(b),$=l.getFragmentShaderID(b);let Y=n.getRenderTarget(),oe=b.alphaTest>0,ie=b.clearcoat>0,re=b.iridescence>0;return{isWebGL2:u,shaderID:H,shaderName:b.type,vertexShader:G,fragmentShader:Z,defines:b.defines,customVertexShaderID:te,customFragmentShaderID:$,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,instancing:D.isInstancedMesh===!0,instancingColor:D.isInstancedMesh===!0&&D.instanceColor!==null,supportsVertexTextures:d,outputEncoding:Y===null?n.outputEncoding:Y.isXRRenderTarget===!0?Y.texture.encoding:un,map:!!b.map,matcap:!!b.matcap,envMap:!!j,envMapMode:j&&j.mapping,envMapCubeUVHeight:V,lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,objectSpaceNormalMap:b.normalMapType===bF,tangentSpaceNormalMap:b.normalMapType===xF,decodeVideoTexture:!!b.map&&b.map.isVideoTexture===!0&&b.map.encoding===at,clearcoat:ie,clearcoatMap:ie&&!!b.clearcoatMap,clearcoatRoughnessMap:ie&&!!b.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!b.clearcoatNormalMap,iridescence:re,iridescenceMap:re&&!!b.iridescenceMap,iridescenceThicknessMap:re&&!!b.iridescenceThicknessMap,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,specularIntensityMap:!!b.specularIntensityMap,specularColorMap:!!b.specularColorMap,opaque:b.transparent===!1&&b.blending===Wa,alphaMap:!!b.alphaMap,alphaTest:oe,gradientMap:!!b.gradientMap,sheen:b.sheen>0,sheenColorMap:!!b.sheenColorMap,sheenRoughnessMap:!!b.sheenRoughnessMap,transmission:b.transmission>0,transmissionMap:!!b.transmissionMap,thicknessMap:!!b.thicknessMap,combine:b.combine,vertexTangents:!!b.normalMap&&!!O.attributes.tangent,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,vertexUvs:!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatMap||!!b.clearcoatRoughnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||!!b.displacementMap||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||!!b.sheenColorMap||!!b.sheenRoughnessMap,uvsVertexOnly:!(!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||b.transmission>0||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||b.sheen>0||!!b.sheenColorMap||!!b.sheenRoughnessMap)&&!!b.displacementMap,fog:!!_,useFog:b.fog===!0,fogExp2:_&&_.isFogExp2,flatShading:!!b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:h,skinning:D.isSkinnedMesh===!0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:q,morphTextureStride:K,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&C.length>0,shadowMapType:n.shadowMap.type,toneMapping:b.toneMapped?n.toneMapping:Os,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===ji,flipSided:b.side===ui,useDepthPacking:!!b.depthPacking,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionDerivatives:b.extensions&&b.extensions.derivatives,extensionFragDepth:b.extensions&&b.extensions.fragDepth,extensionDrawBuffers:b.extensions&&b.extensions.drawBuffers,extensionShaderTextureLOD:b.extensions&&b.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:b.customProgramCacheKey()}}function g(b){let T=[];if(b.shaderID?T.push(b.shaderID):(T.push(b.customVertexShaderID),T.push(b.customFragmentShaderID)),b.defines!==void 0)for(let C in b.defines)T.push(C),T.push(b.defines[C]);return b.isRawShaderMaterial===!1&&(y(T,b),v(T,b),T.push(n.outputEncoding)),T.push(b.customProgramCacheKey),T.join()}function y(b,T){b.push(T.precision),b.push(T.outputEncoding),b.push(T.envMapMode),b.push(T.envMapCubeUVHeight),b.push(T.combine),b.push(T.vertexUvs),b.push(T.fogExp2),b.push(T.sizeAttenuation),b.push(T.morphTargetsCount),b.push(T.morphAttributeCount),b.push(T.numDirLights),b.push(T.numPointLights),b.push(T.numSpotLights),b.push(T.numSpotLightMaps),b.push(T.numHemiLights),b.push(T.numRectAreaLights),b.push(T.numDirLightShadows),b.push(T.numPointLightShadows),b.push(T.numSpotLightShadows),b.push(T.numSpotLightShadowsWithMaps),b.push(T.shadowMapType),b.push(T.toneMapping),b.push(T.numClippingPlanes),b.push(T.numClipIntersection),b.push(T.depthPacking)}function v(b,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.map&&a.enable(4),T.matcap&&a.enable(5),T.envMap&&a.enable(6),T.lightMap&&a.enable(7),T.aoMap&&a.enable(8),T.emissiveMap&&a.enable(9),T.bumpMap&&a.enable(10),T.normalMap&&a.enable(11),T.objectSpaceNormalMap&&a.enable(12),T.tangentSpaceNormalMap&&a.enable(13),T.clearcoat&&a.enable(14),T.clearcoatMap&&a.enable(15),T.clearcoatRoughnessMap&&a.enable(16),T.clearcoatNormalMap&&a.enable(17),T.iridescence&&a.enable(18),T.iridescenceMap&&a.enable(19),T.iridescenceThicknessMap&&a.enable(20),T.displacementMap&&a.enable(21),T.specularMap&&a.enable(22),T.roughnessMap&&a.enable(23),T.metalnessMap&&a.enable(24),T.gradientMap&&a.enable(25),T.alphaMap&&a.enable(26),T.alphaTest&&a.enable(27),T.vertexColors&&a.enable(28),T.vertexAlphas&&a.enable(29),T.vertexUvs&&a.enable(30),T.vertexTangents&&a.enable(31),T.uvsVertexOnly&&a.enable(32),b.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.skinning&&a.enable(4),T.morphTargets&&a.enable(5),T.morphNormals&&a.enable(6),T.morphColors&&a.enable(7),T.premultipliedAlpha&&a.enable(8),T.shadowMapEnabled&&a.enable(9),T.physicallyCorrectLights&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.specularIntensityMap&&a.enable(15),T.specularColorMap&&a.enable(16),T.transmission&&a.enable(17),T.transmissionMap&&a.enable(18),T.thicknessMap&&a.enable(19),T.sheen&&a.enable(20),T.sheenColorMap&&a.enable(21),T.sheenRoughnessMap&&a.enable(22),T.decodeVideoTexture&&a.enable(23),T.opaque&&a.enable(24),b.push(a.mask)}function x(b){let T=p[b.type],C;if(T){let P=co[T];C=Bs.clone(P.uniforms)}else C=b.uniforms;return C}function S(b,T){let C;for(let P=0,D=c.length;P<D;P++){let _=c[P];if(_.cacheKey===T){C=_,++C.usedTimes;break}}return C===void 0&&(C=new Jk(n,T,b,s),c.push(C)),C}function w(b){if(--b.usedTimes===0){let T=c.indexOf(b);c[T]=c[c.length-1],c.pop(),b.destroy()}}function A(b){l.remove(b)}function M(){l.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:x,acquireProgram:S,releaseProgram:w,releaseShaderCache:A,programs:c,dispose:M}}function tG(){let n=new WeakMap;function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function e(s){n.delete(s)}function r(s,o,a){n.get(s)[o]=a}function i(){n=new WeakMap}return{get:t,remove:e,update:r,dispose:i}}function rG(n,t){return n.groupOrder!==t.groupOrder?n.groupOrder-t.groupOrder:n.renderOrder!==t.renderOrder?n.renderOrder-t.renderOrder:n.material.id!==t.material.id?n.material.id-t.material.id:n.z!==t.z?n.z-t.z:n.id-t.id}function ZT(n,t){return n.groupOrder!==t.groupOrder?n.groupOrder-t.groupOrder:n.renderOrder!==t.renderOrder?n.renderOrder-t.renderOrder:n.z!==t.z?t.z-n.z:n.id-t.id}function JT(){let n=[],t=0,e=[],r=[],i=[];function s(){t=0,e.length=0,r.length=0,i.length=0}function o(h,d,f,p,m,g){let y=n[t];return y===void 0?(y={id:h.id,object:h,geometry:d,material:f,groupOrder:p,renderOrder:h.renderOrder,z:m,group:g},n[t]=y):(y.id=h.id,y.object=h,y.geometry=d,y.material=f,y.groupOrder=p,y.renderOrder=h.renderOrder,y.z=m,y.group=g),t++,y}function a(h,d,f,p,m,g){let y=o(h,d,f,p,m,g);f.transmission>0?r.push(y):f.transparent===!0?i.push(y):e.push(y)}function l(h,d,f,p,m,g){let y=o(h,d,f,p,m,g);f.transmission>0?r.unshift(y):f.transparent===!0?i.unshift(y):e.unshift(y)}function c(h,d){e.length>1&&e.sort(h||rG),r.length>1&&r.sort(d||ZT),i.length>1&&i.sort(d||ZT)}function u(){for(let h=t,d=n.length;h<d;h++){let f=n[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:r,transparent:i,init:s,push:a,unshift:l,finish:u,sort:c}}function iG(){let n=new WeakMap;function t(r,i){let s=n.get(r),o;return s===void 0?(o=new JT,n.set(r,[o])):i>=s.length?(o=new JT,s.push(o)):o=s[i],o}function e(){n=new WeakMap}return{get:t,dispose:e}}function nG(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new E,color:new We};break;case"SpotLight":e={position:new E,direction:new E,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new E,color:new We,distance:0,decay:0};break;case"HemisphereLight":e={direction:new E,skyColor:new We,groundColor:new We};break;case"RectAreaLight":e={color:new We,position:new E,halfWidth:new E,halfHeight:new E};break}return n[t.id]=e,e}}}function sG(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new U};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new U};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new U,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[t.id]=e,e}}}var oG=0;function aG(n,t){return(t.castShadow?2:0)-(n.castShadow?2:0)+(t.map?1:0)-(n.map?1:0)}function lG(n,t){let e=new nG,r=sG(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let u=0;u<9;u++)i.probe.push(new E);let s=new E,o=new ce,a=new ce;function l(u,h){let d=0,f=0,p=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let m=0,g=0,y=0,v=0,x=0,S=0,w=0,A=0,M=0,b=0;u.sort(aG);let T=h!==!0?Math.PI:1;for(let P=0,D=u.length;P<D;P++){let _=u[P],O=_.color,L=_.intensity,j=_.distance,V=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)d+=O.r*L*T,f+=O.g*L*T,p+=O.b*L*T;else if(_.isLightProbe)for(let H=0;H<9;H++)i.probe[H].addScaledVector(_.sh.coefficients[H],L);else if(_.isDirectionalLight){let H=e.get(_);if(H.color.copy(_.color).multiplyScalar(_.intensity*T),_.castShadow){let W=_.shadow,q=r.get(_);q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,i.directionalShadow[m]=q,i.directionalShadowMap[m]=V,i.directionalShadowMatrix[m]=_.shadow.matrix,S++}i.directional[m]=H,m++}else if(_.isSpotLight){let H=e.get(_);H.position.setFromMatrixPosition(_.matrixWorld),H.color.copy(O).multiplyScalar(L*T),H.distance=j,H.coneCos=Math.cos(_.angle),H.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),H.decay=_.decay,i.spot[y]=H;let W=_.shadow;if(_.map&&(i.spotLightMap[M]=_.map,M++,W.updateMatrices(_),_.castShadow&&b++),i.spotLightMatrix[y]=W.matrix,_.castShadow){let q=r.get(_);q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,i.spotShadow[y]=q,i.spotShadowMap[y]=V,A++}y++}else if(_.isRectAreaLight){let H=e.get(_);H.color.copy(O).multiplyScalar(L),H.halfWidth.set(_.width*.5,0,0),H.halfHeight.set(0,_.height*.5,0),i.rectArea[v]=H,v++}else if(_.isPointLight){let H=e.get(_);if(H.color.copy(_.color).multiplyScalar(_.intensity*T),H.distance=_.distance,H.decay=_.decay,_.castShadow){let W=_.shadow,q=r.get(_);q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,q.shadowCameraNear=W.camera.near,q.shadowCameraFar=W.camera.far,i.pointShadow[g]=q,i.pointShadowMap[g]=V,i.pointShadowMatrix[g]=_.shadow.matrix,w++}i.point[g]=H,g++}else if(_.isHemisphereLight){let H=e.get(_);H.skyColor.copy(_.color).multiplyScalar(L*T),H.groundColor.copy(_.groundColor).multiplyScalar(L*T),i.hemi[x]=H,x++}}v>0&&(t.isWebGL2||n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=De.LTC_FLOAT_1,i.rectAreaLTC2=De.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=De.LTC_HALF_1,i.rectAreaLTC2=De.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=p;let C=i.hash;(C.directionalLength!==m||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==v||C.hemiLength!==x||C.numDirectionalShadows!==S||C.numPointShadows!==w||C.numSpotShadows!==A||C.numSpotMaps!==M)&&(i.directional.length=m,i.spot.length=y,i.rectArea.length=v,i.point.length=g,i.hemi.length=x,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=A+M-b,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=b,C.directionalLength=m,C.pointLength=g,C.spotLength=y,C.rectAreaLength=v,C.hemiLength=x,C.numDirectionalShadows=S,C.numPointShadows=w,C.numSpotShadows=A,C.numSpotMaps=M,i.version=oG++)}function c(u,h){let d=0,f=0,p=0,m=0,g=0,y=h.matrixWorldInverse;for(let v=0,x=u.length;v<x;v++){let S=u[v];if(S.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),w.direction.sub(s),w.direction.transformDirection(y),d++}else if(S.isSpotLight){let w=i.spot[p];w.position.setFromMatrixPosition(S.matrixWorld),w.position.applyMatrix4(y),w.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),w.direction.sub(s),w.direction.transformDirection(y),p++}else if(S.isRectAreaLight){let w=i.rectArea[m];w.position.setFromMatrixPosition(S.matrixWorld),w.position.applyMatrix4(y),a.identity(),o.copy(S.matrixWorld),o.premultiply(y),a.extractRotation(o),w.halfWidth.set(S.width*.5,0,0),w.halfHeight.set(0,S.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),m++}else if(S.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(S.matrixWorld),w.position.applyMatrix4(y),f++}else if(S.isHemisphereLight){let w=i.hemi[g];w.direction.setFromMatrixPosition(S.matrixWorld),w.direction.transformDirection(y),g++}}}return{setup:l,setupView:c,state:i}}function $T(n,t){let e=new lG(n,t),r=[],i=[];function s(){r.length=0,i.length=0}function o(h){r.push(h)}function a(h){i.push(h)}function l(h){e.setup(r,h)}function c(h){e.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:e},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function cG(n,t){let e=new WeakMap;function r(s,o=0){let a=e.get(s),l;return a===void 0?(l=new $T(n,t),e.set(s,[l])):o>=a.length?(l=new $T(n,t),a.push(l)):l=a[o],l}function i(){e=new WeakMap}return{get:r,dispose:i}}var lp=class extends uc{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ii,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},FS=class extends uc{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new E,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},uG=`void main() {
gl_Position = vec4( position, 1.0 );
}`,hG=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function dG(n,t,e){let r=new ap,i=new U,s=new U,o=new Ke,a=new lp({depthPacking:lw}),l=new FS,c={},u=e.maxTextureSize,h={[Gn]:ui,[ui]:Gn,[ji]:ji},d=new st({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:uG,fragmentShader:hG}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new _e;p.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Xt(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=by,this.render=function(S,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;let M=n.getRenderTarget(),b=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),C=n.state;C.setBlending(Zt),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,D=S.length;P<D;P++){let _=S[P],O=_.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",_,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);let L=O.getFrameExtents();if(i.multiply(L),s.copy(O.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,O.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,O.mapSize.y=s.y)),O.map===null){let V=this.type!==Kf?{minFilter:Vt,magFilter:Vt}:{};O.map=new dt(i.x,i.y,V),O.map.texture.name=_.name+".shadowMap",O.camera.updateProjectionMatrix()}n.setRenderTarget(O.map),n.clear();let j=O.getViewportCount();for(let V=0;V<j;V++){let H=O.getViewport(V);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),C.viewport(o),O.updateMatrices(_,V),r=O.getFrustum(),x(w,A,O.camera,_,this.type)}O.isPointLightShadow!==!0&&this.type===Kf&&y(O,A),O.needsUpdate=!1}g.needsUpdate=!1,n.setRenderTarget(M,b,T)};function y(S,w){let A=t.update(m);d.defines.VSM_SAMPLES!==S.blurSamples&&(d.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=S.map.texture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(w,null,A,d,m,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(w,null,A,f,m,null)}function v(S,w,A,M,b,T){let C=null,P=A.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(P!==void 0)C=P;else if(C=A.isPointLight===!0?l:a,n.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let D=C.uuid,_=w.uuid,O=c[D];O===void 0&&(O={},c[D]=O);let L=O[_];L===void 0&&(L=C.clone(),O[_]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,T===Kf?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:h[w.side],C.alphaMap=w.alphaMap,C.alphaTest=w.alphaTest,C.map=w.map,C.clipShadows=w.clipShadows,C.clippingPlanes=w.clippingPlanes,C.clipIntersection=w.clipIntersection,C.displacementMap=w.displacementMap,C.displacementScale=w.displacementScale,C.displacementBias=w.displacementBias,C.wireframeLinewidth=w.wireframeLinewidth,C.linewidth=w.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=M,C.farDistance=b),C}function x(S,w,A,M,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===Kf)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let P=t.update(S),D=S.material;if(Array.isArray(D)){let _=P.groups;for(let O=0,L=_.length;O<L;O++){let j=_[O],V=D[j.materialIndex];if(V&&V.visible){let H=v(S,V,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,H,S,j)}}}else if(D.visible){let _=v(S,D,M,A.near,A.far,b);n.renderBufferDirect(A,null,P,_,S,null)}}let C=S.children;for(let P=0,D=C.length;P<D;P++)x(C[P],w,A,M,b)}}function fG(n,t,e){let r=e.isWebGL2;function i(){let Q=!1,ye=new Ke,Me=null,je=new Ke(0,0,0,0);return{setMask:function(He){Me!==He&&!Q&&(n.colorMask(He,He,He,He),Me=He)},setLocked:function(He){Q=He},setClear:function(He,_t,Br,Nr,Xo){Xo===!0&&(He*=Nr,_t*=Nr,Br*=Nr),ye.set(He,_t,Br,Nr),je.equals(ye)===!1&&(n.clearColor(He,_t,Br,Nr),je.copy(ye))},reset:function(){Q=!1,Me=null,je.set(-1,0,0,0)}}}function s(){let Q=!1,ye=null,Me=null,je=null;return{setTest:function(He){He?oe(2929):ie(2929)},setMask:function(He){ye!==He&&!Q&&(n.depthMask(He),ye=He)},setFunc:function(He){if(Me!==He){switch(He){case HN:n.depthFunc(512);break;case WN:n.depthFunc(519);break;case qN:n.depthFunc(513);break;case wS:n.depthFunc(515);break;case YN:n.depthFunc(514);break;case XN:n.depthFunc(518);break;case QN:n.depthFunc(516);break;case KN:n.depthFunc(517);break;default:n.depthFunc(515)}Me=He}},setLocked:function(He){Q=He},setClear:function(He){je!==He&&(n.clearDepth(He),je=He)},reset:function(){Q=!1,ye=null,Me=null,je=null}}}function o(){let Q=!1,ye=null,Me=null,je=null,He=null,_t=null,Br=null,Nr=null,Xo=null;return{setTest:function(Er){Q||(Er?oe(2960):ie(2960))},setMask:function(Er){ye!==Er&&!Q&&(n.stencilMask(Er),ye=Er)},setFunc:function(Er,es,An){(Me!==Er||je!==es||He!==An)&&(n.stencilFunc(Er,es,An),Me=Er,je=es,He=An)},setOp:function(Er,es,An){(_t!==Er||Br!==es||Nr!==An)&&(n.stencilOp(Er,es,An),_t=Er,Br=es,Nr=An)},setLocked:function(Er){Q=Er},setClear:function(Er){Xo!==Er&&(n.clearStencil(Er),Xo=Er)},reset:function(){Q=!1,ye=null,Me=null,je=null,He=null,_t=null,Br=null,Nr=null,Xo=null}}}let a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,O=null,L=n.getParameter(35661),j=!1,V=0,H=n.getParameter(7938);H.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(H)[1]),j=V>=1):H.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),j=V>=2);let W=null,q={},K=n.getParameter(3088),G=n.getParameter(2978),Z=new Ke().fromArray(K),te=new Ke().fromArray(G);function $(Q,ye,Me){let je=new Uint8Array(4),He=n.createTexture();n.bindTexture(Q,He),n.texParameteri(Q,10241,9728),n.texParameteri(Q,10240,9728);for(let _t=0;_t<Me;_t++)n.texImage2D(ye+_t,0,6408,1,1,0,6408,5121,je);return He}let Y={};Y[3553]=$(3553,3553,1),Y[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),oe(2929),l.setFunc(wS),Ue(!1),ze(WM),oe(2884),Oe(Zt);function oe(Q){d[Q]!==!0&&(n.enable(Q),d[Q]=!0)}function ie(Q){d[Q]!==!1&&(n.disable(Q),d[Q]=!1)}function re(Q,ye){return f[Q]!==ye?(n.bindFramebuffer(Q,ye),f[Q]=ye,r&&(Q===36009&&(f[36160]=ye),Q===36160&&(f[36009]=ye)),!0):!1}function J(Q,ye){let Me=m,je=!1;if(Q)if(Me=p.get(ye),Me===void 0&&(Me=[],p.set(ye,Me)),Q.isWebGLMultipleRenderTargets){let He=Q.texture;if(Me.length!==He.length||Me[0]!==36064){for(let _t=0,Br=He.length;_t<Br;_t++)Me[_t]=36064+_t;Me.length=He.length,je=!0}}else Me[0]!==36064&&(Me[0]=36064,je=!0);else Me[0]!==1029&&(Me[0]=1029,je=!0);je&&(e.isWebGL2?n.drawBuffers(Me):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function Ae(Q){return g!==Q?(n.useProgram(Q),g=Q,!0):!1}let xe={[wu]:32774,[RN]:32778,[LN]:32779};if(r)xe[QM]=32775,xe[KM]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(xe[QM]=Q.MIN_EXT,xe[KM]=Q.MAX_EXT)}let de={[BN]:0,[NN]:1,[FN]:768,[AC]:770,[jN]:776,[kN]:774,[zN]:772,[VN]:769,[EC]:771,[GN]:775,[UN]:773};function Oe(Q,ye,Me,je,He,_t,Br,Nr){if(Q===Zt){y===!0&&(ie(3042),y=!1);return}if(y===!1&&(oe(3042),y=!0),Q!==IN){if(Q!==v||Nr!==T){if((x!==wu||A!==wu)&&(n.blendEquation(32774),x=wu,A=wu),Nr)switch(Q){case Wa:n.blendFuncSeparate(1,771,1,771);break;case qM:n.blendFunc(1,1);break;case YM:n.blendFuncSeparate(0,769,0,1);break;case XM:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case Wa:n.blendFuncSeparate(770,771,1,771);break;case qM:n.blendFunc(770,1);break;case YM:n.blendFuncSeparate(0,769,0,1);break;case XM:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}S=null,w=null,M=null,b=null,v=Q,T=Nr}return}He=He||ye,_t=_t||Me,Br=Br||je,(ye!==x||He!==A)&&(n.blendEquationSeparate(xe[ye],xe[He]),x=ye,A=He),(Me!==S||je!==w||_t!==M||Br!==b)&&(n.blendFuncSeparate(de[Me],de[je],de[_t],de[Br]),S=Me,w=je,M=_t,b=Br),v=Q,T=!1}function Ce(Q,ye){Q.side===ji?ie(2884):oe(2884);let Me=Q.side===ui;ye&&(Me=!Me),Ue(Me),Q.blending===Wa&&Q.transparent===!1?Oe(Zt):Oe(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let je=Q.stencilWrite;c.setTest(je),je&&(c.setMask(Q.stencilWriteMask),c.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),c.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),Ie(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?oe(32926):ie(32926)}function Ue(Q){C!==Q&&(Q?n.frontFace(2304):n.frontFace(2305),C=Q)}function ze(Q){Q!==_N?(oe(2884),Q!==P&&(Q===WM?n.cullFace(1029):Q===DN?n.cullFace(1028):n.cullFace(1032))):ie(2884),P=Q}function Ve(Q){Q!==D&&(j&&n.lineWidth(Q),D=Q)}function Ie(Q,ye,Me){Q?(oe(32823),(_!==ye||O!==Me)&&(n.polygonOffset(ye,Me),_=ye,O=Me)):ie(32823)}function Ye(Q){Q?oe(3089):ie(3089)}function F(Q){Q===void 0&&(Q=33984+L-1),W!==Q&&(n.activeTexture(Q),W=Q)}function N(Q,ye,Me){Me===void 0&&(W===null?Me=33984+L-1:Me=W);let je=q[Me];je===void 0&&(je={type:void 0,texture:void 0},q[Me]=je),(je.type!==Q||je.texture!==ye)&&(W!==Me&&(n.activeTexture(Me),W=Me),n.bindTexture(Q,ye||Y[Q]),je.type=Q,je.texture=ye)}function B(){let Q=q[W];Q!==void 0&&Q.type!==void 0&&(n.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ge(){try{n.compressedTexImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function me(){try{n.texSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Le(){try{n.texSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ne(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Re(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function rt(){try{n.texStorage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ge(){try{n.texImage2D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Be(){try{n.texImage3D.apply(n,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Je(Q){Z.equals(Q)===!1&&(n.scissor(Q.x,Q.y,Q.z,Q.w),Z.copy(Q))}function nt(Q){te.equals(Q)===!1&&(n.viewport(Q.x,Q.y,Q.z,Q.w),te.copy(Q))}function Bt(Q,ye){let Me=h.get(ye);Me===void 0&&(Me=new WeakMap,h.set(ye,Me));let je=Me.get(Q);je===void 0&&(je=n.getUniformBlockIndex(ye,Q.name),Me.set(Q,je))}function ur(Q,ye){let je=h.get(ye).get(Q);u.get(ye)!==je&&(n.uniformBlockBinding(ye,je,Q.__bindingPointIndex),u.set(ye,je))}function Ar(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),r===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},W=null,q={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,S=null,w=null,A=null,M=null,b=null,T=!1,C=null,P=null,D=null,_=null,O=null,Z.set(0,0,n.canvas.width,n.canvas.height),te.set(0,0,n.canvas.width,n.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:oe,disable:ie,bindFramebuffer:re,drawBuffers:J,useProgram:Ae,setBlending:Oe,setMaterial:Ce,setFlipSided:Ue,setCullFace:ze,setLineWidth:Ve,setPolygonOffset:Ie,setScissorTest:Ye,activeTexture:F,bindTexture:N,unbindTexture:B,compressedTexImage2D:ae,compressedTexImage3D:ge,texImage2D:Ge,texImage3D:Be,updateUBOMapping:Bt,uniformBlockBinding:ur,texStorage2D:pe,texStorage3D:rt,texSubImage2D:me,texSubImage3D:Le,compressedTexSubImage2D:Ne,compressedTexSubImage3D:Re,scissor:Je,viewport:nt,reset:Ar}}function pG(n,t,e,r,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(N,B){return y?new OffscreenCanvas(N,B):sp("canvas")}function x(N,B,ae,ge){let me=1;if((N.width>ge||N.height>ge)&&(me=ge/Math.max(N.width,N.height)),me<1||B===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){let Le=B?Xg:Math.floor,Ne=Le(me*N.width),Re=Le(me*N.height);m===void 0&&(m=v(Ne,Re));let pe=ae?v(Ne,Re):m;return pe.width=Ne,pe.height=Re,pe.getContext("2d").drawImage(N,0,0,Ne,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+Ne+"x"+Re+")."),pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function S(N){return PS(N.width)&&PS(N.height)}function w(N){return a?!1:N.wrapS!==Yt||N.wrapT!==Yt||N.minFilter!==Vt&&N.minFilter!==tt}function A(N,B){return N.generateMipmaps&&B&&N.minFilter!==Vt&&N.minFilter!==tt}function M(N){n.generateMipmap(N)}function b(N,B,ae,ge,me=!1){if(a===!1)return B;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Le=B;return B===6403&&(ae===5126&&(Le=33326),ae===5131&&(Le=33325),ae===5121&&(Le=33321)),B===33319&&(ae===5126&&(Le=33328),ae===5131&&(Le=33327),ae===5121&&(Le=33323)),B===6408&&(ae===5126&&(Le=34836),ae===5131&&(Le=34842),ae===5121&&(Le=ge===at&&me===!1?35907:32856),ae===32819&&(Le=32854),ae===32820&&(Le=32855)),(Le===33325||Le===33326||Le===33327||Le===33328||Le===34842||Le===34836)&&t.get("EXT_color_buffer_float"),Le}function T(N,B,ae){return A(N,ae)===!0||N.isFramebufferTexture&&N.minFilter!==Vt&&N.minFilter!==tt?Math.log2(Math.max(B.width,B.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?B.mipmaps.length:1}function C(N){return N===Vt||N===ZM||N===zb?9728:9729}function P(N){let B=N.target;B.removeEventListener("dispose",P),_(B),B.isVideoTexture&&p.delete(B)}function D(N){let B=N.target;B.removeEventListener("dispose",D),L(B)}function _(N){let B=r.get(N);if(B.__webglInit===void 0)return;let ae=N.source,ge=g.get(ae);if(ge){let me=ge[B.__cacheKey];me.usedTimes--,me.usedTimes===0&&O(N),Object.keys(ge).length===0&&g.delete(ae)}r.remove(N)}function O(N){let B=r.get(N);n.deleteTexture(B.__webglTexture);let ae=N.source,ge=g.get(ae);delete ge[B.__cacheKey],o.memory.textures--}function L(N){let B=N.texture,ae=r.get(N),ge=r.get(B);if(ge.__webglTexture!==void 0&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)n.deleteFramebuffer(ae.__webglFramebuffer[me]),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer[me]);else{if(n.deleteFramebuffer(ae.__webglFramebuffer),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer),ae.__webglMultisampledFramebuffer&&n.deleteFramebuffer(ae.__webglMultisampledFramebuffer),ae.__webglColorRenderbuffer)for(let me=0;me<ae.__webglColorRenderbuffer.length;me++)ae.__webglColorRenderbuffer[me]&&n.deleteRenderbuffer(ae.__webglColorRenderbuffer[me]);ae.__webglDepthRenderbuffer&&n.deleteRenderbuffer(ae.__webglDepthRenderbuffer)}if(N.isWebGLMultipleRenderTargets)for(let me=0,Le=B.length;me<Le;me++){let Ne=r.get(B[me]);Ne.__webglTexture&&(n.deleteTexture(Ne.__webglTexture),o.memory.textures--),r.remove(B[me])}r.remove(B),r.remove(N)}let j=0;function V(){j=0}function H(){let N=j;return N>=l&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+l),j+=1,N}function W(N){let B=[];return B.push(N.wrapS),B.push(N.wrapT),B.push(N.wrapR||0),B.push(N.magFilter),B.push(N.minFilter),B.push(N.anisotropy),B.push(N.internalFormat),B.push(N.format),B.push(N.type),B.push(N.generateMipmaps),B.push(N.premultiplyAlpha),B.push(N.flipY),B.push(N.unpackAlignment),B.push(N.encoding),B.join()}function q(N,B){let ae=r.get(N);if(N.isVideoTexture&&Ye(N),N.isRenderTargetTexture===!1&&N.version>0&&ae.__version!==N.version){let ge=N.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,N,B);return}}e.bindTexture(3553,ae.__webglTexture,33984+B)}function K(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(35866,ae.__webglTexture,33984+B)}function G(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(32879,ae.__webglTexture,33984+B)}function Z(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){re(ae,N,B);return}e.bindTexture(34067,ae.__webglTexture,33984+B)}let te={[Is]:10497,[Yt]:33071,[MS]:33648},$={[Vt]:9728,[ZM]:9984,[zb]:9986,[tt]:9729,[nF]:9985,[cc]:9987};function Y(N,B,ae){if(ae?(n.texParameteri(N,10242,te[B.wrapS]),n.texParameteri(N,10243,te[B.wrapT]),(N===32879||N===35866)&&n.texParameteri(N,32882,te[B.wrapR]),n.texParameteri(N,10240,$[B.magFilter]),n.texParameteri(N,10241,$[B.minFilter])):(n.texParameteri(N,10242,33071),n.texParameteri(N,10243,33071),(N===32879||N===35866)&&n.texParameteri(N,32882,33071),(B.wrapS!==Yt||B.wrapT!==Yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,10240,C(B.magFilter)),n.texParameteri(N,10241,C(B.minFilter)),B.minFilter!==Vt&&B.minFilter!==tt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let ge=t.get("EXT_texture_filter_anisotropic");if(B.magFilter===Vt||B.minFilter!==zb&&B.minFilter!==cc||B.type===yr&&t.has("OES_texture_float_linear")===!1||a===!1&&B.type===jn&&t.has("OES_texture_half_float_linear")===!1)return;(B.anisotropy>1||r.get(B).__currentAnisotropy)&&(n.texParameterf(N,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(B.anisotropy,i.getMaxAnisotropy())),r.get(B).__currentAnisotropy=B.anisotropy)}}function oe(N,B){let ae=!1;N.__webglInit===void 0&&(N.__webglInit=!0,B.addEventListener("dispose",P));let ge=B.source,me=g.get(ge);me===void 0&&(me={},g.set(ge,me));let Le=W(B);if(Le!==N.__cacheKey){me[Le]===void 0&&(me[Le]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Le].usedTimes++;let Ne=me[N.__cacheKey];Ne!==void 0&&(me[N.__cacheKey].usedTimes--,Ne.usedTimes===0&&O(B)),N.__cacheKey=Le,N.__webglTexture=me[Le].texture}return ae}function ie(N,B,ae){let ge=3553;(B.isDataArrayTexture||B.isCompressedArrayTexture)&&(ge=35866),B.isData3DTexture&&(ge=32879);let me=oe(N,B),Le=B.source;e.bindTexture(ge,N.__webglTexture,33984+ae);let Ne=r.get(Le);if(Le.version!==Ne.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Re=w(B)&&S(B.image)===!1,pe=x(B.image,Re,!1,u);pe=F(B,pe);let rt=S(pe)||a,Ge=s.convert(B.format,B.encoding),Be=s.convert(B.type),Je=b(B.internalFormat,Ge,Be,B.encoding,B.isVideoTexture);Y(ge,B,rt);let nt,Bt=B.mipmaps,ur=a&&B.isVideoTexture!==!0,Ar=Ne.__version===void 0||me===!0,Q=T(B,pe,rt);if(B.isDepthTexture)Je=6402,a?B.type===yr?Je=36012:B.type===Ds?Je=33190:B.type===qa?Je=35056:Je=33189:B.type===yr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),B.format===ac&&Je===6402&&B.type!==CC&&B.type!==Ds&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),B.type=Ds,Be=s.convert(B.type)),B.format===Qa&&Je===6402&&(Je=34041,B.type!==qa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),B.type=qa,Be=s.convert(B.type))),Ar&&(ur?e.texStorage2D(3553,1,Je,pe.width,pe.height):e.texImage2D(3553,0,Je,pe.width,pe.height,0,Ge,Be,null));else if(B.isDataTexture)if(Bt.length>0&&rt){ur&&Ar&&e.texStorage2D(3553,Q,Je,Bt[0].width,Bt[0].height);for(let ye=0,Me=Bt.length;ye<Me;ye++)nt=Bt[ye],ur?e.texSubImage2D(3553,ye,0,0,nt.width,nt.height,Ge,Be,nt.data):e.texImage2D(3553,ye,Je,nt.width,nt.height,0,Ge,Be,nt.data);B.generateMipmaps=!1}else ur?(Ar&&e.texStorage2D(3553,Q,Je,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,pe.width,pe.height,Ge,Be,pe.data)):e.texImage2D(3553,0,Je,pe.width,pe.height,0,Ge,Be,pe.data);else if(B.isCompressedTexture)if(B.isCompressedArrayTexture){ur&&Ar&&e.texStorage3D(35866,Q,Je,Bt[0].width,Bt[0].height,pe.depth);for(let ye=0,Me=Bt.length;ye<Me;ye++)nt=Bt[ye],B.format!==jr?Ge!==null?ur?e.compressedTexSubImage3D(35866,ye,0,0,0,nt.width,nt.height,pe.depth,Ge,nt.data,0,0):e.compressedTexImage3D(35866,ye,Je,nt.width,nt.height,pe.depth,0,nt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ur?e.texSubImage3D(35866,ye,0,0,0,nt.width,nt.height,pe.depth,Ge,Be,nt.data):e.texImage3D(35866,ye,Je,nt.width,nt.height,pe.depth,0,Ge,Be,nt.data)}else{ur&&Ar&&e.texStorage2D(3553,Q,Je,Bt[0].width,Bt[0].height);for(let ye=0,Me=Bt.length;ye<Me;ye++)nt=Bt[ye],B.format!==jr?Ge!==null?ur?e.compressedTexSubImage2D(3553,ye,0,0,nt.width,nt.height,Ge,nt.data):e.compressedTexImage2D(3553,ye,Je,nt.width,nt.height,0,nt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ur?e.texSubImage2D(3553,ye,0,0,nt.width,nt.height,Ge,Be,nt.data):e.texImage2D(3553,ye,Je,nt.width,nt.height,0,Ge,Be,nt.data)}else if(B.isDataArrayTexture)ur?(Ar&&e.texStorage3D(35866,Q,Je,pe.width,pe.height,pe.depth),e.texSubImage3D(35866,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(35866,0,Je,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isData3DTexture)ur?(Ar&&e.texStorage3D(32879,Q,Je,pe.width,pe.height,pe.depth),e.texSubImage3D(32879,0,0,0,0,pe.width,pe.height,pe.depth,Ge,Be,pe.data)):e.texImage3D(32879,0,Je,pe.width,pe.height,pe.depth,0,Ge,Be,pe.data);else if(B.isFramebufferTexture){if(Ar)if(ur)e.texStorage2D(3553,Q,Je,pe.width,pe.height);else{let ye=pe.width,Me=pe.height;for(let je=0;je<Q;je++)e.texImage2D(3553,je,Je,ye,Me,0,Ge,Be,null),ye>>=1,Me>>=1}}else if(Bt.length>0&&rt){ur&&Ar&&e.texStorage2D(3553,Q,Je,Bt[0].width,Bt[0].height);for(let ye=0,Me=Bt.length;ye<Me;ye++)nt=Bt[ye],ur?e.texSubImage2D(3553,ye,0,0,Ge,Be,nt):e.texImage2D(3553,ye,Je,Ge,Be,nt);B.generateMipmaps=!1}else ur?(Ar&&e.texStorage2D(3553,Q,Je,pe.width,pe.height),e.texSubImage2D(3553,0,0,0,Ge,Be,pe)):e.texImage2D(3553,0,Je,Ge,Be,pe);A(B,rt)&&M(ge),Ne.__version=Le.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function re(N,B,ae){if(B.image.length!==6)return;let ge=oe(N,B),me=B.source;e.bindTexture(34067,N.__webglTexture,33984+ae);let Le=r.get(me);if(me.version!==Le.__version||ge===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Ne=B.isCompressedTexture||B.image[0].isCompressedTexture,Re=B.image[0]&&B.image[0].isDataTexture,pe=[];for(let ye=0;ye<6;ye++)!Ne&&!Re?pe[ye]=x(B.image[ye],!1,!0,c):pe[ye]=Re?B.image[ye].image:B.image[ye],pe[ye]=F(B,pe[ye]);let rt=pe[0],Ge=S(rt)||a,Be=s.convert(B.format,B.encoding),Je=s.convert(B.type),nt=b(B.internalFormat,Be,Je,B.encoding),Bt=a&&B.isVideoTexture!==!0,ur=Le.__version===void 0||ge===!0,Ar=T(B,rt,Ge);Y(34067,B,Ge);let Q;if(Ne){Bt&&ur&&e.texStorage2D(34067,Ar,nt,rt.width,rt.height);for(let ye=0;ye<6;ye++){Q=pe[ye].mipmaps;for(let Me=0;Me<Q.length;Me++){let je=Q[Me];B.format!==jr?Be!==null?Bt?e.compressedTexSubImage2D(34069+ye,Me,0,0,je.width,je.height,Be,je.data):e.compressedTexImage2D(34069+ye,Me,nt,je.width,je.height,0,je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Bt?e.texSubImage2D(34069+ye,Me,0,0,je.width,je.height,Be,Je,je.data):e.texImage2D(34069+ye,Me,nt,je.width,je.height,0,Be,Je,je.data)}}}else{Q=B.mipmaps,Bt&&ur&&(Q.length>0&&Ar++,e.texStorage2D(34067,Ar,nt,pe[0].width,pe[0].height));for(let ye=0;ye<6;ye++)if(Re){Bt?e.texSubImage2D(34069+ye,0,0,0,pe[ye].width,pe[ye].height,Be,Je,pe[ye].data):e.texImage2D(34069+ye,0,nt,pe[ye].width,pe[ye].height,0,Be,Je,pe[ye].data);for(let Me=0;Me<Q.length;Me++){let He=Q[Me].image[ye].image;Bt?e.texSubImage2D(34069+ye,Me+1,0,0,He.width,He.height,Be,Je,He.data):e.texImage2D(34069+ye,Me+1,nt,He.width,He.height,0,Be,Je,He.data)}}else{Bt?e.texSubImage2D(34069+ye,0,0,0,Be,Je,pe[ye]):e.texImage2D(34069+ye,0,nt,Be,Je,pe[ye]);for(let Me=0;Me<Q.length;Me++){let je=Q[Me];Bt?e.texSubImage2D(34069+ye,Me+1,0,0,Be,Je,je.image[ye]):e.texImage2D(34069+ye,Me+1,nt,Be,Je,je.image[ye])}}}A(B,Ge)&&M(34067),Le.__version=me.version,B.onUpdate&&B.onUpdate(B)}N.__version=B.version}function J(N,B,ae,ge,me){let Le=s.convert(ae.format,ae.encoding),Ne=s.convert(ae.type),Re=b(ae.internalFormat,Le,Ne,ae.encoding);r.get(B).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Re,B.width,B.height,B.depth,0,Le,Ne,null):e.texImage2D(me,0,Re,B.width,B.height,0,Le,Ne,null)),e.bindFramebuffer(36160,N),Ie(B)?d.framebufferTexture2DMultisampleEXT(36160,ge,me,r.get(ae).__webglTexture,0,Ve(B)):(me===3553||me>=34069&&me<=34074)&&n.framebufferTexture2D(36160,ge,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ae(N,B,ae){if(n.bindRenderbuffer(36161,N),B.depthBuffer&&!B.stencilBuffer){let ge=33189;if(ae||Ie(B)){let me=B.depthTexture;me&&me.isDepthTexture&&(me.type===yr?ge=36012:me.type===Ds&&(ge=33190));let Le=Ve(B);Ie(B)?d.renderbufferStorageMultisampleEXT(36161,Le,ge,B.width,B.height):n.renderbufferStorageMultisample(36161,Le,ge,B.width,B.height)}else n.renderbufferStorage(36161,ge,B.width,B.height);n.framebufferRenderbuffer(36160,36096,36161,N)}else if(B.depthBuffer&&B.stencilBuffer){let ge=Ve(B);ae&&Ie(B)===!1?n.renderbufferStorageMultisample(36161,ge,35056,B.width,B.height):Ie(B)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,B.width,B.height):n.renderbufferStorage(36161,34041,B.width,B.height),n.framebufferRenderbuffer(36160,33306,36161,N)}else{let ge=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0;me<ge.length;me++){let Le=ge[me],Ne=s.convert(Le.format,Le.encoding),Re=s.convert(Le.type),pe=b(Le.internalFormat,Ne,Re,Le.encoding),rt=Ve(B);ae&&Ie(B)===!1?n.renderbufferStorageMultisample(36161,rt,pe,B.width,B.height):Ie(B)?d.renderbufferStorageMultisampleEXT(36161,rt,pe,B.width,B.height):n.renderbufferStorage(36161,pe,B.width,B.height)}}n.bindRenderbuffer(36161,null)}function xe(N,B){if(B&&B.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,N),!(B.depthTexture&&B.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(B.depthTexture).__webglTexture||B.depthTexture.image.width!==B.width||B.depthTexture.image.height!==B.height)&&(B.depthTexture.image.width=B.width,B.depthTexture.image.height=B.height,B.depthTexture.needsUpdate=!0),q(B.depthTexture,0);let ge=r.get(B.depthTexture).__webglTexture,me=Ve(B);if(B.depthTexture.format===ac)Ie(B)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ge,0,me):n.framebufferTexture2D(36160,36096,3553,ge,0);else if(B.depthTexture.format===Qa)Ie(B)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ge,0,me):n.framebufferTexture2D(36160,33306,3553,ge,0);else throw new Error("Unknown depthTexture format")}function de(N){let B=r.get(N),ae=N.isWebGLCubeRenderTarget===!0;if(N.depthTexture&&!B.__autoAllocateDepthBuffer){if(ae)throw new Error("target.depthTexture not supported in Cube render targets");xe(B.__webglFramebuffer,N)}else if(ae){B.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)e.bindFramebuffer(36160,B.__webglFramebuffer[ge]),B.__webglDepthbuffer[ge]=n.createRenderbuffer(),Ae(B.__webglDepthbuffer[ge],N,!1)}else e.bindFramebuffer(36160,B.__webglFramebuffer),B.__webglDepthbuffer=n.createRenderbuffer(),Ae(B.__webglDepthbuffer,N,!1);e.bindFramebuffer(36160,null)}function Oe(N,B,ae){let ge=r.get(N);B!==void 0&&J(ge.__webglFramebuffer,N,N.texture,36064,3553),ae!==void 0&&de(N)}function Ce(N){let B=N.texture,ae=r.get(N),ge=r.get(B);N.addEventListener("dispose",D),N.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=n.createTexture()),ge.__version=B.version,o.memory.textures++);let me=N.isWebGLCubeRenderTarget===!0,Le=N.isWebGLMultipleRenderTargets===!0,Ne=S(N)||a;if(me){ae.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)ae.__webglFramebuffer[Re]=n.createFramebuffer()}else{if(ae.__webglFramebuffer=n.createFramebuffer(),Le)if(i.drawBuffers){let Re=N.texture;for(let pe=0,rt=Re.length;pe<rt;pe++){let Ge=r.get(Re[pe]);Ge.__webglTexture===void 0&&(Ge.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&N.samples>0&&Ie(N)===!1){let Re=Le?B:[B];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe<Re.length;pe++){let rt=Re[pe];ae.__webglColorRenderbuffer[pe]=n.createRenderbuffer(),n.bindRenderbuffer(36161,ae.__webglColorRenderbuffer[pe]);let Ge=s.convert(rt.format,rt.encoding),Be=s.convert(rt.type),Je=b(rt.internalFormat,Ge,Be,rt.encoding,N.isXRRenderTarget===!0),nt=Ve(N);n.renderbufferStorageMultisample(36161,nt,Je,N.width,N.height),n.framebufferRenderbuffer(36160,36064+pe,36161,ae.__webglColorRenderbuffer[pe])}n.bindRenderbuffer(36161,null),N.depthBuffer&&(ae.__webglDepthRenderbuffer=n.createRenderbuffer(),Ae(ae.__webglDepthRenderbuffer,N,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ge.__webglTexture),Y(34067,B,Ne);for(let Re=0;Re<6;Re++)J(ae.__webglFramebuffer[Re],N,B,36064,34069+Re);A(B,Ne)&&M(34067),e.unbindTexture()}else if(Le){let Re=N.texture;for(let pe=0,rt=Re.length;pe<rt;pe++){let Ge=Re[pe],Be=r.get(Ge);e.bindTexture(3553,Be.__webglTexture),Y(3553,Ge,Ne),J(ae.__webglFramebuffer,N,Ge,36064+pe,3553),A(Ge,Ne)&&M(3553)}e.unbindTexture()}else{let Re=3553;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(a?Re=N.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Re,ge.__webglTexture),Y(Re,B,Ne),J(ae.__webglFramebuffer,N,B,36064,Re),A(B,Ne)&&M(Re),e.unbindTexture()}N.depthBuffer&&de(N)}function Ue(N){let B=S(N)||a,ae=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let ge=0,me=ae.length;ge<me;ge++){let Le=ae[ge];if(A(Le,B)){let Ne=N.isWebGLCubeRenderTarget?34067:3553,Re=r.get(Le).__webglTexture;e.bindTexture(Ne,Re),M(Ne),e.unbindTexture()}}}function ze(N){if(a&&N.samples>0&&Ie(N)===!1){let B=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],ae=N.width,ge=N.height,me=16384,Le=[],Ne=N.stencilBuffer?33306:36096,Re=r.get(N),pe=N.isWebGLMultipleRenderTargets===!0;if(pe)for(let rt=0;rt<B.length;rt++)e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+rt,36161,null),e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+rt,3553,null,0);e.bindFramebuffer(36008,Re.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Re.__webglFramebuffer);for(let rt=0;rt<B.length;rt++){Le.push(36064+rt),N.depthBuffer&&Le.push(Ne);let Ge=Re.__ignoreDepthValues!==void 0?Re.__ignoreDepthValues:!1;if(Ge===!1&&(N.depthBuffer&&(me|=256),N.stencilBuffer&&(me|=1024)),pe&&n.framebufferRenderbuffer(36008,36064,36161,Re.__webglColorRenderbuffer[rt]),Ge===!0&&(n.invalidateFramebuffer(36008,[Ne]),n.invalidateFramebuffer(36009,[Ne])),pe){let Be=r.get(B[rt]).__webglTexture;n.framebufferTexture2D(36009,36064,3553,Be,0)}n.blitFramebuffer(0,0,ae,ge,0,0,ae,ge,me,9728),f&&n.invalidateFramebuffer(36008,Le)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),pe)for(let rt=0;rt<B.length;rt++){e.bindFramebuffer(36160,Re.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064+rt,36161,Re.__webglColorRenderbuffer[rt]);let Ge=r.get(B[rt]).__webglTexture;e.bindFramebuffer(36160,Re.__webglFramebuffer),n.framebufferTexture2D(36009,36064+rt,3553,Ge,0)}e.bindFramebuffer(36009,Re.__webglMultisampledFramebuffer)}}function Ve(N){return Math.min(h,N.samples)}function Ie(N){let B=r.get(N);return a&&N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&B.__useRenderToTexture!==!1}function Ye(N){let B=o.render.frame;p.get(N)!==B&&(p.set(N,B),N.update())}function F(N,B){let ae=N.encoding,ge=N.format,me=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===CS||ae!==un&&(ae===at?a===!1?t.has("EXT_sRGB")===!0&&ge===jr?(N.format=CS,N.minFilter=tt,N.generateMipmaps=!1):B=Qg.sRGBToLinear(B):(ge!==jr||me!==Cr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),B}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=q,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=Oe,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=Ue,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Ie}function mG(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===Cr)return 5121;if(s===lF)return 32819;if(s===cF)return 32820;if(s===sF)return 5120;if(s===oF)return 5122;if(s===CC)return 5123;if(s===aF)return 5124;if(s===Ds)return 5125;if(s===yr)return 5126;if(s===jn)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===uF)return 6406;if(s===jr)return 6408;if(s===hF)return 6409;if(s===dF)return 6410;if(s===ac)return 6402;if(s===Qa)return 34041;if(s===CS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===fF)return 6403;if(s===pF)return 36244;if(s===Xu)return 33319;if(s===mF)return 33320;if(s===nw)return 36249;if(s===Ub||s===kb||s===Gb||s===jb)if(o===at)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ub)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===kb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Gb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===jb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ub)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===kb)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Gb)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===jb)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===JM||s===$M||s===eT||s===tT)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===JM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===$M)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===eT)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===tT)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===gF)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===rT||s===iT)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===rT)return o===at?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===iT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===nT||s===sT||s===oT||s===aT||s===lT||s===cT||s===uT||s===hT||s===dT||s===fT||s===pT||s===mT||s===gT||s===yT)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===nT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===sT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===oT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===aT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===lT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===cT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===uT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===hT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===dT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===fT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===pT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===mT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===yT)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Hb)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Hb)return o===at?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===yF||s===vT||s===xT||s===bT)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Hb)return a.COMPRESSED_RED_RGTC1_EXT;if(s===vT)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===xT)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===bT)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===qa?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var VS=class extends Kr{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},En=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},gG={type:"move"},ep=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new En,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new En,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new En,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(c,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gG)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new En;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ns=class extends Jt{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:ac,u!==ac&&u!==Qa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===ac&&(r=Ds),r===void 0&&u===Qa&&(r=qa),super(null,i,s,o,a,l,u,r,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Vt,this.minFilter=l!==void 0?l:Vt,this.flipY=!1,this.generateMipmaps=!1}},zS=class extends hr{constructor(t,e){super();let r=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],S=new Set,w=new Map,A=new Kr;A.layers.enable(1),A.viewport=new Ke;let M=new Kr;M.layers.enable(2),M.viewport=new Ke;let b=[A,M],T=new VS;T.layers.enable(1),T.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let Z=v[G];return Z===void 0&&(Z=new ep,v[G]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(G){let Z=v[G];return Z===void 0&&(Z=new ep,v[G]=Z),Z.getGripSpace()},this.getHand=function(G){let Z=v[G];return Z===void 0&&(Z=new ep,v[G]=Z),Z.getHandSpace()};function D(G){let Z=x.indexOf(G.inputSource);if(Z===-1)return;let te=v[Z];te!==void 0&&te.dispatchEvent({type:G.type,data:G.inputSource})}function _(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",_),i.removeEventListener("inputsourceschange",O);for(let G=0;G<v.length;G++){let Z=x[G];Z!==null&&(x[G]=null,v[G].disconnect(Z))}C=null,P=null,t.setRenderTarget(g),f=null,d=null,h=null,i=null,y=null,K.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(G){c=G},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(G){if(i=G,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",_),i.addEventListener("inputsourceschange",O),m.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Z={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,Z),i.updateRenderState({baseLayer:f}),y=new dt(f.framebufferWidth,f.framebufferHeight,{format:jr,type:Cr,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let Z=null,te=null,$=null;m.depth&&($=m.stencil?35056:33190,Z=m.stencil?Qa:ac,te=m.stencil?qa:Ds);let Y={colorFormat:32856,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,e),d=h.createProjectionLayer(Y),i.updateRenderState({layers:[d]}),y=new dt(d.textureWidth,d.textureHeight,{format:jr,type:Cr,depthTexture:new ns(d.textureWidth,d.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let oe=t.properties.get(y);oe.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),K.setContext(i),K.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function O(G){for(let Z=0;Z<G.removed.length;Z++){let te=G.removed[Z],$=x.indexOf(te);$>=0&&(x[$]=null,v[$].disconnect(te))}for(let Z=0;Z<G.added.length;Z++){let te=G.added[Z],$=x.indexOf(te);if($===-1){for(let oe=0;oe<v.length;oe++)if(oe>=x.length){x.push(te),$=oe;break}else if(x[oe]===null){x[oe]=te,$=oe;break}if($===-1)break}let Y=v[$];Y&&Y.connect(te)}}let L=new E,j=new E;function V(G,Z,te){L.setFromMatrixPosition(Z.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),Y=Z.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),re=Y[14]/(Y[10]+1),J=(Y[9]+1)/Y[5],Ae=(Y[9]-1)/Y[5],xe=(Y[8]-1)/Y[0],de=(oe[8]+1)/oe[0],Oe=ie*xe,Ce=ie*de,Ue=$/(-xe+de),ze=Ue*-xe;Z.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(ze),G.translateZ(Ue),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ve=ie+Ue,Ie=re+Ue,Ye=Oe-ze,F=Ce+($-ze),N=J*re/Ie*Ve,B=Ae*re/Ie*Ve;G.projectionMatrix.makePerspective(Ye,F,N,B,Ve,Ie)}function H(G,Z){Z===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(Z.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(i===null)return;T.near=M.near=A.near=G.near,T.far=M.far=A.far=G.far,(C!==T.near||P!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,P=T.far);let Z=G.parent,te=T.cameras;H(T,Z);for(let Y=0;Y<te.length;Y++)H(te[Y],Z);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),G.matrix.copy(T.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let $=G.children;for(let Y=0,oe=$.length;Y<oe;Y++)$[Y].updateMatrixWorld(!0);te.length===2?V(T,A,M):T.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(G){l=G,d!==null&&(d.fixedFoveation=G),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=G)},this.getPlanes=function(){return S};let W=null;function q(G,Z){if(u=Z.getViewerPose(c||o),p=Z,u!==null){let te=u.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let $=!1;te.length!==T.cameras.length&&(T.cameras.length=0,$=!0);for(let Y=0;Y<te.length;Y++){let oe=te[Y],ie=null;if(f!==null)ie=f.getViewport(oe);else{let J=h.getViewSubImage(d,oe);ie=J.viewport,Y===0&&(t.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),t.setRenderTarget(y))}let re=b[Y];re===void 0&&(re=new Kr,re.layers.enable(Y),re.viewport=new Ke,b[Y]=re),re.matrix.fromArray(oe.transform.matrix),re.projectionMatrix.fromArray(oe.projectionMatrix),re.viewport.set(ie.x,ie.y,ie.width,ie.height),Y===0&&T.matrix.copy(re.matrix),$===!0&&T.cameras.push(re)}}for(let te=0;te<v.length;te++){let $=x[te],Y=v[te];$!==null&&Y!==void 0&&Y.update($,Z,c||o)}if(W&&W(G,Z),Z.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:Z.detectedPlanes});let te=null;for(let $ of S)Z.detectedPlanes.has($)||(te===null&&(te=[]),te.push($));if(te!==null)for(let $ of te)S.delete($),w.delete($),r.dispatchEvent({type:"planeremoved",data:$});for(let $ of Z.detectedPlanes)if(!S.has($))S.add($),w.set($,Z.lastChangedTime),r.dispatchEvent({type:"planeadded",data:$});else{let Y=w.get($);$.lastChangedTime>Y&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}p=null}let K=new RC;K.setAnimationLoop(q),this.setAnimationLoop=function(G){W=G},this.dispose=function(){}}};function yG(n,t){function e(m,g){g.color.getRGB(m.fogColor.value,IC(n)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(m,g):g.isMeshToonMaterial?(i(m,g),u(m,g)):g.isMeshPhongMaterial?(i(m,g),c(m,g)):g.isMeshStandardMaterial?(i(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(i(m,g),f(m,g)):g.isMeshDepthMaterial?i(m,g):g.isMeshDistanceMaterial?(i(m,g),p(m,g)):g.isMeshNormalMaterial?i(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===ui&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===ui&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let S=n.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*S}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function c(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===ui&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function vG(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(v,x){let S=x.program;r.uniformBlockBinding(v,S)}function c(v,x){let S=i[v.id];S===void 0&&(p(v),S=u(v),i[v.id]=S,v.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function u(v){let x=h();v.__bindingPointIndex=x;let S=n.createBuffer(),w=v.__size,A=v.usage;return n.bindBuffer(35345,S),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,x,S),S}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=i[v.id],S=v.uniforms,w=v.__cache;n.bindBuffer(35345,x);for(let A=0,M=S.length;A<M;A++){let b=S[A];if(f(b,A,w)===!0){let T=b.__offset,C=Array.isArray(b.value)?b.value:[b.value],P=0;for(let D=0;D<C.length;D++){let _=C[D],O=m(_);typeof _=="number"?(b.__data[0]=_,n.bufferSubData(35345,T+P,b.__data)):_.isMatrix3?(b.__data[0]=_.elements[0],b.__data[1]=_.elements[1],b.__data[2]=_.elements[2],b.__data[3]=_.elements[0],b.__data[4]=_.elements[3],b.__data[5]=_.elements[4],b.__data[6]=_.elements[5],b.__data[7]=_.elements[0],b.__data[8]=_.elements[6],b.__data[9]=_.elements[7],b.__data[10]=_.elements[8],b.__data[11]=_.elements[0]):(_.toArray(b.__data,P),P+=O.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(35345,T,b.__data)}}n.bindBuffer(35345,null)}function f(v,x,S){let w=v.value;if(S[x]===void 0){if(typeof w=="number")S[x]=w;else{let A=Array.isArray(w)?w:[w],M=[];for(let b=0;b<A.length;b++)M.push(A[b].clone());S[x]=M}return!0}else if(typeof w=="number"){if(S[x]!==w)return S[x]=w,!0}else{let A=Array.isArray(S[x])?S[x]:[S[x]],M=Array.isArray(w)?w:[w];for(let b=0;b<A.length;b++){let T=A[b];if(T.equals(M[b])===!1)return T.copy(M[b]),!0}}return!1}function p(v){let x=v.uniforms,S=0,w=16,A=0;for(let M=0,b=x.length;M<b;M++){let T=x[M],C={boundary:0,storage:0},P=Array.isArray(T.value)?T.value:[T.value];for(let D=0,_=P.length;D<_;D++){let O=P[D],L=m(O);C.boundary+=L.boundary,C.storage+=L.storage}if(T.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=S,M>0){A=S%w;let D=w-A;A!==0&&D-C.boundary<0&&(S+=w-A,T.__offset=S)}S+=C.storage}return A=S%w,A>0&&(S+=w-A),v.__size=S,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function xG(){let n=sp("canvas");return n.style.display="block",n}function hw(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:xG(),e=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,u;e!==null?u=e.getContextAttributes().alpha:u=n.alpha!==void 0?n.alpha:!1;let h=null,d=null,f=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=un,this.physicallyCorrectLights=!1,this.toneMapping=Os,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,S=-1,w=null,A=new Ke,M=new Ke,b=null,T=t.width,C=t.height,P=1,D=null,_=null,O=new Ke(0,0,T,C),L=new Ke(0,0,T,C),j=!1,V=new ap,H=!1,W=!1,q=null,K=new ce,G=new U,Z=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return x===null?P:1}let Y=e;function oe(k,le){for(let ve=0;ve<k.length;ve++){let se=k[ve],be=t.getContext(se,le);if(be!==null)return be}return null}try{let k={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${oa}`),t.addEventListener("webglcontextlost",Je,!1),t.addEventListener("webglcontextrestored",nt,!1),t.addEventListener("webglcontextcreationerror",Bt,!1),Y===null){let le=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&le.shift(),Y=oe(le,k),Y===null)throw oe(le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Y.getShaderPrecisionFormat===void 0&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let ie,re,J,Ae,xe,de,Oe,Ce,Ue,ze,Ve,Ie,Ye,F,N,B,ae,ge,me,Le,Ne,Re,pe,rt;function Ge(){ie=new UU(Y),re=new LU(Y,ie,n),ie.init(re),Re=new mG(Y,ie,re),J=new fG(Y,ie,re),Ae=new jU,xe=new tG,de=new pG(Y,ie,J,xe,re,Re,Ae),Oe=new NU(m),Ce=new zU(m),Ue=new JF(Y,re),pe=new IU(Y,ie,Ue,re),ze=new kU(Y,Ue,Ae,pe),Ve=new YU(Y,ze,Ue,Ae),me=new qU(Y,re,de),B=new BU(xe),Ie=new eG(m,Oe,Ce,ie,re,pe,B),Ye=new yG(m,xe),F=new iG,N=new cG(ie,re),ge=new OU(m,Oe,Ce,J,Ve,u,o),ae=new dG(m,Ve,re),rt=new vG(Y,Ae,re,J),Le=new RU(Y,ie,Ae,re),Ne=new GU(Y,ie,Ae,re),Ae.programs=Ie.programs,m.capabilities=re,m.extensions=ie,m.properties=xe,m.renderLists=F,m.shadowMap=ae,m.state=J,m.info=Ae}Ge();let Be=new zS(m,Y);this.xr=Be,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){let k=ie.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){let k=ie.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(k){k!==void 0&&(P=k,this.setSize(T,C,!1))},this.getSize=function(k){return k.set(T,C)},this.setSize=function(k,le,ve){if(Be.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=k,C=le,t.width=Math.floor(k*P),t.height=Math.floor(le*P),ve!==!1&&(t.style.width=k+"px",t.style.height=le+"px"),this.setViewport(0,0,k,le)},this.getDrawingBufferSize=function(k){return k.set(T*P,C*P).floor()},this.setDrawingBufferSize=function(k,le,ve){T=k,C=le,P=ve,t.width=Math.floor(k*ve),t.height=Math.floor(le*ve),this.setViewport(0,0,k,le)},this.getCurrentViewport=function(k){return k.copy(A)},this.getViewport=function(k){return k.copy(O)},this.setViewport=function(k,le,ve,se){k.isVector4?O.set(k.x,k.y,k.z,k.w):O.set(k,le,ve,se),J.viewport(A.copy(O).multiplyScalar(P).floor())},this.getScissor=function(k){return k.copy(L)},this.setScissor=function(k,le,ve,se){k.isVector4?L.set(k.x,k.y,k.z,k.w):L.set(k,le,ve,se),J.scissor(M.copy(L).multiplyScalar(P).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(k){J.setScissorTest(j=k)},this.setOpaqueSort=function(k){D=k},this.setTransparentSort=function(k){_=k},this.getClearColor=function(k){return k.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(k=!0,le=!0,ve=!0){let se=0;k&&(se|=16384),le&&(se|=256),ve&&(se|=1024),Y.clear(se)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Je,!1),t.removeEventListener("webglcontextrestored",nt,!1),t.removeEventListener("webglcontextcreationerror",Bt,!1),F.dispose(),N.dispose(),xe.dispose(),Oe.dispose(),Ce.dispose(),Ve.dispose(),pe.dispose(),rt.dispose(),Ie.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",je),Be.removeEventListener("sessionend",He),q&&(q.dispose(),q=null),_t.stop()};function Je(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function nt(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let k=Ae.autoReset,le=ae.enabled,ve=ae.autoUpdate,se=ae.needsUpdate,be=ae.type;Ge(),Ae.autoReset=k,ae.enabled=le,ae.autoUpdate=ve,ae.needsUpdate=se,ae.type=be}function Bt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function ur(k){let le=k.target;le.removeEventListener("dispose",ur),Ar(le)}function Ar(k){Q(k),xe.remove(k)}function Q(k){let le=xe.get(k).programs;le!==void 0&&(le.forEach(function(ve){Ie.releaseProgram(ve)}),k.isShaderMaterial&&Ie.releaseShaderCache(k))}this.renderBufferDirect=function(k,le,ve,se,be,ct){le===null&&(le=te);let mt=be.isMesh&&be.matrixWorld.determinant()<0,wt=Rb(k,le,ve,se,be);J.setMaterial(se,mt);let Tt=ve.index,kt=1;se.wireframe===!0&&(Tt=ze.getWireframeAttribute(ve),kt=2);let Nt=ve.drawRange,Dt=ve.attributes.position,Ft=Nt.start*kt,Ji=(Nt.start+Nt.count)*kt;ct!==null&&(Ft=Math.max(Ft,ct.start*kt),Ji=Math.min(Ji,(ct.start+ct.count)*kt)),Tt!==null?(Ft=Math.max(Ft,0),Ji=Math.min(Ji,Tt.count)):Dt!=null&&(Ft=Math.max(Ft,0),Ji=Math.min(Ji,Dt.count));let $i=Ji-Ft;if($i<0||$i===1/0)return;pe.setup(be,se,wt,ve,Tt);let oo,gt=Le;if(Tt!==null&&(oo=Ue.get(Tt),gt=Ne,gt.setIndex(oo)),be.isMesh)se.wireframe===!0?(J.setLineWidth(se.wireframeLinewidth*$()),gt.setMode(1)):gt.setMode(4);else if(be.isLine){let Rt=se.linewidth;Rt===void 0&&(Rt=1),J.setLineWidth(Rt*$()),be.isLineSegments?gt.setMode(1):be.isLineLoop?gt.setMode(2):gt.setMode(3)}else be.isPoints?gt.setMode(0):be.isSprite&>.setMode(4);if(be.isInstancedMesh)gt.renderInstances(Ft,$i,be.count);else if(ve.isInstancedBufferGeometry){let Rt=ve._maxInstanceCount!==void 0?ve._maxInstanceCount:1/0,nu=Math.min(ve.instanceCount,Rt);gt.renderInstances(Ft,$i,nu)}else gt.render(Ft,$i)},this.compile=function(k,le){function ve(se,be,ct){se.transparent===!0&&se.side===ji&&se.forceSinglePass===!1?(se.side=ui,se.needsUpdate=!0,An(se,be,ct),se.side=Gn,se.needsUpdate=!0,An(se,be,ct),se.side=ji):An(se,be,ct)}d=N.get(k),d.init(),p.push(d),k.traverseVisible(function(se){se.isLight&&se.layers.test(le.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(m.physicallyCorrectLights),k.traverse(function(se){let be=se.material;if(be)if(Array.isArray(be))for(let ct=0;ct<be.length;ct++){let mt=be[ct];ve(mt,k,se)}else ve(be,k,se)}),p.pop(),d=null};let ye=null;function Me(k){ye&&ye(k)}function je(){_t.stop()}function He(){_t.start()}let _t=new RC;_t.setAnimationLoop(Me),typeof self<"u"&&_t.setContext(self),this.setAnimationLoop=function(k){ye=k,Be.setAnimationLoop(k),k===null?_t.stop():_t.start()},Be.addEventListener("sessionstart",je),Be.addEventListener("sessionend",He),this.render=function(k,le){if(le!==void 0&&le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(le),le=Be.getCamera()),k.isScene===!0&&k.onBeforeRender(m,k,le,x),d=N.get(k,p.length),d.init(),p.push(d),K.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),V.setFromProjectionMatrix(K),W=this.localClippingEnabled,H=B.init(this.clippingPlanes,W),h=F.get(k,f.length),h.init(),f.push(h),Br(k,le,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(D,_),H===!0&&B.beginShadows();let ve=d.state.shadowsArray;if(ae.render(ve,k,le),H===!0&&B.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(h,k),d.setupLights(m.physicallyCorrectLights),le.isArrayCamera){let se=le.cameras;for(let be=0,ct=se.length;be<ct;be++){let mt=se[be];Nr(h,k,mt,mt.viewport)}}else Nr(h,k,le);x!==null&&(de.updateMultisampleRenderTarget(x),de.updateRenderTargetMipmap(x)),k.isScene===!0&&k.onAfterRender(m,k,le),pe.resetDefaultState(),S=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Br(k,le,ve,se){if(k.visible===!1)return;if(k.layers.test(le.layers)){if(k.isGroup)ve=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(le);else if(k.isLight)d.pushLight(k),k.castShadow&&d.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||V.intersectsSprite(k)){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),wt=k.material;wt.visible&&h.push(k,mt,wt,ve,Z.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(k.isSkinnedMesh&&k.skeleton.frame!==Ae.render.frame&&(k.skeleton.update(),k.skeleton.frame=Ae.render.frame),!k.frustumCulled||V.intersectsObject(k))){se&&Z.setFromMatrixPosition(k.matrixWorld).applyMatrix4(K);let mt=Ve.update(k),wt=k.material;if(Array.isArray(wt)){let Tt=mt.groups;for(let kt=0,Nt=Tt.length;kt<Nt;kt++){let Dt=Tt[kt],Ft=wt[Dt.materialIndex];Ft&&Ft.visible&&h.push(k,mt,Ft,ve,Z.z,Dt)}}else wt.visible&&h.push(k,mt,wt,ve,Z.z,null)}}let ct=k.children;for(let mt=0,wt=ct.length;mt<wt;mt++)Br(ct[mt],le,ve,se)}function Nr(k,le,ve,se){let be=k.opaque,ct=k.transmissive,mt=k.transparent;d.setupLightsView(ve),H===!0&&B.setGlobalState(m.clippingPlanes,ve),ct.length>0&&Xo(be,le,ve),se&&J.viewport(A.copy(se)),be.length>0&&Er(be,le,ve),ct.length>0&&Er(ct,le,ve),mt.length>0&&Er(mt,le,ve),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Xo(k,le,ve){let se=re.isWebGL2;q===null&&(q=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?jn:Cr,minFilter:cc,samples:se&&s===!0?4:0})),m.getDrawingBufferSize(G),se?q.setSize(G.x,G.y):q.setSize(Xg(G.x),Xg(G.y));let be=m.getRenderTarget();m.setRenderTarget(q),m.clear();let ct=m.toneMapping;m.toneMapping=Os,Er(k,le,ve),m.toneMapping=ct,de.updateMultisampleRenderTarget(q),de.updateRenderTargetMipmap(q),m.setRenderTarget(be)}function Er(k,le,ve){let se=le.isScene===!0?le.overrideMaterial:null;for(let be=0,ct=k.length;be<ct;be++){let mt=k[be],wt=mt.object,Tt=mt.geometry,kt=se===null?mt.material:se,Nt=mt.group;wt.layers.test(ve.layers)&&es(wt,le,ve,Tt,kt,Nt)}}function es(k,le,ve,se,be,ct){k.onBeforeRender(m,le,ve,se,be,ct),k.modelViewMatrix.multiplyMatrices(ve.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),be.onBeforeRender(m,le,ve,se,k,ct),be.transparent===!0&&be.side===ji&&be.forceSinglePass===!1?(be.side=ui,be.needsUpdate=!0,m.renderBufferDirect(ve,le,se,be,k,ct),be.side=Gn,be.needsUpdate=!0,m.renderBufferDirect(ve,le,se,be,k,ct),be.side=ji):m.renderBufferDirect(ve,le,se,be,k,ct),k.onAfterRender(m,le,ve,se,be,ct)}function An(k,le,ve){le.isScene!==!0&&(le=te);let se=xe.get(k),be=d.state.lights,ct=d.state.shadowsArray,mt=be.state.version,wt=Ie.getParameters(k,be.state,ct,le,ve),Tt=Ie.getProgramCacheKey(wt),kt=se.programs;se.environment=k.isMeshStandardMaterial?le.environment:null,se.fog=le.fog,se.envMap=(k.isMeshStandardMaterial?Ce:Oe).get(k.envMap||se.environment),kt===void 0&&(k.addEventListener("dispose",ur),kt=new Map,se.programs=kt);let Nt=kt.get(Tt);if(Nt!==void 0){if(se.currentProgram===Nt&&se.lightsStateVersion===mt)return zf(k,wt),Nt}else wt.uniforms=Ie.getUniforms(k),k.onBuild(ve,wt,m),k.onBeforeCompile(wt,m),Nt=Ie.acquireProgram(wt,Tt),kt.set(Tt,Nt),se.uniforms=wt.uniforms;let Dt=se.uniforms;(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Dt.clippingPlanes=B.uniform),zf(k,wt),se.needsLights=Bb(k),se.lightsStateVersion=mt,se.needsLights&&(Dt.ambientLightColor.value=be.state.ambient,Dt.lightProbe.value=be.state.probe,Dt.directionalLights.value=be.state.directional,Dt.directionalLightShadows.value=be.state.directionalShadow,Dt.spotLights.value=be.state.spot,Dt.spotLightShadows.value=be.state.spotShadow,Dt.rectAreaLights.value=be.state.rectArea,Dt.ltc_1.value=be.state.rectAreaLTC1,Dt.ltc_2.value=be.state.rectAreaLTC2,Dt.pointLights.value=be.state.point,Dt.pointLightShadows.value=be.state.pointShadow,Dt.hemisphereLights.value=be.state.hemi,Dt.directionalShadowMap.value=be.state.directionalShadowMap,Dt.directionalShadowMatrix.value=be.state.directionalShadowMatrix,Dt.spotShadowMap.value=be.state.spotShadowMap,Dt.spotLightMatrix.value=be.state.spotLightMatrix,Dt.spotLightMap.value=be.state.spotLightMap,Dt.pointShadowMap.value=be.state.pointShadowMap,Dt.pointShadowMatrix.value=be.state.pointShadowMatrix);let Ft=Nt.getUniforms(),Ji=Cu.seqWithValue(Ft.seq,Dt);return se.currentProgram=Nt,se.uniformsList=Ji,Nt}function zf(k,le){let ve=xe.get(k);ve.outputEncoding=le.outputEncoding,ve.instancing=le.instancing,ve.skinning=le.skinning,ve.morphTargets=le.morphTargets,ve.morphNormals=le.morphNormals,ve.morphColors=le.morphColors,ve.morphTargetsCount=le.morphTargetsCount,ve.numClippingPlanes=le.numClippingPlanes,ve.numIntersection=le.numClipIntersection,ve.vertexAlphas=le.vertexAlphas,ve.vertexTangents=le.vertexTangents,ve.toneMapping=le.toneMapping}function Rb(k,le,ve,se,be){le.isScene!==!0&&(le=te),de.resetTextureUnits();let ct=le.fog,mt=se.isMeshStandardMaterial?le.environment:null,wt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:un,Tt=(se.isMeshStandardMaterial?Ce:Oe).get(se.envMap||mt),kt=se.vertexColors===!0&&!!ve.attributes.color&&ve.attributes.color.itemSize===4,Nt=!!se.normalMap&&!!ve.attributes.tangent,Dt=!!ve.morphAttributes.position,Ft=!!ve.morphAttributes.normal,Ji=!!ve.morphAttributes.color,$i=se.toneMapped?m.toneMapping:Os,oo=ve.morphAttributes.position||ve.morphAttributes.normal||ve.morphAttributes.color,gt=oo!==void 0?oo.length:0,Rt=xe.get(se),nu=d.state.lights;if(H===!0&&(W===!0||k!==w)){let ai=k===w&&se.id===S;B.setState(se,k,ai)}let oi=!1;se.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==nu.state.version||Rt.outputEncoding!==wt||be.isInstancedMesh&&Rt.instancing===!1||!be.isInstancedMesh&&Rt.instancing===!0||be.isSkinnedMesh&&Rt.skinning===!1||!be.isSkinnedMesh&&Rt.skinning===!0||Rt.envMap!==Tt||se.fog===!0&&Rt.fog!==ct||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==B.numPlanes||Rt.numIntersection!==B.numIntersection)||Rt.vertexAlphas!==kt||Rt.vertexTangents!==Nt||Rt.morphTargets!==Dt||Rt.morphNormals!==Ft||Rt.morphColors!==Ji||Rt.toneMapping!==$i||re.isWebGL2===!0&&Rt.morphTargetsCount!==gt)&&(oi=!0):(oi=!0,Rt.__version=se.version);let ao=Rt.currentProgram;oi===!0&&(ao=An(se,le,be));let su=!1,zn=!1,At=!1,gi=ao.getUniforms(),ts=Rt.uniforms;if(J.useProgram(ao.program)&&(su=!0,zn=!0,At=!0),se.id!==S&&(S=se.id,zn=!0),su||w!==k){if(gi.setValue(Y,"projectionMatrix",k.projectionMatrix),re.logarithmicDepthBuffer&&gi.setValue(Y,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),w!==k&&(w=k,zn=!0,At=!0),se.isShaderMaterial||se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshStandardMaterial||se.envMap){let ai=gi.map.cameraPosition;ai!==void 0&&ai.setValue(Y,Z.setFromMatrixPosition(k.matrixWorld))}(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&gi.setValue(Y,"isOrthographic",k.isOrthographicCamera===!0),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial||se.isShadowMaterial||be.isSkinnedMesh)&&gi.setValue(Y,"viewMatrix",k.matrixWorldInverse)}if(be.isSkinnedMesh){gi.setOptional(Y,be,"bindMatrix"),gi.setOptional(Y,be,"bindMatrixInverse");let ai=be.skeleton;ai&&(re.floatVertexTextures?(ai.boneTexture===null&&ai.computeBoneTexture(),gi.setValue(Y,"boneTexture",ai.boneTexture,de),gi.setValue(Y,"boneTextureSize",ai.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let ou=ve.morphAttributes;if((ou.position!==void 0||ou.normal!==void 0||ou.color!==void 0&&re.isWebGL2===!0)&&me.update(be,ve,se,ao),(zn||Rt.receiveShadow!==be.receiveShadow)&&(Rt.receiveShadow=be.receiveShadow,gi.setValue(Y,"receiveShadow",be.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(ts.envMap.value=Tt,ts.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),zn&&(gi.setValue(Y,"toneMappingExposure",m.toneMappingExposure),Rt.needsLights&&Lb(ts,At),ct&&se.fog===!0&&Ye.refreshFogUniforms(ts,ct),Ye.refreshMaterialUniforms(ts,se,P,C,q),Cu.upload(Y,Rt.uniformsList,ts,de)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(Cu.upload(Y,Rt.uniformsList,ts,de),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&gi.setValue(Y,"center",be.center),gi.setValue(Y,"modelViewMatrix",be.modelViewMatrix),gi.setValue(Y,"normalMatrix",be.normalMatrix),gi.setValue(Y,"modelMatrix",be.matrixWorld),be.previousModelViewMatrix&&gi.setValue(Y,"previousModelViewMatrix",be.previousModelViewMatrix),k.previousProjectionMatrix&&gi.setValue(Y,"previousProjectionMatrix",k.previousProjectionMatrix),se.isShaderMaterial||se.isRawShaderMaterial){let ai=se.uniformsGroups;for(let I=0,R=ai.length;I<R;I++)if(re.isWebGL2){let X=ai[I];rt.update(X,ao),rt.bind(X,ao)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ao}function Lb(k,le){k.ambientLightColor.needsUpdate=le,k.lightProbe.needsUpdate=le,k.directionalLights.needsUpdate=le,k.directionalLightShadows.needsUpdate=le,k.pointLights.needsUpdate=le,k.pointLightShadows.needsUpdate=le,k.spotLights.needsUpdate=le,k.spotLightShadows.needsUpdate=le,k.rectAreaLights.needsUpdate=le,k.hemisphereLights.needsUpdate=le}function Bb(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(k,le,ve){xe.get(k.texture).__webglTexture=le,xe.get(k.depthTexture).__webglTexture=ve;let se=xe.get(k);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=ve===void 0,se.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(k,le){let ve=xe.get(k);ve.__webglFramebuffer=le,ve.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(k,le=0,ve=0){x=k,y=le,v=ve;let se=!0,be=null,ct=!1,mt=!1;if(k){let Tt=xe.get(k);Tt.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),se=!1):Tt.__webglFramebuffer===void 0?de.setupRenderTarget(k):Tt.__hasExternalTextures&&de.rebindTextures(k,xe.get(k.texture).__webglTexture,xe.get(k.depthTexture).__webglTexture);let kt=k.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(mt=!0);let Nt=xe.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(be=Nt[le],ct=!0):re.isWebGL2&&k.samples>0&&de.useMultisampledRTT(k)===!1?be=xe.get(k).__webglMultisampledFramebuffer:be=Nt,A.copy(k.viewport),M.copy(k.scissor),b=k.scissorTest}else A.copy(O).multiplyScalar(P).floor(),M.copy(L).multiplyScalar(P).floor(),b=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&se&&J.drawBuffers(k,be),J.viewport(A),J.scissor(M),J.setScissorTest(b),ct){let Tt=xe.get(k.texture);Y.framebufferTexture2D(36160,36064,34069+le,Tt.__webglTexture,ve)}else if(mt){let Tt=xe.get(k.texture),kt=le||0;Y.framebufferTextureLayer(36160,36064,Tt.__webglTexture,ve||0,kt)}S=-1},this.readRenderTargetPixels=function(k,le,ve,se,be,ct,mt){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let wt=xe.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&mt!==void 0&&(wt=wt[mt]),wt){J.bindFramebuffer(36160,wt);try{let Tt=k.texture,kt=Tt.format,Nt=Tt.type;if(kt!==jr&&Re.convert(kt)!==Y.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Dt=Nt===jn&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Nt!==Cr&&Re.convert(Nt)!==Y.getParameter(35738)&&!(Nt===yr&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!Dt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=k.width-se&&ve>=0&&ve<=k.height-be&&Y.readPixels(le,ve,se,be,Re.convert(kt),Re.convert(Nt),ct)}finally{let Tt=x!==null?xe.get(x).__webglFramebuffer:null;J.bindFramebuffer(36160,Tt)}}},this.copyFramebufferToTexture=function(k,le,ve=0){let se=Math.pow(2,-ve),be=Math.floor(le.image.width*se),ct=Math.floor(le.image.height*se);de.setTexture2D(le,0),Y.copyTexSubImage2D(3553,ve,0,0,k.x,k.y,be,ct),J.unbindTexture()},this.copyTextureToTexture=function(k,le,ve,se=0){let be=le.image.width,ct=le.image.height,mt=Re.convert(ve.format),wt=Re.convert(ve.type);de.setTexture2D(ve,0),Y.pixelStorei(37440,ve.flipY),Y.pixelStorei(37441,ve.premultiplyAlpha),Y.pixelStorei(3317,ve.unpackAlignment),le.isDataTexture?Y.texSubImage2D(3553,se,k.x,k.y,be,ct,mt,wt,le.image.data):le.isCompressedTexture?Y.compressedTexSubImage2D(3553,se,k.x,k.y,le.mipmaps[0].width,le.mipmaps[0].height,mt,le.mipmaps[0].data):Y.texSubImage2D(3553,se,k.x,k.y,mt,wt,le.image),se===0&&ve.generateMipmaps&&Y.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(k,le,ve,se,be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ct=k.max.x-k.min.x+1,mt=k.max.y-k.min.y+1,wt=k.max.z-k.min.z+1,Tt=Re.convert(se.format),kt=Re.convert(se.type),Nt;if(se.isData3DTexture)de.setTexture3D(se,0),Nt=32879;else if(se.isDataArrayTexture)de.setTexture2DArray(se,0),Nt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(37440,se.flipY),Y.pixelStorei(37441,se.premultiplyAlpha),Y.pixelStorei(3317,se.unpackAlignment);let Dt=Y.getParameter(3314),Ft=Y.getParameter(32878),Ji=Y.getParameter(3316),$i=Y.getParameter(3315),oo=Y.getParameter(32877),gt=ve.isCompressedTexture?ve.mipmaps[0]:ve.image;Y.pixelStorei(3314,gt.width),Y.pixelStorei(32878,gt.height),Y.pixelStorei(3316,k.min.x),Y.pixelStorei(3315,k.min.y),Y.pixelStorei(32877,k.min.z),ve.isDataTexture||ve.isData3DTexture?Y.texSubImage3D(Nt,be,le.x,le.y,le.z,ct,mt,wt,Tt,kt,gt.data):ve.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Nt,be,le.x,le.y,le.z,ct,mt,wt,Tt,gt.data)):Y.texSubImage3D(Nt,be,le.x,le.y,le.z,ct,mt,wt,Tt,kt,gt),Y.pixelStorei(3314,Dt),Y.pixelStorei(32878,Ft),Y.pixelStorei(3316,Ji),Y.pixelStorei(3315,$i),Y.pixelStorei(32877,oo),be===0&&se.generateMipmaps&&Y.generateMipmap(Nt),J.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?de.setTextureCube(k,0):k.isData3DTexture?de.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?de.setTexture2DArray(k,0):de.setTexture2D(k,0),J.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var US=class extends hw{};US.prototype.isWebGL1Renderer=!0;var Du=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new We(t),this.near=e,this.far=r}clone(){return new Du(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},bi=class extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},ry=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=TS,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=is()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[r+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=is()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=is()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},ln=new E,hc=class{constructor(t,e,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)ln.fromBufferAttribute(this,e),ln.applyMatrix4(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)ln.fromBufferAttribute(this,e),ln.applyNormalMatrix(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)ln.fromBufferAttribute(this,e),ln.transformDirection(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}setX(t,e){return this.normalized&&(e=gr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=gr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=gr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=gr(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=na(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=na(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=na(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=na(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array),i=gr(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=gr(e,this.array),r=gr(r,this.array),i=gr(i,this.array),s=gr(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Xe(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new hc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var cp=class extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}},di=class extends Jt{constructor(t=null,e=1,r=1,i,s,o,a,l,c=Vt,u=Vt,h,d){super(null,o,a,l,c,u,i,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},eC=new ce,bG=new ce,Za=class{constructor(t=[],e=[]){this.uuid=is(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,i=this.bones.length;r<i;r++)this.boneInverses.push(new ce)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ce;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,i=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:bG;eC.multiplyMatrices(a,e[s]),eC.toArray(r,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Za(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=_C(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new di(e,t,t,jr,yr);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,i=t.bones.length;r<i;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new cp),this.bones.push(o),this.boneInverses.push(new ce().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let i=0,s=e.length;i<s;i++){let o=e[i];t.bones.push(o.uuid);let a=r[i];t.boneInverses.push(a.toArray())}return t}},ho=class extends Xe{constructor(t,e,r,i=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},tC=new ce,rC=new ce,Bg=[],SG=new ce,Xf=new Xt,iy=class extends Xt{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ho(new Float32Array(r*16),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1;for(let i=0;i<r;i++)this.setMatrixAt(i,SG)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}raycast(t,e){let r=this.matrixWorld,i=this.count;if(Xf.geometry=this.geometry,Xf.material=this.material,Xf.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,tC),rC.multiplyMatrices(r,tC),Xf.matrixWorld=rC,Xf.raycast(t,Bg);for(let o=0,a=Bg.length;o<a;o++){let l=Bg[o];l.instanceId=s,l.object=this,e.push(l)}Bg.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new ho(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},ss=class extends uc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},iC=new E,nC=new E,sC=new ce,gS=new Rs,Ng=new Dr,dc=class extends Et{constructor(t=new _e,e=new ss){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let i=1,s=e.count;i<s;i++)iC.fromBufferAttribute(e,i-1),nC.fromBufferAttribute(e,i),r[i]=r[i-1],r[i]+=iC.distanceTo(nC);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ng.copy(r.boundingSphere),Ng.applyMatrix4(i),Ng.radius+=s,t.ray.intersectsSphere(Ng)===!1)return;sC.copy(i).invert(),gS.copy(t.ray).applyMatrix4(sC);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new E,u=new E,h=new E,d=new E,f=this.isLineSegments?2:1,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){let w=p.getX(x),A=p.getX(x+1);if(c.fromBufferAttribute(g,w),u.fromBufferAttribute(g,A),gS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,S=v-1;x<S;x+=f){if(c.fromBufferAttribute(g,x),u.fromBufferAttribute(g,x+1),gS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},oC=new E,aC=new E,Ja=class extends dc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let i=0,s=e.count;i<s;i+=2)oC.fromBufferAttribute(e,i),aC.fromBufferAttribute(e,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+oC.distanceTo(aC);t.setAttribute("lineDistance",new Te(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ny=class extends Jt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:tt,this.magFilter=s!==void 0?s:tt,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var sy=class extends Jt{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},os=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),i=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let u=r[i],d=r[i+1]-u,f=(o-u)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new U:new E);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new E,i=[],s=[],o=[],a=new E,l=new ce;for(let f=0;f<=t;f++){let p=f/t;i[f]=this.getTangentAt(p,new E)}s[0]=new E,o[0]=new E;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(ci(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(ci(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},fc=class extends os{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new U,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},kS=class extends fc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function dw(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return n+t*s+e*o+r*a}}}var Fg=new E,yS=new dw,vS=new dw,xS=new dw,GS=class extends os{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new E){let r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(Fg.subVectors(i[0],i[1]).add(i[0]),c=Fg);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(Fg.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=Fg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(u),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),yS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,m,g),vS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,m,g),xS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,m,g)}else this.curveType==="catmullrom"&&(yS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),vS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),xS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(yS.calc(l),vS.calc(l),xS.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new E().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function lC(n,t,e,r,i){let s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function wG(n,t){let e=1-n;return e*e*t}function AG(n,t){return 2*(1-n)*n*t}function EG(n,t){return n*n*t}function tp(n,t,e,r){return wG(n,t)+AG(n,e)+EG(n,r)}function MG(n,t){let e=1-n;return e*e*e*t}function TG(n,t){let e=1-n;return 3*e*e*n*t}function CG(n,t){return 3*(1-n)*n*n*t}function PG(n,t){return n*n*n*t}function rp(n,t,e,r,i){return MG(n,t)+TG(n,e)+CG(n,r)+PG(n,i)}var tn=class extends os{constructor(t=new U,e=new U,r=new U,i=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(rp(t,i.x,s.x,o.x,a.x),rp(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},pc=class extends os{constructor(t=new E,e=new E,r=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(rp(t,i.x,s.x,o.x,a.x),rp(t,i.y,s.y,o.y,a.y),rp(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},rn=class extends os{constructor(t=new U,e=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new U){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new U;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},up=class extends os{constructor(t=new E,e=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new E){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},qn=class extends os{constructor(t=new U,e=new U,r=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new U){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(tp(t,i.x,s.x,o.x),tp(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},jS=class extends os{constructor(t=new E,e=new E,r=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new E){let r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(tp(t,i.x,s.x,o.x),tp(t,i.y,s.y,o.y),tp(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ou=class extends os{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new U){let r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return r.set(lC(a,l.x,c.x,u.x,h.x),lC(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let i=t.points[e];this.points.push(new U().fromArray(i))}return this}},_G=Object.freeze({__proto__:null,ArcCurve:kS,CatmullRomCurve3:GS,CubicBezierCurve:tn,CubicBezierCurve3:pc,EllipseCurve:fc,LineCurve:rn,LineCurve3:up,QuadraticBezierCurve:qn,QuadraticBezierCurve3:jS,SplineCurve:Ou}),hp=class extends os{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new rn(e,t))}getPoint(t,e){let r=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];r&&r.equals(u)||(e.push(u),r=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let i=t.curves[e];this.curves.push(new _G[i.type]().fromJSON(i))}return this}},mc=class extends hp{constructor(t){super(),this.type="Path",this.currentPoint=new U,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new rn(this.currentPoint.clone(),new U(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){let s=new qn(this.currentPoint.clone(),new U(t,e),new U(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){let a=new tn(this.currentPoint.clone(),new U(t,e),new U(r,i),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new Ou(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+c,e+u,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){let c=new fc(t,e,r,i,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Iu=class extends _e{constructor(t=[new U(0,-.5),new U(.5,0),new U(0,.5)],e=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=Math.floor(e),i=ci(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new U,f=new E,p=new E,m=new E,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*i,S=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*S,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let M=l[3*A+0]*S,b=l[3*A+1],T=l[3*A+0]*w;c.push(M,b,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let S=x+v*t.length,w=S,A=S+t.length,M=S+t.length+1,b=S+1;s.push(w,A,b),s.push(M,b,A)}this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("uv",new Te(a,2)),this.setAttribute("normal",new Te(c,3))}static fromJSON(t){return new Iu(t.points,t.segments,t.phiStart,t.phiLength)}};var gc=class extends _e{constructor(t=1,e=1,r=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let u=[],h=[],d=[],f=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(d,3)),this.setAttribute("uv",new Te(f,2));function v(){let S=new E,w=new E,A=0,M=(e-t)/r;for(let b=0;b<=s;b++){let T=[],C=b/s,P=C*(e-t)+t;for(let D=0;D<=i;D++){let _=D/i,O=_*l+a,L=Math.sin(O),j=Math.cos(O);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),S.set(L,M,j).normalize(),d.push(S.x,S.y,S.z),f.push(_,1-C),T.push(p++)}m.push(T)}for(let b=0;b<i;b++)for(let T=0;T<s;T++){let C=m[T][b],P=m[T+1][b],D=m[T+1][b+1],_=m[T][b+1];u.push(C,P,_),u.push(P,D,_),A+=6}c.addGroup(y,A,0),y+=A}function x(S){let w=p,A=new U,M=new E,b=0,T=S===!0?t:e,C=S===!0?1:-1;for(let D=1;D<=i;D++)h.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),p++;let P=p;for(let D=0;D<=i;D++){let O=D/i*l+a,L=Math.cos(O),j=Math.sin(O);M.x=T*j,M.y=g*C,M.z=T*L,h.push(M.x,M.y,M.z),d.push(0,C,0),A.x=L*.5+.5,A.y=j*.5*C+.5,f.push(A.x,A.y),p++}for(let D=0;D<i;D++){let _=w+D,O=P+D;S===!0?u.push(O,O+1,_):u.push(O+1,O,_),b+=3}c.addGroup(y,b,S===!0?1:2),y+=b}}static fromJSON(t){return new gc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},$a=class extends gc{constructor(t=1,e=1,r=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new $a(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Ru=class extends _e{constructor(t=[],e=[],r=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:i};let s=[],o=[];a(i),c(r),u(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new E,S=new E,w=new E;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],S),f(e[A+2],w),l(x,S,w,v)}function l(v,x,S,w){let A=w+1,M=[];for(let b=0;b<=A;b++){M[b]=[];let T=v.clone().lerp(S,b/A),C=x.clone().lerp(S,b/A),P=A-b;for(let D=0;D<=P;D++)D===0&&b===A?M[b][D]=T:M[b][D]=T.clone().lerp(C,D/P)}for(let b=0;b<A;b++)for(let T=0;T<2*(A-b)-1;T++){let C=Math.floor(T/2);T%2===0?(d(M[b][C+1]),d(M[b+1][C]),d(M[b][C])):(d(M[b][C+1]),d(M[b+1][C+1]),d(M[b+1][C]))}}function c(v){let x=new E;for(let S=0;S<s.length;S+=3)x.x=s[S+0],x.y=s[S+1],x.z=s[S+2],x.normalize().multiplyScalar(v),s[S+0]=x.x,s[S+1]=x.y,s[S+2]=x.z}function u(){let v=new E;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let S=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(S,1-w)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],S=o[v+2],w=o[v+4],A=Math.max(x,S,w),M=Math.min(x,S,w);A>.9&&M<.1&&(x<.2&&(o[v+0]+=1),S<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function p(){let v=new E,x=new E,S=new E,w=new E,A=new U,M=new U,b=new U;for(let T=0,C=0;T<s.length;T+=9,C+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),S.set(s[T+6],s[T+7],s[T+8]),A.set(o[C+0],o[C+1]),M.set(o[C+2],o[C+3]),b.set(o[C+4],o[C+5]),w.copy(v).add(x).add(S).divideScalar(3);let P=g(w);m(A,C+0,v,P),m(M,C+2,x,P),m(b,C+4,S,P)}}function m(v,x,S,w){w<0&&v.x===1&&(o[x]=v.x-1),S.x===0&&S.z===0&&(o[x]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Ru(t.vertices,t.indices,t.radius,t.details)}},Lu=class extends Ru{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=1/r,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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],o=[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];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Lu(t.radius,t.detail)}};var sa=class extends mc{constructor(t){super(t),this.uuid=is(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let i=t.holes[e];this.holes.push(new mc().fromJSON(i))}return this}},DG={triangulate:function(n,t,e=2){let r=t&&t.length,i=r?t[0]*e:n.length,s=VC(n,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,f;if(r&&(s=BG(n,t,s,e)),n.length>80*e){a=c=n[0],l=u=n[1];for(let p=e;p<i;p+=e)h=n[p],d=n[p+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return dp(s,o,e,a,l,f,0),o}};function VC(n,t,e,r,i){let s,o;if(i===qG(n,t,e,r)>0)for(s=t;s<e;s+=r)o=cC(s,n[s],n[s+1],o);else for(s=e-r;s>=t;s-=r)o=cC(s,n[s],n[s+1],o);return o&&wy(o,o.next)&&(pp(o),o=o.next),o}function yc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(wy(e,e.next)||Fr(e.prev,e,e.next)===0)){if(pp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function dp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&UG(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?IG(n,r,i,s):OG(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),pp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=RG(yc(n),t,e),dp(n,t,e,r,i,s,2)):o===2&&LG(n,t,e,r,i,s):dp(yc(n),t,e,r,i,s,1);break}}}function OG(n){let t=n.prev,e=n,r=n.next;if(Fr(t,e,r)>=0)return!1;let i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=i<s?i<o?i:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=i>s?i>o?i:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Tu(i,a,s,l,o,c,p.x,p.y)&&Fr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function IG(n,t,e,r){let i=n.prev,s=n,o=n.next;if(Fr(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,p=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=HS(f,p,t,e,r),v=HS(m,g,t,e,r),x=n.prevZ,S=n.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Tu(a,u,l,h,c,d,x.x,x.y)&&Fr(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Tu(a,u,l,h,c,d,S.x,S.y)&&Fr(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Tu(a,u,l,h,c,d,x.x,x.y)&&Fr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Tu(a,u,l,h,c,d,S.x,S.y)&&Fr(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function RG(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!wy(i,s)&&zC(i,r,r.next,s)&&fp(i,s)&&fp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),pp(r),pp(r.next),r=n=s),r=r.next}while(r!==n);return yc(r)}function LG(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&jG(o,a)){let l=UC(o,a);o=yc(o,o.next),l=yc(l,l.next),dp(o,t,e,r,i,s,0),dp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function BG(n,t,e,r){let i=[],s,o,a,l,c;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=VC(n,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(GG(c));for(i.sort(NG),s=0;s<i.length;s++)e=FG(i[s],e);return e}function NG(n,t){return n.x-t.x}function FG(n,t){let e=VG(n,t);if(!e)return t;let r=UC(e,n);return yc(r,r.next),yc(e,e.next)}function VG(n,t){let e=t,r=-1/0,i,s=n.x,o=n.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,i=e.x<e.next.x?e:e.next,d===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,c=i.y,u=1/0,h;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&Tu(o<c?s:r,o,l,c,o<c?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),fp(e,n)&&(h<u||h===u&&(e.x>i.x||e.x===i.x&&zG(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function zG(n,t){return Fr(n.prev,n,t.prev)<0&&Fr(t.next,n,n.next)<0}function UG(n,t,e,r){let i=n;do i.z===0&&(i.z=HS(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,kG(i)}function kG(n){let t,e,r,i,s,o,a,l,c=1;do{for(e=n,n=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<c&&(a++,r=r.nextZ,!!r);t++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(i=e,e=e.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;e=r}s.nextZ=null,c*=2}while(o>1);return n}function HS(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function GG(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function Tu(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function jG(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!HG(n,t)&&(fp(n,t)&&fp(t,n)&&WG(n,t)&&(Fr(n.prev,n,t.prev)||Fr(n,t.prev,t))||wy(n,t)&&Fr(n.prev,n,n.next)>0&&Fr(t.prev,t,t.next)>0)}function Fr(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function wy(n,t){return n.x===t.x&&n.y===t.y}function zC(n,t,e,r){let i=zg(Fr(n,t,e)),s=zg(Fr(n,t,r)),o=zg(Fr(e,r,n)),a=zg(Fr(e,r,t));return!!(i!==s&&o!==a||i===0&&Vg(n,e,t)||s===0&&Vg(n,r,t)||o===0&&Vg(e,n,r)||a===0&&Vg(e,t,r))}function Vg(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function zg(n){return n>0?1:n<0?-1:0}function HG(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&zC(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function fp(n,t){return Fr(n.prev,n,n.next)<0?Fr(n,t,n.next)>=0&&Fr(n,n.prev,t)>=0:Fr(n,t,n.prev)<0||Fr(n,n.next,t)<0}function WG(n,t){let e=n,r=!1,i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function UC(n,t){let e=new WS(n.i,n.x,n.y),r=new WS(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function cC(n,t,e,r){let i=new WS(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function pp(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function WS(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qG(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}var Bu=class{static area(t){let e=t.length,r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return Bu.area(t)<0}static triangulateShape(t,e){let r=[],i=[],s=[];uC(t),hC(r,t);let o=t.length;e.forEach(uC);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,hC(r,e[l]);let a=DG.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function uC(n){let t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function hC(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}var Nu=class extends Ru{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],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];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Nu(t.radius,t.detail)}};var Ls=class extends _e{constructor(t=1,e=32,r=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new E,d=new E,f=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,S=0;y==0&&o==0?S=.5/e:y==r&&l==Math.PI&&(S=-.5/e);for(let w=0;w<=e;w++){let A=w/e;h.x=-t*Math.cos(i+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(i+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+S,1-x),v.push(c++)}u.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=u[y][v+1],S=u[y][v],w=u[y+1][v],A=u[y+1][v+1];(y!==0||o>0)&&f.push(x,S,A),(y!==r-1||l<Math.PI)&&f.push(S,w,A)}this.setIndex(f),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2))}static fromJSON(t){return new Ls(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Fu=class extends _e{constructor(t=1,e=.4,r=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,arc:s},r=Math.floor(r),i=Math.floor(i);let o=[],a=[],l=[],c=[],u=new E,h=new E,d=new E;for(let f=0;f<=r;f++)for(let p=0;p<=i;p++){let m=p/i*s,g=f/r*Math.PI*2;h.x=(t+e*Math.cos(g))*Math.cos(m),h.y=(t+e*Math.cos(g))*Math.sin(m),h.z=e*Math.sin(g),a.push(h.x,h.y,h.z),u.x=t*Math.cos(m),u.y=t*Math.sin(m),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(p/i),c.push(f/r)}for(let f=1;f<=r;f++)for(let p=1;p<=i;p++){let m=(i+1)*f+p-1,g=(i+1)*(f-1)+p-1,y=(i+1)*(f-1)+p,v=(i+1)*f+p;o.push(m,g,v),o.push(g,y,v)}this.setIndex(o),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}static fromJSON(t){return new Fu(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},Vu=class extends _e{constructor(t=1,e=.4,r=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:i,p:s,q:o},r=Math.floor(r),i=Math.floor(i);let a=[],l=[],c=[],u=[],h=new E,d=new E,f=new E,p=new E,m=new E,g=new E,y=new E;for(let x=0;x<=r;++x){let S=x/r*s*Math.PI*2;v(S,s,o,t,f),v(S+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,M=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(M*y.x+b*m.x),h.y=f.y+(M*y.y+b*m.y),h.z=f.z+(M*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(x/r),u.push(w/i)}}for(let x=1;x<=r;x++)for(let S=1;S<=i;S++){let w=(i+1)*(x-1)+(S-1),A=(i+1)*x+(S-1),M=(i+1)*x+S,b=(i+1)*(x-1)+S;a.push(w,A,b),a.push(A,M,b)}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function v(x,S,w,A,M){let b=Math.cos(x),T=Math.sin(x),C=w/S*x,P=Math.cos(C);M.x=A*(2+P)*.5*b,M.y=A*(2+P)*T*.5,M.z=A*Math.sin(C)*.5}}static fromJSON(t){return new Vu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Ha(n,t,e){return kC(n)?new n.constructor(n.subarray(t,e!==void 0?e:n.length)):n.slice(t,e)}function Ug(n,t,e){return!n||!e&&n.constructor===t?n:typeof t.BYTES_PER_ELEMENT=="number"?new t(n):Array.prototype.slice.call(n)}function kC(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function YG(n){function t(i,s){return n[i]-n[s]}let e=n.length,r=new Array(e);for(let i=0;i!==e;++i)r[i]=i;return r.sort(t),r}function dC(n,t,e){let r=n.length,i=new n.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)i[o++]=n[a+l]}return i}function GC(n,t,e,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=n[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=n[i++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=n[i++];while(s!==void 0)}var zu=class{constructor(t,e,r,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,i=e[r],s=e[r-1];e:{t:{let o;r:{i:if(!(t<i)){for(let a=r+2;;){if(i===void 0){if(t<s)break i;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=i,i=e[++r],t<i)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(i=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(i=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,i)}return this.interpolate_(r,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},qS=class extends zu{constructor(t,e,r,i){super(t,e,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Au,endingEnd:Au}}intervalChanged_(t,e,r){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Eu:s=t,a=2*e-r;break;case Yg:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case Eu:o=t,l=2*r-e;break;case Yg:o=1,l=r+i[1]-i[0];break;default:o=t-1,l=e}let c=(r-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-r),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(i-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,S=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[u+w]+v*o[c+w]+x*o[l+w]+S*o[h+w];return s}},oy=class extends zu{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(r-e)/(i-e),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},YS=class extends zu{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t){return this.copySampleValue_(t-1)}},as=class{constructor(t,e,r,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ug(e,this.TimeBufferType),this.values=Ug(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:Ug(t.times,Array),values:Ug(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(r.interpolation=i)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new YS(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new oy(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new qS(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Wg:e=this.InterpolantFactoryMethodDiscrete;break;case qg:e=this.InterpolantFactoryMethodLinear;break;case Wb:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Wg;case this.InterpolantFactoryMethodLinear:return qg;case this.InterpolantFactoryMethodSmooth:return Wb}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,i=e.length;r!==i;++r)e[r]*=t}return this}trim(t,e){let r=this.times,i=r.length,s=0,o=i-1;for(;s!==i&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Ha(r,s,o),this.values=Ha(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&kC(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=Ha(this.times),e=Ha(this.values),r=this.getValueSize(),i=this.getInterpolation()===Wb,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(i)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=Ha(t,0,o),this.values=Ha(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Ha(this.times,0),e=Ha(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};as.prototype.TimeBufferType=Float32Array;as.prototype.ValueBufferType=Float32Array;as.prototype.DefaultInterpolation=qg;var el=class extends as{};el.prototype.ValueTypeName="bool";el.prototype.ValueBufferType=Array;el.prototype.DefaultInterpolation=Wg;el.prototype.InterpolantFactoryMethodLinear=void 0;el.prototype.InterpolantFactoryMethodSmooth=void 0;var ay=class extends as{};ay.prototype.ValueTypeName="color";var Uu=class extends as{};Uu.prototype.ValueTypeName="number";var XS=class extends zu{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(i-e),c=t*a;for(let u=c+a;c!==u;c+=4)Qe.slerpFlat(s,0,o,c-a,o,c,l);return s}},vc=class extends as{InterpolantFactoryMethodLinear(t){return new XS(this.times,this.values,this.getValueSize(),t)}};vc.prototype.ValueTypeName="quaternion";vc.prototype.DefaultInterpolation=qg;vc.prototype.InterpolantFactoryMethodSmooth=void 0;var tl=class extends as{};tl.prototype.ValueTypeName="string";tl.prototype.ValueBufferType=Array;tl.prototype.DefaultInterpolation=Wg;tl.prototype.InterpolantFactoryMethodLinear=void 0;tl.prototype.InterpolantFactoryMethodSmooth=void 0;var ku=class extends as{};ku.prototype.ValueTypeName="vector";var Gu=class{constructor(t,e=-1,r,i=aw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=is(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,i=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(QG(r[o]).scale(i));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(as.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(t,e,r,i){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=YG(l);l=dC(l,1,u),c=dC(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Uu(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let i=t;r=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<r.length;i++)if(r[i].name===e)return r[i];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let c=t[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];GC(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}i.push(new Uu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(ku,f+".position",d,"pos",i),r(vc,f+".quaternion",d,"rot",i),r(ku,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,i=t.length;r!==i;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function XG(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Uu;case"vector":case"vector2":case"vector3":case"vector4":return ku;case"color":return ay;case"quaternion":return vc;case"bool":case"boolean":return el;case"string":return tl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function QG(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=XG(n.type);if(n.times===void 0){let e=[],r=[];GC(n.keys,e,r,"value"),n.times=e,n.values=r}return t.parse!==void 0?t.parse(n):new t(n.name,n.times,n.values,n.interpolation)}var ly={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},mp=class{constructor(t,e,r){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let f=c[h],p=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},KG=new mp,rl=class{constructor(t){this.manager=t!==void 0?t:KG,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},ra={},QS=class extends Error{constructor(t,e){super(t),this.response=e}},ju=class extends rl{constructor(t){super(t)}load(t,e,r,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=ly.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(ra[t]!==void 0){ra[t].push({onLoad:e,onProgress:r,onError:i});return}ra[t]=[],ra[t].push({onLoad:e,onProgress:r,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=ra[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:S})=>{if(x)y.close();else{m+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,M=u.length;A<M;A++){let b=u[A];b.onProgress&&b.onProgress(w)}y.enqueue(S),v()}})}}});return new Response(g)}else throw new QS(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{ly.add(t,c);let u=ra[t];delete ra[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=ra[t];if(u===void 0)throw this.manager.itemError(t),c;delete ra[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var KS=class extends rl{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=ly.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=sp("img");function l(){u(),ly.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),i&&i(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var cy=class extends rl{constructor(t){super(t)}load(t,e,r,i){let s=new Jt,o=new KS(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}},il=class extends Et{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new We(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},uy=class extends il{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},bS=new ce,fC=new E,pC=new E,gp=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new ce,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ap,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;fC.setFromMatrixPosition(t.matrixWorld),e.position.copy(fC),pC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(pC),e.updateMatrixWorld(),bS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(bS)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},ZS=class extends gp{constructor(){super(new Kr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=np*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},hy=class extends il{constructor(t,e,r=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new ZS}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},mC=new ce,Qf=new E,SS=new E,JS=class extends gp{constructor(){super(new Kr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,i=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Qf.setFromMatrixPosition(t.matrixWorld),r.position.copy(Qf),SS.copy(r.position),SS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(SS),r.updateMatrixWorld(),i.makeTranslation(-Qf.x,-Qf.y,-Qf.z),mC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mC)}},dy=class extends il{constructor(t,e,r=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new JS}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},$S=class extends gp{constructor(){super(new Ka(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},fy=class extends il{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new $S}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var yp=class extends _e{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Hu=class extends rl{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new ju(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},r,i)}parse(t){let e={},r={};function i(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=gg(g.type,y),x=new ry(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new yp:new _e,a=t.data.index;if(a!==void 0){let f=gg(a.type,a.array);o.setIndex(new Xe(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=i(t.data,p.data);m=new hc(g,p.itemSize,p.offset,p.normalized)}else{let g=gg(p.type,p.array),y=p.isInstancedBufferAttribute?ho:Xe;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let S=i(t.data,v.data);x=new hc(S,v.itemSize,v.offset,v.normalized)}else{let S=gg(v.type,v.array);x=new Xe(S,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new E;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Dr(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var py=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gC(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=gC();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function gC(){return(typeof performance>"u"?Date:performance).now()}var ew=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,i=this.valueSize,s=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,i=r*this._origIndex;t.getValue(e,i);for(let s=r,o=i;s!==o;++s)e[s]=e[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,i,s){if(i>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,i){Qe.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Qe.multiplyQuaternionsFlat(t,o,t,e,t,r),Qe.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,r,i,s){let o=1-i;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*i}}_lerpAdditive(t,e,r,i,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*i}}},fw="\\[\\]\\.:\\/",ZG=new RegExp("["+fw+"]","g"),pw="[^"+fw+"]",JG="[^"+fw.replace("\\.","")+"]",$G=/((?:WC+[\/:])*)/.source.replace("WC",pw),e4=/(WCOD+)?/.source.replace("WCOD",JG),t4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pw),r4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pw),i4=new RegExp("^"+$G+e4+t4+r4+"$"),n4=["material","materials","bones","map"],tw=class{constructor(t,e,r){let i=r||Kt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},Kt=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Kt.parseTrackName(e),this.node=Kt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new Kt.Composite(t,e,r):new Kt(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ZG,"")}static parseTrackName(t){let e=i4.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);n4.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},i=r(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)t[e++]=r[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let i=0,s=r.length;i!==s;++i)r[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=Kt.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let c=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[i];if(o===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Kt.Composite=tw;Kt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Kt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Kt.prototype.GetterByBindingType=[Kt.prototype._getValue_direct,Kt.prototype._getValue_array,Kt.prototype._getValue_arrayElement,Kt.prototype._getValue_toArray];Kt.prototype.SetterByBindingTypeAndVersioning=[[Kt.prototype._setValue_direct,Kt.prototype._setValue_direct_setNeedsUpdate,Kt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Kt.prototype._setValue_array,Kt.prototype._setValue_array_setNeedsUpdate,Kt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Kt.prototype._setValue_arrayElement,Kt.prototype._setValue_arrayElement_setNeedsUpdate,Kt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Kt.prototype._setValue_fromArray,Kt.prototype._setValue_fromArray_setNeedsUpdate,Kt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var rw=class{constructor(t,e,r=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=i;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Au,endingEnd:Au};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ow,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let i=this._clip.duration,s=t._clip.duration,o=s/i,a=i/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let i=this._mixer,s=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+r,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,i){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case vF:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case aw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,i=this.time+t,s=this._loopCount,o=r===xp;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===sw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,r){let i=this._interpolantSettings;r?(i.endingStart=Eu,i.endingEnd=Eu):(t?i.endingStart=this.zeroSlopeAtStart?Eu:Au:i.endingStart=Yg,e?i.endingEnd=this.zeroSlopeAtEnd?Eu:Au:i.endingEnd=Yg)}_scheduleFading(t,e,r){let i=this._mixer,s=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},s4=new Float32Array(1),my=class extends hr{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new ew(Kt.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,r)}let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let i=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],i=t._cacheIndex;r._cacheIndex=i,e[i]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let i=this._bindingsByRootAndName,s=this._bindings,o=i[e];o===void 0&&(o={},i[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,i=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new oy(new Float32Array(2),new Float32Array(2),1,s4),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let i=e||this._root,s=i.uuid,o=typeof t=="string"?Gu.findByName(i,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],c=null;if(r===void 0&&(o!==null?r=o.blendMode:r=aw),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new rw(this,o,e,r);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(t,e){let r=e||this._root,i=r.uuid,s=typeof t=="string"?Gu.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(i,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,i=this._actionsByClip,s=i[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},ue=class{constructor(t){this.value=t}clone(){return new ue(this.value.clone===void 0?this.value:this.value.clone())}};var Wu=class{constructor(t,e,r=0,i=1/0){this.ray=new Rs(t,e),this.near=r,this.far=i,this.camera=null,this.layers=new op,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return iw(t,this,r,e),r.sort(yC),r}intersectObjects(t,e=!0,r=[]){for(let i=0,s=t.length;i<s;i++)iw(t[i],this,r,e);return r.sort(yC),r}};function yC(n,t){return n.distance-t.distance}function iw(n,t,e,r){if(n.layers.test(t.layers)&&n.raycast(t,e),r===!0){let i=n.children;for(let s=0,o=i.length;s<o;s++)iw(i[s],t,e,!0)}}var vp=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(ci(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var vC=new U,qu=class{constructor(t=new U(1/0,1/0),e=new U(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=vC.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return vC.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},xC=new E,kg=new E,Si=class{constructor(t=new E,e=new E){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){xC.subVectors(t,this.start),kg.subVectors(this.end,this.start);let r=kg.dot(kg),s=kg.dot(xC)/r;return e&&(s=ci(s,0,1)),s}closestPointToPoint(t,e,r){let i=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},bC=new E,gy=class extends Et{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new _e,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}r.setAttribute("position",new Te(i,3));let s=new ss({fog:!1,toneMapped:!1});this.cone=new Ja(r,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),bC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(bC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var yy=class extends Xt{constructor(t,e,r){let i=new Ls(e,4,2),s=new Hn({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var SC=new E,Gg=new E,wC=new E,vy=class extends Et{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new _e;i.setAttribute("position",new Te([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ss({fog:!1,toneMapped:!1});this.lightPlane=new dc(i,s),this.add(this.lightPlane),i=new _e,i.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new dc(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),SC.setFromMatrixPosition(this.light.matrixWorld),Gg.setFromMatrixPosition(this.light.target.matrixWorld),wC.subVectors(Gg,SC),this.lightPlane.lookAt(Gg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Gg),this.targetLine.scale.z=wC.length()}},jg=new E,Gr=new Wn,nl=class extends Ja{constructor(t){let e=new _e,r=new ss({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){i.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}e.setAttribute("position",new Te(i,3)),e.setAttribute("color",new Te(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new We(16755200),u=new We(16711680),h=new We(43775),d=new We(16777215),f=new We(3355443);this.setColors(c,u,h,d,f)}setColors(t,e,r,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,r=1,i=1;Gr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Qr("c",e,t,Gr,0,0,-1),Qr("t",e,t,Gr,0,0,1),Qr("n1",e,t,Gr,-r,-i,-1),Qr("n2",e,t,Gr,r,-i,-1),Qr("n3",e,t,Gr,-r,i,-1),Qr("n4",e,t,Gr,r,i,-1),Qr("f1",e,t,Gr,-r,-i,1),Qr("f2",e,t,Gr,r,-i,1),Qr("f3",e,t,Gr,-r,i,1),Qr("f4",e,t,Gr,r,i,1),Qr("u1",e,t,Gr,r*.7,i*1.1,-1),Qr("u2",e,t,Gr,-r*.7,i*1.1,-1),Qr("u3",e,t,Gr,0,i*2,-1),Qr("cf1",e,t,Gr,-r,0,1),Qr("cf2",e,t,Gr,r,0,1),Qr("cf3",e,t,Gr,0,-i,1),Qr("cf4",e,t,Gr,0,i,1),Qr("cn1",e,t,Gr,-r,0,-1),Qr("cn2",e,t,Gr,r,0,-1),Qr("cn3",e,t,Gr,0,-i,-1),Qr("cn4",e,t,Gr,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Qr(n,t,e,r,i,s,o){jg.set(i,s,o).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],jg.x,jg.y,jg.z)}}var sl=class extends Ja{constructor(t,e=16776960){let r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new _e;s.setIndex(new Xe(r,1)),s.setAttribute("position",new Te(i,3)),super(s,new ss({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var xy=class extends Ja{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new _e;i.setAttribute("position",new Te(e,3)),i.setAttribute("color",new Te(r,3));let s=new ss({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,r){let i=new We,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var ia=o4();function o4(){let n=new ArrayBuffer(4),t=new Float32Array(n),e=new Uint32Array(n),r=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(r[l]=0,r[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(r[l]=1024>>-c-14,r[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(r[l]=c+15<<10,r[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(r[l]=31744,r[l|256]=64512,i[l]=24,i[l|256]=24):(r[l]=31744,r[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function a4(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=ci(n,-65504,65504),ia.floatView[0]=n;let t=ia.uint32View[0],e=t>>23&511;return ia.baseTable[e]+((t&8388607)>>ia.shiftTable[e])}function l4(n){let t=n>>10;return ia.uint32View[0]=ia.mantissaTable[ia.offsetTable[t]+(n&1023)]+ia.exponentTable[t],ia.floatView[0]}var jC=Object.freeze({__proto__:null,fromHalfFloat:l4,toHalfFloat:a4});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:oa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=oa);var Ku=".",bp=Symbol("target"),mw=Symbol("unsubscribe");function Sp(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function HC(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var Xn=Array.isArray;function xc(n){return typeof n=="symbol"}var c4={after:(n,t)=>Xn(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>Xn(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=Ku),xc(t)?n+t.toString():n+t):n,initial:n=>{if(Xn(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(Ku);return t===-1?"":n.slice(0,t)},last:n=>{if(Xn(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(Ku);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(Xn(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(Ku);if(r===-1)t(n);else for(;e<n.length;)r===-1&&(r=n.length),t(n.slice(e,r)),e=r+1,r=n.indexOf(Ku,e)}},get(n,t){return this.walk(t,e=>{n&&(n=n[e])}),n}},dn=c4;function gw(n){return typeof n=="object"&&typeof n.next=="function"}function yw(n,t,e,r,i){let s=n.next;if(t.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],r),o.value[1]=i(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[bp].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,r)),o};return n}function Ay(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&xc(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var wp=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),i=r[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),r[e]=i),i}getProxy(t,e,r,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,dn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,i,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,i):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let i=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Zu(n){return toString.call(n)==="[object Object]"}function Ju(){return!0}function ol(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var Ey=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var u4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),vw={push:Ju,pop:Ju,shift:Ju,unshift:Ju,copyWithin:ol,reverse:ol,sort:ol,splice:ol,flat:ol,fill:ol},WC=new Set([...Ey,...u4,...Object.keys(vw)]);function $u(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var xw=["keys","values","entries"],bw=new Set(["has","toString"]),Sw={add:$u,clear:$u,delete:$u,forEach:$u},qC=new Set([...bw,...Object.keys(Sw),...xw]);function eh(n,t){if(n.size!==t.size)return!0;let e;for(let[r,i]of n)if(e=t.get(r),e!==i||e===void 0&&!t.has(r))return!0;return!1}var h4=new Set([...bw,"get"]),ww={set:eh,clear:eh,delete:eh,forEach:eh},YC=new Set([...h4,...Object.keys(ww),...xw]);var Ri=class{constructor(t,e,r,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Ey.has(t)}_shallowClone(t){let e=t;if(Zu(t))e={...t};else if(Xn(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,i]of t.entries())e.set(r,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,i){return t?(Xn(i)?this._onIsChanged=vw[e]:i instanceof Set?this._onIsChanged=Sw[e]:i instanceof Map&&(this._onIsChanged=ww[e]),i):r}update(t,e,r){let i=dn.after(t,this._path);if(e!=="length"){let s=this.clone;dn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],dn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var th=class extends Ri{static isHandledMethod(t){return WC.has(t)}};var Ap=class extends Ri{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var rh=class extends Ri{static isHandledMethod(t){return qC.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var ih=class extends Ri{static isHandledMethod(t){return YC.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Ep=class extends Ri{constructor(t,e,r,i){super(void 0,e,r,i),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Mp=class extends Ri{constructor(t,e,r,i){super(void 0,e,r,i),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Ns=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Zu(t)||Xn(t)||Sp(t)}static isHandledMethod(t,e){return Zu(t)?Ri.isHandledMethod(e):Xn(t)?th.isHandledMethod(e):t instanceof Set?rh.isHandledMethod(e):t instanceof Map?ih.isHandledMethod(e):Sp(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Ri;Xn(t)?i=th:t instanceof Date?i=Ap:t instanceof Set?i=rh:t instanceof Map?i=ih:t instanceof WeakSet?i=Ep:t instanceof WeakMap&&(i=Mp),this._stack.push(new i(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:i}=t,s=Ns.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var d4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Aw=(n,t,e={})=>{e={...d4,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new wp(i),c=typeof e.onValidate=="function",u=new Ns(c),h=(v,x,S,w,A)=>!c||u.isCloning||e.onValidate(dn.concat(l.getPath(v),x),S,w,A)===!0,d=(v,x,S,w)=>{!Ay(l,e,x)&&!(o&&l.isDetached(v,n))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,A)=>{u.isCloning?u.update(v,x,w):t(dn.concat(v,x),S,w,A)},p=v=>v&&(v[r]||v),m=(v,x,S,w)=>HC(v)||S==="constructor"||s&&!Ns.isHandledMethod(x,S)||Ay(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,n)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,dn.concat(w,S),g,r)),g={get(v,x,S){if(xc(x)){if(x===r||x===bp)return v;if(x===mw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Sp(v)?Reflect.get(v,x):Reflect.get(v,x,S);return m(w,v,x)},set(v,x,S,w){S=p(S);let A=v[r]||v,M=A[x];if(i(M,S)&&x in v)return!0;let b=h(v,x,S,M);return b&&l.setProperty(A,x,S,w,M)?(d(v,x,v[x],M),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];h(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&d(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=h(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(d(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Ns.isHandledType(w)){let A=dn.initial(l.getPath(v)),M=Ns.isHandledMethod(w,v.name);u.start(w,A,S);let b=Reflect.apply(v,u.preferredThisArg(v,x,w),M?S.map(P=>p(P)):S),T=u.isChanged(w,i),C=u.stop();if(Ns.isHandledType(b)&&M&&(x instanceof Map&&v.name==="get"&&(A=dn.concat(A,S[0])),b=l.getProxy(b,A,g)),T){let P={name:v.name,args:S,result:b},D=u.isCloning?dn.initial(A):A,_=u.isCloning?dn.last(A):"";h(dn.get(n,D),_,w,C,P)?f(D,_,w,C,P):u.undo(w)}return(x instanceof Map||x instanceof Set)&&gw(b)?yw(b,v,x,A,m):b}return Reflect.apply(v,x,S)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};Aw.target=n=>n&&n[bp]||n;Aw.unsubscribe=n=>n[mw]||n;var Ew=Aw;var f4=typeof global=="object"&&global&&global.Object===Object&&global,My=f4;var p4=typeof self=="object"&&self&&self.Object===Object&&self,m4=My||p4||Function("return this")(),Hr=m4;var g4=Hr.Symbol,Li=g4;var XC=Object.prototype,y4=XC.hasOwnProperty,v4=XC.toString,Tp=Li?Li.toStringTag:void 0;function x4(n){var t=y4.call(n,Tp),e=n[Tp];try{n[Tp]=void 0;var r=!0}catch{}var i=v4.call(n);return r&&(t?n[Tp]=e:delete n[Tp]),i}var QC=x4;var b4=Object.prototype,S4=b4.toString;function w4(n){return S4.call(n)}var KC=w4;var A4="[object Null]",E4="[object Undefined]",ZC=Li?Li.toStringTag:void 0;function M4(n){return n==null?n===void 0?E4:A4:ZC&&ZC in Object(n)?QC(n):KC(n)}var Qn=M4;function T4(n){return n!=null&&typeof n=="object"}var Hi=T4;var C4="[object Symbol]";function P4(n){return typeof n=="symbol"||Hi(n)&&Qn(n)==C4}var al=P4;function _4(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var Ty=_4;var D4=Array.isArray,wi=D4;var O4=1/0,JC=Li?Li.prototype:void 0,$C=JC?JC.toString:void 0;function eP(n){if(typeof n=="string")return n;if(wi(n))return Ty(n,eP)+"";if(al(n))return $C?$C.call(n):"";var t=n+"";return t=="0"&&1/n==-O4?"-0":t}var tP=eP;var I4=/\s/;function R4(n){for(var t=n.length;t--&&I4.test(n.charAt(t)););return t}var rP=R4;var L4=/^\s+/;function B4(n){return n&&n.slice(0,rP(n)+1).replace(L4,"")}var iP=B4;function N4(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var fi=N4;var nP=0/0,F4=/^[-+]0x[0-9a-f]+$/i,V4=/^0b[01]+$/i,z4=/^0o[0-7]+$/i,U4=parseInt;function k4(n){if(typeof n=="number")return n;if(al(n))return nP;if(fi(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=fi(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=iP(n);var e=V4.test(n);return e||z4.test(n)?U4(n.slice(2),e?2:8):F4.test(n)?nP:+n}var Mw=k4;function G4(n){return n}var sP=G4;var j4="[object AsyncFunction]",H4="[object Function]",W4="[object GeneratorFunction]",q4="[object Proxy]";function Y4(n){if(!fi(n))return!1;var t=Qn(n);return t==H4||t==W4||t==j4||t==q4}var Cy=Y4;var X4=Hr["__core-js_shared__"],Py=X4;var oP=function(){var n=/[^.]+$/.exec(Py&&Py.keys&&Py.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Q4(n){return!!oP&&oP in n}var aP=Q4;var K4=Function.prototype,Z4=K4.toString;function J4(n){if(n!=null){try{return Z4.call(n)}catch{}try{return n+""}catch{}}return""}var aa=J4;var $4=/[\\^$.*+?()[\]{}|]/g,ej=/^\[object .+?Constructor\]$/,tj=Function.prototype,rj=Object.prototype,ij=tj.toString,nj=rj.hasOwnProperty,sj=RegExp("^"+ij.call(nj).replace($4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function oj(n){if(!fi(n)||aP(n))return!1;var t=Cy(n)?sj:ej;return t.test(aa(n))}var lP=oj;function aj(n,t){return n?.[t]}var cP=aj;function lj(n,t){var e=cP(n,t);return lP(e)?e:void 0}var Mn=lj;var cj=Mn(Hr,"WeakMap"),_y=cj;var uP=Object.create,uj=function(){function n(){}return function(t){if(!fi(t))return{};if(uP)return uP(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),hP=uj;function hj(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var dP=hj;function dj(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var fP=dj;var fj=800,pj=16,mj=Date.now;function gj(n){var t=0,e=0;return function(){var r=mj(),i=pj-(r-e);if(e=r,i>0){if(++t>=fj)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var pP=gj;function yj(n){return function(){return n}}var mP=yj;var vj=function(){try{var n=Mn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),nh=vj;var xj=nh?function(n,t){return nh(n,"toString",{configurable:!0,enumerable:!1,value:mP(t),writable:!0})}:sP,gP=xj;var bj=pP(gP),yP=bj;function Sj(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var vP=Sj;var wj=9007199254740991,Aj=/^(?:0|[1-9]\d*)$/;function Ej(n,t){var e=typeof n;return t=t??wj,!!t&&(e=="number"||e!="symbol"&&Aj.test(n))&&n>-1&&n%1==0&&n<t}var sh=Ej;function Mj(n,t,e){t=="__proto__"&&nh?nh(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Dy=Mj;function Tj(n,t){return n===t||n!==n&&t!==t}var oh=Tj;var Cj=Object.prototype,Pj=Cj.hasOwnProperty;function _j(n,t,e){var r=n[t];(!(Pj.call(n,t)&&oh(r,e))||e===void 0&&!(t in n))&&Dy(n,t,e)}var ah=_j;function Dj(n,t,e,r){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Dy(e,a,l):ah(e,a,l)}return e}var fo=Dj;var xP=Math.max;function Oj(n,t,e){return t=xP(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,s=xP(r.length-t,0),o=Array(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(o),dP(n,this,a)}}var bP=Oj;var Ij=9007199254740991;function Rj(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Ij}var lh=Rj;function Lj(n){return n!=null&&lh(n.length)&&!Cy(n)}var Oy=Lj;var Bj=Object.prototype;function Nj(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Bj;return n===e}var ch=Nj;function Fj(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var SP=Fj;var Vj="[object Arguments]";function zj(n){return Hi(n)&&Qn(n)==Vj}var Tw=zj;var wP=Object.prototype,Uj=wP.hasOwnProperty,kj=wP.propertyIsEnumerable,Gj=Tw(function(){return arguments}())?Tw:function(n){return Hi(n)&&Uj.call(n,"callee")&&!kj.call(n,"callee")},uh=Gj;function jj(){return!1}var AP=jj;var TP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,EP=TP&&typeof module=="object"&&module&&!module.nodeType&&module,Hj=EP&&EP.exports===TP,MP=Hj?Hr.Buffer:void 0,Wj=MP?MP.isBuffer:void 0,qj=Wj||AP,bc=qj;var Yj="[object Arguments]",Xj="[object Array]",Qj="[object Boolean]",Kj="[object Date]",Zj="[object Error]",Jj="[object Function]",$j="[object Map]",eH="[object Number]",tH="[object Object]",rH="[object RegExp]",iH="[object Set]",nH="[object String]",sH="[object WeakMap]",oH="[object ArrayBuffer]",aH="[object DataView]",lH="[object Float32Array]",cH="[object Float64Array]",uH="[object Int8Array]",hH="[object Int16Array]",dH="[object Int32Array]",fH="[object Uint8Array]",pH="[object Uint8ClampedArray]",mH="[object Uint16Array]",gH="[object Uint32Array]",Pr={};Pr[lH]=Pr[cH]=Pr[uH]=Pr[hH]=Pr[dH]=Pr[fH]=Pr[pH]=Pr[mH]=Pr[gH]=!0;Pr[Yj]=Pr[Xj]=Pr[oH]=Pr[Qj]=Pr[aH]=Pr[Kj]=Pr[Zj]=Pr[Jj]=Pr[$j]=Pr[eH]=Pr[tH]=Pr[rH]=Pr[iH]=Pr[nH]=Pr[sH]=!1;function yH(n){return Hi(n)&&lh(n.length)&&!!Pr[Qn(n)]}var CP=yH;function vH(n){return function(t){return n(t)}}var hh=vH;var PP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Cp=PP&&typeof module=="object"&&module&&!module.nodeType&&module,xH=Cp&&Cp.exports===PP,Cw=xH&&My.process,bH=function(){try{var n=Cp&&Cp.require&&Cp.require("util").types;return n||Cw&&Cw.binding&&Cw.binding("util")}catch{}}(),la=bH;var _P=la&&la.isTypedArray,SH=_P?hh(_P):CP,Iy=SH;var wH=Object.prototype,AH=wH.hasOwnProperty;function EH(n,t){var e=wi(n),r=!e&&uh(n),i=!e&&!r&&bc(n),s=!e&&!r&&!i&&Iy(n),o=e||r||i||s,a=o?SP(n.length,String):[],l=a.length;for(var c in n)(t||AH.call(n,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||sh(c,l)))&&a.push(c);return a}var Ry=EH;function MH(n,t){return function(e){return n(t(e))}}var Ly=MH;var TH=Ly(Object.keys,Object),DP=TH;var CH=Object.prototype,PH=CH.hasOwnProperty;function _H(n){if(!ch(n))return DP(n);var t=[];for(var e in Object(n))PH.call(n,e)&&e!="constructor"&&t.push(e);return t}var OP=_H;function DH(n){return Oy(n)?Ry(n):OP(n)}var dh=DH;function OH(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var IP=OH;var IH=Object.prototype,RH=IH.hasOwnProperty;function LH(n){if(!fi(n))return IP(n);var t=ch(n),e=[];for(var r in n)r=="constructor"&&(t||!RH.call(n,r))||e.push(r);return e}var RP=LH;function BH(n){return Oy(n)?Ry(n,!0):RP(n)}var ls=BH;var NH=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,FH=/^\w*$/;function VH(n,t){if(wi(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||al(n)?!0:FH.test(n)||!NH.test(n)||t!=null&&n in Object(t)}var LP=VH;var zH=Mn(Object,"create"),ca=zH;function UH(){this.__data__=ca?ca(null):{},this.size=0}var BP=UH;function kH(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var NP=kH;var GH="__lodash_hash_undefined__",jH=Object.prototype,HH=jH.hasOwnProperty;function WH(n){var t=this.__data__;if(ca){var e=t[n];return e===GH?void 0:e}return HH.call(t,n)?t[n]:void 0}var FP=WH;var qH=Object.prototype,YH=qH.hasOwnProperty;function XH(n){var t=this.__data__;return ca?t[n]!==void 0:YH.call(t,n)}var VP=XH;var QH="__lodash_hash_undefined__";function KH(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=ca&&t===void 0?QH:t,this}var zP=KH;function fh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}fh.prototype.clear=BP;fh.prototype.delete=NP;fh.prototype.get=FP;fh.prototype.has=VP;fh.prototype.set=zP;var Pw=fh;function ZH(){this.__data__=[],this.size=0}var UP=ZH;function JH(n,t){for(var e=n.length;e--;)if(oh(n[e][0],t))return e;return-1}var ll=JH;var $H=Array.prototype,e5=$H.splice;function t5(n){var t=this.__data__,e=ll(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():e5.call(t,e,1),--this.size,!0}var kP=t5;function r5(n){var t=this.__data__,e=ll(t,n);return e<0?void 0:t[e][1]}var GP=r5;function i5(n){return ll(this.__data__,n)>-1}var jP=i5;function n5(n,t){var e=this.__data__,r=ll(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var HP=n5;function ph(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}ph.prototype.clear=UP;ph.prototype.delete=kP;ph.prototype.get=GP;ph.prototype.has=jP;ph.prototype.set=HP;var cl=ph;var s5=Mn(Hr,"Map"),ul=s5;function o5(){this.size=0,this.__data__={hash:new Pw,map:new(ul||cl),string:new Pw}}var WP=o5;function a5(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var qP=a5;function l5(n,t){var e=n.__data__;return qP(t)?e[typeof t=="string"?"string":"hash"]:e.map}var hl=l5;function c5(n){var t=hl(this,n).delete(n);return this.size-=t?1:0,t}var YP=c5;function u5(n){return hl(this,n).get(n)}var XP=u5;function h5(n){return hl(this,n).has(n)}var QP=h5;function d5(n,t){var e=hl(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var KP=d5;function mh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}mh.prototype.clear=WP;mh.prototype.delete=YP;mh.prototype.get=XP;mh.prototype.has=QP;mh.prototype.set=KP;var Sc=mh;var f5="Expected a function";function _w(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(f5);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=e.cache;if(s.has(i))return s.get(i);var o=n.apply(this,r);return e.cache=s.set(i,o)||s,o};return e.cache=new(_w.Cache||Sc),e}_w.Cache=Sc;var ZP=_w;var p5=500;function m5(n){var t=ZP(n,function(r){return e.size===p5&&e.clear(),r}),e=t.cache;return t}var JP=m5;var g5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,y5=/\\(\\)?/g,v5=JP(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(g5,function(e,r,i,s){t.push(i?s.replace(y5,"$1"):r||e)}),t}),$P=v5;function x5(n){return n==null?"":tP(n)}var e_=x5;function b5(n,t){return wi(n)?n:LP(n,t)?[n]:$P(e_(n))}var cs=b5;var S5=1/0;function w5(n){if(typeof n=="string"||al(n))return n;var t=n+"";return t=="0"&&1/n==-S5?"-0":t}var dl=w5;function A5(n,t){t=cs(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[dl(t[e++])];return e&&e==r?n:void 0}var By=A5;function E5(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var gh=E5;var t_=Li?Li.isConcatSpreadable:void 0;function M5(n){return wi(n)||uh(n)||!!(t_&&n&&n[t_])}var r_=M5;function i_(n,t,e,r,i){var s=-1,o=n.length;for(e||(e=r_),i||(i=[]);++s<o;){var a=n[s];t>0&&e(a)?t>1?i_(a,t-1,e,r,i):gh(i,a):r||(i[i.length]=a)}return i}var n_=i_;function T5(n){var t=n==null?0:n.length;return t?n_(n,1):[]}var s_=T5;function C5(n){return yP(bP(n,void 0,s_),n+"")}var Ny=C5;var P5=Ly(Object.getPrototypeOf,Object),yh=P5;var _5="[object Object]",D5=Function.prototype,O5=Object.prototype,o_=D5.toString,I5=O5.hasOwnProperty,R5=o_.call(Object);function L5(n){if(!Hi(n)||Qn(n)!=_5)return!1;var t=yh(n);if(t===null)return!0;var e=I5.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&o_.call(e)==R5}var a_=L5;function B5(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+t];return s}var l_=B5;function N5(){this.__data__=new cl,this.size=0}var c_=N5;function F5(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var u_=F5;function V5(n){return this.__data__.get(n)}var h_=V5;function z5(n){return this.__data__.has(n)}var d_=z5;var U5=200;function k5(n,t){var e=this.__data__;if(e instanceof cl){var r=e.__data__;if(!ul||r.length<U5-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Sc(r)}return e.set(n,t),this.size=e.size,this}var f_=k5;function vh(n){var t=this.__data__=new cl(n);this.size=t.size}vh.prototype.clear=c_;vh.prototype.delete=u_;vh.prototype.get=h_;vh.prototype.has=d_;vh.prototype.set=f_;var xh=vh;function G5(n,t){return n&&fo(t,dh(t),n)}var p_=G5;function j5(n,t){return n&&fo(t,ls(t),n)}var m_=j5;var x_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,g_=x_&&typeof module=="object"&&module&&!module.nodeType&&module,H5=g_&&g_.exports===x_,y_=H5?Hr.Buffer:void 0,v_=y_?y_.allocUnsafe:void 0;function W5(n,t){if(t)return n.slice();var e=n.length,r=v_?v_(e):new n.constructor(e);return n.copy(r),r}var b_=W5;function q5(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var S_=q5;function Y5(){return[]}var Fy=Y5;var X5=Object.prototype,Q5=X5.propertyIsEnumerable,w_=Object.getOwnPropertySymbols,K5=w_?function(n){return n==null?[]:(n=Object(n),S_(w_(n),function(t){return Q5.call(n,t)}))}:Fy,bh=K5;function Z5(n,t){return fo(n,bh(n),t)}var A_=Z5;var J5=Object.getOwnPropertySymbols,$5=J5?function(n){for(var t=[];n;)gh(t,bh(n)),n=yh(n);return t}:Fy,Vy=$5;function eW(n,t){return fo(n,Vy(n),t)}var E_=eW;function tW(n,t,e){var r=t(n);return wi(n)?r:gh(r,e(n))}var zy=tW;function rW(n){return zy(n,dh,bh)}var Pp=rW;function iW(n){return zy(n,ls,Vy)}var Uy=iW;var nW=Mn(Hr,"DataView"),ky=nW;var sW=Mn(Hr,"Promise"),Gy=sW;var oW=Mn(Hr,"Set"),jy=oW;var M_="[object Map]",aW="[object Object]",T_="[object Promise]",C_="[object Set]",P_="[object WeakMap]",__="[object DataView]",lW=aa(ky),cW=aa(ul),uW=aa(Gy),hW=aa(jy),dW=aa(_y),wc=Qn;(ky&&wc(new ky(new ArrayBuffer(1)))!=__||ul&&wc(new ul)!=M_||Gy&&wc(Gy.resolve())!=T_||jy&&wc(new jy)!=C_||_y&&wc(new _y)!=P_)&&(wc=function(n){var t=Qn(n),e=t==aW?n.constructor:void 0,r=e?aa(e):"";if(r)switch(r){case lW:return __;case cW:return M_;case uW:return T_;case hW:return C_;case dW:return P_}return t});var ua=wc;var fW=Object.prototype,pW=fW.hasOwnProperty;function mW(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&pW.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var D_=mW;var gW=Hr.Uint8Array,Sh=gW;function yW(n){var t=new n.constructor(n.byteLength);return new Sh(t).set(new Sh(n)),t}var wh=yW;function vW(n,t){var e=t?wh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var O_=vW;var xW=/\w*$/;function bW(n){var t=new n.constructor(n.source,xW.exec(n));return t.lastIndex=n.lastIndex,t}var I_=bW;var R_=Li?Li.prototype:void 0,L_=R_?R_.valueOf:void 0;function SW(n){return L_?Object(L_.call(n)):{}}var B_=SW;function wW(n,t){var e=t?wh(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var N_=wW;var AW="[object Boolean]",EW="[object Date]",MW="[object Map]",TW="[object Number]",CW="[object RegExp]",PW="[object Set]",_W="[object String]",DW="[object Symbol]",OW="[object ArrayBuffer]",IW="[object DataView]",RW="[object Float32Array]",LW="[object Float64Array]",BW="[object Int8Array]",NW="[object Int16Array]",FW="[object Int32Array]",VW="[object Uint8Array]",zW="[object Uint8ClampedArray]",UW="[object Uint16Array]",kW="[object Uint32Array]";function GW(n,t,e){var r=n.constructor;switch(t){case OW:return wh(n);case AW:case EW:return new r(+n);case IW:return O_(n,e);case RW:case LW:case BW:case NW:case FW:case VW:case zW:case UW:case kW:return N_(n,e);case MW:return new r;case TW:case _W:return new r(n);case CW:return I_(n);case PW:return new r;case DW:return B_(n)}}var F_=GW;function jW(n){return typeof n.constructor=="function"&&!ch(n)?hP(yh(n)):{}}var V_=jW;var HW="[object Map]";function WW(n){return Hi(n)&&ua(n)==HW}var z_=WW;var U_=la&&la.isMap,qW=U_?hh(U_):z_,k_=qW;var YW="[object Set]";function XW(n){return Hi(n)&&ua(n)==YW}var G_=XW;var j_=la&&la.isSet,QW=j_?hh(j_):G_,H_=QW;var KW=1,ZW=2,JW=4,W_="[object Arguments]",$W="[object Array]",e6="[object Boolean]",t6="[object Date]",r6="[object Error]",q_="[object Function]",i6="[object GeneratorFunction]",n6="[object Map]",s6="[object Number]",Y_="[object Object]",o6="[object RegExp]",a6="[object Set]",l6="[object String]",c6="[object Symbol]",u6="[object WeakMap]",h6="[object ArrayBuffer]",d6="[object DataView]",f6="[object Float32Array]",p6="[object Float64Array]",m6="[object Int8Array]",g6="[object Int16Array]",y6="[object Int32Array]",v6="[object Uint8Array]",x6="[object Uint8ClampedArray]",b6="[object Uint16Array]",S6="[object Uint32Array]",Tr={};Tr[W_]=Tr[$W]=Tr[h6]=Tr[d6]=Tr[e6]=Tr[t6]=Tr[f6]=Tr[p6]=Tr[m6]=Tr[g6]=Tr[y6]=Tr[n6]=Tr[s6]=Tr[Y_]=Tr[o6]=Tr[a6]=Tr[l6]=Tr[c6]=Tr[v6]=Tr[x6]=Tr[b6]=Tr[S6]=!0;Tr[r6]=Tr[q_]=Tr[u6]=!1;function Hy(n,t,e,r,i,s){var o,a=t&KW,l=t&ZW,c=t&JW;if(e&&(o=i?e(n,r,i,s):e(n)),o!==void 0)return o;if(!fi(n))return n;var u=wi(n);if(u){if(o=D_(n),!a)return fP(n,o)}else{var h=ua(n),d=h==q_||h==i6;if(bc(n))return b_(n,a);if(h==Y_||h==W_||d&&!i){if(o=l||d?{}:V_(n),!a)return l?E_(n,m_(o,n)):A_(n,p_(o,n))}else{if(!Tr[h])return i?n:{};o=F_(n,h,a)}}s||(s=new xh);var f=s.get(n);if(f)return f;s.set(n,o),H_(n)?n.forEach(function(g){o.add(Hy(g,t,e,g,n,s))}):k_(n)&&n.forEach(function(g,y){o.set(y,Hy(g,t,e,y,n,s))});var p=c?l?Uy:Pp:l?ls:dh,m=u?void 0:p(n);return vP(m||n,function(g,y){m&&(y=g,g=n[y]),ah(o,y,Hy(g,t,e,y,n,s))}),o}var Wy=Hy;var w6=1,A6=4;function E6(n){return Wy(n,w6|A6)}var ha=E6;var M6="__lodash_hash_undefined__";function T6(n){return this.__data__.set(n,M6),this}var X_=T6;function C6(n){return this.__data__.has(n)}var Q_=C6;function qy(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Sc;++t<e;)this.add(n[t])}qy.prototype.add=qy.prototype.push=X_;qy.prototype.has=Q_;var K_=qy;function P6(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var Z_=P6;function _6(n,t){return n.has(t)}var J_=_6;var D6=1,O6=2;function I6(n,t,e,r,i,s){var o=e&D6,a=n.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(n),u=s.get(t);if(c&&u)return c==t&&u==n;var h=-1,d=!0,f=e&O6?new K_:void 0;for(s.set(n,t),s.set(t,n);++h<a;){var p=n[h],m=t[h];if(r)var g=o?r(m,p,h,t,n,s):r(p,m,h,n,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!Z_(t,function(y,v){if(!J_(f,v)&&(p===y||i(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||i(p,m,e,r,s))){d=!1;break}}return s.delete(n),s.delete(t),d}var Yy=I6;function R6(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var $_=R6;function L6(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var e2=L6;var B6=1,N6=2,F6="[object Boolean]",V6="[object Date]",z6="[object Error]",U6="[object Map]",k6="[object Number]",G6="[object RegExp]",j6="[object Set]",H6="[object String]",W6="[object Symbol]",q6="[object ArrayBuffer]",Y6="[object DataView]",t2=Li?Li.prototype:void 0,Dw=t2?t2.valueOf:void 0;function X6(n,t,e,r,i,s,o){switch(e){case Y6:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case q6:return!(n.byteLength!=t.byteLength||!s(new Sh(n),new Sh(t)));case F6:case V6:case k6:return oh(+n,+t);case z6:return n.name==t.name&&n.message==t.message;case G6:case H6:return n==t+"";case U6:var a=$_;case j6:var l=r&B6;if(a||(a=e2),n.size!=t.size&&!l)return!1;var c=o.get(n);if(c)return c==t;r|=N6,o.set(n,t);var u=Yy(a(n),a(t),r,i,s,o);return o.delete(n),u;case W6:if(Dw)return Dw.call(n)==Dw.call(t)}return!1}var r2=X6;var Q6=1,K6=Object.prototype,Z6=K6.hasOwnProperty;function J6(n,t,e,r,i,s){var o=e&Q6,a=Pp(n),l=a.length,c=Pp(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:Z6.call(t,d)))return!1}var f=s.get(n),p=s.get(t);if(f&&p)return f==t&&p==n;var m=!0;s.set(n,t),s.set(t,n);for(var g=o;++h<l;){d=a[h];var y=n[d],v=t[d];if(r)var x=o?r(v,y,d,t,n,s):r(y,v,d,n,t,s);if(!(x===void 0?y===v||i(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var S=n.constructor,w=t.constructor;S!=w&&"constructor"in n&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(n),s.delete(t),m}var i2=J6;var $6=1,n2="[object Arguments]",s2="[object Array]",Xy="[object Object]",e8=Object.prototype,o2=e8.hasOwnProperty;function t8(n,t,e,r,i,s){var o=wi(n),a=wi(t),l=o?s2:ua(n),c=a?s2:ua(t);l=l==n2?Xy:l,c=c==n2?Xy:c;var u=l==Xy,h=c==Xy,d=l==c;if(d&&bc(n)){if(!bc(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new xh),o||Iy(n)?Yy(n,t,e,r,i,s):r2(n,t,l,e,r,i,s);if(!(e&$6)){var f=u&&o2.call(n,"__wrapped__"),p=h&&o2.call(t,"__wrapped__");if(f||p){var m=f?n.value():n,g=p?t.value():t;return s||(s=new xh),i(m,g,e,r,s)}}return d?(s||(s=new xh),i2(n,t,e,r,i,s)):!1}var a2=t8;function l2(n,t,e,r,i){return n===t?!0:n==null||t==null||!Hi(n)&&!Hi(t)?n!==n&&t!==t:a2(n,t,e,r,l2,i)}var c2=l2;function r8(n,t){return n!=null&&t in Object(n)}var u2=r8;function i8(n,t,e){t=cs(t,n);for(var r=-1,i=t.length,s=!1;++r<i;){var o=dl(t[r]);if(!(s=n!=null&&e(n,o)))break;n=n[o]}return s||++r!=i?s:(i=n==null?0:n.length,!!i&&lh(i)&&sh(o,i)&&(wi(n)||uh(n)))}var h2=i8;function n8(n,t){return n!=null&&h2(n,t,u2)}var d2=n8;var s8=function(){return Hr.Date.now()},Qy=s8;var o8="Expected a function",a8=Math.max,l8=Math.min;function c8(n,t,e){var r,i,s,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof n!="function")throw new TypeError(o8);t=Mw(t)||0,fi(e)&&(u=!!e.leading,h="maxWait"in e,s=h?a8(Mw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var M=r,b=i;return r=i=void 0,c=A,o=n.apply(b,M),o}function p(A){return c=A,a=setTimeout(y,t),u?f(A):o}function m(A){var M=A-l,b=A-c,T=t-M;return h?l8(T,s-b):T}function g(A){var M=A-l,b=A-c;return l===void 0||M>=t||M<0||h&&b>=s}function y(){var A=Qy();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function S(){return a===void 0?o:v(Qy())}function w(){var A=Qy(),M=g(A);if(r=arguments,i=this,l=A,M){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=S,w}var Ac=c8;function u8(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var f2=u8;function h8(n,t){return t.length<2?n:By(n,l_(t,0,-1))}var p2=h8;function d8(n,t){return c2(n,t)}var Ec=d8;function f8(n,t){return t=cs(t,n),n=p2(n,t),n==null||delete n[dl(f2(t))]}var m2=f8;function p8(n){return a_(n)?void 0:n}var g2=p8;var m8=1,g8=2,y8=4,v8=Ny(function(n,t){var e={};if(n==null)return e;var r=!1;t=Ty(t,function(s){return s=cs(s,n),r||(r=s.length>1),s}),fo(n,Uy(n),e),r&&(e=Wy(e,m8|g8|y8,g2));for(var i=t.length;i--;)m2(e,t[i]);return e}),Ah=v8;function x8(n,t,e,r){if(!fi(n))return n;t=cs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++i<s;){var l=dl(t[i]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(i!=o){var u=a[l];c=r?r(u,l,a):void 0,c===void 0&&(c=fi(u)?u:sh(t[i+1])?[]:{})}ah(a,l,c),a=a[l]}return n}var y2=x8;function b8(n,t,e){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=By(n,o);e(a,o)&&y2(s,cs(o,n),a)}return s}var v2=b8;function S8(n,t){return v2(n,t,function(e,r){return d2(n,r)})}var x2=S8;var w8=Ny(function(n,t){return n==null?{}:x2(n,t)}),Kn=w8;var A8="Expected a function";function E8(n,t,e){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(A8);return fi(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),Ac(n,t,{leading:r,maxWait:t,trailing:i})}var Ow=E8;function Ky(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function fn(n,t){return Object.setPrototypeOf(n,t),n}var M8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),T8=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),C8=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Eh&&"ontouchend"in document,P8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,_8=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,D8=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},O8=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},I8=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Iw=M8(),nle=Iw?I8():void 0,Eh=T8(),po=C8(),b2=P8(),Ai=_8(),Rw=D8(),S2=Number(O8());function Zy(n){return Array.isArray(n)?n:[n]}function Jy(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}function _p(n){return Eh?n.metaKey:n.ctrlKey}function w2(n){return n.wheelDeltaY===0||n.deltaY===0?Eh&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX||n.wheelDeltaX===-3*window.devicePixelRatio*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY||n.wheelDeltaY===-3*window.devicePixelRatio*n.deltaY:n.deltaMode===0}var $e=[],ev={},Dp={},$y={};function A2(n){$e.includes(n)||$e.push(n)}function Mh(n){delete ev[n.pointerId];for(let t=0;t<$e.length;t++)if($e[t].pointerId===n.pointerId){$e.splice(t,1);break}}function E2(){$e.splice(0,$e.length)}function tv(n){if(n.pointerType!=="touch")return;let t=ev[n.pointerId];t===void 0&&(t={x:0,y:0},ev[n.pointerId]=t),t.x=n.pageX,t.y=n.pageY}function rv(n){let t=n.pointerId===$e[0].pointerId?$e[1]:$e[0];return ev[t.pointerId]}function M2(n){Dp[n.key]=!0,$y[n.key]=$y[n.key]===void 0?1:$y[n.key]+1}function T2(n){if(Eh&&Dp.Meta)for(let t in Dp)Dp[t]=!1;else Dp[n.key]=!1;$y={}}function C2(n){n.addEventListener("pointerdown",A2,!0),n.addEventListener("pointerdown",tv,!0),n.addEventListener("pointermove",tv,!0),n.addEventListener("pointerup",Mh,!0),n.addEventListener("pointercancel",Mh,!0),n.addEventListener("pointerleave",Mh,!0),window.addEventListener("keydown",M2,!0),window.addEventListener("keyup",T2,!0)}function P2(n){n.removeEventListener("pointerdown",A2,!0),n.removeEventListener("pointerdown",tv,!0),n.removeEventListener("pointermove",tv,!0),n.removeEventListener("pointerup",Mh,!0),n.removeEventListener("pointercancel",Mh,!0),n.removeEventListener("pointerleave",Mh,!0),window.removeEventListener("keydown",M2,!0),window.removeEventListener("keyup",T2,!0)}var _2,D2=new Promise(n=>{_2=n});var iv;function O2(){if(iv)return iv;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.7.6/build",i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});_2(l)}return iv=n(),iv}var I2,R2=new Promise(n=>{I2=n});var nv;function L2(){if(nv)return nv;async function n(){let e=await import("./physics.js");await e.init(),I2(e)}return nv=n(),nv}var it=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,it.prototype),s}}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],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,it.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,it.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function Op(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Op(r)}return Object.freeze(n)}function B2(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Th=class extends Error{};function sv(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function mo(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let s=n;n=t,t=s}let r=[],i=1/(e+1);for(let s=0;s<e;s++){let o=n+(t-n)*(s+.75+Math.random()*.5)*i;r.push(o)}return r}function Ch(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function N2(){return typeof process<"u"}function F2(n,t){for(let e of n)t(e.id,e.data)!==!0&&F2(e.children,t)}function V2(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)V2(e,t)}var fr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,fr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Op(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let i of e.children)this.fillCaches0(i,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)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}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 i=this.get(e);i&&V2(i,r)}}traverse(e){F2(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 s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let i=e,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,fr.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:s,data:o,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:i,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Th("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:i},l=[...l,u],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[s].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 i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>B2(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let s=this.childrenArray(e);if(r===null){if(s.length===0)return mo(0,i,i);{let o=s[0].fi;return mo(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return mo(l,l+i,i)}else return mo(o.fi,a.fi,i)}}};var Ph;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let i=r.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=n})(Ph||(Ph={}));var ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Op(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 s=this,o=s.findIndex(c=>c.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,ke.prototype);let r=e;return N2()||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)}return null}addOp(e){let{fi:r,id:i,data:s}=e,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:i}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return mo(0,r,r);{let s=i[0].fi;return mo(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return mo(a,a+r,r)}else return mo(s.fi,o.fi,r)}}};function _h(n){return n&&typeof n=="object"&&n instanceof pr}var pr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,s={};for(;i<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[i]],r!==void 0&&!_h(r))return null;i+=1}r=r?sv(r):new pr;for(let[l,c]of Object.entries(t.props)){let u=r[l];s[l]=u,c===void 0?delete r[l]:r[l]=c}for(;i>0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=sv(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=sv(l);c[t.path[i-1]]=r,r=c}else{let c=new pr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,pr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},go;(r=>{function n(i,s){return Ip(i,s)??i}r.apply=n;function t(i,s){return Bw(i,s)}r.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=Or.zoomOnce(l,a[o]),l===void 0)return s;if(!_h(l))return;o+=1}if(l===void 0)return s;if(!!_h(l))if(s.type===0){let c={...s.props};for(let u of Object.keys(l))delete c[u];return{...s,props:c}}else if(s.type===1||s.type===4||s.type===7){let c=Lw([s],l);return c?(console.log(c),c):s}else return s}r.filterOp=e})(go||(go={}));function Lw(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Ip(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=Lw(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return r}function R8(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Ip(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Ip(n,t){if(!_h(t))return t;if(n instanceof fr){let e=Lw(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ke)return R8(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=Ip(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof pr)return Bw(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=Ip(s,t[i]);r=r||o!==void 0,o===void 0&&(o=s),e[i]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Bw(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!_h(t))return t;if(!_h(n))return go.apply(n,t);let e=new Set;for(let i of Object.keys(n))e.add(i);for(let i of Object.keys(t))e.add(i);let r=new pr;for(let i of e){let s=Bw(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function z2(n,t){let e={cur:[],result:[],len:0};return n=Rp(n,t,e)??n,[n,e.result]}function ov(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function av(n){n&&(n.len-=1)}function L8(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function U2(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Rp(s.data,t,ov(e,o));av(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=U2(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return i}function B8(n,t,e){let r=!1,i=n.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Rp(s.data,t,ov(e,o));return av(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i}function Rp(n,t,e){if(n instanceof fr){let r=U2(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof ke)return B8(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=Rp(s,t,ov(e,o));return av(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(n)),i):void 0}else if(n&&typeof n=="object"&&!Ch(n)){let r={},i=!1;for(let[s,o]of Object.entries(n))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=Rp(o,t,ov(e,s));av(e),i=i||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&L8(e),r}else return}}var Dh;(t=>{function n(e,r){let i=Or.zoom(r,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=n})(Dh||(Dh={}));var Ir;(a=>{function n(l,c){return{...l,path:l.path.slice(c)}}a.drop=n;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof pr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof fr||l instanceof ke||l instanceof it?d=l.runOp(c):d=Ph.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=u[g],v=h[g];if(v instanceof fr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof ke){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof it){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof pr){let x={...v,[y]:m};m=Object.setPrototypeOf(x,pr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof fr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof ke){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}a.pathDisjoint=r;function i(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}a.pathEq=i;function s(l,c){return r(l.path,c.path)}a.commutative=s;function o(l,c){return l.type===0&&c.type===0&&i(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}a.subsumed=o})(Ir||(Ir={}));var Lp;(l=>{function n(){return[]}l.empty=n;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function i(c,u){return[...c.filter(d=>!u.some(f=>Ir.subsumed(d,f))),...u]}l.compress=i;function s(c,u){return c.every(h=>u.every(d=>Ir.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Or.zoom(h,[...p.path,p.id]),y=Ir.apply(h,{...p,type:2})):(m=Or.zoom(h,[...p.path,p.id,"value"]),y=Ir.apply(h,p)),y!==null){h=y.data;let[v,x]=z2(h,{[p.id]:m});h=v;for(let S=0;S<x.length;S++){let w=x[S],A=w.pop();if(typeof A=="number"){let M=[A];for(let T=S+1;T<x.length;T++){let C=x[T],P=C[C.length-1];if(typeof P=="number"&&Or.equal(w,C.slice(0,C.length-1)))M.push(P),x.splice(T,1);else break}let b=Or.zoom(h,w);g=b.map((T,C)=>M.includes(C)?p.id:T),m=b,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let M=m,b=Or.zoom(h,w.slice(0,w.length-2)),T=b.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:M}}:C);Object.setPrototypeOf(T,Object.getPrototypeOf(b.layers)),b.layers=T}g=p.id}d.push({type:0,path:w,props:{[A]:m}}),f.push({type:0,path:w,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Ir.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Th)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Lp||(Lp={}));var k2=Symbol(),N8=Symbol(),cv=Symbol(),Mc=class{reportOp(t,e,r=[]){let i=this;if(e===null)return;i._current=e.data;let s=r;for(;!(i instanceof lv);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[cv];r&&r(),delete this._children[t]}}}},Fw=class extends Mc{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,Ph.runOp(this._current,t),t.path)}},Vw=class extends Mc{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,it.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},G2={get(n,t){if(t===cv)return()=>{n._parent=null};if(t===k2)return n._current;if(t===N8)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e[t],o=uv(n,t,s);return o!==s?(r===void 0&&(r={},n._children=r),r[t]=o,o):s},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},F8={...G2,set(n,t,e){let r={type:0,props:{[t]:Vr(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},V8={...G2,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},Oh=class extends Mc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[cv]=()=>{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,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=uv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,i,s){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,i[s],o)}}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)}},Ih=class extends Mc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[cv]=()=>{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 i=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),i,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;if(t(this.data(i),i))return this.get(i)}}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,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=uv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}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 i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(r[i],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(r[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Nw(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&Or.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var lv=class extends Mc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){Nw(this.ts,e,t),Nw(this.actual,r,t),Nw(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function uv(n,t,e){return e instanceof fr?new Oh(n,t,e):e instanceof ke?new Ih(n,t,e):e instanceof it?new Proxy(new Vw(n,t,e),V8):e!==null&&typeof e=="object"?Ch(e)?e:new Proxy(new Fw(n,t,e),F8):e}function zw(n){let t=new lv(n);return[uv(t,"",n),t]}function fl(n,t){let[e,r]=zw(n);return t(e),r.result()}function Vr(n){return n instanceof Oh||n instanceof Ih?n._current:n!==null&&typeof n=="object"?n[k2]:n}var Or;(i=>{function n(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=n;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...o};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof fr||s instanceof Oh)&&typeof o=="string")return s.data(o);if((s instanceof ke||s instanceof Ih)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=r})(Or||(Or={}));function j2(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Lt(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var hv=class{},Bp=class extends hv{constructor(e){super();this.id=e}},Np=class extends hv{constructor(e){super();this.data=e}};var kw;try{kw=new TextDecoder}catch{}var qe,ml,ne=0;var Z2=[],Gw=Z2,jw=0,Tn={},Qt,pl,us=0,yo=0,Zn,da,pn=[],ir,H2={useRecords:!1,mapsAsObjects:!0},Fp=class{},Ww=new Fp;Ww.name="MessagePack 0xC1";var Rh=!1,vo=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(qe)return rD(()=>(fv(),this?this.unpack(t,e):vo.prototype.unpack.call(H2,t,e)));ml=e>-1?e:t.length,ne=0,jw=0,yo=0,pl=null,Gw=Z2,Zn=null,qe=t;try{ir=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=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 vo){if(Tn=this,this.structures)return Qt=this.structures,dv();(!Qt||Qt.length>0)&&(Qt=[])}else Tn=H2,(!Qt||Qt.length>0)&&(Qt=[]);return dv()}unpackMultiple(t,e){let r,i=0;try{Rh=!0;let s=t.length,o=this?this.unpack(t,s):gv.unpack(t,s);if(e){for(e(o);ne<s;)if(i=ne,e(dv())===!1)return}else{for(r=[o];ne<s;)i=ne,r.push(dv());return r}}catch(s){throw s.lastPosition=i,s.values=r,s}finally{Rh=!1,fv()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],s=e[r];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function dv(){try{if(!Tn.trusted&&!Rh){let t=Qt.sharedLength||0;t<Qt.length&&(Qt.length=t)}let n=qr();if(ne==ml)Qt.restoreStructures&&W2(),Qt=null,qe=null,da&&(da=null);else if(ne>ml){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Rh)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Qt.restoreStructures&&W2(),fv(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function W2(){for(let n in Qt.restoreStructures)Qt[n]=Qt.restoreStructures[n];Qt.restoreStructures=null}function qr(){let n=qe[ne++];if(n<160)if(n<128){if(n<64)return n;{let t=Qt[n&63]||Tn.getStructures&&J2()[n&63];return t?(t.read||(t.read=qw(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Tn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[eD()]=qr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(qr(),qr());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=qr();return t}else if(n<192){let t=n-160;if(yo>=ne)return pl.slice(ne-us,(ne+=t)-us);if(yo==0&&ml<140){let e=t<16?Yw(t):$2(t);if(e!=null)return e}return Hw(t)}else{let t;switch(n){case 192:return null;case 193:return Zn?(t=qr(),t>0?Zn[1].slice(Zn.position1,Zn.position1+=t):Zn[0].slice(Zn.position0,Zn.position0-=t)):Ww;case 194:return!1;case 195:return!0;case 196:return Uw(qe[ne++]);case 197:return t=ir.getUint16(ne),ne+=2,Uw(t);case 198:return t=ir.getUint32(ne),ne+=4,Uw(t);case 199:return Tc(qe[ne++]);case 200:return t=ir.getUint16(ne),ne+=2,Tc(t);case 201:return t=ir.getUint32(ne),ne+=4,Tc(t);case 202:if(t=ir.getFloat32(ne),Tn.useFloat32>2){let e=mv[(qe[ne]&127)<<1|qe[ne+1]>>7];return ne+=4,(e*t+(t>0?.5:-.5)>>0)/e}return ne+=4,t;case 203:return t=ir.getFloat64(ne),ne+=8,t;case 204:return qe[ne++];case 205:return t=ir.getUint16(ne),ne+=2,t;case 206:return t=ir.getUint32(ne),ne+=4,t;case 207:return Tn.int64AsNumber?(t=ir.getUint32(ne)*4294967296,t+=ir.getUint32(ne+4)):t=ir.getBigUint64(ne),ne+=8,t;case 208:return ir.getInt8(ne++);case 209:return t=ir.getInt16(ne),ne+=2,t;case 210:return t=ir.getInt32(ne),ne+=4,t;case 211:return Tn.int64AsNumber?(t=ir.getInt32(ne)*4294967296,t+=ir.getUint32(ne+4)):t=ir.getBigInt64(ne),ne+=8,t;case 212:if(t=qe[ne++],t==114)return K2(qe[ne++]&63);{let e=pn[t];if(e)return e.read?(ne++,e.read(qr())):e.noBuffer?(ne++,e()):e(qe.subarray(ne,++ne));throw new Error("Unknown extension "+t)}case 213:return t=qe[ne],t==114?(ne++,K2(qe[ne++]&63,qe[ne++])):Tc(2);case 214:return Tc(4);case 215:return Tc(8);case 216:return Tc(16);case 217:return t=qe[ne++],yo>=ne?pl.slice(ne-us,(ne+=t)-us):U8(t);case 218:return t=ir.getUint16(ne),ne+=2,yo>=ne?pl.slice(ne-us,(ne+=t)-us):k8(t);case 219:return t=ir.getUint32(ne),ne+=4,yo>=ne?pl.slice(ne-us,(ne+=t)-us):G8(t);case 220:return t=ir.getUint16(ne),ne+=2,Y2(t);case 221:return t=ir.getUint32(ne),ne+=4,Y2(t);case 222:return t=ir.getUint16(ne),ne+=2,X2(t);case 223:return t=ir.getUint32(ne),ne+=4,X2(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var z8=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function qw(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>z8.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(qr);return n.highByte===0&&(n.read=q2(t,n.read)),i()}let r={};for(let i=0,s=n.length;i<s;i++){let o=n[i];r[o]=qr()}return r}return e.count=0,n.highByte===0?q2(t,e):e}var q2=(n,t)=>function(){let e=qe[ne++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Qt[r]||J2()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=qw(i,n)),i.read()};function J2(){let n=rD(()=>(qe=null,Tn.getStructures()));return Qt=Tn._mergeStructures(n,Qt)}var Hw=pv,U8=pv,k8=pv,G8=pv;function pv(n){let t;if(n<16&&(t=Yw(n)))return t;if(n>64&&kw)return kw.decode(qe.subarray(ne,ne+=n));let e=ne+n,r=[];for(t="";ne<e;){let i=qe[ne++];if((i&128)===0)r.push(i);else if((i&224)===192){let s=qe[ne++]&63;r.push((i&31)<<6|s)}else if((i&240)===224){let s=qe[ne++]&63,o=qe[ne++]&63;r.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=qe[ne++]&63,o=qe[ne++]&63,a=qe[ne++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=Bi.apply(String,r),r.length=0)}return r.length>0&&(t+=Bi.apply(String,r)),t}function Y2(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=qr();return t}function X2(n){if(Tn.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[eD()]=qr();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(qr(),qr());return t}}var Bi=String.fromCharCode;function $2(n){let t=ne,e=new Array(n);for(let r=0;r<n;r++){let i=qe[ne++];if((i&128)>0){ne=t;return}e[r]=i}return Bi.apply(String,e)}function Yw(n){if(n<4)if(n<2){if(n===0)return"";{let t=qe[ne++];if((t&128)>1){ne-=1;return}return Bi(t)}}else{let t=qe[ne++],e=qe[ne++];if((t&128)>0||(e&128)>0){ne-=2;return}if(n<3)return Bi(t,e);let r=qe[ne++];if((r&128)>0){ne-=3;return}return Bi(t,e,r)}else{let t=qe[ne++],e=qe[ne++],r=qe[ne++],i=qe[ne++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){ne-=4;return}if(n<6){if(n===4)return Bi(t,e,r,i);{let s=qe[ne++];if((s&128)>0){ne-=5;return}return Bi(t,e,r,i,s)}}else if(n<8){let s=qe[ne++],o=qe[ne++];if((s&128)>0||(o&128)>0){ne-=6;return}if(n<7)return Bi(t,e,r,i,s,o);let a=qe[ne++];if((a&128)>0){ne-=7;return}return Bi(t,e,r,i,s,o,a)}else{let s=qe[ne++],o=qe[ne++],a=qe[ne++],l=qe[ne++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){ne-=8;return}if(n<10){if(n===8)return Bi(t,e,r,i,s,o,a,l);{let c=qe[ne++];if((c&128)>0){ne-=9;return}return Bi(t,e,r,i,s,o,a,l,c)}}else if(n<12){let c=qe[ne++],u=qe[ne++];if((c&128)>0||(u&128)>0){ne-=10;return}if(n<11)return Bi(t,e,r,i,s,o,a,l,c,u);let h=qe[ne++];if((h&128)>0){ne-=11;return}return Bi(t,e,r,i,s,o,a,l,c,u,h)}else{let c=qe[ne++],u=qe[ne++],h=qe[ne++],d=qe[ne++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){ne-=12;return}if(n<14){if(n===12)return Bi(t,e,r,i,s,o,a,l,c,u,h,d);{let f=qe[ne++];if((f&128)>0){ne-=13;return}return Bi(t,e,r,i,s,o,a,l,c,u,h,d,f)}}else{let f=qe[ne++],p=qe[ne++];if((f&128)>0||(p&128)>0){ne-=14;return}if(n<15)return Bi(t,e,r,i,s,o,a,l,c,u,h,d,f,p);let m=qe[ne++];if((m&128)>0){ne-=15;return}return Bi(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m)}}}}}function Uw(n){return Tn.copyBuffers?Uint8Array.prototype.slice.call(qe,ne,ne+=n):qe.subarray(ne,ne+=n)}function Tc(n){let t=qe[ne++];if(pn[t])return pn[t](qe.subarray(ne,ne+=n));throw new Error("Unknown extension type "+t)}var Q2=new Array(4096);function eD(){let n=qe[ne++];if(n>=160&&n<192){if(n=n-160,yo>=ne)return pl.slice(ne-us,(ne+=n)-us);if(!(yo==0&&ml<180))return Hw(n)}else return ne--,qr();let t=(n<<5^(n>1?ir.getUint16(ne):n>0?qe[ne]:0))&4095,e=Q2[t],r=ne,i=ne+n-3,s,o=0;if(e&&e.bytes==n){for(;r<i;){if(s=ir.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(s=qe[r++],s!=e[o++]){r=1879048192;break}if(r===i)return ne=r,e.string;i-=3,r=ne}for(e=[],Q2[t]=e,e.bytes=n;r<i;)s=ir.getUint32(r),e.push(s),r+=4;for(i+=3;r<i;)s=qe[r++],e.push(s);let a=n<16?Yw(n):$2(n);return a!=null?e.string=a:e.string=Hw(n)}var K2=(n,t)=>{var e=qr();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Qt[n];return i&&i.isShared&&((Qt.restoreStructures||(Qt.restoreStructures=[]))[n]=i),Qt[n]=e,e.read=qw(e,r),e.read()},tD=typeof self=="object"?self:global;pn[0]=()=>{};pn[0].noBuffer=!0;pn[101]=()=>{let n=qr();return(tD[n[0]]||Error)(n[1])};pn[105]=n=>{let t=ir.getUint32(ne-4);da||(da=new Map);let e=qe[ne],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};da.set(t,i);let s=qr();return i.used?Object.assign(r,s):(i.target=s,s)};pn[112]=n=>{let t=ir.getUint32(ne-4),e=da.get(t);return e.used=!0,e.target};pn[115]=()=>new Set(qr());var Xw=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");pn[116]=n=>{let t=n[0],e=Xw[t];if(!e)throw new Error("Could not find typed array for code "+t);return new tD[e](Uint8Array.prototype.slice.call(n,1).buffer)};pn[120]=()=>{let n=qr();return new RegExp(n[0],n[1])};pn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=ne;ne+=t-4,Zn=[qr(),qr()],Zn.position0=0,Zn.position1=0;let r=ne;ne=e;try{return qr()}finally{ne=r}};pn[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function rD(n){let t=ml,e=ne,r=jw,i=us,s=yo,o=pl,a=Gw,l=da,c=Zn,u=new Uint8Array(qe.slice(0,ml)),h=Qt,d=Qt.slice(0,Qt.length),f=Tn,p=Rh,m=n();return ml=t,ne=e,jw=r,us=i,yo=s,pl=o,Gw=a,da=l,Zn=c,qe=u,Rh=p,Qt=h,Qt.splice(0,Qt.length,...d),Tn=f,ir=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),m}function fv(){qe=null,da=null,Qt=null}function iD(n){n.unpack?pn[n.type]=n.unpack:pn[n.type]=n}var mv=new Array(147);for(let n=0;n<256;n++)mv[n]=+("1e"+Math.floor(45.15-n*.30103));var gv=new vo({useRecords:!1}),j8=gv.unpack,H8=gv.unpackMultiple,W8=gv.unpack,yv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},q8=new Float32Array(1),mce=new Uint8Array(q8.buffer,0,4);var vv;try{vv=new TextEncoder}catch{}var xv,Kw,bv=typeof Buffer<"u",Qw=bv?Buffer.allocUnsafeSlow:Uint8Array,aD=bv?Buffer:Uint8Array,nD=bv?4294967296:2144337920,Se,Jr,he=0,xo,bo=null,Y8=/[\u0080-\uFFFF]/,Vp=Symbol("record-id"),Cc=class extends vo{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=aD.prototype.utf8Write?function(b,T,C){return Se.utf8Write(b,T,C)}:vv&&vv.encodeInto?function(b,T){return vv.encodeInto(b,Se.subarray(T)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,S=0;this.pack=this.encode=function(b,T){if(Se||(Se=new Qw(8192),Jr=new DataView(Se.buffer,0,8192),he=0),xo=Se.length-10,xo-he<2048?(Se=new Qw(Se.length),Jr=new DataView(Se.buffer,0,Se.length),xo=Se.length-10,he=0):he=he+7&2147483640,r=he,a=u.structuredClone?new Map:null,u.bundleStrings?(bo=["",""],Se[he++]=214,Se[he++]=98,bo.position=he-r,he+=4):bo=null,i=u.structures,i){i.uninitialized&&(i=u._mergeStructures(u.getStructures()));let C=i.sharedLength||0;if(C>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let P=0;P<C;P++){let D=i[P];if(!D)continue;let _,O=i.transitions;for(let L=0,j=D.length;L<j;L++){let V=D[L];_=O[V],_||(_=O[V]=Object.create(null)),O=_}O[Vp]=P+64}l=C}h||(i.nextId=C+64)}s&&(s=!1),o=i||[];try{if(w(b),bo){Jr.setUint32(bo.position+r,he-bo.position-r);let C=bo;bo=null,w(C[0]),w(C[1])}if(u.offset=he,a&&a.idsToInsert){he+=a.idsToInsert.length*6,he>xo&&M(he),u.offset=he;let C=Q8(Se.subarray(r,he),a.idsToInsert);return a=null,C}return T&cD?(Se.start=r,Se.end=he,Se):Se.subarray(r,he)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let C=0,P=v.length;C<P;C++)v[C][Vp]=0;v=[]}if(s&&u.saveStructures){let C=i.sharedLength||f;i.length>C&&(i=i.slice(0,C));let P=Se.subarray(r,he);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(b)):(l=C,P)}}T&rq&&(he=r)}};let w=b=>{he>xo&&(Se=M(he));var T=typeof b,C;if(T==="string"){let P=b.length;if(bo&&P>=8&&P<4096){let O=Y8.test(b);bo[O?0:1]+=b,Se[he++]=193,w(O?-P:P);return}let D;P<32?D=1:P<256?D=2:P<65536?D=3:D=5;let _=P*3;if(he+_>xo&&(Se=M(he+_)),P<64||!c){let O,L,j,V=he+D;for(O=0;O<P;O++)L=b.charCodeAt(O),L<128?Se[V++]=L:L<2048?(Se[V++]=L>>6|192,Se[V++]=L&63|128):(L&64512)===55296&&((j=b.charCodeAt(O+1))&64512)===56320?(L=65536+((L&1023)<<10)+(j&1023),O++,Se[V++]=L>>18|240,Se[V++]=L>>12&63|128,Se[V++]=L>>6&63|128,Se[V++]=L&63|128):(Se[V++]=L>>12|224,Se[V++]=L>>6&63|128,Se[V++]=L&63|128);C=V-he-D}else C=c(b,he+D,_);C<32?Se[he++]=160|C:C<256?(D<2&&Se.copyWithin(he+2,he+1,he+1+C),Se[he++]=217,Se[he++]=C):C<65536?(D<3&&Se.copyWithin(he+3,he+2,he+2+C),Se[he++]=218,Se[he++]=C>>8,Se[he++]=C&255):(D<5&&Se.copyWithin(he+5,he+3,he+3+C),Se[he++]=219,Jr.setUint32(he,C),he+=4),he+=C}else if(T==="number")if(b>>>0===b)b<64?Se[he++]=b:b<256?(Se[he++]=204,Se[he++]=b):b<65536?(Se[he++]=205,Se[he++]=b>>8,Se[he++]=b&255):(Se[he++]=206,Jr.setUint32(he,b),he+=4);else if(b>>0===b)b>=-32?Se[he++]=256+b:b>=-128?(Se[he++]=208,Se[he++]=b+256):b>=-32768?(Se[he++]=209,Jr.setInt16(he,b),he+=2):(Se[he++]=210,Jr.setInt32(he,b),he+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Se[he++]=202,Jr.setFloat32(he,b);let D;if(P<4||(D=b*mv[(Se[he]&127)<<1|Se[he+1]>>7])>>0===D){he+=4;return}else he--}Se[he++]=203,Jr.setFloat64(he,b),he+=8}else if(T==="object")if(!b)Se[he++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let _=a.idsToInsert||(a.idsToInsert=[]);D.id=_.push(D)}Se[he++]=214,Se[he++]=112,Jr.setUint32(he,D.id),he+=4;return}else a.set(b,{offset:he-r})}let P=b.constructor;if(P===Object)A(b,!0);else if(P===Array){C=b.length,C<16?Se[he++]=144|C:C<65536?(Se[he++]=220,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=221,Jr.setUint32(he,C),he+=4);for(let D=0;D<C;D++)w(b[D])}else if(P===Map){C=b.size,C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,Jr.setUint32(he,C),he+=4);for(let[D,_]of b)w(D),w(_)}else{for(let D=0,_=xv.length;D<_;D++){let O=Kw[D];if(b instanceof O){let L=xv[D];if(L.write){L.type&&(Se[he++]=212,Se[he++]=L.type,Se[he++]=0),w(L.write.call(this,b));return}let j=Se,V=Jr,H=he;Se=null;let W;try{W=L.pack.call(this,b,q=>(Se=j,j=null,he+=q,he>xo&&M(he),{target:Se,targetView:Jr,position:he-q}),w)}finally{j&&(Se=j,Jr=V,he=H,xo=Se.length-10)}W&&(W.length+he>xo&&M(W.length+he),he=X8(W,Se,he,L.type));return}}A(b,!b.hasOwnProperty)}}else if(T==="boolean")Se[he++]=b?195:194;else if(T==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))Se[he++]=211,Jr.setBigInt64(he,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)Se[he++]=207,Jr.setBigUint64(he,b);else if(this.largeBigIntToFloat)Se[he++]=203,Jr.setFloat64(he,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");he+=8}else if(T==="undefined")this.encodeUndefinedAsNil?Se[he++]=192:(Se[he++]=212,Se[he++]=0,Se[he++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},A=this.useRecords===!1?this.variableMapSize?b=>{let T=Object.keys(b),C=T.length;C<16?Se[he++]=128|C:C<65536?(Se[he++]=222,Se[he++]=C>>8,Se[he++]=C&255):(Se[he++]=223,Jr.setUint32(he,C),he+=4);let P;for(let D=0;D<C;D++)w(P=T[D]),w(b[P])}:(b,T)=>{Se[he++]=222;let C=he-r;he+=2;let P=0;for(let D in b)(T||b.hasOwnProperty(D))&&(w(D),w(b[D]),P++);Se[C+++r]=P>>8,Se[C+r]=P&255}:b=>{let T=Object.keys(b),C,P=o.transitions||(o.transitions=Object.create(null)),D=0;for(let O=0,L=T.length;O<L;O++){let j=T[O];C=P[j],C||(C=P[j]=Object.create(null),D++),P=C}let _=P[Vp];if(_)_>=96&&m?(Se[he++]=((_-=96)&31)+96,Se[he++]=_>>5):Se[he++]=_;else{_=o.nextId,_||(_=64),_<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(_=o.nextOwnId,_<y||(_=g),o.nextOwnId=_+1):(_>=y&&(_=g),o.nextId=_+1);let O=T.highByte=_>=96&&m?_-96>>5:-1;P[Vp]=_,o[_-64]=T,_<g?(T.isShared=!0,o.sharedLength=_-63,s=!0,O>=0?(Se[he++]=(_&31)+96,Se[he++]=O):Se[he++]=_):(O>=0?(Se[he++]=213,Se[he++]=114,Se[he++]=(_&31)+96,Se[he++]=O):(Se[he++]=212,Se[he++]=114,Se[he++]=_),D&&(x+=S*D),v.length>=p&&(v.shift()[Vp]=0),v.push(P),w(T))}for(let O=0,L=T.length;O<L;O++)w(b[T[O]])},M=b=>{let T;if(b>16777216){if(b-r>nD)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(nD,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(b-r<<2,Se.length-1)>>12)+1<<12;let C=new Qw(T);return Jr=new DataView(C.buffer,0,T),Se.copy?Se.copy(C,0,r,b):C.set(Se.slice(r,b)),he-=r,r=0,xo=C.length-10,Se=C}}useBuffer(t){Se=t,Jr=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),he=0}};Kw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Fp];xv=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,n.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?sD(n,16,t):oD(bv?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==aD&&this.structuredClone?sD(n,Xw.indexOf(e.name),t):oD(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function sD(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),o)}function oD(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:s}=t(e+5);r[i++]=198,s.setUint32(i,e),i+=4}r.set(n,i)}function X8(n,t,e,r){let i=n.length;switch(i){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:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function Q8(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;n.copyWithin(s+r,s,i),r-=6;let a=s+r;n[a++]=214,n[a++]=105,n[a++]=o>>24,n[a++]=o>>16&255,n[a++]=o>>8&255,n[a++]=o&255,i=s}return n}function gl(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");Kw.unshift(n.Class),xv.unshift(n)}iD(n)}var lD=new Cc({useRecords:!1}),K8=lD.pack,Z8=lD.pack;var{NEVER:J8,ALWAYS:$8,DECIMAL_ROUND:eq,DECIMAL_FIT:tq}=yv,cD=512,rq=1024;var uD=new Cc({structuredClone:!0});gl({Class:it.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,it.prototype),n}});gl({Class:ke.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ke.prototype),n}});gl({Class:fr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,fr.prototype),n}});gl({Class:Bp.prototype.constructor,type:4,write(n){return n.id},read(n){return new Bp(n)}});gl({Class:Np.prototype.constructor,type:5,write(n){return n.data},read(n){return new Np(n)}});gl({Class:pr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,pr.prototype),n}});function iq(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function Zw(n){if(Ch(n))return n;if(Array.isArray(n))return n.map(Zw);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=Zw(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Sv;(r=>{function n(i){return uD.pack(i)}r.serialize=n;function t(i){return uD.unpack(i)}r.deserialize=t;function e(i){return iq(n(Zw(i))).toString()}r.checksum=e})(Sv||(Sv={}));var hD;(e=>{function n(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=n;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(hD||(hD={}));function $w(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var nn={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["MouseHover"]:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["Start"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["Conditional"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["MouseDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["MouseUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["MousePress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["KeyDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["KeyUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["GameControl"]:["Transition","Animation","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["Trigger"]:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["Resize"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"],["VariableChange"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage"]},dD;(e=>{function n(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=n;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new ke}:{type:r,disabled:!1,key:void 0,actions:new ke}}e.defaultData=t})(dD||(dD={}));var wv;(e=>{function n(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=n,e.valueDefaultData={type:"Literal",value:0}})(wv||(wv={}));var Jw;(r=>{function n(i){return{type:"Comparison",operator:"==",lOperand:wv.propertyDefaultData(i),rOperand:{...wv.valueDefaultData}}}r.comparisonDefaultData=n;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}r.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}r.stateDefaultData=e})(Jw||(Jw={}));var fD;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!==void 0}t.isConditionalSubActions=n})(fD||(fD={}));var pD;(e=>{function n(r){return r.type==="Conditional"}e.is=n;function t(r){return{type:"Conditional",disabled:!1,inActions:new ke,outActions:new ke,condition:Jw.distanceDefaultData(r)}}e.defaultData=t})(pD||(pD={}));var mD;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ke,drop:new ke}})(mD||(mD={}));var Av;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ke})(Av||(Av={}));var Ev;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Ev||(Ev={}));var gD;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,actions:new ke}}e.defaultData=t})(gD||(gD={}));var yD;(e=>{function n(r){return r.type==="Scroll"}e.is=n;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ke}}e.defaultData=t})(yD||(yD={}));var vD;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,actions:new ke}}e.defaultData=t})(vD||(vD={}));var xD;(e=>{function n(r){return r.type==="Collision"}e.is=n;function t(){return{type:"Collision",disabled:!1,target:"character",actions:new ke}}e.defaultData=t})(xD||(xD={}));var bD;(e=>{function n(r){return r.type==="Trigger"}e.is=n;function t(r,i){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new ke,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(bD||(bD={}));var Mv;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function i(){let a={size:"mobile",operator:"<",actions:new ke},l={size:"tablet",operator:"<",actions:new ke},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new ke},u=new ke;return u.push({id:we.generateUUID(),fi:0,data:a},{id:we.generateUUID(),fi:1,data:l},{id:we.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=i;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new ke}}o.defaultBreakpointData=s})(Mv||(Mv={}));var Tv;(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(i){return i.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new ke,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Tv||(Tv={}));var hs="personal camera",vl="a218fcc3-276b-49b9-b485-49037fd14f5f",ED=2960946,$r=5526619;var Fs;(f=>{function n(p,m){return p[0]===m[0]&&p[1]===m[1]}f.isEqual=n;function t(p,m,g){return[p[0]+(m[0]-p[0])*g,p[1]+(m[1]-p[1])*g]}f.lerp=t;function e(p,m){return[p[0]+m[0],p[1]+m[1]]}f.add=e;function r(p,m){return[p[0]-m[0],p[1]-m[1]]}f.sub=r;function i(p,m){return[p[0]*m[0],p[1]*m[1]]}f.multiply=i;function s(p,m){return[p[0]/m[0],p[1]/m[1]]}f.divide=s;function o(p,m){return Math.pow(m[0]-p[0],2)+Math.pow(m[1]-p[1],2)}f.distanceSquared=o;function a(p,m){return Math.sqrt(o(p,m))}f.distance=a;function l(p,m){return p[0]*m[0]+p[1]*m[1]}f.dot=l;function c(p,m){return[p[0]*m,p[1]*m]}f.scalarMultiply=c;function u(p,m,g){let y=f.sub(m,p),v=f.sub(g,p),x=f.dot(y,v)/f.dot(y,y),S=f.scalarMultiply(y,x);return f.add(p,S)}f.projectionOnto=u;function h(p,m,g){return a(p,u(p,m,g))}f.projectionOntoDistance=h;function d(p,m){return[(p[0]+m[0])*.5,(p[1]+m[1])*.5]}f.center=d})(Fs||(Fs={}));var So;(a=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=n;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function i(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=i;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(So||(So={}));var zp;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,s){return[r[0]+(i[0]-r[0])*s,r[1]+(i[1]-r[1])*s,r[2]+(i[2]-r[2])*s,r[3]+(i[3]-r[3])*s]}e.lerp=t})(zp||(zp={}));var SD;(o=>{let n=180/Math.PI,t=Math.PI/180;function e(a){return typeof a=="number"?a*n:a}function r(a){return typeof a=="number"?a*t:a}function i(a){return[e(a[0]),e(a[1]),e(a[2])]}o.radToDeg=i;function s(a){return[r(a[0]),r(a[1]),r(a[2])]}o.degToRad=s})(SD||(SD={}));var yl;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=t;function e(s){return s??i.identity}i.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let u=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/u,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/u,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/u}return a}i.applyMatrix4=r})(yl||(yl={}));var Ei;(h=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=n,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function i(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=i;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(Ei||(Ei={}));var bt;(c=>{c.white={...Ei.white,a:1},c.transparent={...Ei.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...Ei.fromHex(u),a:h}}c.fromHexAndA=r;function i(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=i;function s(u,h){return Ei.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return Ei.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(bt||(bt={}));var Cv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Cv||(Cv={}));var wD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(wD||(wD={}));var AD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(AD||(AD={}));var fa;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(fa||(fa={}));function e1(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Vs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Vs||(Vs={}));var xl;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}i.getZoom=r})(xl||(xl={}));var wo;(e=>{function n(r,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*i,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function t(r,i){let s={...r};if(t1.forEach(o=>{Object.assign(s,{[o]:i[o]??r[o]})}),s.radial={...r.radial},i.radial){let o=r.radial,a=i.radial;r1.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},i.linear){let o=r.linear,a=i.linear;i1.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},i.grid){let o=r.grid,a=i.grid;n1.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},i.toObject){let o=r.toObject,a=i.toObject;s1.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},i.randomnessObject){let o=r.randomnessObject,a=i.randomnessObject;o1.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(wo||(wo={}));var Pv;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Pv||(Pv={}));var t1=["count"],r1=["radius","start","end","position","scale","rotation"],i1=["position","scale","rotation"],n1=["count","size"],s1=["count","position","scale","rotation"],o1=["strength","scale","rotation","position","movement","seed","freqScale"];var _v;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(_v||(_v={}));var Dv;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:bt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:bt.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:bt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Dv||(Dv={}));var Lh;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(Lh||(Lh={}));var bl;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(bl||(bl={}));var a1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(a1||(a1={}));var l1;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})(l1||(l1={}));var Ov;(t=>t.defaultData={...l1.defaultData,...a1.defaultData})(Ov||(Ov={}));var MD;(t=>{function n(e,r){let i=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&i.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&i.push(o)}return i}t.getMaterialData=n})(MD||(MD={}));var Bh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Bh||(Bh={}));var TD;(t=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(TD||(TD={}));function PD(n){return n.type!=="displace"}var CD;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(CD||(CD={}));var Iv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],_D=["wrapping","image","video","name","minFilter","magFilter"],zr;(i=>{function n(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}i.patch=n;function t(s,o){return s==="light"&&o?e(o):r(s)}i.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Bh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...o,type:"color",color:Ei.fromHex($r)};case"depth":return{...o,type:"depth",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]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",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{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ei.fromHex(6710886),a:1},colorB:{...Ei.fromHex(6710886),a:1},colorC:{...Ei.fromHex(16777215),a:1},colorD:{...Ei.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:bt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",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:bt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:bt.fromHexAndA(0,1),contourColor:bt.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{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ei.fromHex(0),a:1},colorB:{...Ei.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(zr||(zr={}));var ei;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(m=>h+=`${m}`):typeof p=="object"?Object.values(p).forEach(m=>{typeof m=="number"?h+=`${m.toFixed(4)}`:h+=`${m}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new ke}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function i(u,h){return{...u,name:h}}c.withName=i;function s(u,h="layer1",d="layer2"){let f=new ke;return f.push({fi:0,data:zr.defaultData("light",u),id:h}),f.push({fi:1,data:zr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=zr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new ke;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...zr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...zr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=zr.defaultData("texture");Object.assign(p.texture,{image:u});let m=new ke;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:zr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=zr.defaultData("video");Object.assign(p.texture,{video:u});let m=new ke;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:zr.defaultData("light",h),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(ei||(ei={}));var Nh;(t=>{function n(){return{points:new ke,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Nh||(Nh={}));var Fh;(t=>{function n(){return{points:new ke,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Fh||(Fh={}));var c1={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Rv;(t=>{function n(e,r){let i={...e};return u1.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(Rv||(Rv={}));var Lv={shape:c1,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},u1=["depth","offset","angle","twist","startScale","endScale"];var Up;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})(Up||(Up={}));var Bv;(t=>{function n(e,r){let i={...e};return Object.assign(i,r),i.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Rv.merge(i.extrusion,r.extrusion))),i}t.merge=n})(Bv||(Bv={}));var Sl;(t=>{function n(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==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Fh.defaultData(),extrusion:Lv};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Nh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=n})(Sl||(Sl={}));var h1=["width","height","depth"];var Nv;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ei.white,near:.1,far:2e3})(Nv||(Nv={}));var Vh;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focusDistance:100,focalLength:20,bokehScale:5},noise:{...n,blendFunction:16}}})(Vh||(Vh={}));var d1;(t=>t.defaultData={softShadowQuality:"low"})(d1||(d1={}));var f1;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(f1||(f1={}));var p1;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(p1||(p1={}));var wl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(wl||(wl={}));var m1;(t=>t.defaultData={playCamera:hs,gameControlObject:null})(m1||(m1={}));var Fv;(t=>t.defaultData={backgroundColor:bt.fromHexAndA(ED,1),postprocessing:Vh.defaultData,fog:Nv.defaultData,globalPhysics:wl.defaultData,ambient:f1.defaultData,ao:p1.defaultData,shadow:d1.defaultData,publish:m1.defaultData})(Fv||(Fv={}));var Vv;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Vv||(Vv={}));var DD;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(DD||(DD={}));var zh;(i=>{i.identity={...Cv.identity,hiddenMatrix:yl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=e;function r(s,o){return Ky({position:So.isEqual(s.position,o.position)?void 0:o.position,rotation:So.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:So.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:yl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(zh||(zh={}));var Mi;(t=>t.defaultData={states:new ke,events:new ke,visible:!0,raycastLock:!1,physics:bl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...zh.identity,cloner:null})(Mi||(Mi={}));var zv;(t=>t.defaultData={type:"Empty",...Mi.defaultData})(zv||(zv={}));var OD;(t=>t.defaultData={type:"ParticleCollider",...Vv.defaultData,...Mi.defaultData})(OD||(OD={}));var ID;(t=>t.defaultData={type:"Component",...Mi.defaultData})(ID||(ID={}));var RD;(t=>t.defaultData={type:"Particle",...Mi.defaultData,...Lh.defaultData})(RD||(RD={}));var Pc;(t=>t.defaultData={type:"Mesh",...Mi.defaultData,...Ov.defaultData})(Pc||(Pc={}));var _c;(t=>t.defaultData={...Mi.defaultData,...zh.identity,position:[0,0,xl.DefaultTargetOffset],...xl.defaultData})(_c||(_c={}));var Uv;(e=>{function n(r){return{...Mi.defaultData,...Dv.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Uv||(Uv={}));var Uh;(e=>{function n(r,i,s=0){for(;s<i.length;){let o=r?r[i[s]]:void 0;if(i.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=n;function t(r,i,s=0){let o=n(r,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Uh||(Uh={}));var Ao;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...Mi.defaultData,...a,component:o,overrides:new pr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function i(o){let a=zh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(Ao||(Ao={}));var pa;(e=>{e.defaultData={type:"Page",...Mi.defaultData,physics:{...bl.defaultData,fusedBody:!1},...Fv.defaultData,camera:_c.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(pa||(pa={}));var kv;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:yl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:bl.defaultData,states:new ke,events:new ke,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xl.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Mi.defaultData,...Pc.defaultData,geometry:Sl.defaultData("RectangleGeometry"),material:ei.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Mi.defaultData,...Pc.defaultData,geometry:Sl.defaultData("BooleanGeometry"),material:ei.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Mi.defaultData,...Pc.defaultData,geometry:Sl.defaultData("TextGeometry"),material:ei.defaultTwoLayerData("phong","layer1","layer2")}))(kv||(kv={}));var ma;(i=>{function n(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new pr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new pr})))):Vs.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=n;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=fl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&zr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=fl(a.materials,l=>{for(let c=0;c<a.materials.length;c++){let u=o.materials[c];if(typeof u!="string")for(let[h,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(h);f&&zr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],c={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Pv.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))u(["materials",f],p);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}i.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,zh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Vs.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Bv.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:wo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:wo.merge(a.cloner,o.cloner)});else if(_v.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Ei.clone(l.color))}return a}i.patch=r})(ma||(ma={}));var kh;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(kh||(kh={}));var zs;(t=>t.defaultData={orbitControls:kh.defaultData,playPage:vl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let i=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?i=30:(r===4||r===11||r===9)&&(i=-30),[120,[i,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70}},stopRaycast:!0,hdTransmission:!1})(zs||(zs={}));var g1;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(g1||(g1={}));var y1;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(y1||(y1={}));var ga;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...g1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:y1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ga||(ga={}));var Al;(e=>{function n(r){return r.find(i=>i.data.type==="Page"&&i.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,i,s){r.scene.objects.traverseFrom(i,(o,a)=>{if(a.type==="Instance"){let l=Gh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Al||(Al={}));var ya;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Uv.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,h=[]){let d=[],f=kv.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...h);let p=new fr;return p.push({fi:1,id:vl,data:{...pa.defaultData,name:"Scene 1"},children:d}),p}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:zs.defaultData,styles:ga.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new fr,publish:zs.defaultData,styles:ga.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:zs.defaultData,styles:ga.defaultData()}},c.emptyData=function(){return{objects:new fr,publish:{...zs.defaultData},styles:ga.defaultData()}};function a(u){return{...c.defaultData,objects:fn(u,fr.prototype)}}c.withObjs=a;function l(u,h){return a([{id:u,data:h,children:[],fi:0}])}c.withObj=l})(ya||(ya={}));var jh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(jh||(jh={}));var Ni;(s=>{function n(o){return o.textValue!==void 0}s.isTextValue=n;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return n(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function i(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=i})(Ni||(Ni={}));var v1;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(v1||(v1={}));var LD;(t=>t.all=[...v1.all,"components"])(LD||(LD={}));var BD;(t=>{function n(){return{images:new it,videos:new it,colors:new it,audios:new it,particles:new it,fonts:new it,materials:new it,components:new it,variables:new it}}t.defaultData=n})(BD||(BD={}));var va;(t=>{function n(){return{images:new it,videos:new it,colors:new it,audios:new it,particles:new it,fonts:new it,materials:new it,components:new it,variables:new it}}t.defaultData=n})(va||(va={}));var mn;(s=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},fn(o,it.prototype)}s.defaultColors=n;function t(){return fn({},it.prototype)}s.defaultImages=t;function e(){return{catelogs:new it,materials:new it,images:new it,videos:new it,colors:new it,audios:new it,particles:new it,fonts:new it,variables:new ke,lib:va.defaultData()}}s.emptyData=e;function r(o){switch(o){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",o)}}s.defaultVariables=r;function i(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=i})(mn||(mn={}));var Hh;(t=>t.list=["idle","move","jump","run"])(Hh||(Hh={}));var Wh;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ke,move:new ke,jump:new ke,run:new ke},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:bt.fromHexAndA(3728051,1)}}))(Wh||(Wh={}));function ND(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,i=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Kn(Vr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Vr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function xa(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function ba(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((i,s)=>{i===void 0&&(r.materials[s]=ei.defaultData(),i=r.materials[s]),typeof i!="string"&&t(i)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ei.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ei.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&Object.getPrototypeOf(i.material)!==pr.prototype&&t(i.material)})})}function sq(n){Object.assign(n.scene.publish,{orbitControls:{...kh.defaultData,...Vr(n.scene.publish.orbitControls)}})}function oq(n){Object.assign(n.scene.publish.settings,{video:{...zs.defaultData.settings.video,...Vr(n.scene.publish.settings.video)}})}function aq(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[i,s]of Object.entries(r))if((Iv.includes(i)||typeof s=="boolean")&&delete r[i],i==="texture")for(let[o,a]of Object.entries(s))(_D.includes(o)||typeof a=="boolean")&&delete s[o]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function lq(n){n.scene.publish.withBackground=!0}function cq(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function uq(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(i=>i+1),r.linear.scale=r.linear.scale.map(i=>i+1))})}function hq(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function dq(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let i=Vr(n.scene.objects.data(r));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Vr(e).booleanExclude!==!0)}})}function fq(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function pq(n){function t(r){Object.setPrototypeOf(r,pr.prototype),r.texture&&Object.setPrototypeOf(r.texture,pr.prototype)}function e(r){Object.setPrototypeOf(r,pr.prototype);for(let i in r)t(r[i])}n.scene.objects.traverse((r,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Vr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],c=Vr(l).layers;e(c),l.layers=c}})})}function FD(n){n.layers===void 0&&Object.assign(n,ei.defaultTwoLayerData("lambert"))}function x1(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let i={...Vr(t),colors:e,steps:r};Object.assign(t,i)}})}function mq(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function VD(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&x1(r)}):"material"in e&&typeof e.material!="string"&&x1(e.material)}),Object.values(n.shared.materials).forEach(t=>x1(t))}function gq(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function yq(n){n.shared.audios=fn({},it.prototype)}function vq(n){n.shared.videos=fn({},it.prototype)}function xq(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function bq(n){Object.entries(Vr(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(Vr(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function Sq(n){n.scene.publish.settings.web.preload=!1}function zD(n){n.layers&&n.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function UD(n){n.layers&&n.layers.forEach(t=>{PD(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function wq(n){n.shared.fonts=fn({},it.prototype)}function Aq(n){return n.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Eq(n){let t=[];n.scene.objects.traverse((e,r)=>{let i=r;if(i.type==="TextFrame"){let s=ei.defaultTwoLayerData("phong"),o=typeof i.color=="string"?n.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=Aq(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...Mi.defaultData,...Pc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Sl.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Vr(i.states),events:Vr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},c=Vr(n.scene.objects).parent(e);n.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function Mq(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new ke,move:new ke,jump:new ke}});else{let s=new ke;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:we.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Kn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ke({fi:0,id:we.generateUUID(),data:c},{fi:1,id:we.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function Tq(n){n.scene.objects.traverse((t,e)=>{function r(i,s){let o=new ke,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Kn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Kn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:we.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function kD(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=zr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function GD(n){xa(n,kD),ba(n,kD)}function Cq(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function Pq(n){n.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function _q(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=ei.defaultTwoLayerData("phong"))})}function Dq(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function Oq(n){n.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function Iq(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function Rq(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function Lq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function Bq(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function Nq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Wh.defaultDataThirdPerson.navmesh)})})}function Fq(n){n.scene.styles||(n.scene.styles=ga.defaultData())}function jD(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Vq(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ba(n,jD),xa(n,jD)}function zq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ke})})})}function Uq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function HD(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function WD(n,t){if(t<1&&(ba(n,ND),xa(n,ND),n.schema=1),t<2&&(sq(n),n.schema=2),t<3&&(aq(n),n.schema=3),t<4&&(lq(n),n.schema=4),t<5&&(cq(n),n.schema=5),t<6&&(uq(n),n.schema=6),t<7&&(hq(n),n.schema=7),t<8&&(n.schema=8),t<9&&(VD(n),n.schema=9),t<10&&(mq(n),n.schema=10),t<11&&(gq(n),n.schema=11),t<12&&(VD(n),n.schema=12),t<13&&(yq(n),n.schema=13),t<14&&(xq(n),n.schema=14),t<15&&(bq(n),n.schema=15),t<16&&(Sq(n),n.schema=16),t<17&&(ba(n,zD),xa(n,zD),n.schema=17),t<18&&(ba(n,FD),xa(n,FD),n.schema=18),t<19&&(oq(n),n.schema=19),t<20&&(wq(n),Eq(n),n.schema=20),t<21&&(Mq(n),Tq(n),n.schema=21),t<22&&(GD(n),n.schema=22),t<23&&(Cq(n),n.schema=23),t<24&&(Pq(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(vq(n),t<25&&(n.schema=25)),t<26&&(dq(n),n.schema=26),t<27&&(fq(n),n.schema=27),t<28&&(GD(n),n.schema=28),t<29&&(pq(n),n.schema=29),t<30&&(_q(n),n.schema=30),t<31&&(Dq(n),n.schema=31),t<33&&(Oq(n),n.schema=33),t<34&&(Iq(n),n.schema=34),t<35&&(Rq(n),n.schema=35),t<36&&(Lq(n),n.schema=36),t<37&&(Bq(n),n.schema=37),t<38&&(ba(n,UD),xa(n,UD),n.schema=38),t<39&&(Nq(n),n.schema=39),t<40&&(Fq(n),n.schema=40),t<41&&(Vq(n),n.schema=41),t<42&&(zq(n),n.schema=42),t<43&&(Uq(n),n.schema=43),t<99){ba(n,HD),xa(n,HD),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=hs);let e=Vr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=vl,r.insertBefore(null,null,[{id:vl,data:{...pa.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Kn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Kn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...wl.defaultData,...Kn(n.scene.environment,"usePhysics","gravity")},camera:Vr(n.scene.ownerCamera)??pa.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==ya.TRASH_CAN_ID&&r.move(vl,o.fi,o.id);let i=0,s=0;n.shared.penumbraSize&&n.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(i,2)],i+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,bl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function qD(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function kq(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function Gq(n){Array.isArray(Vr(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var qh=180/Math.PI;function YD(n){n.rotation=n.rotation.slice(0,3).map(t=>t*qh)}function XD(n){YD(n),n.type==="Page"&&YD(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*qh))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*qh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*qh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=qh,t.extrusion.twist*=qh),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(Vr(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function jq(n){n.shared.variables=fn({},it.prototype)}function Hq(n){let t=Vr(n.shared.variables);n.shared.variables=fn(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),ke.prototype)}var Eo=113;function QD(n,t){t(n.data);for(let e of n.children)QD(e,t)}function Wq(n){let t=n.schema??104;t!==Eo&&t<105&&(QD(n.asset,XD),n.schema=105)}function qq(n){n.shared.particles=fn({},it.prototype),n.shared.lib&&(n.shared.lib.particles=va.defaultData().particles)}function Yq(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function Xq(n){n.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function Qq(n){n.scene.objects.traverse((t,e)=>{Array.isArray(Vr(e.events))!==!1&&e.events?.forEach(r=>{let i=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode=i??"Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode=i==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(o=>{r.gameActions[o]?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),a.type==="Animation"&&(a.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(s=>{(s.type==="Transition"||s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(s=>{s.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"||o.type==="SwitchCamera")&&(o.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Once"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}),r.outActions?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),(s.type==="Animation"||s.type==="SwitchCamera")&&(s.runMode="Normal")}))})})}function Gv(n){let t=n.schema??0;if(t!==Eo){console.warn("updating from ",t,"to ",Eo),WD(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=zs.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(ba(n,qD),xa(n,qD),n.schema=101),t<102&&(kq(n),n.schema=102),t<104&&(n.shared.catelogs=new it,n.shared.lib=va.defaultData(),n.schema=104),t<105&&(jq(n),n.scene.objects.traverse((e,r)=>{XD(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))Wq(e);t<106&&(Hq(n),n.schema=106),t<107&&(n.shared.lib.variables=va.defaultData().variables,n.schema=107),t<109&&(qq(n),n.schema=109),t<110&&(Yq(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{Gq(r)}),n.schema=111),t<112&&(Xq(n),n.schema=112),t<113&&(Qq(n),n.schema=113)}}var Gh;(l=>{l.defaultData={schema:Eo,scene:ya.defaultData,frames:new it().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",jh.defaultData),shared:{...mn.emptyData(),colors:mn.defaultColors()}},l.emptyDataForImports=function(){let c=ya.emptyDataWithPage();return{schema:Eo,scene:c,frames:new it().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",jh.defaultData),shared:{...mn.emptyData(),colors:mn.defaultColors(),images:mn.defaultImages()}}},l.emptyData=function(){return{schema:Eo,scene:ya.emptyDataWithPage(),frames:new it().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",jh.defaultData),shared:mn.emptyData()}},l.clipboard2dData=function(){return{schema:Eo,scene:ya.emptyData(),frames:new it,shared:mn.emptyData()}},l.collabHelper={...Lp,updateSchema(c){return(c.schema??0)<Eo?fl(c,Gv):(c.schema??0)-Eo}};function s(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=s;function o(c){return{...c,shared:{...c.shared,lib:va.defaultData()}}}l.withoutLib=o;function a(c,u){let h=c.scene.objects.get(u);if(h&&h.data.type==="Component")return h;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=a})(Gh||(Gh={}));var jv;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(jv||(jv={}));var KD;(t=>{function n(e){return!0}t.is=n})(KD||(KD={}));var Hv;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(i,s){return{position:s?.position??i.position,rotation:s?.rotation??i.rotation,scale:s?.scale??i.scale,shear:s?.shear??i.shear}}r.merge=t;function e(i,s){return Ky({position:Fs.isEqual(i.position,s.position)?void 0:s.position,rotation:i.rotation===s.rotation?void 0:s.rotation,scale:Fs.isEqual(i.scale,s.scale)?void 0:s.scale,shear:i.shear&&s.shear&&Fs.isEqual(i.shear,s.shear)?void 0:s.shear})}r.diff=e})(Hv||(Hv={}));var b1;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(b1||(b1={}));var ZD;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(ZD||(ZD={}));var Wv;(t=>t.defaultData={opacity:1,fill:{color:bt.fromHexAndA($r,1),enabled:!0},stroke:{color:bt.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:bt.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:bt.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Wv||(Wv={}));var Sa;(s=>{function n(o,a){return{name:a}}s.newEmpty=n;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,Hv.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function i(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=i})(Sa||(Sa={}));var kp;(t=>t.defaultData={...Hv.defaultData,...b1.defaultData,states:new ke,events:new ke,visible:!0,raycastLock:!1})(kp||(kp={}));var Yh;(t=>t.defaultData={...kp.defaultData,...Wv.defaultData})(Yh||(Yh={}));var qv;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(qv||(qv={}));var S1;(t=>t.defaultData={...Yh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(S1||(S1={}));var Xh;(t=>t.defaultData={...Yh.defaultData,...qv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Xh||(Xh={}));var w1;(t=>t.defaultData={...Yh.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(w1||(w1={}));var A1;(t=>t.defaultData={...Yh.defaultData,type:"path2d",path:"",name:"Path"})(A1||(A1={}));var JD;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(JD||(JD={}));var Gp;(t=>t.defaultData={...kp.defaultData,name:"Group",type:"group2d"})(Gp||(Gp={}));var E1;(t=>t.defaultData=()=>({...kp.defaultData,...qv.defaultData,...Wv.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:bt.fromHexAndA(4737101,1),enabled:!0},stroke:{color:bt.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(E1||(E1={}));var wa;(s=>{function n(o){switch(o){case"rectangle2d":return{...Xh.defaultData};case"ellipse2d":return{...S1.defaultData};case"text2d":return{...w1.defaultData};case"vector2d":return{...Xh.defaultData};case"path2d":return{...A1.defaultData};case"frame2d":return{...E1.defaultData()};case"group2d":return{...Gp.defaultData}}}s.defaultData=n;function t(o){return"width"in o&&"height"in o?[typeof o.width=="number"?o.width*.5:0,typeof o.height=="number"?o.height*.5:0]:[0,0]}s.getPivot=t;function e(o){return o.type==="rectangle2d"||o.type==="ellipse2d"||o.type==="text2d"||o.type==="frame2d"}s.isResizeable=e;function r(o){return o.type==="frame2d"&&o.autoLayout!==void 0}s.isAutoLayoutable=r;function i(o){return o.type==="rectangle2d"||o.type==="frame2d"}s.hasCorners=i})(wa||(wa={}));var Yv;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new fr},e.emptyData=function(){return{type:"scene2d",objects:new fr}}))(Yv||(Yv={}));function Us(n,t=!1){let e=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,l=new _e,c=0;for(let u=0;u<n.length;++u){let h=n[u],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,u),c+=f}}if(e){let u=0,h=[];for(let d=0;d<n.length;++d){let f=n[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+u);u+=n[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=$D(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[u].length;++m)f.push(o[u][m][d]);let p=$D(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return l}function $D(n){let t,e,r,i=0;for(let a=0;a<n.length;++a){let l=n[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<n.length;++a)s.set(n[a].array,o),o+=n[a].array.length;return new Xe(s,e,r)}var eO=Math.pow(2,-24);var Dc=class{constructor(){}};function fs(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function M1(n){let t=-1,e=-1/0;for(let r=0;r<3;r++){let i=n[r+3]-n[r];i>e&&(e=i,t=r)}return t}function T1(n,t){t.set(n)}function C1(n,t,e){let r,i;for(let s=0;s<3;s++){let o=s+3;r=n[s],i=t[s],e[s]=r<i?r:i,r=n[o],i=t[o],e[o]=r>i?r:i}}function jp(n,t,e){for(let r=0;r<3;r++){let i=t[n+2*r],s=t[n+2*r+1],o=i-s,a=i+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Qh(n){let t=n[3]-n[0],e=n[4]-n[1],r=n[5]-n[2];return 2*(t*e+e*r+r*t)}function Jq(n,t){if(!n.index){let e=n.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new r(4*e)):i=new Uint16Array(new r(2*e)),n.setIndex(new Xe(i,1));for(let s=0;s<e;s++)i[s]=s}}function $q(n){if(!n.groups||!n.groups.length)return[{offset:0,count:n.index.count/3}];let t=[],e=new Set;for(let i of n.groups)e.add(i.start),e.add(i.start+i.count);let r=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<r.length-1;i++){let s=r[i],o=r[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function _1(n,t,e,r,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let S=n[v+0],w=n[v+1],A=S-w,M=S+w;A<s&&(s=A),M>l&&(l=M),y&&S<h&&(h=S),y&&S>p&&(p=S);let b=n[v+2],T=n[v+3],C=b-T,P=b+T;C<o&&(o=C),P>c&&(c=P),y&&b<d&&(d=b),y&&b>m&&(m=b);let D=n[v+4],_=n[v+5],O=D-_,L=D+_;O<a&&(a=O),L>u&&(u=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,y&&(i[0]=h,i[1]=d,i[2]=f,i[3]=p,i[4]=m,i[5]=g)}function e9(n,t,e,r){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;u<h;u+=6){let d=n[u+0];d<i&&(i=d),d>a&&(a=d);let f=n[u+2];f<s&&(s=f),f>l&&(l=f);let p=n[u+4];p<o&&(o=p),p>c&&(c=p)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function t9(n,t,e,r,i){let s=e,o=e+r-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let c=0;c<3;c++){let u=n[s*3+c];n[s*3+c]=n[o*3+c],n[o*3+c]=u;let h=t[s*6+c*2+0];t[s*6+c*2+0]=t[o*6+c*2+0],t[o*6+c*2+0]=h;let d=t[s*6+c*2+1];t[s*6+c*2+1]=t[o*6+c*2+1],t[o*6+c*2+1]=d}s++,o--}else return s}}var Aa=32,r9=(n,t)=>n.candidate-t.candidate,El=new Array(Aa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Xv=new Float32Array(6);function i9(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=M1(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=M1(n),o!==-1&&(a=n9(e,r,i,o));else if(s===2){let l=Qh(n),c=1.25*i,u=r*6,h=(r+i)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Aa;if(i<Aa/4){let y=[...El];y.length=i;let v=0;for(let S=u;S<h;S+=6,v++){let w=y[v];w.candidate=e[S+2*d],w.count=0;let{bounds:A,leftCacheBounds:M,rightCacheBounds:b}=w;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,A[T]=1/0,A[T+3]=-1/0;jp(S,e,A)}y.sort(r9);let x=i;for(let S=0;S<x;S++){let w=y[S];for(;S+1<x&&y[S+1].candidate===w.candidate;)y.splice(S+1,1),x--}for(let S=u;S<h;S+=6){let w=e[S+2*d];for(let A=0;A<x;A++){let M=y[A];w>=M.candidate?jp(S,e,M.rightCacheBounds):(jp(S,e,M.leftCacheBounds),M.count++)}}for(let S=0;S<x;S++){let w=y[S],A=w.count,M=i-w.count,b=w.leftCacheBounds,T=w.rightCacheBounds,C=0;A!==0&&(C=Qh(b)/l);let P=0;M!==0&&(P=Qh(T)/l);let D=1+1.25*(C*A+P*M);D<c&&(o=d,c=D,a=w.candidate)}}else{for(let x=0;x<Aa;x++){let S=El[x];S.count=0,S.candidate=f+g+x*g;let w=S.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let x=u;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=Aa&&(A=Aa-1);let M=El[A];M.count++,jp(x,e,M.bounds)}let y=El[Aa-1];T1(y.bounds,y.rightCacheBounds);for(let x=Aa-2;x>=0;x--){let S=El[x],w=El[x+1];C1(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;x<Aa-1;x++){let S=El[x],w=S.count,A=S.bounds,b=El[x+1].rightCacheBounds;w!==0&&(v===0?T1(A,Xv):C1(A,Xv,Xv)),v+=w;let T=0,C=0;v!==0&&(T=Qh(Xv)/l);let P=i-v;P!==0&&(C=Qh(b)/l);let D=1+1.25*(T*v+C*P);D<c&&(o=d,c=D,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function n9(n,t,e,r){let i=0;for(let s=t,o=t+e;s<o;s++)i+=n[s*6+r*2];return i/e}function s9(n,t){let e=n.attributes.position,r=n.index.array,i=r.length/3,s=new Float32Array(i*6),o=e.normalized,a=e.array,l=e.offset||0,c=3;e.isInterleavedBufferAttribute&&(c=e.data.stride);let u=["getX","getY","getZ"];for(let h=0;h<i;h++){let d=h*3,f=h*6,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*c+l,m=r[d+1]*c+l,g=r[d+2]*c+l);for(let y=0;y<3;y++){let v,x,S;o?(v=e[u[y]](p),x=e[u[y]](m),S=e[u[y]](g)):(v=a[p+y],x=a[m+y],S=a[g+y]);let w=v;x<w&&(w=x),S<w&&(w=S);let A=v;x>A&&(A=x),S>A&&(A=S);let M=(A-w)/2,b=y*2;s[f+b+0]=w+M,s[f+b+1]=M+(Math.abs(w)+M)*eO,w<t[y]&&(t[y]=w),A>t[y+3]&&(t[y+3]=A)}}return s}function o9(n,t){function e(y){d&&d(y/f)}function r(y,v,x,S=null,w=0){if(!p&&w>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),x<=u||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=i9(y.boundingData,S,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=t9(a,o,v,x,A);if(M===v||M===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new Dc,T=v,C=M-v;y.left=b,b.boundingData=new Float32Array(6),_1(o,T,C,b.boundingData,s),r(b,T,C,s,w+1);let P=new Dc,D=M,_=x-C;y.right=P,P.boundingData=new Float32Array(6),_1(o,D,_,P.boundingData,s),r(P,D,_,s,w+1)}return y}Jq(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=s9(n,i),a=n.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=n.index.count/3,p=!1,m=[],g=$q(n);if(g.length===1){let y=g[0],v=new Dc;v.boundingData=i,e9(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Dc;v.boundingData=new Float32Array(6),_1(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function iO(n,t){let e=o9(n,t),r,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<e.length;u++){let h=e[u],d=l(h),f=new a(32*d);r=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),c(0,h),o.push(f)}return o;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function c(u,h){let d=u/4,f=u/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){let g=h.offset,y=h.count;return i[d+6]=g,s[f+14]=y,s[f+15]=65535,u+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=c(u+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=x/4,x=c(x,y),i[d+7]=v,x}}}var Cn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}setFromPoints(t,e){let r=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,i=l>i?l:i}this.min=r,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Cn.prototype.setFromBox=function(){let n=new E;return function(e,r){let i=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){n.x=i.x*l+s.x*(1-l),n.y=i.y*c+s.y*(1-c),n.z=i.z*u+s.z*(1-u);let h=e.dot(n);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var bfe=function(){let n=new Cn;return function(e,r){let i=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(n.setFromPoints(d,a),h.isSeparated(n))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(n.setFromPoints(d,i),h.isSeparated(n))return!1}}}();var a9=function(){let n=new E,t=new E,e=new E;return function(i,s,o){let a=i.start,l=n,c=s.start,u=t;e.subVectors(a,c),n.subVectors(i.end,i.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),Hp=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){a9(i,s,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(i.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),nO=function(){let n=new E,t=new E,e=new Zr,r=new Si;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var l9=1e-15;function Kh(n){return Math.abs(n)<l9}var Pn=class extends Mr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Cn),this.points=[this.a,this.b,this.c],this.sphere=new Dr,this.plane=new Zr,this.needsUpdate=!0}intersectsSphere(t){return nO(t,this)}update(){let t=this.a,e=this.b,r=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,i);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,i);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Pn.prototype.closestPointToSegment=function(){let n=new E,t=new E,e=new Si;return function(i,s=null,o=null){let{start:a,end:l}=i,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),Hp(e,i,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),o&&o.copy(t))}return this.closestPointToPoint(a,n),u=a.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(a)),this.closestPointToPoint(l,n),u=l.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),o&&o.copy(l)),Math.sqrt(h)}}();Pn.prototype.intersectsTriangle=function(){let n=new Pn,t=new Array(3),e=new Array(3),r=new Cn,i=new Cn,s=new E,o=new E,a=new E,l=new E,c=new Si,u=new Si,h=new Si;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(n.copy(f),n.update(),f=n);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let M=v[A],b=x[A];if(r.setFromPoints(b,e),M.isSeparated(r))return!1}let S=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let M=S[A],b=w[A];if(r.setFromPoints(b,t),M.isSeparated(r))return!1}for(let A=0;A<4;A++){let M=x[A];for(let b=0;b<4;b++){let T=w[b];if(s.crossVectors(M,T),r.setFromPoints(s,t),i.setFromPoints(s,e),r.isSeparated(i))return!1}}return p&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,S=0;for(let O=0;O<3;O++){let L=v[O],j=v[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(o);let V=x?u.start:u.end,H=Kh(y.distanceToPoint(L));if(Kh(y.normal.dot(o))&&H){u.copy(c),S=2;break}if((y.intersectLine(c,V)||H)&&!Kh(V.distanceTo(j))){if(S++,x)break;x=!0}}if(S===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;let w=f.points,A=!1,M=0;for(let O=0;O<3;O++){let L=w[O],j=w[(O+1)%3];c.start.copy(L),c.end.copy(j),c.delta(a);let V=A?h.start:h.end,H=Kh(g.distanceToPoint(L));if(Kh(g.normal.dot(a))&&H){h.copy(c),M=2;break}if((g.intersectLine(c,V)||H)&&!Kh(V.distanceTo(j))){if(M++,A)break;A=!0}}if(M===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(M!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let b=u.start.dot(o),T=u.end.dot(o),C=h.start.dot(o),P=h.end.dot(o),D=T<C,_=b<P;return b!==P&&C!==T&&D===_?!1:(p&&(l.subVectors(u.start,h.start),l.dot(o)>0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();Pn.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Pn.prototype.distanceToTriangle=function(){let n=new E,t=new E,e=["a","b","c"],r=new Si,i=new Si;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,n),d=p.distanceToSquared(n),d<u&&(u=d,a&&a.copy(n),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,n),d=m.distanceToSquared(n),d<u&&(u=d,a&&a.copy(m),l&&l.copy(n))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];i.set(o[m],o[g]),Hp(r,i,n,t);let y=n.distanceToSquared(t);y<u&&(u=y,a&&a.copy(n),l&&l.copy(t))}}return Math.sqrt(u)}}();var _n=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new ce,this.invMatrix=new ce,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Cn),this.alignedSatBounds=new Array(3).fill().map(()=>new Cn),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};_n.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=i[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<<c,f=i[d];u.subVectors(a,f),h.setFromPoints(u,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();_n.prototype.intersectsBox=function(){let n=new Cn;return function(e){this.needsUpdate&&this.update();let r=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(n.min=r.x,n.max=i.x,a[0].isSeparated(n)||(n.min=r.y,n.max=i.y,a[1].isSeparated(n))||(n.min=r.z,n.max=i.z,a[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){let c=o[l],u=s[l];if(n.setFromBox(c,e),u.isSeparated(n))return!1}return!0}}();_n.prototype.intersectsTriangle=function(){let n=new Pn,t=new Array(3),e=new Cn,r=new Cn,i=new E;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let c=o.satBounds,u=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=c[d],p=u[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=u[p];if(i.crossVectors(f,m),e.setFromPoints(i,t),r.setFromPoints(i,h),e.isSeparated(r))return!1}}return!0}}();_n.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();_n.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();_n.prototype.distanceToBox=function(){let n=["x","y","z"],t=new Array(12).fill().map(()=>new Si),e=new Array(12).fill().map(()=>new Si),r=new E,i=new E;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,r),o.closestPointToPoint(r,i),l&&l.copy(r),c&&c.copy(i)),0;let u=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];i.copy(y).clamp(h,d);let v=y.distanceToSquared(i);if(v<p&&(p=v,l&&l.copy(y),c&&c.copy(i),v<u))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,S=(g+2)%3,w=y<<x|v<<S,A=1<<g|y<<x|v<<S,M=f[w],b=f[A];t[m].set(M,b);let C=n[g],P=n[x],D=n[S],_=e[m],O=_.start,L=_.end;O[C]=h[C],O[P]=y?h[P]:d[P],O[D]=v?h[D]:d[P],L[C]=d[C],L[P]=y?h[P]:d[P],L[D]=v?h[D]:d[P],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?d.x:h.x,i.y=y?d.y:h.y,i.z=v?d.z:h.z,this.closestPointToPoint(i,r);let x=i.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),c&&c.copy(i),x<u))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Hp(y,x,r,i);let S=r.distanceToSquared(i);if(S<p&&(p=S,l&&l.copy(r),c&&c.copy(i),S<u))return Math.sqrt(S)}}return Math.sqrt(p)}}();var Zh=new E,Jh=new E,$h=new E,Kv=new U,Zv=new U,Jv=new U,sO=new E,oO=new E,aO=new E,$v=new E;function c9(n,t,e,r,i,s){let o;return s===ui?o=n.intersectTriangle(r,e,t,!0,i):o=n.intersectTriangle(t,e,r,s!==ji,i),o===null?null:{distance:n.origin.distanceTo(i),point:i.clone()}}function u9(n,t,e,r,i,s,o,a,l){Zh.fromBufferAttribute(t,s),Jh.fromBufferAttribute(t,o),$h.fromBufferAttribute(t,a);let c=c9(n,Zh,Jh,$h,$v,l);if(c){r&&(Kv.fromBufferAttribute(r,s),Zv.fromBufferAttribute(r,o),Jv.fromBufferAttribute(r,a),c.uv=Mr.getInterpolation($v,Zh,Jh,$h,Kv,Zv,Jv,new U)),i&&(Kv.fromBufferAttribute(i,s),Zv.fromBufferAttribute(i,o),Jv.fromBufferAttribute(i,a),c.uv1=Mr.getInterpolation($v,Zh,Jh,$h,Kv,Zv,Jv,new U)),e&&(sO.fromBufferAttribute(e,s),oO.fromBufferAttribute(e,o),aO.fromBufferAttribute(e,a),c.normal=Mr.getInterpolation($v,Zh,Jh,$h,sO,oO,aO,new E),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new E,materialIndex:0};Mr.getNormal(Zh,Jh,$h,u.normal),c.face=u,c.faceIndex=s}return c}function O1(n,t,e,r,i){let s=r*3,o=n.index.getX(s),a=n.index.getX(s+1),l=n.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=n.attributes,f=u9(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function lO(n,t,e,r,i,s){for(let o=r,a=r+i;o<a;o++)O1(n,t,e,o,s)}function cO(n,t,e,r,i){let s=1/0,o=null;for(let a=r,l=r+i;a<l;a++){let c=O1(n,t,e,a);c&&c.distance<s&&(o=c,s=c.distance)}return o}function ps(n,t,e,r){let i=n.a,s=n.b,o=n.c,a=t,l=t+1,c=t+2;e&&(a=e.getX(t),l=e.getX(t+1),c=e.getX(t+2)),i.x=r.getX(a),i.y=r.getY(a),i.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c)}function I1(n,t,e,r,i,s,o){let a=e.index,l=e.attributes.position;for(let c=n,u=t+n;c<u;c++)if(ps(o,c*3,a,l),o.needsUpdate=!0,r(o,c,i,s))return!0;return!1}var ed=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Ea(n,t){return t[n+15]===65535}function Oc(n,t){return t[n+6]}function td(n,t){return t[n+14]}function rd(n){return n+8}function id(n,t){return t[n+6]}function uO(n,t){return t[n+7]}var nd=new Gt,t0=new E,d9=["x","y","z"];function r0(n,t,e,r,i){let s=n*2,o=sd,a=Ml,l=Tl;if(Ea(s,a)){let u=Oc(n,l),h=td(s,a);lO(t,e,r,u,h,i)}else{let u=rd(n);n0(u,o,r,t0)&&r0(u,t,e,r,i);let h=id(n,l);n0(h,o,r,t0)&&r0(h,t,e,r,i)}}function i0(n,t,e,r){let i=n*2,s=sd,o=Ml,a=Tl;if(Ea(i,o)){let c=Oc(n,a),u=td(i,o);return cO(t,e,r,c,u)}else{let c=uO(n,a),u=d9[c],d=r.direction[u]>=0,f,p;d?(f=rd(n),p=id(n,a)):(f=id(n,a),p=rd(n));let g=n0(f,s,r,t0)?i0(f,t,e,r):null;if(g){let x=g.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return g}let v=n0(p,s,r,t0)?i0(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var hO=function(){let n,t,e=[],r=new ed(()=>new Gt);return function(...o){n=r.getPrimitive(),t=r.getPrimitive(),e.push(n,t);let a=i(...o);r.releasePrimitive(n),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],n=e[l-2]),a};function i(s,o,a,l,c=null,u=0,h=0){function d(x){let S=x*2,w=Ml,A=Tl;for(;!Ea(S,w);)x=rd(x),S=x*2;return Oc(x,A)}function f(x){let S=x*2,w=Ml,A=Tl;for(;!Ea(S,w);)x=id(x,A),S=x*2;return Oc(x,A)+td(S,w)}let p=s*2,m=sd,g=Ml,y=Tl;if(Ea(p,g)){let x=Oc(s,y),S=td(p,g);return fs(s,m,n),l(x,S,!1,h,u+s,n)}else{let x=rd(s),S=id(s,y),w=x,A=S,M,b,T,C;if(c&&(T=n,C=t,fs(w,m,T),fs(A,m,C),M=c(T),b=c(C),b<M)){w=S,A=x;let V=M;M=b,b=V,T=C}T||(T=n,fs(w,m,T));let P=Ea(w*2,g),D=a(T,P,M,h+1,u+w),_;if(D===2){let V=d(w),W=f(w)-V;_=l(V,W,!0,h+1,u+w,T)}else _=D&&i(w,o,a,l,c,u,h+1);if(_)return!0;C=t,fs(A,m,C);let O=Ea(A*2,g),L=a(C,O,b,h+1,u+A),j;if(L===2){let V=d(A),W=f(A)-V;j=l(V,W,!0,h+1,u+A,C)}else j=L&&i(A,o,a,l,c,u,h+1);return!!j}}}(),dO=function(){let n=new Pn,t=new Pn,e=new ce,r=new _n,i=new _n;return function s(o,a,l,c,u=null){let h=o*2,d=sd,f=Ml,p=Tl;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),Ea(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,S=l.attributes.position,w=Oc(o,p),A=td(h,f);if(e.copy(c).invert(),l.boundsTree)return fs(o,d,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(c),b.b.applyMatrix4(c),b.c.applyMatrix4(c),b.needsUpdate=!0;for(let T=w*3,C=(A+w)*3;T<C;T+=3)if(ps(t,T,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let M=w*3,b=A+w*3;M<b;M+=3){ps(n,M,y,v),n.a.applyMatrix4(e),n.b.applyMatrix4(e),n.c.applyMatrix4(e),n.needsUpdate=!0;for(let T=0,C=x.count;T<C;T+=3)if(ps(t,T,x,S),t.needsUpdate=!0,n.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return fs(g,d,nd),!!(u.intersectsBox(nd)&&s(g,a,l,c,u)||(fs(y,d,nd),u.intersectsBox(nd)&&s(y,a,l,c,u)))}}}();function n0(n,t,e,r){return fs(n,t,nd),e.intersectBox(nd,r)}var R1=[],e0,sd,Ml,Tl;function od(n){e0&&R1.push(e0),e0=n,sd=new Float32Array(n),Ml=new Uint16Array(n),Tl=new Uint32Array(n)}function Wp(){e0=null,sd=null,Ml=null,Tl=null,R1.length&&od(R1.pop())}var L1=Symbol("skip tree generation"),B1=new Gt,N1=new Gt,ad=new ce,Ic=new _n,qp=new _n,Yp=new E,s0=new E,f9=new E,p9=new E,m9=new E,fO=new Gt,Mo=new ed(()=>new Pn),To=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),To.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,i=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),To.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:i,roots:s}=t,o=new To(e,{...r,[L1]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Xe(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[L1]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[L1]||(this._roots=iO(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Gt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,i=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;d<f;d++)s=u[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,c),c+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,S=1/0,w=1/0,A=-1/0,M=-1/0,b=-1/0;for(let T=3*y,C=3*(y+v);T<C;T++){let P=r[T],D=i.getX(P),_=i.getY(P),O=i.getZ(P);D<x&&(x=D),D>A&&(A=D),_<S&&(S=_),_>M&&(M=_),O<w&&(w=O),O>b&&(b=O)}return l[d+0]!==x||l[d+1]!==S||l[d+2]!==w||l[d+3]!==A||l[d+4]!==M||l[d+5]!==b?(l[d+0]=x,l[d+1]=S,l[d+2]=w,l[d+3]=A,l[d+4]=M,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,S=v+f,w=p,A=!1,M=!1;t?w||(A=t.has(x),M=t.has(S),w=!A&&!M):(A=!0,M=!0);let b=w||A,T=w||M,C=!1;b&&(C=h(y,f,w));let P=!1;T&&(P=h(v,f,w));let D=C||P;if(D)for(let _=0;_<3;_++){let O=y+_,L=v+_,j=l[O],V=l[O+3],H=l[L],W=l[L+3];l[d+_]=j<H?j:H,l[d+_+3]=V>W?V:W}return D}}}traverse(t,e=0){let r=this._roots[e],i=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=i[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Gn){let r=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,c=o?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=a?e[l[u].materialIndex].side:c,f=s.length;if(od(r[u]),r0(0,i,d,t,s),Wp(),a){let p=l[u].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Gn){let r=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,c=s?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=o?e[l[u].materialIndex].side:c;od(r[u]);let f=i0(0,i,d,t);Wp(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,i=!1;for(let s of this._roots)if(od(s),i=dO(0,r,t,e),Wp(),i)break;return i}shapecast(t,e,r){let i=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Mo.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:I1(f,p,i,c,m,g,s)}else l||(c?l=(d,f,p,m)=>I1(d,f,i,c,p,m,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(od(d),u=hO(0,i,a,l,o,h),Wp(),u)break;h+=d.byteLength}return Mo.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:i,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;ad.copy(e).invert();let u=Mo.getPrimitive(),h=Mo.getPrimitive();if(s){let f=function(p,m,g,y,v,x,S,w){for(let A=g,M=g+y;A<M;A++){ps(h,A*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,T=p+m;b<T;b++)if(ps(u,b*3,o,a),u.needsUpdate=!0,s(u,h,b,A,v,x,S,w))return!0}return!1};if(i){let p=i;i=function(m,g,y,v,x,S,w,A){return p(m,g,y,v,x,S,w,A)?!0:f(m,g,y,v,x,S,w,A)}}else i=f}t.getBoundingBox(N1),N1.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>N1.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(B1.copy(v),B1.applyMatrix4(ad),t.shapecast({intersectsBounds:x=>B1.intersectsBox(x),intersectsRange:(x,S,w,A,M)=>i(f,p,x,S,g,y,A,M)}))});return Mo.releasePrimitive(u),Mo.releasePrimitive(h),d}intersectsBox(t,e){return Ic.set(t.min,t.max,e),Ic.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Ic.intersectsBox(r),intersectsTriangle:r=>Ic.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Ic.set(t.boundingBox.min,t.boundingBox.max,e),Ic.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=Mo.getPrimitive(),f=Mo.getPrimitive(),p=s0,m=f9,g=null,y=null;i&&(g=p9,y=m9);let v=1/0,x=null,S=null;return ad.copy(e).invert(),qp.matrix.copy(ad),this.shapecast({boundsTraverseOrder:w=>Ic.distanceToBox(w),intersectsBounds:(w,A,M)=>M<v&&M<o?(A&&(qp.min.copy(w.min),qp.max.copy(w.max),qp.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>qp.distanceToBox(M),intersectsBounds:(M,b,T)=>T<v&&T<o,intersectsRange:(M,b)=>{for(let T=M*3,C=(M+b)*3;T<C;T+=3){ps(f,T,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let P=w*3,D=(w+A)*3;P<D;P+=3){ps(d,P,c,l),d.needsUpdate=!0;let _=d.distanceToTriangle(f,p,g);if(_<v&&(m.copy(p),y&&y.copy(g),v=_,x=P/3,S=T/3),_<s)return!0}}}});{let M=h?h.count:u.count;for(let b=0,T=M;b<T;b+=3){ps(f,b,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,P=(w+A)*3;C<P;C+=3){ps(d,C,c,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,S=b/3),D<s)return!0}}}}}),Mo.releasePrimitive(d),Mo.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ad),m.applyMatrix4(ad),i.distance=m.sub(i.point).length(),i.faceIndex=S),r)}closestPointToPoint(t,e={},r=0,i=1/0){let s=r*r,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:u=>(Yp.copy(t).clamp(u.min,u.max),Yp.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Yp);let d=t.distanceToSquared(Yp);return d<a&&(s0.copy(Yp),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(s0):e.point=s0.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{fs(0,new Float32Array(r),fO),t.union(fO)}),t}};var $d=Ko(mO());var g9=.5*(Math.sqrt(3)-1),Xp=(3-Math.sqrt(3))/6,y9=1/3,Co=1/6,fpe=(Math.sqrt(5)-1)/4,ppe=(5-Math.sqrt(5))/20,Qp=n=>Math.floor(n)|0,gO=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),V1=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function o0(n=Math.random){let t=vO(n),e=new Float64Array(t).map(i=>gO[i%12*2]),r=new Float64Array(t).map(i=>gO[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*g9,h=Qp(s+u),d=Qp(o+u),f=(h+d)*Xp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let S=g-v+Xp,w=y-x+Xp,A=g-1+2*Xp,M=y-1+2*Xp,b=h&255,T=d&255,C=.5-g*g-y*y;if(C>=0){let _=b+t[T],O=e[_],L=r[_];C*=C,a=C*C*(O*g+L*y)}let P=.5-S*S-w*w;if(P>=0){let _=b+v+t[T+x],O=e[_],L=r[_];P*=P,l=P*P*(O*S+L*w)}let D=.5-A*A-M*M;if(D>=0){let _=b+1+t[T+1],O=e[_],L=r[_];D*=D,c=D*D*(O*A+L*M)}return 70*(a+l+c)}}function yO(n=Math.random){let t=vO(n),e=new Float64Array(t).map(s=>V1[s%12*3]),r=new Float64Array(t).map(s=>V1[s%12*3+1]),i=new Float64Array(t).map(s=>V1[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*y9,p=Qp(o+f),m=Qp(a+f),g=Qp(l+f),y=(p+m+g)*Co,v=p-y,x=m-y,S=g-y,w=o-v,A=a-x,M=l-S,b,T,C,P,D,_;w>=A?A>=M?(b=1,T=0,C=0,P=1,D=1,_=0):w>=M?(b=1,T=0,C=0,P=1,D=0,_=1):(b=0,T=0,C=1,P=1,D=0,_=1):A<M?(b=0,T=0,C=1,P=0,D=1,_=1):w<M?(b=0,T=1,C=0,P=0,D=1,_=1):(b=0,T=1,C=0,P=1,D=1,_=0);let O=w-b+Co,L=A-T+Co,j=M-C+Co,V=w-P+2*Co,H=A-D+2*Co,W=M-_+2*Co,q=w-1+3*Co,K=A-1+3*Co,G=M-1+3*Co,Z=p&255,te=m&255,$=g&255,Y=.6-w*w-A*A-M*M;if(Y<0)c=0;else{let J=Z+t[te+t[$]];Y*=Y,c=Y*Y*(e[J]*w+r[J]*A+i[J]*M)}let oe=.6-O*O-L*L-j*j;if(oe<0)u=0;else{let J=Z+b+t[te+T+t[$+C]];oe*=oe,u=oe*oe*(e[J]*O+r[J]*L+i[J]*j)}let ie=.6-V*V-H*H-W*W;if(ie<0)h=0;else{let J=Z+P+t[te+D+t[$+_]];ie*=ie,h=ie*ie*(e[J]*V+r[J]*H+i[J]*W)}let re=.6-q*q-K*K-G*G;if(re<0)d=0;else{let J=Z+1+t[te+1+t[$+1]];re*=re,d=re*re*(e[J]*q+r[J]*K+i[J]*G)}return 32*(c+u+h+d)}}function vO(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let i=r+~~(n()*(256-r)),s=e[r];e[r]=e[i],e[i]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var ks=new Mr,a0=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let s=1;ks.a.fromBufferAttribute(t,i),ks.b.fromBufferAttribute(t,i+1),ks.c.fromBufferAttribute(t,i+2),s*=ks.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,s=-1;for(;r<=i;){let o=Math.ceil((r+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:r=o+1}return s}sampleFace(t,e,r){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),ks.a.fromBufferAttribute(this.positionAttribute,t*3),ks.b.fromBufferAttribute(this.positionAttribute,t*3+1),ks.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ks.a,i).addScaledVector(ks.b,s).addScaledVector(ks.c,1-(i+s)),ks.getNormal(r),this}};var bO=Ko(z1()),v9=new ce,x9=new ce,b9=new ce,ld;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(ld||(ld={}));var cd=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new ce;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ce;this.matrixWorldRigid=new ce;this.shearScale=new ce;this.shearScaleInv=new ce}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Et&&(r=r.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===r)return!0;i=i.parent}return!1}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 i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let s=this.parent;if(r&&s!==null&&s.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,i=0){for(let s of this.children)ld.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)ld.is(o)&&o.traverseObject(r,i+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,i=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,bO.SVD)(i),l=v9.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=x9.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),u=b9.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,i){this.updateWorldMatrix(!0,!1);let s=new ce().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ce?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),i!==void 0&&(this.children.pop(),this.children.splice(i,0,r)),this}copy(r,i=!1){return super.copy(r,i),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,i,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var U1=class extends cd(Et){},S9=n=>n.type==="Mesh",Rr=class extends U1{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new Rr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return S9(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Rc=new E,Lc=new E,ud=new ce,wO=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],w9=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],A9=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],SO=(n,t,e)=>{n.updateEntityBoxSize(Rc,Lc),ud.copy(t).multiply(n.matrixWorld),Lc.x===0&&Lc.y===0&&Lc.z===0?e.push(new E(Rc.x,Rc.y,Rc.z).applyMatrix4(ud)):wO.forEach(r=>{e.push(r.clone().multiply(Lc).add(Rc).applyMatrix4(ud))})},Kp=class extends Gt{constructor(){super(...arguments);this.matrix=new ce;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 i=new ce().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new E);return}SO(o,r,s)}}):SO(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ud.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Lc).multiplyScalar(.5),this.getCenter(Rc),ud.copy(this.matrix).setPosition(Rc),this.vertices=wO.map(e=>e.clone().multiply(Lc).applyMatrix4(ud))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=w9.map(([e,r])=>new Si(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=A9.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Gs={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var G1=class extends hp{constructor(){super()}getPoints(t=12){let e=[],r,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let c=l[a],u=a===0?i[a]:i[a]-i[a-1],h=Math.ceil(t*u/o),d=c.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var j1=.001;function H1(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=j1}function k1(n,t){let e=new E(...n.position),r=new E(...n.controlNext.position),i=new E(...t.controlPrevious.position),s=new E(...t.position);return H1(e,r,s)&&H1(e,i,s)}function c0(n){let t=n.points.map(u=>new E(...u.data.position)),e=[n.points[0]],r=new E(...e[0].data.position);for(let u=0;u<n.points.length-1;u++)H1(r,t[u],t[u+1])||(e.push(n.points[u]),r=t[u]);e.push(n.points[n.points.length-1]);let i=n.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let u=0;u<o;u++){let h=e[u].data,d=new E(...h.position),f=new E(...h.controlPrevious.position),p=new E(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!n.isClosed&&(u===0||u===o-1)){a[u]={...m,removedLength:0};continue}let g=i&&u==0?o-1:u-1,y=i&&u==o-1?0:u+1,v=e[g].data,x=e[y].data,S=new E(...v.position),w=new E(...x.position),A=S.clone().sub(d).normalize(),M=w.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:M});let b=k1(v,h),T=k1(h,x);if(!b||!T)a[u]={...m,removedLength:0};else{let C=A.clone().add(M).normalize(),P=C.clone().cross(A).length()/A.dot(C);a[u]={...m,tan:P,removedLength:h.roundness/P}}}for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=i&&u===o-1?0:u+1,f=a[h],p=a[d],m=null;if(!k1(e[h].data,e[d].data))f.position.distanceTo(p.position)>j1&&(m=new pc(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>j1&&(m=new pc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=m}for(let u=0;u<o;u++){let h=a[u];if(h.removedLength===0){l[2*u]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),S=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(S)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),M=A.clone().lerp(S,2),b=f.clone().lerp(A,4/3),T=p.clone().lerp(M,4/3);l[2*u]=new pc(f,b,T,p)}let c=new G1;return l.forEach(u=>{u&&c.add(u)}),c}var yt;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(yt||(yt={}));var Po=n=>yt.is(n),E9={type:"completeState",isfromEntity:!0},M9=["x","y","z"],W1=new E,T9=new E().set(0,1,0),hd=n=>class extends cd(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Kp;this._recursiveBBox=new Kp;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let i=this.children[r];if(yt.is(i))return i}entityChildrenCount(){let r=this.children.length;for(;r--;)if(yt.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let i=r.parent;if(yt.is(i))r=i;else return}return r}forInstancesRec(r){this.instances.forEach(i=>{i.disposed||r(i),i.forInstancesRec(r)})}super_Entity(r,i){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ma.toOps(this.data,o.data).forEach(l=>{let c=Dh.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,i)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ma.patch(this.data,o),ma.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched,i),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}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}updateEntityBoxSize(r,i){r.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Po(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let i;return this.traverseEntity(s=>{s.uuid===r&&(i=s)}),i}traverseSortNextHelper(){let r=this.parent;if(r){let i=r.children,s=i.indexOf(this)+1;if(yt.is(i[s]))return i[s];if(yt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&yt.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let i=this;for(;r>0&&i!==null;)i=i.parent,r-=1;return i}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let i=this.parent;for(;i;){if(r===i)return!0;i=i.parent}return!1}countToAccestor(r){let i=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(r){for(let i of this.children)Po(i)&&r(i)}traverseEntityAncestors(r){this.traverseAncestors(i=>{yt.is(i)&&r(i)})}traverseConcreteEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Po(o)&&o.isConcreteEntity&&o.traverseEntity(r,i+1)}traverseEntity(r,i=0){if(r(this,i)!==!0)for(let o of this.children)Po(o)&&o.traverseEntity(r,i+1)}traverseVisibleEntity(r){r(this);for(let i of this.children)Po(i)&&i.visible&&i.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,i=!1){return super.copy(r,i),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Po(r))}isAncestorOf(r){if(this.uuid===r)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===r&&(i=!0)}),i}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*we.RAD2DEG,this.rotation.y*we.RAD2DEG,this.rotation.z*we.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ah(i,r)}getTransformValues(r,i,s){return i[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,M9[a]])??o)}updateTransformState(r,i){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,i)),s=!0),r.rotation&&(W1.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(we.DEG2RAD),this.rotation.setFromVector3(W1),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,i)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??yl.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)yt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{yt.is(r)&&r.disposeRecursively()})}toState(r=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Ah(i,r)}updateByObjUpdateOp(r,i){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},i,!1)}updateByOp(r,i,s,o){let a=this.data;this.data=i;let l=r,c=Lt(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Or.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Or.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ma.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Lt(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(go.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Or.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=Uh.resolve(i.overrides,u),d.updateByOp(r,Ir.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of Ao.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of Ao.rootOverrideProps)if(Lt(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=go.filterOp(h.overrideData,u);d&&h.updateByOp(d,Ir.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=go.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=i:f=Ir.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,i,s){if(this.dataPatched=i,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Vs.is(r.props.type)&&Gs.changeEntityProptotype(this,i,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Gs.changeEntityProptotype(this,i,s);for(let o of this.children)yt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,i,s)}updateByPatchedOp(r,i,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),Lt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Lt(r.path,["cloner"])!==null){let o=Ir.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=r.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=c0(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=u.curves.length?u.getPointAt(h):null;if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ce;l.updateMatrixWorld();let p=new ce().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let g=new ce().extractRotation(l.matrixWorld),y=u.getTangentAt(h).applyMatrix4(g).add(d),v=new ce().lookAt(d,y,T9),x=W1.setFromEuler(new rr().setFromRotationMatrix(v)).multiplyScalar(we.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(E9)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&r.reloadSplats()}updateState_Entity(r,i){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(r,i)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Gs.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,i){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Gs.Cloner(this,r),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,i.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var u0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=we.clamp(e.thetaLength,0,360);let r=e.width/2,i=e.radiusTop??r,s=e.radiusBottom??r;return i===s?(i=r,s=r):i>s?(i=r,s=s*r/i):(i=i*r/s,s=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:i,radiusBottom:s})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=n.parameters,p;return l===0?(p=new _e,p.setAttribute("position",new Te([],3))):h||f?p=new Zp(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new gc(c,u,r,i,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"CylinderGeometry"}})}};function Cl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function AO(n){return new U(n.y,-n.x)}var Zp=class extends _e{constructor(t,e,r,i,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,S=new E,w=new E;f&&t==0&&(t=c),f&&e==0&&(e=u);let A=new U(t,x),M=new U(e,-x),b=null,T=null,C=null,P=null,D=A.clone().sub(M),_=0,O=0,L=0;d>0&&(_=Math.min(t,e)*(1-d),O=t-_,L=e-_);let j=A.clone();j.x-=_;let V=Math.PI-D.angle(),H=D.angle(),W=Math.tan(H/2),q=Math.tan(V/2),K=W+q,G=d?K:q,Z=d?K:W;if(c=Math.min(c,(t-O)/G,D.length()/K),u=Math.min(u,(e-L)/Z,D.length()/K),c>0){let re=c/W;b=A.clone().sub(new U(re,c)),d&&(C=b.clone(),C.x-=_-K*c),A.sub(D.clone().setLength(re))}if(u>0){let re=u/q;T=M.clone().sub(new U(re,-u)),M.add(D.clone().setLength(re)),d&&(P=T.clone(),P.x-=_-K*u,j.sub(D.clone().setLength(re)))}D=A.clone().sub(M);let te=D.length()<.5,$=[];for(let re=0;re<=i;re++){let J=[],Ae=re/i,xe=Ae*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&T?(Y(J,Ae,de,V,u,P,-1,!0),Y(J,Ae,de,H,u,T,-1,!1)):T?(oe(J,de,T.x,0,-1),Y(J,Ae,de,H,u,T,-1,!1)):o||oe(J,de,e,L,-1);let Oe=AO(D).normalize();if(Cl(Oe,de,S),!te)for(let Ce=0;Ce<=s;Ce++){let Ue=Ce/s,ze=D.clone().multiplyScalar(Ue).add(M);Cl(ze,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}if(C&&b?(Y(J,Ae,de,V,c,b,1,!1),Y(J,Ae,de,H,c,C,1,!0)):b?(Y(J,Ae,de,V,c,b,1,!1),oe(J,de,b.x,0,1)):o||oe(J,de,t,O,1),d&&!te){let Ce=AO(D).multiplyScalar(-1).normalize();Cl(Ce,de,S);for(let Ue=0;Ue<=s;Ue++){let ze=Ue/s,Ve=D.clone().multiplyScalar(-ze).add(j);Cl(Ve,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(Ae,.5+w.y/r),J.push(v++)}}d&&!o&&J.push(J[0]),$.push(J)}for(let re=0;re<$.length-1;re++)for(let J=0;J<$[0].length-1;J++){if(o&&d&&J==s)continue;let Ae=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],Oe=$[re][J+1],Ce=m[de*3+0],Ue=m[de*3+2];p.push(Ae,xe,Oe),(Ce!=0||Ue!=0)&&p.push(xe,de,Oe)}l<Math.PI*2&&(ie(-1,$[0],a),ie(1,$[$.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(g,3)),this.setAttribute("uv",new Te(y,2));function Y(re,J,Ae,xe,de,Oe,Ce,Ue){for(let ze=0;ze<h+1;ze++){let Ve=ze/h,Ie=Ce<0?Ve:1-Ve;Ue&&(Ie-=1),Ie*=xe;let Ye=new U(Math.sin(Ie),Math.cos(Ie)*Ce),F=Ye.clone().multiplyScalar(de).add(Oe);Cl(F,Ae,w),m.push(w.x,w.y,w.z),Cl(Ye,Ae,S),g.push(S.x,S.y,S.z),y.push(J,.5+w.y/r),re.push(v++)}}function oe(re,J,Ae,xe,de){let Oe=new E,Ce=new U,Ue=[Ae,xe];de<0&&Ue.reverse();for(let ze of Ue)Ce.set(ze,x*de),Cl(Ce,J,Oe),m.push(Oe.x,Oe.y,Oe.z),g.push(0,de,0),y.push(.5,.5),re.push(v++)}function ie(re,J,Ae){let xe=new U(Math.sin(Ae),Math.cos(Ae)),de=new U(-Math.cos(Ae),Math.sin(Ae)),Oe=new E,Ce=re<0?(Ve,Ie,Ye)=>p.push(Ve,Ie,Ye):(Ve,Ie,Ye)=>p.push(Ve,Ye,Ie),Ue=new U((t+e+O+L)/4,0);Cl(Ue,xe,Oe),m.push(Oe.x,Oe.y,Oe.z),g.push(de.x,0,de.y),y.push(.5,.5);let ze=v++;for(let Ve of J){let Ie=m.slice(Ve*3,Ve*3+3);m.push(...Ie),g.push(de.x,0,de.y);let Ye=y.slice(Ve*2,Ve*2+2);y.push(...Ye),v++}for(let Ve=ze+1;Ve<v-1;Ve++)Ce(ze,Ve,Ve+1);Ce(ze,v-1,ze+1)}}};var EO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=we.clamp(e.thetaLength,0,360),{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(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:h}=n.parameters,d;return l===0?(d=new _e,d.setAttribute("position",new Te([],3))):c>0||u>0||l<360?d=new Zp(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new $a(t/2,r,i,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...n,type:"ConeGeometry"}})}};var MO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a===0?c=new hi(t,e,r,i,s,o):c=new Y1(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},q1=Math.PI/2,Y1=class extends _e{constructor(t=1,e=1,r=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],u=[],h=[],d=[],f=0;p("z","y","x",-1,-1,r,e,t,o,s),p("z","y","x",1,-1,r,e,-t,o,s),p("x","z","y",1,1,t,r,e,i,o),p("x","z","y",1,-1,t,r,-e,i,o),p("x","y","z",1,-1,t,e,r,i,s),p("x","y","z",-1,-1,t,e,-r,i,s),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o),m("z","y","x",1,-1,-1,r,e,t,o),m("z","y","x",-1,1,-1,r,e,t,o),m("z","y","x",1,1,1,r,e,t,o),m("x","y","z",-1,-1,-1,t,e,r,i),m("x","y","z",1,-1,1,t,e,r,i),m("x","y","z",-1,1,1,t,e,r,i),m("x","y","z",1,1,-1,t,e,r,i),m("y","x","z",-1,-1,1,e,t,r,s),m("y","x","z",1,-1,-1,e,t,r,s),m("y","x","z",1,1,1,e,t,r,s),m("y","x","z",-1,1,-1,e,t,r,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function p(y,v,x,S,w,A,M,b,T,C){let P=(A-2*a)/T,D=(M-2*a)/C,_=A/2-a,O=M/2-a,L=b/2,j=T+1,V=C+1,H=0,W=new E;for(let q=0;q<V;q++){let K=q*D-O;for(let G=0;G<j;G++){let Z=G*P-_;W[y]=Z*S,W[v]=K*w,W[x]=L,u.push(W.x,W.y,W.z),W[y]=0,W[v]=0,W[x]=b>0?1:-1,h.push(W.x,W.y,W.z),d.push(G/T),d.push(1-q/C),H+=1}}for(let q=0;q<C;q++)for(let K=0;K<T;K++){let G=f+K+j*q,Z=f+K+j*(q+1),te=f+(K+1)+j*(q+1),$=f+(K+1)+j*q;c.push(G,Z,$),c.push(Z,te,$)}f+=H}function m(y,v,x,S,w,A,M,b,T,C){let P=(M-2*a)/C,D=M/2-a,_=b/2-a,O=T/2,L=C+1,j=0,V=new E,H=new E;for(let W=0;W<l+1;W++){let q=W/l*q1,K=Math.sin(q)*a,G=(1-Math.cos(q))*a,Z=Math.sin(q),te=Math.cos(q);V[v]=(_+K)*w,V[x]=(O-G)*A,H[y]=0,H[v]=Z*Math.sign(V[v]),H[x]=te*Math.sign(V[x]);for(let $=0;$<L;$++){let Y=$*P-D;V[y]=Y*S,u.push(V.x,V.y,V.z),h.push(H.x,H.y,H.z),d.push($/C),d.push(0),j+=1}}for(let W=0;W<l;W++)for(let q=0;q<C;q++){let K=f+q+L*W,G=f+q+L*(W+1),Z=f+(q+1)+L*(W+1),te=f+(q+1)+L*W;c.push(K,G,te),c.push(G,Z,te)}f+=j}function g(y,v,x){let S=new E,w=new E(t/2,e/2,r/2);w.subScalar(a);let A=[],M=y*v*x>0?(T,C,P)=>c.push(T,C,P):(T,C,P)=>c.push(T,P,C);for(let T=0;T<=l;T++){let C=[],P=q1*(1-T/l),D=Math.cos(P),_=Math.sin(P),O=0;for(let L=0;L<=T;L++){let j=Math.cos(O),V=Math.sin(O);S.x=D*j,S.y=_,S.z=D*V;let H=w.clone().addScaledVector(S,a);u.push(y*H.x,v*H.y,x*H.z),h.push(y*S.x,v*S.y,x*S.z),d.push(0,0),C.push(f++),O+=q1/T}A.push(C)}let b=A.length-1;for(let T=0;T<b;T++){let C=A[T],P=A[T+1],D=C.length-1;M(C[0],P[1],P[0]);for(let _=1;_<=D;_++)M(C[_-1],C[_],P[_]),M(C[_],P[_+1],P[_])}}}};var Pl=class extends _e{constructor(t=[],e=[],r="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(l,2));return;function u(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new E,m=p.clone(),g=new Mr,y=s*i,v=i-y,x=o+1,S=new E,w=(W,q)=>S.subVectors(W,q).normalize(),A=(W,q)=>Array(W).fill(void 0).map(q),M=A(t.length/3,(W,q)=>new E().fromArray(t,q*3).setLength(i)),b=[],T=1e6;for(let W=0;W<M.length;W++){let q=M[W],K=[],G,Z,te,$=1e10,Y=-1;for(;(Y=e.indexOf(W,Y+1))!=-1;){let J=Y-Y%3;G=e[J+(Y+1)%3],Z=e[J+(Y+2)%3],te=q.distanceToSquared(M[G]),$=Math.min($,te),K.push([G,Z,te])}$+=1e-6;let oe=[],ie=0,re=K.length;for(let J=0;J<re;J++){[G,Z,te]=K[ie];let Ae=b[G]?.includes(W)==!0;te<=$&&oe.push(G+ +Ae*T),ie=K.findIndex(xe=>xe[0]==Z)}b.push(oe)}let C=[];{let W=0,q=0,K,G,Z=f==3;for(let te=0;te<=o;te++){K=te*(te+1)/2,G=(te+1)*(te+2)/2;for(let $=0;$<o-te;$++)[W,q]=[K+$+te+2,G+$+te+3],C.push(K,G,...Z?[q,K]:[W,G],q,W),[K,G]=[W,q];C.push(K,G,K+o+2)}}let P=p.clone(),D=p.clone(),_=p.clone(),O=p.clone(),L=p.clone(),j=[],V=A(M.length,()=>A(f,()=>p.clone()));for(let W=0;W<M.length;W++){p.copy(M[W]).normalize(),P.copy(p).multiplyScalar(v);let q=b[W];for(let oe=0;oe<q.length;oe++){let ie=q[oe],re=q[(oe+1)%f];g.setFromPointsAndIndices(M,W,ie%T,re%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(P,V[W][oe])}let K=[],G=[],Z=[],te=new E;o==0&&[...V[W]].reduce((oe,ie)=>oe.add(ie),te).multiplyScalar(1/f);for(let oe=0;oe<f;oe++){let ie=[],re=(oe-1+f)%f,J=V[W][re],Ae=V[W][oe];p.copy(J).sub(P),m.copy(Ae).sub(P);let xe=P.angleTo(p),de=p.angleTo(m),Oe=Math.cos(xe)*y;o==0?D.copy(te):D.copy(P).setLength(v+Oe),G.push(Oe);let Ce=[D,J,Ae];for(let Ue=0;Ue<2;Ue++){let ze=Ce[Ue],Ve=Ce[Ue+1];O.subVectors(ze,P),L.subVectors(Ve,P),_.crossVectors(O,L).normalize();for(let Ie=0;Ie<x;Ie++){let Ye=[xe,de][Ue]*Ie/x;p.copy(O).applyAxisAngle(_,Ye).add(P),K.push(p.clone()),Ue&&(w(p,P),ie.push([Ie==0?ze:p.clone(),S.clone()]))}Ue&&(w(Ve,P),ie.push([Ve,S.clone()]))}Z.push(ie)}j.push(Z);let $=2*x,Y=2;for(let oe=0;oe<f;oe++){let ie=$*oe,re=$*((oe+1)%f),J=[K[ie]];for(let xe=1;xe<x;xe++){O=K[ie+xe],L=K[re+xe],J.push(O);for(let de=1,Oe=xe-Y+1;de<=Oe;de++)p.lerpVectors(O,L,de/(Oe+1)),p.sub(P).setLength(G[oe]).add(P),J.push(p.clone());J.push(L)}for(let xe=0;xe<x;xe++)J.push(K[xe+x+ie]);J.push(K[re+x]);let Ae=C.map(xe=>J[xe]);a.push(...Ae.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...Ae.map(xe=>(w(xe,P),[S.x,S.y,S.z])).flat())}}let H=[];for(let W=0;W<b.length;W++)for(let q=0;q<f;q++){let K=b[W][q];if(K<T){let G=b[K].findIndex($=>$%T==W),Z=j[W][q],te=j[K][G];for(let $=0;$<x;$++){let Y=Z[$],oe=te[x-$],ie=Z[$+1],re=te[x-($+1)];[Y,oe,ie,ie,oe,re].forEach(J=>{a.push(J[0].x,J[0].y,J[0].z),c.push(J[1].x,J[1].y,J[1].z)})}H.push(Z[0][0],te[x][0],Z[x][0],te[0][0])}}for(;H.length;){let W,q,K,G;[W,q]=H.splice(0,2);let Z=[W];for(;W!=q;)Z.push(q),K=H.indexOf(q),G=K%2,q=H.splice(K-G,2)[1-G];S.subVectors(Z[0],Z[1]).cross(p.subVectors(Z[0],Z[2])).normalize();let te=S.dot(Z[0])<0;te&&S.negate();for(let $=1;$<=Z.length-2;$++)[Z[$+ +te],Z[$+1-+te],Z[0]].forEach(Y=>{a.push(Y.x,Y.y,Y.z),c.push(S.x,S.y,S.z)})}}function h(){let d=new E;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let b=w(d)/2/Math.PI+.5,T=A(d)/Math.PI+.5;l.push(b,1-T)}let f=new E,p=new E,m=new E,g=new E,y=new U,v=new U,x=new U,S=(M,b,T,C)=>{C<0&&M.x===1&&(l[b]=M.x-1),T.x===0&&T.z===0&&(l[b]=C/2/Math.PI+.5)};for(let M=0,b=0;M<a.length;M+=9,b+=6){f.set(a[M+0],a[M+1],a[M+2]),p.set(a[M+3],a[M+4],a[M+5]),m.set(a[M+6],a[M+7],a[M+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);S(y,b+0,f,T),S(v,b+2,p,T),S(x,b+4,m,T)}for(let M=0;M<l.length;M+=6){let b=l[M+0],T=l[M+2],C=l[M+4],P=Math.max(b,T,C),D=Math.min(b,T,C);P>.9&&D<.1&&(b<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),C<.2&&(l[M+4]+=1))}function w(M){return Math.atan2(M.z,-M.x)}function A(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Pl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var TO=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new Jp(t*.5,s,o):new Lu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Jp=class extends Pl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-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,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],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(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Jp(t.radius,t.corner,t.cornerSides)}};var $p=1e-12,dd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=we.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 dd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},fd=class extends dd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new fd(this.parent).copy(this)}},js=class extends dd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new fd(this),new fd(this))}static create(e,r){let i=new js(e,new U(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}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 i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.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 js(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 U,r=new U){let[i,s]=this.computeTangents();return i&&s&&(CO(i,e),CO(s,r)),[e,r]}computeTangent(e=new U){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new U){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function CO(n,t=new U){let e=n.length();return t.set(-n.y/e,n.x/e)}var Q1=n=>n,pd=new U,h0=new U,C9=new U,P9=new U,_9=new U,D9=new U,_O=new E,DO=new E;function OO(n){let t=new U;t.addVectors(n.v0,pd.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(n.v2,h0.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new tn(n.v0,t,e,n.v2)}function em(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function O9(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function I9(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function K1(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-s*s)/(2*i*r))}function IO(n,t,e){return PO(n,t)&&PO(t,e)&&X1(n.position,t.position,e.position)}function X1(n,t,e){return pd.copy(t).sub(n).cross(h0.copy(e).sub(n))===0}function RO(n,t,e,r,i){let s=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(n.y-t.y)/s,c=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-n.x)/s;return r.set(a+l,o+c),i.set(a-l,o-c),[r,i]}function LO(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function BO(n,t,e,r,i,s){let o=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),h;return K1(t,n,e)>Math.PI&&(u*=-1),em(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[i,s]}function Z1(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function PO(n,t){return X1(n.position,n.controls[1].position,t.position)&&X1(n.position,t.controls[0].position,t.position)}function NO(n,t,e,r,i=.5){let s=pd.subVectors(t,n).multiplyScalar(i).add(n),o=h0.subVectors(e,t).multiplyScalar(i).add(t),a=C9.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=P9.subVectors(o,s).multiplyScalar(i).add(s),u=_9.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=D9.subVectors(u,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function FO(n,t,e=12,r=!0){let i=DO.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=Q1(t[l]),u=pd,h=_l(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof tn||c instanceof qn||c instanceof rn){if(c.getPoint(d/h,u),i.set(u.x,u.y,0),s!==void 0&&I9(s,i))continue;s===void 0&&(s=_O),s.copy(i),n.setXYZ(o,i.x,i.y,i.z),o++}}return r&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),n}function VO(n,t,e,r=12,i=!0){let s=DO.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=Q1(t[l]),h=pd,d=_l(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof tn||u instanceof qn||u instanceof rn){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=_O:(n.setXYZ(o,c.x,c.y,c.z),o++,n.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(n.getX(o-1)===n.getX(0)&&n.getY(o-1)===n.getY(0)&&n.getZ(o-1)===n.getZ(0))&&(n.setXYZ(o,n.getX(0),n.getY(0),n.getZ(0)),o++),a}function J1(n,t=12,e=!1){let r=[];for(let i=0,s=n.length;i<s;i++){let o=n[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=_l(o.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=_l(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=_l(n[0].roundedCurveCorner,t)*.5),r}function _l(n,t=12){return n&&n instanceof fc?t*2:n&&(n instanceof rn||n instanceof up)?1:n&&n instanceof Ou?t*n.points.length:t}function zO(n,t,e=12,r=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=Q1(t[o]),l=_l(a,e),c=pd;for(let u=0;u<=l;u++)if(a instanceof tn||a instanceof qn||a instanceof rn){if(a.getPoint(u/l,c),i!==void 0&&O9(i,c,$p))continue;i===void 0&&(i=h0),i.copy(c),n.push(c.x,c.y),s++}}return em(n[0],n[n.length-2],$p)&&em(n[1],n[n.length-1],$p)&&(n.pop(),n.pop()),r&&s>1&&!(em(n[s-1],n[1],$p)&&em(n[s-2],n[0],$p))&&(n.push(n[0],n[1]),s++),n}var $1=new U,R9=new U,L9=new U,B9=new U,N9=new U,F9=new U,Wt=class extends sa{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Zr(new E(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=we.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let s=new Wt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>js.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Wt.createFromState(o)),r!==void 0&&i!==void 0&&s.applySize(r,i),s.update(),s}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,i=this.points.length;r<i;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,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length,u=l.getPointIndexById(e);if(u<0)s+=c;else return u+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}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 i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.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 i=$1.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,i=we.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new js(i,s);return o.roundness=this.roundness,o}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,i=this.points.length;r<i;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}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(i=>i.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=i?this.roundedCurveDivisions:this.curveDivisions;return FO(e,i?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=J1(this.points,e,!1),this.roundedCurveDivisions=J1(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return VO(e,this.curves,r,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),zO(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=_l(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let u=s[l];if(a<i+u)return[l,(a-i+1)/u];i+=u}return[0,1]}getCurveT(e,r,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(Z1(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo($1.set(i.x,i.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){Z1(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 i=this.curves[this.curves.length-1];e.curveBefore=i,r.curveAfter=i;let s=i.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,i=this.points.length;r<i;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(r,i)}if(this.points.length>2){let r=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],c=o.roundness,u=a&&l&&IO(a,o,l);if(!o.controlsMoved()&&c>0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(c,m*.499),v=Math.min(c,g*.499),x=Math.min(y,v),S=1-x/m,w=x/g,A=h.getPointAt(S,$1),M=d.getPointAt(w,R9);this._subSplitCurve(h,f,S,A,void 0),this._subSplitCurve(d,p,w,void 0,M);let b;if(this.useCubicForRoundedCorners){let T=K1(A,o.position,M)/2,C=Math.tan(T)*A.distanceTo(o.position),[P,D]=RO(A,M,C,L9,B9),_=LO(P,D,o.position),[O,L]=BO(_,A,M,C,N9,F9);b=new tn(A.clone(),O.clone(),L.clone(),M.clone())}else b=new qn(A.clone(),o.position.clone(),M.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+r,0,b),r++}}}}_subSplitCurve(e,r,i,s,o){if(e instanceof rn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(i,0),u=NO(a.v0,a.v1,a.v2,a.v3,c);return s!==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])),o!==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 Wt(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 i=0;i<r;i++){let s=i*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],u=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new js(we.generateUUID(),new U(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(u,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new Wt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(o,a)=>{a instanceof tn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l<c;l++)o[l]instanceof qn&&(o[l]=OO(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof tn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof rn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&i(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof tn?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof rn&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof sa&&(this.shapeHoles=e.holes.map(o=>{let a=new Wt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var tA=Math.PI*2;function eA({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function V9(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),s=Math.cos(n+t),o=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function UO(n,t,e,r){let i=n*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(s)}function z9(n,t,e,r,i,s,o,a,l,c){let u=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let m=p*i/s*a,g=p*-s/i*o,y=m+(n+e)/2,v=g+(t+r)/2,x=(o-m)/i,S=(a-g)/s,w=(-o-m)/i,A=(-a-g)/s,M=UO(1,0,x,S),b=UO(x,S,w,A);return!c&&b>0&&(b-=tA),c&&b<0&&(b+=tA),{centerx:y,centery:v,ang1:M,ang2:b}}function kO({px:n,py:t,cx:e,cy:r,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(n-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=z9(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(tA/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(V9(f,p)),f+=p;return l.map(x=>{let{x:S,y:w}=eA(x[0],i,s,m,g),{x:A,y:M}=eA(x[1],i,s,m,g),{x:b,y:T}=eA(x[2],i,s,m,g);return{x1:S,y1:w,x2:A,y2:M,x:b,y:T}})}var zt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(zt||(zt={}));var Ur;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Ur||(Ur={}));function ut(n,t){if(!n)throw t||"Assertion Failed!"}var ot=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ut(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-r.t)*(i/(i+s)):e.t-r.t+(r.t-t.t)*(s/(i+s)):0},n.edgeSign=function(t,e,r){ut(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,s=r.s-e.s;return i+s>0?(e.t-r.t)*i+(e.t-t.t)*s:0},n.transEval=function(t,e,r){ut(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-r.s)*(i/(i+s)):e.s-r.s+(r.s-t.s)*(s/(i+s)):0},n.transSign=function(t,e,r){ut(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,s=r.t-e.t;return i+s>0?(e.s-r.s)*i+(e.s-t.s)*s:0},n.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},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,s){var o,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(o=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,e.s)):(o=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=n.interpolate(o,r.s,a,i.s)):s.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(o=n.transEval(t,r,e),a=n.transEval(r,e,i),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,e.t)):(o=n.transSign(t,r,e),a=-n.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=n.interpolate(o,r.t,a,i.t)):s.t=(r.t+e.t)/2},n}(),tm=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),d0=function(){function n(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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),md=function(){function n(){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 n}(),GO=function(){function n(){var t=new md,e=new tm,r=new d0(0),i=new d0(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new d0(0),r=new d0(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.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},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;ut(i,"Vertex can't be null!");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;ut(i,"Face can't be null");var s=r.prev;i.prev=s,s.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},n.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},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},n.prototype.makeEdge=function(){var t=new md,e=new md,r=new tm,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new md;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new tm;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},n.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 i=new tm;this.makeFace_(i,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)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new md;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.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},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new tm;this.makeFace_(o,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,s,o,a;i=e.Lnext;do r=i,i=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;i=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&ot.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ot.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,s,o,a,l,c;for(s=t,s=t;(i=s.next)!==t;s=i){ut(i.prev===s),l=i.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ut(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){ut(o.prev===a),l=o.anEdge;do ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l),ut(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(ut(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ut(l.Sym.next===c.Sym),ut(l.Sym!==l),ut(l.Sym.Sym===l),ut(l.Org!==null),ut(l.Dst!==null),ut(l.Lnext.Onext.Sym===l),ut(l.Onext.Sym.Lnext===l);ut(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)},n}(),jO=function(){function n(){this.handle=null}return n}(),HO=function(){function n(){this.key=null,this.node=0}return n}(),U9=function(){function n(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 jO,this.handles[r]=new HO;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,ut(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[i].key,r[s].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=s,r[s].node=t,t=o}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new jO;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new HO}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},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=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)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ut(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),rA=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),WO=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),k9=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new WO,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.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},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new WO;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),G9=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,s=e.eUp,o=r.eUp;if(s.Dst===i)return o.Dst===i?ot.vertLeq(s.Org,o.Org)?ot.edgeSign(o.Dst,s.Org,o.Org)<=0:ot.edgeSign(s.Dst,o.Org,s.Org)>=0:ot.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ot.edgeSign(s.Dst,i,s.Org)>=0;var a=ot.edgeEval(s.Dst,i,s.Org),l=ot.edgeEval(o.Dst,i,o.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ut(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ut(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new rA;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case zt.ODD:return(e&1)!==0;case zt.NONZERO:return e!==0;case zt.POSITIVE:return e>0;case zt.NEGATIVE:return e<0;case zt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=n.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){n.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,o),a=s.eUp,o=s}return a},n.addRightEdges=function(t,e,r,i,s,o){var a,l,c,u,h=!0;c=r;do ut(ot.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=n.regionBelow(e).eUp.Rprev),l=e,u=s;a=n.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=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,u),n.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,ut(l.windingNumber-c.winding===a.windingNumber),o&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=ot.vertL1dist(e,t),s=ot.vertL1dist(r,t),o=.5*s/(i+s),a=.5*i/(i+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,s,o)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp;if(ot.vertLeq(i.Org,s.Org)){if(ot.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ot.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=r.dirty=!0)}else{if(ot.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o;if(ut(!ot.vertEq(i.Dst,s.Dst)),ot.vertLeq(i.Dst,s.Dst)){if(ot.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(ot.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,s=r.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,u,h,d=new md,f,p;if(ut(!ot.vertEq(c,l)),ut(ot.edgeSign(l,t.event,o)<=0),ut(ot.edgeSign(c,t.event,a)>=0),ut(o!==t.event&&a!==t.event),ut(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(ot.vertLeq(o,a)){if(ot.edgeSign(c,o,a)>0)return!1}else if(ot.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),ot.intersect(l,o,c,a,d),ut(Math.min(o.t,l.t)<=d.t),ut(d.t<=Math.max(a.t,c.t)),ut(Math.min(c.s,l.s)<=d.s),ut(d.s<=Math.max(a.s,o.s)),ot.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=ot.vertLeq(o,a)?o:a,ot.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ot.vertEq(d,o)||ot.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ot.vertEq(l,t.event)&&ot.edgeSign(l,t.event,d)>=0||!ot.vertEq(c,t.event)&&ot.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),r=e,e=n.topRightRegion(e),p=n.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,s.Onext,i.Rprev,p,!0),!0):(ot.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ot.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,o,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,s;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=r.eUp,i.Dst!==s.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(s),r=n.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(n.addWinding(s,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,s=r.Onext,o=n.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),ot.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=n.topLeftRegion(t,e),s=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),o),c=!0),ot.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,o,null),c=!0),c){n.addRightEdges(t,e,r.Onext,s,s,!0);return}ot.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,s,o,a,l;if(i=e.eUp,ot.vertEq(i.Org,r)){ut(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ot.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ut(!1),e=n.topRightRegion(e),l=n.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(ut(s!==o),n.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),ot.edgeGoesLeft(s)||(s=null),n.addRightEdges(t,e,o.Onext,a,s,!0)},n.connectLeftVertex=function(t,e){var r,i,s,o,a,l,c=new rA;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,ot.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=ot.vertLeq(a.Dst,o.Dst)?r:i,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?n.fixUpperEdge(t,s,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ut(i!==null);var s=n.regionBelow(i),o=s.eUp,a=n.finishLeftRegions(t,s,null);a.Onext===o?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,o,o,!0)},n.addSentinel=function(t,e,r,i){var s=new rA,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},n.initEdgeDict=function(t){t.dict=new k9(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,s,o),n.addSentinel(t,i,s,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ut(e.fixUpperEdge),ut(++r===1)),ut(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,i=e.Lnext,ot.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,s=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)s++;for(s+=8,e=t.pq=new U9(s,ot.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,s;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,s=r.anEdge,ut(s.Lnext!==s),s.Lnext.Lnext===s&&(n.addWinding(s.Onext,s),t.mesh.delete(s));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ot.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),j9=function(){function n(){this.mesh=new GO,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=zt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.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},n.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},n.prototype.computeNormal_=function(t){var e,r,i,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],c[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<c[y]&&(c[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[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=p[v],i=f[v],u[0]=r.coords[0]-i.coords[0],u[1]=r.coords[1]-i.coords[1],u[2]=r.coords[2]-i.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<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]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,s=!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),s=!0),r=this.sUnit,i=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=e[o]>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,i);s&&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))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ot.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ot.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(ot.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ot.edgeGoesLeft(i.Lnext)||ot.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ot.edgeGoesRight(r.Lprev)||ot.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},n.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},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var s,o=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){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===Ur.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===Ur.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);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;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,i=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,o++,r=r.Lnext;while(r!==i);this.elements[u++]=s,this.elements[u++]=o,s+=o}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new GO),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=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[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,s,o){if(t===void 0&&(t=zt.ODD),e===void 0&&(e=Ur.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),G9.computeInterior(this,o);var a=this.mesh;return e===Ur.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===Ur.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function Hs(n){var t=n.windingRule,e=t===void 0?zt.ODD:t,r=n.elementType,i=r===void 0?Ur.POLYGONS:r,s=n.polySize,o=s===void 0?3:s,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,u=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,f=n.strict,p=f===void 0?!0:f,m=n.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new j9;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,i,o,l,u,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Gme=zt.ODD,jme=zt.NONZERO,Hme=zt.POSITIVE,Wme=zt.NEGATIVE,qme=zt.ABS_GEQ_TWO,Yme=Ur.POLYGONS,Xme=Ur.CONNECTED_POLYGONS,Qme=Ur.BOUNDARY_CONTOURS;var f0=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*f0.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,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*f0.eSize,i=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let c=new Float32Array(i,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=i,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 i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}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)}},rm=f0;rm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var QO=Ko(XO()),im={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},aA={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},lA={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},oA=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Ol=class extends _e{constructor(e,r,i=0,s=12,o=3,a=zt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let c=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(P=>{let D=P.extractShapePointsToFlatArray([],s),_=[];for(let O=D.length-1;O>=1;O-=2){let L=D[O-1],j=D[O-0];_.push(L,j)}return _}),h=[],d=[];for(let P=0;P<c.length;P+=2)d.push([c[P],c[P+1]]);h.push(d);for(let P=0;P<u.length;P++){let D=u[P],_=[];for(let O=0;O<D.length;O+=2)_.push([D[O],D[O+1]]);h.push(_)}let f;e.isText?f=new qu().setFromPoints(e.points.map(D=>D.position)).getSize(new U).length()*.1:h[0].length===0?f=i:f=(0,QO.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Hs({windingRule:a,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=im}let m;try{m=Hs({windingRule:zt.ODD,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=aA}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let P=0;P<m.elements.length;P++){let D=m.elements[P],_=P%2===0?p.vertexCount:0;p.elements.push(D+_)}for(let P=0;P<m.vertexIndices.length;P++){let D=m.vertexIndices[P],_=p.vertexCount;p.vertexIndices.push(D+_)}for(let P=0;P<m.vertices.length;P++){let D=m.vertices[P];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,S=-1/0;for(let P=0,D=p.vertexCount;P<D;P++){let _=P*2,O=p.vertices[_+0],L=p.vertices[_+1];O<y&&(y=O),O>v&&(v=O),L<x&&(x=L),L>S&&(S=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=S-x,this._buffer=new rm(this._computeBufferEstimatedSize(p));let w=[],A=[];for(let P=p.elementCount-1;P>=0;P--){let D=P>=g,_=P*2,O=p.elements[_+0],L=p.elements[_+1],j=O+L,V={start:O,count:L,normals:[],continuous:[],concave:[]},H=O,W=j-1,q=O+1,K=this._shape.roundedCurves.length;do{let Y=H-O,oe=p.vertices[W*2+0],ie=p.vertices[W*2+1],re=p.vertices[H*2+0],J=p.vertices[H*2+1],Ae=p.vertices[q*2+0],xe=p.vertices[q*2+1],de=re-oe,Oe=J-ie,Ce=Math.sqrt(de*de+Oe*Oe);de/=Ce,Oe/=Ce;let Ue=re-Ae,ze=J-xe,Ve=Math.sqrt(Ue*Ue+ze*ze);Ue/=Ve,ze/=Ve,V.normals[Y*2+0]=-ze,V.normals[Y*2+1]=Ue,V.concave[Y]=de*ze-Oe*Ue>0;let Ie=p.vertexIndices[H];if(Array.isArray(Ie))V.continuous[Y]=!1;else{let[Ye,F]=this._shape.getCurveIndexFromVertexId(Ie-1,!0);if(F>0&&F<1)V.continuous[Y]=!0;else{let N=F===1?Ye+1:Ye-1;N=(N+K)%K;let B=F===1?0:1,ae=this._shape.roundedCurves[Ye].getTangent(F),ge=this._shape.roundedCurves[N].getTangent(B);V.continuous[Y]=ae.dot(ge)>.95}}D&&(V.normals[Y*2+0]*=-1,V.normals[Y*2+1]*=-1),[W,H,q]=[H,q,q+1],q>=j&&(q-=L)}while(q!==O+1);let G=[];G.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(O*2,j*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((Y,oe)=>[oe,oe]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(O*2,j*2)});let Z=0;for(let Y=1;Y<=this._bevelSegments;Y++){let oe=Y/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,re=[],J=[],Ae=[],xe=[],de=0;for(let Ce=0;Ce<L;Ce++){let Ue=Ce*2,ze=(Ce-1+L)%L*2,Ve=p.vertices[V.start*2+Ue+0],Ie=p.vertices[V.start*2+Ue+1],Ye=-V.normals[ze+0]*ie,F=-V.normals[ze+1]*ie,N=-V.normals[Ue+0]*ie,B=-V.normals[Ue+1]*ie;if(V.concave[Ce]||!V.concave[Ce]&&D){let ae=Math.atan2(F,Ye),ge=Math.atan2(B,N);ge>ae&&(ge-=Math.PI*2);let me=ge-ae;if(V.continuous[Ce]||D){let Le=ae+me/2,Ne=Math.cos(Le)*ie,Re=Math.sin(Le)*ie;re[2*de+0]=Ve+Ne*(D?-1:1),re[2*de+1]=Ie+Re*(D?-1:1),xe[de]=Ce,de++}else{let Le=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Ne=0;Ne<=Le;Ne++){let Re=ae+me*(Ne/Le),pe=Math.cos(Re)*ie,rt=Math.sin(Re)*ie;re[2*de+0]=Ve+pe,re[2*de+1]=Ie+rt,xe[de]=Ce,de++}}}else re[2*de+0]=Ve+Ye,re[2*de+1]=Ie+F,xe[de]=Ce,J[Ce]=de,de++,re[2*de+0]=Ve,re[2*de+1]=Ie,xe[de]=Ce,de++,re[2*de+0]=Ve+N,re[2*de+1]=Ie+B,xe[de]=Ce,Ae[Ce]=de,de++}let Oe=Hs({windingRule:zt.POSITIVE,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Ce=>{let ze=Ce.Org.idx,Ve=xe[ze],Ie=xe[(ze+1)%xe.length];Ce.idx=[Ve,Ie],Ce.Sym.idx=[Ie,Ve]},vertexIdCallback:Ce=>{let Ue=Ce.Lprev.idx;return[Ue?Ue[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!Oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!Oe.vertexCount){let Ce=(Y-1)/this._bevelSegments*Math.PI/2;Z=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce<Oe.vertexIndices.length;Ce++){let[Ue,ze]=Oe.vertexIndices[Ce];if(Ue===ze)continue;let Ve=ze;ze<Ue&&(Ve+=L);for(let Ie=Ue;Ie<Ve;Ie++){let Ye=Ie%L,F=(Ie+1)%L;if(!V.continuous[Ye]||!V.continuous[F]){Oe.vertexIndices[Ce]=[Ue,Ye],Oe.vertexIndices.splice(Ce+1,0,[F,ze]),Oe.vertices.splice((Ce+1)*2,0,Oe.vertices[Ce*2],Oe.vertices[Ce*2+1]);break}}}G.push({bevelI:Y,angle:oe,size:ie,boundary:Oe,reverseMap:xe,insetPoints:re})}let te=(Y,oe,ie)=>{let re=0,J=Y.boundary.vertexIndices.length;for(;re<J&&ie(Y.boundary.vertexIndices[oe]);)oe=(oe+1)%J,re++;return re},$=w.length;for(let Y=1;Y<G.length;Y++){let oe=G[Y-1],ie=G[Y],re=oe.boundary.vertexIndices.length,J=ie.boundary.vertexIndices.length;if(!re||!J)break;let Ae=V.concave.length,xe=0,de=oA(xe,L);for(;!oe.boundary.vertexIndices.filter(de).length||!ie.boundary.vertexIndices.filter(de).length;)xe++,de=oA(xe,L);let Oe=oe.boundary.vertexIndices.findIndex(de),Ce=ie.boundary.vertexIndices.findIndex(de);do Oe=(Oe+1)%re;while(de(oe.boundary.vertexIndices[Oe]));do Ce=(Ce+1)%J;while(de(ie.boundary.vertexIndices[Ce]));xe=(xe+1)%L;let Ue=xe,ze=0,Ve=this._buildBevelVert(V,oe,(Oe-1+re)%re,void 0,ze),Ie=this._buildBevelVert(V,ie,(Ce-1+J)%J,void 0,ze),Ye=Ve,F=Ie,N,B,ae=!1;do{ze=(xe||Ae)/Ae,de=oA(xe,L);let ge=te(oe,Oe,de),me=te(ie,Ce,de),Le=ae;if(ae=!1,ge&&!me){for(let Ne=0;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Oe+Ne)%re,Ne/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N;ae=!0}else if(!ge&&me)for(let Ne=0;Ne<me;Ne++)B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(F.topN,Ye.topP,B.topP),l===!1&&w.push(Ye.bottomP,F.bottomN,B.bottomP),F=B;else if(ge&&me)if(N=this._buildBevelVert(V,oe,Oe,0,ze),B=this._buildBevelVert(V,ie,Ce,0,ze),Le?(w.push(Ye.topN,B.topP,F.topN),w.push(Ye.topN,N.topP,B.topP),l===!1&&(w.push(B.bottomP,Ye.bottomN,F.bottomN),w.push(B.bottomP,N.bottomP,Ye.bottomN))):(w.push(F.topN,Ye.topN,N.topP),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP))),Ye=N,F=B,ge===me)for(let Ne=1;Ne<ge;Ne++)N=this._buildBevelVert(V,oe,(Oe+Ne)%re,Ne/(ge-1),ze),B=this._buildBevelVert(V,ie,(Ce+Ne)%J,Ne/(me-1),ze),w.push(Ye.topN,N.topP,F.topN),w.push(F.topN,N.topP,B.topP),l===!1&&(w.push(N.bottomP,Ye.bottomN,F.bottomN),w.push(N.bottomP,F.bottomN,B.bottomP)),Ye=N,F=B;else if(ge>me){let Ne=ge/me,Re=0;for(let pe=1;pe<ge;pe++)N=this._buildBevelVert(V,oe,(Oe+pe)%re,pe/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N,pe>(Re+1)*Ne&&(Re++,B=this._buildBevelVert(V,ie,(Ce+Re)%J,Re/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B)}else{let Ne=me/ge,Re=0;for(let pe=1;pe<me;pe++)B=this._buildBevelVert(V,ie,(Ce+pe)%J,pe/(me-1),ze),w.push(F.topN,N.topP,B.topP),l===!1&&w.push(N.bottomP,F.bottomN,B.bottomP),F=B,pe>(Re+1)*Ne&&(Re++,N=this._buildBevelVert(V,oe,(Oe+Re)%re,Re/(ge-1),ze),w.push(Ye.topN,N.topP,F.topN),l===!1&&w.push(N.bottomP,Ye.bottomN,F.bottomN),Ye=N)}Oe=(Oe+ge)%re,Ce=(Ce+me)%J,xe=(xe+1)%Ae}while(xe!==Ue)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(G,V,w),D){let Y=[];for(let oe=w.length-1;oe>=$+2;oe-=3){let ie=w[oe-2],re=w[oe-1],J=w[oe-0];Y.push(J,re,ie)}w.splice($,w.length-$,...Y)}if(D){let Y=[];for(let oe=G[G.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=G[G.length-1].boundary.vertices[oe-1],re=G[G.length-1].boundary.vertices[oe-0];Y.push(ie,re)}A.push(Y)}if(!D){let Y=G[G.length-1],oe;try{oe=Hs({windingRule:G.length>1?zt.POSITIVE:zt.ODD,elementType:Ur.POLYGONS,vertexSize:2,strict:!0,contours:[Y.insetPoints,...A]})}catch{oe=lA}if(!oe)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ie=0;ie<oe.elementCount*3;ie+=3){let re=this._buildSurfaceVert(oe,oe.elements[ie+0],Z),J=this._buildSurfaceVert(oe,oe.elements[ie+1],Z),Ae=this._buildSurfaceVert(oe,oe.elements[ie+2],Z);w.push(re.top,J.top,Ae.top),l===!1&&w.push(Ae.bottom,J.bottom,re.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Xe(Uint32Array.from(w),1),b=new Xe(this._buffer.positions,3),T=new Xe(this._buffer.normals,3),C=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,T.needsUpdate=!0,C.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",T),this.setAttribute("uv",C),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,i){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,c=(a-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),h=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[s]=f,f}_buildBevelVert(e,r,i,s=1,o){let a=`${r.bevelI}:${i}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,c]=r.boundary.vertexIndices[i],u,h,d,f;l!==c?(h=l,u=c,f=!1,d=e.continuous[h]&&e.continuous[u]):(u=l,h=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=i*2,y=u*2,v=h*2,x=r.boundary.vertices[g+0],S=r.boundary.vertices[g+1],w=(1-m)*this._bevel,A=(x-this._minX)/this._width,M=(S-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),M=1);let b=e.normals[y+0],T=e.normals[y+1],C=e.normals[v+0],P=e.normals[v+1];if(f){let j=C-b,V=P-T;b=b+j*(1-s),T=T+V*(1-s);let H=Math.sqrt(b*b+T*T);b/=H,T/=H}let D=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=D*3,O=D*2,L={i,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=b*p,this._buffer.normals[_+1]=T*p,this._buffer.normals[_+2]=m,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=b*p,this._buffer.normals[_+4]=T*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[O+2]=M,this._buffer.uvs[O+3]=A),d||(this.forPathBevel?(D+=1,_+=3,O+=2):(D+=2,_+=6,O+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[_+0]=x,this._buffer.positions[_+1]=S,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[_+0]=C*p,this._buffer.normals[_+1]=P*p,this._buffer.normals[_+2]=m,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=x,this._buffer.positions[_+4]=S,this._buffer.positions[_+5]=w,this._buffer.normals[_+3]=C*p,this._buffer.normals[_+4]=P*p,this._buffer.normals[_+5]=-m,this._buffer.uvs[O+2]=M,this._buffer.uvs[O+3]=A)),this.vertexCache[a]=L,L}clone(){let e=new Ol(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ha(this.userData),e}};var gd=class extends _e{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=zt.ODD;this.elementType=Ur.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:zt.ODD,elementType:Ur.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(u!==void 0&&y!==u&&(l=!1),h!==void 0&&v!==h&&(c=!1),u=y,h=v,!l&&!c)break}if(!l&&!c)try{a=Hs({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=im}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(d*3),3),this._normalAttribute=new Xe(new Float32Array(d*3),3),this._uvAttribute=new Xe(new Float32Array(d*2),2),this._indexAttribute=new Xe(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1];M<p&&(p=M),M>m&&(m=M),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let S=0,w=d;S<w;S++){let A=S*2,M=a.vertices[A+0],b=a.vertices[A+1],T=(M-p)/v,C=(b-g)/x;this._positionAttribute.setXYZ(S,M,b,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,C)}for(let S=0,w=f;S<w;S++){let A=S*3,M=a.elements[A+0],b=a.elements[A+1],T=a.elements[A+2];this._indexAttribute.setX(A+0,M),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,T)}}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 gd(this._shape,this._curveSegments);return e.userData=ha(this.userData),e}};var yd=class extends Ol{constructor(e,r,i=0,s=12,o=3,a=zt.ODD){super(e,r,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new yd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ha(this.userData),e}};var Dn=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:zt.ODD},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=n.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Wt?(o.width!==r||o.height!==i)&&o.applySize(r,i):o=new Wt(r,i).fromJSON(o),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&o.update());let l=o??new Wt(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:s,roundness:a}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:s,windingRule:o}=n.parameters;n.shape.roundness=s;let a;return t<=0?a=new gd(n.shape,i,{windingRule:o}):a=new yd(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var ZO=Math.PI*2,xd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=we.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Wt?n.shape:new Wt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=t*.5,h=e*.5,d=X9(c,u,h,i*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return i===0?(f=new _e,f.setAttribute("position",new Te([],3))):f=Dn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function X9(n,t,e,r,i,s){if(r>=ZO)return i>30||i%4===0?(K9(n,t,e,s),Math.round(i/4)):KO(n,r,i,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=kO({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?Q9(n,o.x,o.y,c,i,t,e,s):KO(n,r,i,t,e,s)}function Q9(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(vd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=n.points[c],f=vd(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),n.addPoint(f)}return a>0?JO(n,s,o,a):n.addPoint(vd(0,0)),l}function KO(n,t,e,r,i,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,c=Math.sin(l)*r,u=Math.cos(l)*i;n.addPoint(vd(c,u))}return t<ZO?s>0?JO(n,r,i,s):n.addPoint(vd(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&$O(n,r,i,s)),1}function K9(n,t,e,r=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;n.addPoint(m0(i-t,s,i-t,s-l,i-t,s+l)),n.addPoint(m0(i,s+e,i-a,s+e,i+a,s+e)),n.addPoint(m0(i+t,s,i+t,s+l,i+t,s-l)),n.addPoint(m0(i,s-e,i+a,s-e,i-a,s-e)),r>0&&$O(n,t,e,r)}function vd(n,t){return new js(we.generateUUID(),new U(n,t))}function m0(n,t,e,r,i,s){let o=vd(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function JO(n,t,e,r){eI(n,t,e,r).forEach(s=>n.addPoint(s))}function $O(n,t,e,r){let i=eI(n,t,e,r),s=new Wt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function eI(n,t,e,r){let i=r*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new U(i/t,s/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=we.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var tI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=n.parameters,d=new nm(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},cA=new uo([0,0,0],1),nm=class extends _e{constructor(t=!0,e=1,r=1,i=1,s=1,o=1,a=1,l=1,c=1,u=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new E,m=new E,g=p(),y=p(),v=p(),x,S,w,A,M,b,T,C,P=p(),D=p(),_=p(),O=p(),L=p(),j=p(),V=p(),H=p(),W=r-2*l+.001,q=W/o,K=Math.ceil(a*o),G=K+1,Z=W/K,te=-W/2,$=u+1,Y=2*Math.PI/u,oe=Math.PI/2/d,ie=.01,re=Math.min((1-h/100)*l,l-ie),J=l-re,Ae=0,xe=2,de=d*xe+xe,Oe=$*de/xe,Ce=Oe+$*G,Ue=Math.max(0,$*(G+de)),[ze,Ve,Ie]=[3,3,2].map(Ge=>Array(Ue*Ge).fill(0)),Ye=[],F=s-l;function N(Ge,Be){let Je=Math.PI/2;b=Be*Z,C=2*Math.PI*(b%q)/q+Je,b+=te,T=Math.sin(C)*F,M=Math.cos(C)*F,t?Ge.set(M,T,b):Ge.set(M,b,T)}N(m,-1e-10),N(g,0),P.copy(m),N(m,1);let B=m.distanceTo(g),ae=f?0:J+re,ge=B*K+2*ae,me=re,Le=ge-ae;for(let Ge=0;Ge<=K;Ge++){N(y,Ge),H.subVectors(y,P).normalize(),P.copy(y),j.copy(y).setComponent(+t+1,0).normalize(),V.crossVectors(H,j).normalize();let Be=Ge===0,Je=Ge===K,nt=Be?3*Math.PI/2:oe,Bt=Be?me:Le,ur=Be?$:Ce,Ar=Be?0:Ue-$,Q=H.clone().multiplyScalar(Be?-J:J).add(y),ye=H.clone().multiplyScalar(Be?-1:1).normalize();for(let Me=0;Me<$;Me++){let je=Me*Y;if(D.addVectors(m.copy(j).multiplyScalar(l*Math.cos(je)),g.copy(V).multiplyScalar(l*Math.sin(je))),_.copy(D).normalize(),Be||Je){f||(Ae=Ar+Me,[0,1,2].forEach(He=>{ze[Ae*3+He]=Q.getComponent(He),Ve[Ae*3+He]=ye.getComponent(He)}),Ie[Ae*2]=+Je,Ie[Ae*2+1]=Me/u),g.copy(_).multiplyScalar(re),v.addVectors(y,g);for(let He=0;He<d;He++){let _t=He*oe+nt;O.addVectors(m.copy(H).multiplyScalar(J*Math.sin(_t)),g.copy(_).multiplyScalar(J*Math.cos(_t))),L.copy(O).normalize(),g.addVectors(v,O),O.normalize(),Ae=ur+He*$+Me,[0,1,2].forEach(Nr=>{ze[Ae*3+Nr]=g.getComponent(Nr),Ve[Ae*3+Nr]=L.getComponent(Nr)});let Br=+Be+Math.sin(_t);Ie[Ae*2]=(Bt+J*Br)/ge,Ie[Ae*2+1]=Me/u}}g.addVectors(y,D),Ae=Oe+Ge*$+Me,[0,1,2].forEach(He=>{ze[Ae*3+He]=g.getComponent(He),Ve[Ae*3+He]=_.getComponent(He)}),Ie[Ae*2]=(ae+Ge*B)/ge,Ie[Ae*2+1]=Me/u}}let Ne=G+2*d+xe,Re=1,[pe,rt]=[+f,Ne-1];for(let Ge=pe;Ge<=rt-1;Ge++){let Be=f&&Ge===rt-1;for(let Je=0;Je<$-1;Je++)x=Ge*$+Je,S=x+1,w=(Be?Je:x)+$,A=(Be?Je+1:S)+$,Ge===0?Ye.push(S,A,w):Ge===Ne-2?Ye.push(x,S,w):Ye.push(x,S,w,S,A,w)}this.setIndex(Ye),this.setAttribute("position",new Te(ze,3)),this.setAttribute("normal",new Te(Ve,3)),this.setAttribute("uv",new Te(Ie,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,i=Array.from(this.getIndex().array),s,o,a,l,c=6*(e-1)*t.radialSegments,u=e,h=u===e;for(let d=0;d<t.radialSegments;d++)s=u*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,i[c++]=s,i[c++]=o,i[c++]=a,i[c++]=o,i[c++]=l,i[c++]=a;return i.length=c,cA.array=i,cA.count=i.length,cA}};var rI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:i,corner:s,cornerSides:o}=n.parameters,a=i===0&&s!==0?new sm(t*.5,s,o):new Nu(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},sm=class extends Pl{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[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(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new sm(t.radius,t.corner,t.cornerSides)}};var iI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.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}]},n.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(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new sa;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Iu(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var _o=new ce,uA=new Et,g0=new E,Il=class extends hr{constructor(){super(),this.uuid=we.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 vr().getNormalMatrix(t);for(let r=0,i=this.vertices.length;r<i;r++)this.vertices[r].applyMatrix4(t);for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return _o.makeRotationX(t),this.applyMatrix4(_o),this}rotateY(t){return _o.makeRotationY(t),this.applyMatrix4(_o),this}rotateZ(t){return _o.makeRotationZ(t),this.applyMatrix4(_o),this}translate(t,e,r){return _o.makeTranslation(t,e,r),this.applyMatrix4(_o),this}scale(t,e,r){return _o.makeScale(t,e,r),this.applyMatrix4(_o),this}lookAt(t){return uA.lookAt(t),uA.updateMatrix(),this.applyMatrix4(uA.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new E().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new We().fromBufferAttribute(a,d));function u(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new E().fromBufferAttribute(o,d),new E().fromBufferAttribute(o,f),new E().fromBufferAttribute(o,p)],v=new bd(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,p)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)r!==void 0?u(r.getX(g),r.getX(g+1),r.getX(g+2),f.materialIndex):u(g,g+1,g+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)u(d,d+1,d+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(g0).negate(),this.translate(g0.x,g0.y,g0.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,i=new ce;return i.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(i),this}computeFaceNormals(){let t=new E,e=new E;for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,i=this.vertices.length;r<i;r++)e[r]=new E;if(t){let r=new E,i=new E;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],u=this.vertices[a.c];r.subVectors(u,c),i.subVectors(l,c),r.cross(i),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,i=this.vertices.length;r<i;r++)e[r].normalize();for(let r=0,i=this.faces.length;r<i;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.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],i=r.vertexNormals;i.length===3?(i[0].copy(r.normal),i[1].copy(r.normal),i[2].copy(r.normal)):(i[0]=r.normal.clone(),i[1]=r.normal.clone(),i[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new Il;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 s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new E,u={a:new E,b:new E,c:new E};s.push(c),o.push(u)}}let i=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];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 i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dr),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 i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,c=t.faces,u=this.colors,h=t.colors;e!==void 0&&(i=new vr().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone());for(let d=0,f=c.length;d<f;d++){let p=c[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new bd(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let S=0,w=y.length;S<w;S++)m=y[S].clone(),i!==void 0&&m.applyMatrix3(i).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let S=0,w=v.length;S<w;S++)g=v[S],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++)v.push(y[x].clone());this.faceVertexUvs[d].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=[],i=[],s=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],h=Math.round(u.x*s)+"_"+Math.round(u.y*s)+"_"+Math.round(u.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),i[l]=r.length-1):i[l]=i[e[h]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=i[u.a],u.b=i[u.b],u.c=i[u.c];let h=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u<h;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 i=t[e];this.vertices.push(new E(i.x,i.y,i.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 i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),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 p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],i=[],s={},o=[],a={},l=[],c={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,S=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,M=0;if(M=u(M,0,0),M=u(M,1,g),M=u(M,2,y),M=u(M,3,v),M=u(M,4,x),M=u(M,5,S),M=u(M,6,w),M=u(M,7,A),r.push(M),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),S){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(w&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function u(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=i.length/3,i.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(p.x,p.y)),c[m]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Il().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 d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let i=t.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,S=y.length;x<S;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.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 hA().fromGeometry(this),e=new _e,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",y0.call(new Xe(r,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",y0.call(new Xe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",nI.call(new Xe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",sI.call(new Xe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",sI.call(new Xe(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],u=new Te(c.data.length*3,3);u.name=c.name,s.push(y0.call(u,c.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Te(t.skinIndices.length*4,4);e.setAttribute("skinIndex",oI.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Te(t.skinWeights.length*4,4);e.setAttribute("skinWeight",oI.call(i,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 _e,r=t.geometry;if(t.isPoints||t.isLine){let i=new Te(r.vertices.length*3,3),s=new Te(r.colors.length*3,3);if(e.setAttribute("position",y0.call(i,r.vertices)),e.setAttribute("color",nI.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Te(r.lineDistances.length,1);e.setAttribute("lineDistance",Z9.call(o,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}};Il.prototype.isGeometry=!0;var hA=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,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=i*3-r.start,e.push(r)),r={start:i*3,materialIndex:s})}r!==void 0&&(r.count=i*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[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,h=u.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:u[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===r.length,g=p.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 x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=i[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new U,new U,new U))}if(o===!0){let w=i[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new U,new U,new U))}for(let w=0;w<l;w++){let A=a[w].vertices;c[w].data.push(A[v.a],A[v.b],A[v.c])}for(let w=0;w<h;w++){let A=u[w].vertexNormals[y];d[w].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[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}},bd=class{constructor(t,e,r,i,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=i&&i.isVector3?i:new E,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new We,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}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}};function Z9(n){return this.array.set(n),this}function nI(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new We),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function sI(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new U),t[e++]=s.x,t[e++]=s.y}return this}function y0(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new E),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function oI(n){let t=this.array,e=0;for(let r=0,i=n.length;r<i;r++){let s=n[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Ke),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var J9=["a","b","c"];function $9(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function dA(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),s=r+"_"+i;return e.get(s)}function fA(n,t,e,r,i,s){let o=Math.min(n,t),a=Math.max(n,t),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let u=e[o],h=e[a];c={a:u,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),s[n].edges.push(c),s[t].edges.push(c)}function e7(n,t,e,r){let i,s,o;for(i=0,s=n.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],fA(o.a,o.b,n,r,o,e),fA(o.b,o.c,n,r,o,e),fA(o.c,o.a,n,r,o,e)}function v0(n,t,e,r,i){n.push(new bd(t,e,r,void 0,void 0,i))}function Sd(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function x0(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var b0=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof _e?t=new Il().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 E,r,i,s,o,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;e7(l,c,d,f);let p=[],m,g,y,v,x,S,w;for(let ie of Array.from(f.keys())){for(g=f.get(ie),y=new E,x=3/8,S=1/8,w=g.faces.length,w!=2&&(x=.5,S=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[$9(v,J9[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(S),y.add(e),g.newEdge=p.length,p.push(y)}let A,M,b,T,C,P,D,_=[];for(i=0,s=l.length;i<s;i++){for(P=l[i],C=d[i].edges,r=C.length,r==3?A=3/16:r>3&&(A=3/(8*r)),M=1-r*Number(A),b=A,r<=2&&(r==2?(M=3/4,b=1/8):r==1||r==0),D=P.clone().multiplyScalar(M),e.set(0,0,0),o=0;o<r;o++)T=C[o],m=T.a!==P?T.a:T.b,e.add(m);e.multiplyScalar(Number(b)),D.add(e),_.push(D)}let O=_.concat(p),L=_.length,j,V,H,W=[],q=[],K,G,Z,te,$=new U,Y=new U,oe=new U;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number(dA(v.a,v.b,f).newEdge)+L,V=Number(dA(v.b,v.c,f).newEdge)+L,H=Number(dA(v.c,v.a,f).newEdge)+L,v0(W,j,V,H,v.materialIndex),v0(W,v.a,j,H,v.materialIndex),v0(W,v.b,V,j,v.materialIndex),v0(W,v.c,H,V,v.materialIndex),h&&(K=u[i],G=K[0],Z=K[1],te=K[2],$.set(Sd(G.x,Z.x),Sd(G.y,Z.y)),Y.set(Sd(Z.x,te.x),Sd(Z.y,te.y)),oe.set(Sd(G.x,te.x),Sd(G.y,te.y)),x0(q,$,Y,oe),x0(q,G,$,oe),x0(q,Z,Y,$),x0(q,te,oe,Y));t.vertices=O,t.faces=W,h&&(t.faceVertexUvs[0]=q)}};var Ti=new E,aI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new _e().copy(new hi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ti),r={width:Ti.x,height:Ti.y,depth:Ti.z,subdivisions:0}):r=t.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,s=n.geometry??new _e().copy(new hi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Ti)):Ti.set(o.width,o.height,o.depth),(t!==Ti.x||e!==Ti.y||r!==Ti.z)&&s.scale(Ti.x===0?1:t/Ti.x,Ti.y===0?1:e/Ti.y,Ti.z===0?1:r/Ti.z);let a=s.originalGeometry;try{i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new b0(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete n.geometry,Object.assign(s,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new Hu(e).load(n,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Ti);let o=100/Ti.x;Object.assign(s.parameters,{width:100,height:Ti.y*o,depth:Ti.z*o}),t(this.build(s))})}};var S0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Wt?n.shape:new Wt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=t*.5,u=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*c,v=d+Math.cos(g)*u;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=i;l.roundness=i,l.update();let p=Dn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...n,type:"PolygonGeometry"}})}};var lI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.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(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=new mA(t*.5,e,i,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function om(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function pA(n,t,e,r,i,s){let o=t.clone().sub(n),a=e.clone().sub(n),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===i){let c=o.add(a).normalize();s.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(n),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function t7(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var mA=class extends _e{constructor(t=.5,e=1,r=4,i=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],u=[],h=[],d=0,f=e/2,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new E(0,-f,0),S=new E(0,f,0),w=new U(t,-f),A=new U(m,-f),M=new U(0,S.y).sub(A),b=new U(0,S.y).sub(w),T=new U(M.y,-M.x).normalize(),C=new U(b.y,-b.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,D);let _;{let q=new E(T.x,T.y,0),K=new E(Math.cos(g)*q.x,q.y,Math.sin(g)*q.x);_=q.angleTo(K)}let O=o/Math.tan((Math.PI-M.angle())/2),L=o/Math.tan((Math.PI-_)/2),j=new E;if(!s){c.push(x.x,x.y,x.z),u.push(0,-1,0),h.push(0,0);let q=d++,K=[],G=w.clone(),Z=O/Math.cos(Math.PI/r);G.x-=Z;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+p,Y=new U(Math.sin($),Math.cos($));om(G,Y,j),c.push(j.x,j.y,j.z),u.push(0,-1,0),h.push(0,0),K.push(d++)}for(let te=0;te<K.length;te++)l.push(K[te],q,K[(te+1)%K.length])}let V=[];{let q=new E,K=new E,G=new E,Z=new E,te=new E,$=new E;for(let Y=0;Y<r;Y++){let oe=Y/r*Math.PI*2+p,ie=(Y+.5)/r*Math.PI*2+p,re=(Y+1)/r*Math.PI*2+p,J=new U(Math.sin(oe),Math.cos(oe)),Ae=new U(Math.sin(ie),Math.cos(ie)),xe=new U(Math.sin(re),Math.cos(re));om(w,J,K),om(w,xe,G),om(T,Ae,q),pA(S,K,G,L,L,Z),c.push(Z.x,Z.y,Z.z),pA(K,S,G,L,O,te),c.push(te.x,te.y,te.z),pA(G,K,S,O,L,$),c.push($.x,$.y,$.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),u.push(q.x,q.y,q.z),h.push(0,0),h.push(0,0),h.push(0,0);let de=d++,Oe=d++,Ce=d++;if(l.push(de,Oe,Ce),o>0){{let Ve=K.clone().add(G).multiplyScalar(.5),Ie=S.clone().sub(Ve).normalize(),F=x.clone().sub(Ve).normalize().add(Ie).normalize().multiplyScalar(-1),N=$.clone().sub(te);H(Ve,N,F,M.angle())}let Ue,ze;{let Ve=new E;om(C,xe,Ve);let Ie=$.clone().add(Z).multiplyScalar(.5);Ie=t7(Ie,G,S);let Ye=$.clone().sub(Z);[Ue,ze]=H(Ie,Ye,Ve,_,Z.y)}{let Ve=Ue,Ie=Ve.clone().setY(0).normalize(),Ye=new E(0,-1,0),F=Ie.clone().cross(Ye);W(Ve,Ie,Ye,F)}V.concat(ze);{let Ve=M.angle(),Ie=Math.PI-Ve,Ye=S.clone();Ye.y-=o/Math.sin(Ve-Math.PI/2);let F=new E,N=[];for(let ae=0;ae<a;ae++){let ge=[],me=Math.PI/2-Ie*ae/a,Le=Math.cos(me),Ne=Math.sin(me),Re=ie;for(let pe=0;pe<=ae;pe++){let rt=Math.cos(Re),Ge=Math.sin(Re);q.x=Le*Ge,q.y=Ne,q.z=Le*rt,F.copy(Ye).addScaledVector(q,o),c.push(F.x,F.y,F.z),u.push(q.x,q.y,q.z),h.push(0,0),ge.push(d++),Re+=Math.PI*2/ae/r}N.push(ge)}ze.reverse(),N.push(ze);let B=N.length-1;for(let ae=0;ae<B;ae++){let ge=N[ae],me=N[ae+1],Le=ge.length-1;l.push(me[1],ge[0],me[0]);for(let Ne=1;Ne<=Le;Ne++)l.push(ge[Ne],ge[Ne-1],me[Ne]),l.push(me[Ne+1],ge[Ne],me[Ne])}}}}}this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(h,2));function H(q,K,G,Z,te){let $=-Z/2,Y=(Math.PI-Z)/2,oe=K.clone().normalize().cross(G);q.addScaledVector(G,-o/Math.sin(Y));let ie=new E,re=new E,J=1,Ae=d,xe=[];for(let de=0;de<=a;de++){let Oe=$+de/a*Z;re.set(0,0,0),re.addScaledVector(oe,Math.sin(Oe)),re.addScaledVector(G,Math.cos(Oe));for(let Ce=0;Ce<=J;Ce++){let Ue=Ce/J-.5;if(ie.copy(q),ie.addScaledVector(K,Ue),ie.addScaledVector(re,o),te!=null){let ze=Math.max(0,ie.y-te);ie.addScaledVector(K,-ze/K.y)}c.push(ie.x,ie.y,ie.z),u.push(re.x,re.y,re.z),h.push(0,0),Ce===0&&xe.push(d),d++}}for(let de=0;de<a;de++)for(let Oe=0;Oe<J;Oe++){let Ce=Ae+Oe+(J+1)*de,Ue=Ce+(J+1),ze=Ue+1,Ve=Ce+1;l.push(Ce,Ue,Ve),l.push(Ue,ze,Ve)}return[q.clone().addScaledVector(K,.5),xe]}function W(q,K,G,Z){let te=Math.PI/2,$=b.angle()-te,Y=[],oe=new E,ie=new E;for(let J=0;J<=a;J++){let Ae=[],xe=J/a;for(let de=0;de<=J;de++){let Ce=((J?de/J:0)-.5)*v,Ue=Math.cos(Ce),ze=Math.sin(Ce),Ve=Math.atan(Math.tan($)*Ue),Ie=(te+Ve)*xe,Ye=Math.cos(Ie),F=Math.sin(Ie);oe.set(0,0,0),oe.addScaledVector(K,F*Ue),oe.addScaledVector(G,Ye),oe.addScaledVector(Z,F*ze),ie.copy(q).addScaledVector(oe,o),c.push(ie.x,ie.y,ie.z),u.push(oe.x,oe.y,oe.z),h.push(0,0),Ae.push(d++)}Y.push(Ae)}let re=Y.length-1;for(let J=0;J<re;J++){let Ae=Y[J],xe=Y[J+1],de=Ae.length-1;l.push(Ae[0],xe[1],xe[0]);for(let Oe=1;Oe<=de;Oe++)l.push(Ae[Oe-1],Ae[Oe],xe[Oe]),l.push(Ae[Oe],xe[Oe+1],xe[Oe])}}}};var wd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Wt?n.shape:new Wt,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(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(S,w,A){return w>e&&A>r?Math.min(S*e/w,S*r/A):w>e?S*e/w:A>r?S*r/A:S}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let p=u.x,m=h.x,g=h.y,y=u.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let S=0,w=t.points.length;S<w;S++)t.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Dn.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};var cI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=we.clamp(e.thetaLength,0,180),{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(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,u;return c===0?(u=new _e,u.setAttribute("position",new Te([],3))):u=new Ls(.5*t,i,s,o,a,l,c*we.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var uI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,s=new hn(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var hI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,angle:i,cornerRadius:s,cornerSegments:o}=n.parameters,a=new gA(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},gA=class extends _e{constructor(t=1,e=1,r=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-u,i),i*=Math.PI/180;let h=[],d=Math.PI/2,f=(ie=0,re=0,J=0)=>new E(ie,re,J),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,S=+y,[w,A,M]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(ie,re=!1)=>Math.sin(ie-Math.PI/(1+ +re)),T=(ie,re=!1)=>Math.cos(ie-Math.PI/(1+ +re));M.y=Math.sin(i)*e-g;let C=Math.cos(i)*e-v,P=w.z-u;i<=d?(M.z=Math.min(C,P),M.z==P&&(M.y-=(C-P)/Math.tan(d-i))):A.z=Math.min(A.z-C-v,w.z-u),p.subVectors(w,A),m.subVectors(M,A);let D=Math.min(p.length(),m.length())*s/100,_=D*Math.tan(i/2),O=D/Math.cos(i/2),L=p.clone().normalize().add(m.normalize()).setLength(O).add(A);p.set(0,b(i,!0),T(i,!0)),h.push([M,p.clone()]);let j=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let re=d+i+ie*j;p.set(0,Math.sin(re)*_,Math.cos(re)*_),p.add(L),m.set(0,b(re),T(re)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let V=Math.sin(j/2)*_*2,H=h.length-1,W=h[0][0].distanceTo(h[1][0]),q=h[H-1][0].distanceTo(h[H][0]),K=W+V*o+q;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(W+ie*V)/K);h[H].push(0);let[G,Z,te]=h[0],$,Y,oe;for(let ie=1;ie<h.length;ie++)[$,Y,oe]=h[ie],a.push(x,G.y,G.z,x,$.y,$.z,S,G.y,G.z,S,G.y,G.z,x,$.y,$.z,S,$.y,$.z),l.push(0,Z.y,Z.z,0,Y.y,Y.z,0,Z.y,Z.z,0,Z.y,Z.z,0,Y.y,Y.z,0,Y.y,Y.z),c.push(0,te,0,oe,1,te,1,te,0,oe,1,oe),[G,Z,te]=[$,Y,oe];this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(c,2))}};var w0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Wt?n.shape:new Wt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/i,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(i===3&&r===50){m=2*Math.PI/i;for(let S=0;S<i;S++){let w=m*S,A=f+Math.sin(w)*h,M=p+Math.cos(w)*d;u.addPoint(u.createPoint(A,M))}}else for(let S=0;S<i;S++){let w=f+Math.cos(g)*h,A=p+Math.sin(g)*d;u.addPoint(u.createPoint(w,A)),g+=m,w=f+Math.cos(g)*y,A=p+Math.sin(g)*v,S<=i,u.addPoint(u.createPoint(w,A)),g+=m}u.isClosed=!0;for(let S=0,w=u.points.length;S<w;S++)u.points[S].roundness=s;u.roundness=s,u.update();let x=Dn.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...n,type:"StarGeometry"}})}};var dI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.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(n){let{width:t,height:e}=n.parameters,r=new hn(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};var fI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:i,depth:s})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=n.parameters,c=r7(t,e,r,t*.5,o,s,0,0,i,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function r7(n,t,e,r,i,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=we.clamp(i/360,0,1);if(h===0){let d=new _e;return d.setAttribute("position",new Te([],3)),d}return h===1&&(c=0),new nm(!0,n,t,e,r,h,s,o,a,l,c,u)}var pI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.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(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:s,q:o}=n.parameters,a=t*.5;a!==e&&(a-=e);let l=new Vu(a,e,r,i,s,o);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var mI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Wt?n.shape:new Wt,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(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=n.parameters,l=n.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 d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=Dn.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...n,type:"TriangleGeometry"}})}};function gI(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var yA=class{add(t,e,r){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],e&&this[i][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},vA=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},fe=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+fe.version}static addUnaryOp(t){return fe.max_unop_len=Math.max(t.length,fe.max_unop_len),fe.unary_ops[t]=1,fe}static addBinaryOp(t,e,r){return fe.max_binop_len=Math.max(t.length,fe.max_binop_len),fe.binary_ops[t]=e,r?fe.right_associative.add(t):fe.right_associative.delete(t),fe}static addIdentifierChar(t){return fe.additional_identifier_chars.add(t),fe}static addLiteral(t,e){return fe.literals[t]=e,fe}static removeUnaryOp(t){return delete fe.unary_ops[t],t.length===fe.max_unop_len&&(fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops)),fe}static removeAllUnaryOps(){return fe.unary_ops={},fe.max_unop_len=0,fe}static removeIdentifierChar(t){return fe.additional_identifier_chars.delete(t),fe}static removeBinaryOp(t){return delete fe.binary_ops[t],t.length===fe.max_binop_len&&(fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops)),fe.right_associative.delete(t),fe}static removeAllBinaryOps(){return fe.binary_ops={},fe.max_binop_len=0,fe}static removeLiteral(t){return delete fe.literals[t],fe}static removeAllLiterals(){return fe.literals={},fe}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new fe(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return fe.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!fe.binary_ops[String.fromCharCode(t)]||fe.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return fe.isIdentifierStart(t)||fe.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(fe.hooks[t]){let r={context:this,node:e};return fe.hooks.run(t,r),r.node}return e}searchHook(t){if(fe.hooks[t]){let e={context:this};return fe.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===fe.SPACE_CODE||t===fe.TAB_CODE||t===fe.LF_CODE||t===fe.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:fe.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,i;for(;this.index<this.expr.length;)if(r=this.code,r===fe.SEMCOL_CODE||r===fe.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())e.push(i);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,fe.max_binop_len),e=t.length;for(;e>0;){if(fe.binary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,i,s,o,a,l,c;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:fe.binaryPrecedence(e),right_a:fe.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),i=[o,s,a];e=this.gobbleBinaryOp();){if(r=fe.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:fe.right_associative.has(e)},c=e;let u=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;i.length>2&&u(i[i.length-2]);)a=i.pop(),e=i.pop().value,o=i.pop(),t={type:fe.BINARY_EXP,operator:e,left:o,right:a},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),i.push(s,t)}for(l=i.length-1,t=i[l];l>1;)t={type:fe.BINARY_EXP,operator:i[l-1].value,left:i[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,fe.isDecimalDigit(t)||t===fe.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===fe.SQUOTE_CODE||t===fe.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===fe.OBRACK_CODE)i=this.gobbleArray();else{for(e=this.expr.substr(this.index,fe.max_unop_len),r=e.length;r>0;){if(fe.unary_ops.hasOwnProperty(e)&&(!fe.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:fe.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}fe.isIdentifierStart(t)?(i=this.gobbleIdentifier(),fe.literals.hasOwnProperty(i.name)?i={type:fe.LITERAL,value:fe.literals[i.name],raw:i.name}:i.name===fe.this_str&&(i={type:fe.THIS_EXP})):t===fe.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===fe.PERIOD_CODE||e===fe.OBRACK_CODE||e===fe.OPAREN_CODE||e===fe.QUMARK_CODE;){let r;if(e===fe.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==fe.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===fe.OBRACK_CODE?(t={type:fe.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==fe.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===fe.OPAREN_CODE?t={type:fe.CALL_EXP,arguments:this.gobbleArguments(fe.CPAREN_CODE),callee:t}:(e===fe.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:fe.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===fe.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));fe.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,fe.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===fe.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===fe.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:fe.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),i=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){i=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:fe.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(fe.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,fe.isIdentifierPart(t));)this.index++;return{type:fe.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){r=!0,this.index++,t===fe.CPAREN_CODE&&i&&i>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===fe.COMMA_CODE){if(this.index++,i++,i!==e.length){if(t===fe.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===fe.CBRACK_CODE)for(let o=e.length;o<i;o++)e.push(null)}}else if(e.length!==i&&i!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===fe.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(fe.CPAREN_CODE);if(this.code===fe.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:fe.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:fe.ARRAY_EXP,elements:this.gobbleArguments(fe.CBRACK_CODE)}}},i7=new yA;Object.assign(fe,{hooks:i7,plugins:new vA(fe),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops);fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops);var Bc=n=>new fe(n).parse(),n7=Object.getOwnPropertyNames(fe);n7.forEach(n=>{Bc[n]===void 0&&n!=="prototype"&&(Bc[n]=fe[n])});Bc.Jsep=fe;var s7="ConditionalExpression",o7={name:"ternary",init(n){n.hooks.add("after-expression",function(e){if(e.node&&this.code===n.QUMARK_CODE){this.index++;let r=e.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===n.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:s7,test:r,consequent:i,alternate:s},r.operator&&n.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&n.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};Bc.plugins.register(o7);var a7=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],l7=["0","1","2","3","4","5","6","7","8","9","."],c7=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function u7(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}Bc.addBinaryOp("^",11,!0);function A0(n,t,e="number"){let r="";for(let o=0;o<n.length;o++){let a=n[o];if("id"in a){let l=n[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",n);return}let c=t.getVariable(a.id),u=Ni.getDisplayedValue(c);e==="number"&&Ni.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?u=parseFloat(u).toString():e==="boolean"&&Ni.isBoolean(c)?u=c?"true":"false":e==="boolean"&&Ni.isTextValue(c)&&!Array.isArray(c.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(r+=a.name),a.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!u7(a.name)&&!l7.includes(a.name)&&!a7.includes(a.name)&&!c7.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(n.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let i;try{i=Bc(r)}catch(o){console.error(r,o);return}let s;try{s=jt(i)}catch(o){console.error(r,i,o)}return s}function jt(n){switch(n.type){case"BinaryExpression":switch(n.operator){case"==":return Number(jt(n.left)===jt(n.right));case"!=":return Number(jt(n.left)!==jt(n.right));case">":return Number(jt(n.left)>jt(n.right));case">=":return Number(jt(n.left)>=jt(n.right));case"<":return Number(jt(n.left)<jt(n.right));case"<=":return Number(jt(n.left)<=jt(n.right));case"+":return jt(n.left)+jt(n.right);case"-":return jt(n.left)-jt(n.right);case"*":return jt(n.left)*jt(n.right);case"/":return jt(n.left)/jt(n.right);case"%":return jt(n.left)%jt(n.right);case"&&":return jt(n.left)&&jt(n.right);case"||":return jt(n.left)||jt(n.right);case"^":return Math.pow(jt(n.left),jt(n.right));default:throw new Error("Unknown operator: "+n.operator)}case"UnaryExpression":switch(n.operator){case"-":return-jt(n.argument);case"!":return Number(!jt(n.argument));default:throw new Error("Unknown operator: "+n.operator)}case"Identifier":throw new Error("Unknown identifier: "+n.name);case"Literal":return n.value;case"CallExpression":if(n.callee.type==="Identifier"){if(n.callee.name==="random"){let t=0,e=1;if(n.arguments.length>=1)try{t=jt(n.arguments[0])}catch(r){console.warn(r)}if(n.arguments.length>=2)try{e=jt(n.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[n.callee.name].apply(null,n.arguments.map(jt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+n.type)}}var h7=new ce,d7=new ce;function f7(n,t,e){let r=[new E,new E,new E],i=[new E,new E,new E];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((s,o)=>{let a=i[o],l=we.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ce().makeBasis(r[0],r[1],r[2])}var yI=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??xd.create({parameters:c1}).userData.shape;return{path:n.path??Fh.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:s,extrusion:{...Lv,...e.extrusion}}),shapeData:o}}static build(n){if(n.path.points.length>=2){let e=new xA(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new _e,{userData:{...n,type:"PathGeometry"}})}},xA=class extends _e{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!gI(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:i,offset:s}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((i+s)*o):Math.ceil(Math.min(1,i+s)*o),c=Math.min(Math.max(2,l-a+1),o+2),u=[],h=[];for(let W=0;W<c;W++){let q=this.inputs.path.isClosed?(W+a)%e.length:Math.min(W+a,e.length-1);u.push(e[q].clone()),h.push(r[q].clone())}let d=(W,q,K)=>{u[W]=u[W].clone().lerp(u[q],K),h[W]=f7(h[W],h[q],K)},f=0,p=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&g&&(m=g,d(u.length-1,u.length-2,1-m)),i===0){let W=u.length-1;u[W].copy(u[0]),h[W].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:A,vertices:M}=this._computeShapePoints(S),b=0,T;x==="round"&&(T=new Ol(this.inputs.shapeData,2*y,y,S,v,void 0,!0),b=T.getAttribute("position").count);let C=0,P=0;A.sort((W,q)=>W.start-q.start),A.forEach(W=>{W.verticesStart=C,W.verticesCount=W.continuous.reduce((q,K,G)=>q+(G===0||!K?2:1),0),P+=W.verticesCount,C=P});let D=P*c,_,O=0;if(this._isOpenEnded()&&x==="flat"){try{_=Hs({windingRule:zt.ODD,elementType:Ur.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{_=lA}O=_.vertexCount}let L=D+2*O+b*2,j=D+2*O,V={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},H=[];if(A.forEach(W=>{this._extrudeRegion(W,M,h,u,V,H,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,H,V,h[0],u[0],!1),this._closeEnd(_,D+O,H,V,h[h.length-1],u[u.length-1],!0)),T){V.positions.set(T.getAttribute("position").array,j*3),V.normals.set(T.getAttribute("normal").array,j*3),V.uvs.set(T.getAttribute("uv").array,j*2);for(let G=j;G<j+b;G++)V.uvs[G*2+1]=1e-4;let W=H.length;H.push(...T.getIndex().array.map(G=>G+j)),j+=b,V.positions.set(T.getAttribute("position").array,j*3),V.normals.set(T.getAttribute("normal").array,j*3),V.uvs.set(T.getAttribute("uv").array,j*2);let q=H.length;H.push(...T.getIndex().array.map(G=>G+j)),this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H);let K=h7;K.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(K,j,L),K.copy(h[0]).setPosition(u[0]).multiply(d7.makeScale(1,1,-1)),this.applyMatrix4OnRange(K,j-b,j),this.reverseIndicesOnRange(W,q)}else this.setAttribute("position",new Xe(V.positions,3)),this.setAttribute("normal",new Xe(V.normals,3)),this.setAttribute("uv",new Xe(V.uvs,2)),this.setIndex(H)}_extractPathPoints(){let r=c0(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let i=[r[0]];return r.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let r=[],i=e.length,s=this.inputs.path.isClosed,o=new E,a=new E,l=new E,c=new E,u=new E(0,1,0);for(let g=0;g<i;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let S=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),A=S.clone().add(w).normalize();l.copy(A),g===0&&(A.equals(u)||A.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(A).normalize(),b=A.clone().cross(M).normalize();u.copy(b),c.copy(M),g===0&&(o.copy(b),a.copy(A));let T=new ce().makeBasis(M,b,A);r.push(T)}let h=s?a:l,d=s?o:new E(0,1,0),f=h.clone().cross(c).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return r;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<r.length;g++){let y=new ce().makeRotationZ(p*g/r.length);r[g].multiply(y)}return r}_applyPathModifiers(e,r,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new ce,h=new ce;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-r)/(s-(i===0?0:1)-(r+(1-i)));u.makeRotationZ(we.lerp(o,o+a,p)*we.DEG2RAD);let m=we.lerp(l,c,p);h.makeScale(m,m,m),d.multiply(u).multiply(h)}),e}_computeShapePoints(e=12,r=zt.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],S=g[v-0];y.push(x,S)}return y}),a;try{a=Hs({windingRule:r,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=im}let l;try{l=Hs({windingRule:zt.ODD,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=aA}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<u&&(u=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=c,y=m*2,v=a.elements[y+0],x=a.elements[y+1],S=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let A=v,M=S-1,b=v+1,T=i.roundedCurves.length;do{let C=A-v,P=a.vertices[M*2+0],D=a.vertices[M*2+1],_=a.vertices[A*2+0],O=a.vertices[A*2+1],L=a.vertices[b*2+0],j=a.vertices[b*2+1],V=_-P,H=O-D,W=Math.sqrt(V*V+H*H);V/=W,H/=W;let q=_-L,K=O-j,G=Math.sqrt(q*q+K*K);q/=G,K/=G,w.normals[C*2+0]=-K,w.normals[C*2+1]=q;let Z=a.vertexIndices[A];if(Array.isArray(Z))w.continuous[C]=!1;else{let[te,$]=i.getCurveIndexFromVertexId(Z-1,!0);if($>0&&$<1)w.continuous[C]=!0;else{let Y=$===1?te+1:te-1;Y=(Y+T)%T;let oe=$===1?0:1,ie=i.roundedCurves[te].getTangent($),re=i.roundedCurves[Y].getTangent(oe);w.continuous[C]=ie.dot(re)>.95}}g&&(w.normals[C*2+0]*=-1,w.normals[C*2+1]*=-1),[M,A,b]=[A,b,b+1],b>=S&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,i,s,o){let a=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,i,s,o,a,l){let c=new E,u=new E,h=new E,d=new E,f=new U;i.forEach((m,g)=>{let y=s[g],v=e.verticesStart*i.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let S=(e.start+x)*2;if(c.set(r[S+0],r[S+1],0),h.copy(c).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x===0?(e.start+e.count-1)*2:S-2;u.set(r[w+0],r[w+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(i.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(i.length-1));else{let w=x===e.count-1?e.start*2:S+2;u.set(r[w+0],r[w+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=i.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*i.length+e.verticesCount*m,y=e.verticesStart*i.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let S=x===e.count-1?0:v+1,w=g+v,A=g+S,M=y+S,b=y+v;e.isHole?a.push(w,M,A,w,b,M):a.push(w,A,M,w,M,b),v++}}}_closeEnd(e,r,i,s,o,a,l){let c=e.vertexCount,u=new E(0,0,l?-1:1).applyMatrix4(o),h=new E,d=new U;for(let p=0;p<c;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+p,h,u,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+r,y=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;i.push(g,y,v)}}applyMatrix4OnRange(e,r,i){let s=e.elements,o=new vr().getNormalMatrix(e).elements,a,l,c,u,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=r*m,y=i*m;g<y;g+=m){if(g===r)debugger;a=f[g+0],l=f[g+1],c=f[g+2],u=1/(s[3]*a+s[7]*l+s[11]*c+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*c+s[12])*u,f[g+1]=(s[1]*a+s[5]*l+s[9]*c+s[13])*u,f[g+2]=(s[2]*a+s[6]*l+s[10]*c+s[14])*u,a=p[g+0],l=p[g+1],c=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*c,p[g+1]=o[1]*a+o[4]*l+o[7]*c,p[g+2]=o[2]*a+o[5]*l+o[8]*c}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let s=e;s<r;s+=3){let o=i.getX(s),a=i.getX(s+1),l=i.getX(s+2);i.setXYZ(s,l,a,o)}i.needsUpdate=!0}}};function vI(){let n=new _e;return n.setAttribute("position",new Xe(new Float32Array([]),3)),n.setIndex(new Xe(new Uint16Array([]),1)),n}var m7=vI().attributes,g7=12,y7=1,Ad=class extends _e{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,m7),this.userData={parameters:e,type:"TextGeometry"};let i=r.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:c,textTransform:u}=e,h=Ni.getDisplayedValue(c),d=u===2?h.toUpperCase():u===3?h.toLowerCase():h,f=v7(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof i=="number"?i:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new Wt().fromShape(A,!0));this.vectorShapes=x;let S=x.map(A=>Dn.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?zt.NONZERO:zt.ODD,subdivisions:this.isLowResolution&&o>0?y7:g7}})),w=S.length?Us(S):vI();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([A,M])=>{this.setAttribute(A,M)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=fn(new _e,Ad.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,i])=>{this.setAttribute(r,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function v7(n,t,e){let r=[""],i="";for(let s of e)i+=s,s===" "||s===`
`?(r[r.length-1]+=i,i="",s===`
`&&r.push("")):t.getTextWidth(r[r.length-1]+i,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+i,n)>n.width&&(i.length===1?(r[r.length-1]+=i,i=""):(r[r.length-1]+=i.slice(0,-1),i=i[i.length-1],r.push(""))));return r[r.length-1]+=i,r}var bI,M0=new Promise(n=>{bI=n}),xI=!1;var E0;function SI(){if(xI)return;if(E0)return E0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.7.6/build",i=import("./process.js"),[s,o]=await Promise.all([i,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});bI(l),xI=!0}return E0=n(),E0}var x7=["font"];function Ma(n,t,e,r){let i,s,o;n.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(n)),o=[[],["extrusion"]]):(s={...n},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(i in u){let h=u[i];e1(h)&&!x7.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),e1(u[i])&&(u[i]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=Wt.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry"){if(s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new Hu().parse(s),a.geometry.groups.length===0){let c=a.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(s.type==="SubdivGeometry"){let c=new ti(s,e);return c.data=n,c}else{if(s.type==="TextGeometry")return new Ad(s,t);if(s.type==="UIGeometry")return wd.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=bA(a)}catch(c){console.error(c)}if(!l){let c=Wt.createFromState(Nh.defaultData(),100,100);a.shape=c,l=bA(a)}return l}var b7=new ce;function am(n,t,e,r){let i=n.position.array,s=n.normal.array,o=b7.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=i.length;u<h;u+=3)i[u]*=t,i[u+1]*=e,i[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var T0=new Gt,Ed=new E,lt;M0.then(n=>{lt=n});var wI=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),AI=new Uint32Array([0,1,2,3]),EI=new Uint8Array([4]),ti=class extends _e{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked,s=So.div(r,i);this.subdividedGeometry&&am(this.subdividedGeometry.attributes,...s),this.originalGeometry&&am(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Ed.fromArray(s));let a=Ed.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=ti.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new hi(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ti.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Dr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;T0.setFromBufferAttribute(r),T0.getCenter(i),e.boundingSphere.radius=i.distanceTo(T0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),T0.getSize(Ed);let s={width:Ed.x,height:Ed.y,depth:Ed.z};return this.userData.parameters=s,s}static build(e,r,i,s){let o,a,l,c=e?.phongAngle??35;i===!1&&(c=-1),r&&(lt.free_bvh(r),lt.free_subdivision_surface(r));try{o=ti.allocate(e,s)}catch(u){console.error(u,e),o=ti.allocate({positionWASM:wI,indexWASM:AI,verticesPerFaceWASM:EI},s)}if(lt.set_destination_refinement_level(o,0),a=ti.buildLevel(o,!0,c),e.subdivisions>0)try{lt.set_destination_refinement_level(o,e.subdivisions),l=ti.buildLevel(o,!1,c)}catch{try{lt.set_destination_refinement_level(o,e.subdivisions-1),l=ti.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?r.geometry:Ma(e,i,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=Nc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=EA(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=wI,s=AI,o=EI);let c=i.length,u=s.length,h=o.length,d=i.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=lt._malloc(p),v=new Float32Array(lt.HEAPF32.buffer,y,d),x=new Uint32Array(lt.HEAPU32.buffer,y+m,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let S;e?.scaleBaked?.some(A=>A!==1)&&(S=new ce().makeScale(...e.scaleBaked)),r&&(S?S.premultiply(r):S=r);let w=S?lt.alloc_subdivision_surface2(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,S.elements):lt.alloc_subdivision_surface(y,c,y+m,u,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return lt._free(y),w}static buildLevel(e,r,i,s,o){let a=o?lt.get_mesh_data2(e,r?lt.Level.CONTROL:lt.Level.REFINED,i,o.elements):lt.get_mesh_data(e,r?lt.Level.CONTROL:lt.Level.REFINED,i),l=8,c=lt.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=lt.HEAPU32[c[h]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=lt.HEAPU32[c[h]>>2],m=lt.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let g=lt.HEAPU32[c[h]>>2],y=lt.HEAPU32.subarray(g>>2,(g>>2)+u[h]);h++;let v=lt.HEAPU32[c[h]>>2],x=lt.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let S=new _e;if(S.setIndex(new uo(x,1)),S.setAttribute("position",new Te(f,3)),S.setAttribute("normal",new Te(m,3)),r){S.setAttribute("faceMap",new uo(y,1));let w=new Float32Array(m.length/3*4).fill(0);S.setAttribute("color",new Xe(w,4))}return lt.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,lt.free_mesh_data(a)}static freeSubdivPointer(e){lt.free_bvh(e),lt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let s=lt.get_wireframe_data_for_base_level(e),o=4,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=lt.HEAPU32[a[c]>>2],h=lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=lt.HEAPU32[a[c]>>2],f=lt.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new _e;p.setAttribute("position",new Te(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=i.r,m[g++]=i.g,m[g++]=i.b;return p.setAttribute("color",new Xe(m,3)),p.setIndex(new uo(f,1)),lt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,lt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,i){let s=r===0;s||lt.set_destination_refinement_level(e,r);let o=i?lt.get_topological_data2(e,s?lt.Level.CONTROL:lt.Level.REFINED,i.elements):lt.get_topological_data(e,s?lt.Level.CONTROL:lt.Level.REFINED),a=6,l=lt.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=lt.HEAPU32[l[u]>>2],d=new Float32Array(lt.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=lt.HEAPU32[l[u]>>2],p=new Uint32Array(lt.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=lt.HEAPU32[l[u]>>2],g=new Uint8Array(lt.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return lt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var MI=["getX","getY","getZ"];function Nc(n,t){let e={},r=t?t.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,h="";for(let d=0;d<3;d++)h+=`${~~(n[MI[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(n[MI[d]](u));e[h]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var C0=new E,SA=new E,wA=new E,AA=new E;function EA(n,t,e,r){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);n.length=0;let h=0;if(u<0)for(let d=0;d<l.length;d+=2)n.push(l[d],l[d+1],0),i.push(h++);else for(let d=l.length-2;d>=0;d-=2)n.push(l[d],l[d+1],0),i.push(h++);return s.push(h),{indices:i,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[a]*3+2]===o||n[t[a]*3+2]===0)&&l++,(n[t[a+1]*3+2]===o||n[t[a+1]*3+2]===0)&&l++,(n[t[a+2]*3+2]===o||n[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){C0.set(n[t[a]*3],n[t[a]*3+1],n[t[a]*3+2]),SA.set(n[t[a+1]*3],n[t[a+1]*3+1],n[t[a+1]*3+2]),wA.set(n[t[a+4]*3],n[t[a+4]*3+1],n[t[a+4]*3+2]),AA.set(n[t[a+5]*3],n[t[a+5]*3+1],n[t[a+5]*3+2]),SA.sub(C0).normalize(),wA.sub(C0).normalize(),AA.sub(C0).normalize();let l=SA.cross(wA).dot(AA);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(i.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else i.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let h=0,d=0;h<n.length;h+=3,d++)n[h+2]===0&&(l.push(d),u++),n[h+2]===o&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=c[0];c[0]=c[1],c[1]=h}l.reverse(),i.push(...l,...c),s.push(u,u)}return{indices:i,verticesPerFace:s}}var ms={};jM(ms,{calcBoolean:()=>A7,calcBooleanTopological:()=>w7,freeMeshSet:()=>C7,getMeshSet:()=>E7,hasOpenEdges:()=>M7,transformMeshSet:()=>T7});var TI,CI=new Promise(n=>{TI=n});var P0;function PI(){if(P0)return P0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.7.6/build",i=import("./boolean.js"),[s,o]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});TI(l)}return P0=n(),P0}var Mt,Md;CI.then(n=>Mt=n);function S7(n,t,e){let r,i;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?i=n.getClosedTorusIndicesForBooleanOrSubdiv():i=n.getIndex();let{positions:s,triIndices:o}=Nc(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=EA(s,o,n);a=c.length,r=[];for(let u=0,h=0;u<a;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let c=0,u=0;u<r.length;)r[u++]=3,a++,r[u++]=o[c++],r[u++]=o[c++],r[u++]=o[c++]}return{positions:s,faceIndices:r,nFaces:a}}function _I(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(n[0])?e:r,s=Mt._malloc(i);return(Number.isInteger(n[0])?new Uint32Array(Mt.HEAPU32.buffer,s,t):new Float32Array(Mt.HEAPF32.buffer,s,t)).set(n,0),s}function DI(n){switch(n){case 0:return Mt.OP.UNION;case 1:return Mt.OP.INTERSECTION;case 2:return Mt.OP.A_MINUS_B;case 3:return Mt.OP.B_MINUS_A;case 4:return Mt.OP.SYMMETRIC_DIFFERENCE;case 5:return Mt.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function w7(n,t){Md===void 0&&(Md=Mt.init_csg());let e=_I(n),r=Mt.csg_calc_topological(Md,e,n.length,DI(t));Mt._free(e);let i=6,s=Mt.HEAPU32.subarray(r>>2,(r>>2)+i),o=s.subarray(3,3+3),a=0,l=Mt.HEAPU32[s[a]>>2],c=new Float32Array(Mt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Mt.HEAPU32[s[a]>>2],h=new Uint32Array(Mt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Mt.HEAPU32[s[a]>>2],f=new Uint8Array(Mt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Mt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function A7(n,t,e,r){Md===void 0&&(Md=Mt.init_csg());let i=_I(n),s=Mt.csg_calc(Md,i,n.length,r,DI(t));Mt._free(i);let o=5,a=Mt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Mt.HEAPU32[a[c]>>2],h=Mt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Mt.HEAPU32[a[c]>>2],f=Mt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Te(h,3)),e.setAttribute("normal",new Te(f,3));let m=Mt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Dr),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Mt.free_mesh_data(s),p}function E7(n,t,e){if(Mt===void 0)return-1;let r,i,s;if(t&&n.userData.positions!==void 0){let y=n.userData;s=y.verticesPerFace.length,r=y.positions,i=Array(y.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,S=0;v<y.verticesPerFace.length;v++){i[S++]=y.verticesPerFace[v];for(let w=0;w<y.verticesPerFace[v];w++)i[S++]=y.indices[x++]}}else({positions:r,faceIndices:i,nFaces:s}=S7(n,t,e));let o=r.length,a=i.length,l=r.length,c=i.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Mt._malloc(u),p=new Float32Array(Mt.HEAPF32.buffer,f,l),m=new Uint32Array(Mt.HEAPU32.buffer,f+h,c);p.set(r,0),m.set(i,0);let g=Mt.get_csg_mesh(f,o,f+h,a,s);return Mt._free(f),g}function M7(n){return Mt.has_open_edges(n)}function T7(n,t){Mt.transform_csg_mesh(n,t.elements)}function C7(n){Mt.free_csg_mesh(n)}var P7={ConeGeometry:EO,CubeGeometry:MO,CylinderGeometry:u0,DodecahedronGeometry:TO,EllipseGeometry:xd,HelixGeometry:tI,IcosahedronGeometry:rI,LatheGeometry:iI,NonParametricGeometry:aI,PolygonGeometry:S0,PyramidGeometry:lI,RectangleGeometry:wd,SphereGeometry:cI,PlaneGeometry:uI,BackdropGeometry:hI,StarGeometry:w0,TextFrameGeometry:dI,TorusGeometry:fI,TorusKnotGeometry:pI,TriangleGeometry:mI,PathGeometry:yI,VectorGeometry:Dn},bA=n=>P7[n.type].create(n);function Td(n){return n!==null&&"booleanOp"in n}var Cd=class extends hd(Xt){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ce}updateVisible(e){super.updateVisible(e),this.visible=!Td(this.parent)&&this.visible,Td(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ms.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Td(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Cd&&(e.freeBooleanPointer(),Td(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&Td(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Td(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var _0=new Gt;function lm(n,t=0,e=n.count,r,i){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;h<e;h++){let d=n.getX(h),f=n.getY(h),p=n.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>c&&(c=f),p>u&&(u=p)}_0.min.set(s,o,a),_0.max.set(l,c,u),_0.getCenter(r),_0.getSize(i).multiplyScalar(.5)}var _7=new _e,D7=new Hn,dr=class extends Cd{constructor(t,e){super(_7,D7),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?lm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Ta=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(Ta.uuidContext===null)throw new Error("plz startContext");Ta.uuidContext===Ta.globalContext?this.uuid="_gid"+Ta.uuidContext.nodeContextUuid++:this.uuid="_uid"+Ta.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===Ta.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}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 i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e??this.getType(t,e);let i=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,i,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,i,s,o){return""}generate(t,e,r,i,s){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},nr=Ta;nr.globalContext={nodeContextUuid:0},nr.uuidContext=Ta.globalContext;var cm=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 MA=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}},Ci=new MA;var et=class extends nr{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,i,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=we.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),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,i)):super.build(e,r,i);if(o)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,s);let u=this.generate(e,l,i);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,i)}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 i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var sr=class extends et{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,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var kr=class extends sr{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof U?e:new U(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,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Wi=class extends sr{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof E?e:new E(e,r,i)}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,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var mr=class extends We{constructor(e,r,i,s){super(e,r,i);this.isColorA=!0;this.a=s}setRGBA(e,r,i,s){super.setRGB(e,r,i),this.a=s}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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var On=class extends sr{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof mr?e:new mr(e.r,e.g,e.b,e.a)}generateReadonly(e,r,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var O7=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,OI=/[a-z_0-9]+/gi,Ee=class extends et{constructor(e,r,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,i,s)}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,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let u=[];for(;a=OI.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&Ci.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=Ci.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||Ci.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Ci.contains(m)&&e.include(Ci.get(m))}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,i,s){if(this.src=e||"",this.includes=r??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=O7.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(OI);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 h=a[l++];this.inputs.push({name:h,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var I7=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,TA=class extends et{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||TA.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,s,o){this.src=e||"";let a,l,c="",u=I7.exec(e);this.useDefine=o??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,i,s,o){return e.format(this.name,this.getType(e),r)}},Ht=TA;Ht.PI="PI",Ht.PI2="PI2",Ht.RECIPROCAL_PI="RECIPROCAL_PI",Ht.RECIPROCAL_PI2="RECIPROCAL_PI2",Ht.LOG2="LOG2",Ht.EPSILON="EPSILON";var R7=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
)*?)}`,"gim"),L7=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Pd=class extends et{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,i,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=R7.exec(e);if(r){let i=r[2],s;for(;s=L7.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var _d=class extends et{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),r)}};Ci.addKeyword("uv",function(){return new _d});Ci.addKeyword("uv2",function(){return new _d(1)});var Fc=class extends et{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Fc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case un:return["Linear"];case at:return["sRGB"];default:return[]}}generate(e,r){let i=this.input.build(e,"v4"),s=this.getType(e),o=Fc.Nodes[this.method],a=e.include(o);if(a===Fc.LINEAR_TO_LINEAR)return e.format(i,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,r)}else return e.format(a+"( "+i+" )",s,r)}fromEncoding(e){let r=Fc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Fc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},gn=Fc;gn.Nodes={LinearToLinear:new Ee(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
`)),sRGBToLinear:new Ee(["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(`
`)),LinearTosRGB:new Ee(["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(`
`))},gn.LINEAR_TO_LINEAR="LinearToLinear",gn.SRGB_TO_LINEAR="sRGBToLinear",gn.LINEAR_TO_SRGB="LinearTosRGB";var qt=class extends Ee{constructor(e="",r,i,s,o){super(e,o,s,i,r);this.nodeType="Expression"}};var yn=class extends sr{constructor(e=new Jt,r,i,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new _d,this.bias=i,this.project=s!==void 0?s:!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 i=this.getTexture(e,r),s=this.uv.build(e,this.project?"v4":"v2"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=o?"tex2DBias":"tex2D",o?l=a+"( "+i+", "+s+", "+o+" )":l=a+"( "+i+", "+s+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new gn(new qt("",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 Fe=class extends sr{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,i,s,o,a){return e.format(this.value+(this.value%1?"":".0"),s,r)}};var um=class extends et{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,i,s,o){s=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 h=a.inputs[u],d=this.inputs[u]||this.inputs[h.name];c.push(d.build(e,e.getTypeByFormat(h.type)))}l+=c.join(", ")+" )"}return e.format(l,s,r)}};var CA=class extends et{constructor(e,r,i=CA.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=i}getType(e){let r=this.a.getType(e),i=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(i)>e.getTypeLength(r)?i:r}generate(e,r){let i=this.getType(e);this.type=i;let s=this.a.build(e,i),o=this.b.build(e,i);return e.format("( "+s+" "+this.op+" "+o+" )",i,r)}},Fi=CA;Fi.ADD="+",Fi.SUB="-",Fi.MUL="*",Fi.DIV="/";var or=class extends et{constructor(e,r=or.ABS,i,s){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:s=r,typeof i!="string"?this.c=i:s=i,this.method=s,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case or.MIX:case or.CLAMP:case or.REFRACT:case or.SMOOTHSTEP:case or.FACEFORWARD:return 3;case or.MIN:case or.MAX:case or.MOD:case or.STEP:case or.REFLECT:case or.DISTANCE:case or.DOT:case or.CROSS:case or.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0;return r>i&&r>s?this.a.getType(e):i>s?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case or.LENGTH:case or.DISTANCE:case or.DOT:return"f";case or.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let i,s,o,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),h=this.getType(e);switch(this.type=h,this.method){case or.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,r);case or.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,r);case or.CROSS:i=this.a.build(e,"v3"),s=this.b.build(e,"v3");break;case or.STEP:i=this.a.build(e,a===1?"f":u),s=this.b.build(e,u);break;case or.MIN:case or.MAX:case or.MOD:i=this.a.build(e,u),s=this.b.build(e,l===1?"f":u);break;case or.REFRACT:i=this.a.build(e,u),s=this.b.build(e,u),o=this.c.build(e,"f");break;case or.MIX:i=this.a.build(e,u),s=this.b.build(e,u),o=this.c.build(e,c===1?"f":u);break;default:i=this.a.build(e,u),this.b&&(s=this.b.build(e,u)),this.c&&(o=this.c.build(e,u));break}let d=[];d.push(i),s&&d.push(s),o&&d.push(o);let f=this.getNumInputs(e);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",h,r)}},ft=or;ft.RAD="radians",ft.DEG="degrees",ft.EXP="exp",ft.EXP2="exp2",ft.LOG="log",ft.LOG2="log2",ft.SQRT="sqrt",ft.INV_SQRT="inversesqrt",ft.FLOOR="floor",ft.CEIL="ceil",ft.NORMALIZE="normalize",ft.FRACT="fract",ft.SATURATE="saturate",ft.SIN="sin",ft.COS="cos",ft.TAN="tan",ft.ASIN="asin",ft.ACOS="acos",ft.ARCTAN="atan",ft.ABS="abs",ft.SIGN="sign",ft.LENGTH="length",ft.NEGATE="negate",ft.INVERT="invert",ft.MIN="min",ft.MAX="max",ft.MOD="mod",ft.STEP="step",ft.REFLECT="reflect",ft.DISTANCE="distance",ft.DOT="dot",ft.CROSS="cross",ft.POW="pow",ft.MIX="mix",ft.CLAMP="clamp",ft.REFRACT="refract",ft.SMOOTHSTEP="smoothstep",ft.FACEFORWARD="faceforward";var Dd=class extends et{constructor(e,r,i){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=i}bilinearCubeUV(e,r,i,s){let o=new um(Dd.Nodes.bilinearCubeUV,[r,i,s]);this.colorSpaceTL=this.colorSpaceTL??new gn(new qt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(o.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new gn(new qt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(o.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new gn(new qt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(o.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new gn(new qt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(o.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new qt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new qt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new qt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new qt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new qt("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=o,l}generate(e,r){if(e.isShader("fragment")){let i=this.uv,s=this.bias||e.context.roughness,o=new um(Dd.Nodes.roughnessToMip,[s]),a=new ft(o,Dd.Nodes.m0,Dd.Nodes.cubeUV_maxMipLevel,ft.CLAMP),l=new ft(a,ft.FLOOR),c=new ft(a,ft.FRACT),u=this.bilinearCubeUV(e,this.value,i,l),h=this.bilinearCubeUV(e,this.value,i,new Fi(l,new Fe(1).setReadonly(!0),Fi.ADD)),d=new ft(u,h,c,ft.MIX);return e.format(d.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)}},Od=Dd;Od.Nodes=function(){let e=new Pd(`struct TextureCubeUVData {
vec4 tl;
vec4 tr;
vec4 br;
vec4 bl;
vec2 f;
}`),r=new Ht("float cubeUV_maxMipLevel 8.0",!0),i=new Ht("float cubeUV_minMipLevel 4.0",!0),s=new Ht("float cubeUV_maxTileSize 256.0",!0),o=new Ht("float cubeUV_minTileSize 16.0",!0),a=new Ee(`float getFace(vec3 direction) {
vec3 absDirection = abs(direction);
float face = -1.0;
if (absDirection.x > absDirection.z) {
if (absDirection.x > absDirection.y)
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if (absDirection.z > absDirection.y)
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}`);a.useKeywords=!1;let l=new Ee(`vec2 getUV(vec3 direction, float face) {
vec2 uv;
if (face == 0.0) {
uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
} else if (face == 1.0) {
uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
} else if (face == 2.0) {
uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
} else if (face == 3.0) {
uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
} else if (face == 4.0) {
uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
} else {
uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
}
return 0.5 * (uv + 1.0);
}`);l.useKeywords=!1;let c=new Ee(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
float face = getFace(direction);
float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
mipInt = max(mipInt, cubeUV_minMipLevel);
float faceSize = exp2(mipInt);
float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
vec2 uv = getUV(direction, face) * (faceSize - 1.0);
vec2 f = fract(uv);
uv += 0.5 - f;
if (face > 2.0) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
if(mipInt < cubeUV_maxMipLevel){
uv.y += 2.0 * cubeUV_maxTileSize;
}
uv.y += filterInt * 2.0 * cubeUV_minTileSize;
uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
uv *= texelSize;
vec4 tl = texture2D(envMap, uv);
uv.x += texelSize;
vec4 tr = texture2D(envMap, uv);
uv.y += texelSize;
vec4 br = texture2D(envMap, uv);
uv.x -= texelSize;
vec4 bl = texture2D(envMap, uv);
return TextureCubeUVData( tl, tr, br, bl, f );
}`,[e,a,l,r,i,s,o]);c.useKeywords=!1;let u=new Ht("float r0 1.0",!0),h=new Ht("float v0 0.339",!0),d=new Ht("float m0 -2.0",!0),f=new Ht("float r1 0.8",!0),p=new Ht("float v1 0.276",!0),m=new Ht("float m1 -1.0",!0),g=new Ht("float r4 0.4",!0),y=new Ht("float v4 0.046",!0),v=new Ht("float m4 2.0",!0),x=new Ht("float r5 0.305",!0),S=new Ht("float v5 0.016",!0),w=new Ht("float m5 3.0",!0),A=new Ht("float r6 0.21",!0),M=new Ht("float v6 0.0038",!0),b=new Ht("float m6 4.0",!0),T=[u,h,d,f,p,m,g,y,v,x,S,w,A,M,b],C=new Ee(`float roughnessToMip(float roughness) {
float mip = 0.0;
if (roughness >= r1) {
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
} else if (roughness >= r4) {
mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
} else if (roughness >= r5) {
mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
} else if (roughness >= r6) {
mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
} else {
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
}
return mip;
}`,T);return{bilinearCubeUV:c,roughnessToMip:C,m0:d,cubeUV_maxMipLevel:r}}();var Vc=class extends et{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Vc.VIEW}getShared(){return this.scope===Vc.WORLD}build(e,r,i,s){let o=e.context[this.scope+"Normal"];return o?o.build(e,r,i,s):super.build(e,r,i)}generate(e,r,i,s,o){let a;switch(this.scope){case Vc.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case Vc.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case Vc.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}},Vi=Vc;Vi.LOCAL="local",Vi.WORLD="world",Vi.VIEW="view",Vi.NORMAL="normal";Ci.addKeyword("viewNormal",function(){return new Vi(Vi.VIEW)});Ci.addKeyword("localNormal",function(){return new Vi(Vi.NORMAL)});Ci.addKeyword("worldNormal",function(){return new Vi(Vi.WORLD)});var Do=class extends et{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Do.LOCAL}getType(){switch(this.scope){case Do.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Do.LOCAL:case Do.WORLD:return!1}return!0}generate(e,r,i,s,o){let a;switch(this.scope){case Do.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Do.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Do.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Do.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}},In=Do;In.LOCAL="local",In.WORLD="world",In.VIEW="view",In.PROJECTION="projection";Ci.addKeyword("position",function(){return new In});Ci.addKeyword("worldPosition",function(){return new In(In.WORLD)});Ci.addKeyword("viewPosition",function(){return new In(In.VIEW)});var Ws=class extends et{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Ws.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Ws.SPHERE:return"v2"}return this.type}generate(e,r){let i=this.getUnique(e);if(e.isShader("fragment")){let s;switch(this.scope){case Ws.VECTOR:{let o=new Vi(Vi.VIEW),a=e.context.roughness,l=o.build(e,"v3"),c=new In(In.VIEW).build(e,"v3"),u=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${c} ), ${l} )`;u&&(h=`normalize( mix( ${h}, ${l}, ${u} * ${u} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${d};`),s="reflectVec"):s=d;break}case Ws.CUBE:{let o=new Ws(Ws.VECTOR).build(e,"v3"),a="vec3( -"+o+".x, "+o+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),s="reflectCubeVec"):s=a;break}case Ws.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new Ws(Ws.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),s="reflectSphereVec"):s=a;break}}return e.format(s,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},Oo=Ws;Oo.CUBE="cube",Oo.SPHERE="sphere",Oo.VECTOR="vector";var D0=class extends et{constructor(e=new yn,r,i){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Od(this.value,r??new Oo(Oo.VECTOR),i),this.irradianceNode=new Od(this.value,new Vi(Vi.WORLD),new Fe(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))}};var O0=class extends sr{constructor(e=new _u,r,i){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new Oo,this.bias=i}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let i=this.getTexture(e,r),s=this.uv?.build(e,"v3"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a;o?a="texCubeBias( "+i+", "+s+", "+o+" )":a="texCube( "+i+", "+s+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new gn(new qt("",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 II=`
uniform int frameIndex;
uniform vec2 resolution;
uniform mat4 previousModelViewMatrix;
uniform mat4 previousProjectionMatrix;
varying vec4 vCurrentPosition;
varying vec4 vPreviousPosition;
`,RI=`
layout(location = 1) out vec4 gVelocity;
uniform int frameIndex;
uniform vec2 resolution;
varying vec4 vCurrentPosition;
varying vec4 vPreviousPosition;
const vec2 haltonSequence[16] = vec2[16](
vec2( 0.000000,-0.333334),
vec2(-0.500000, 0.333334),
vec2( 0.500000,-0.777778),
vec2(-0.750000,-0.111112),
vec2( 0.250000, 0.555556),
vec2(-0.250000,-0.555556),
vec2( 0.750000, 0.111112),
vec2(-0.875000, 0.777778),
vec2(0.125000, -0.925926),
vec2(-0.375000, -0.259260),
vec2(0.625000, 0.407408),
vec2(-0.625000, -0.703704),
vec2(0.375000, -0.037038),
vec2(-0.125000, 0.629630),
vec2(0.875000, -0.481482),
vec2(-0.937500, 0.185186));
vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {
const float goldenAngle = 2.399963f; // radians
float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));
float theta = float(sampleIndex) * goldenAngle + angle;
float sine = sin(theta);
float cosine = cos(theta);
return vec2(cosine, sine) * r;
}
// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
float getNoiseInterleavedGradient(vec2 screenPos) {
vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
return fract(magic.z * fract(dot(screenPos, magic.xy)));
}
`,LI=`
// TODO: This could be generated CPU side and passed to the shader every frame
const vec2 haltonSequence[16] = vec2[16](
vec2( 0.000000,-0.333334),
vec2(-0.500000, 0.333334),
vec2( 0.500000,-0.777778),
vec2(-0.750000,-0.111112),
vec2( 0.250000, 0.555556),
vec2(-0.250000,-0.555556),
vec2( 0.750000, 0.111112),
vec2(-0.875000, 0.777778),
vec2(0.125000, -0.925926),
vec2(-0.375000, -0.259260),
vec2(0.625000, 0.407408),
vec2(-0.625000, -0.703704),
vec2(0.375000, -0.037038),
vec2(-0.125000, 0.629630),
vec2(0.875000, -0.481482),
vec2(-0.937500, 0.185186));
// TODO: Pass correct view size
vec2 offset = haltonSequence[frameIndex];
offset.x /= resolution.x;
offset.y /= resolution.y;
vec4 currentPosition = gl_Position;
vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);
// We want to calculate the velocity with unjittered positions
// so that things that are not moving get a velocity = 0
vCurrentPosition = currentPosition;
vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);
#ifdef OUTLINE_COMPENSATION
vPreviousPosition.xy += OUTLINE_COMPENSATION;
#endif
gl_Position = currentPositionJittered;
`,BI=`
vec2 oldPos = vPreviousPosition.xy;
oldPos /= vPreviousPosition.w;
oldPos.xy = (oldPos.xy+1.)/2.0;
vec2 newPos = vCurrentPosition.xy;
newPos /= vCurrentPosition.w;
newPos.xy = (newPos.xy+1.)/2.0;
vec2 velocity = (newPos - oldPos);
// Discard fully transparent pixels
if (gl_FragColor.a <= 0.0) discard;
gVelocity = vec4(velocity, 0.0, 1.0);
`,NI=`
layout(location = 1) out vec4 gVelocity;
`,FI=`
// Discard fully transparent pixels
if (gl_FragColor.a <= 0.0) discard;
gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
`;var VI=["x","y","z","w"],B7=["float","vec2","vec3","vec4"],N7={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},F7={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[]"},Id=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,i){let s=this.getIncludes(r,i);if(!s)return"";let o="";s=s.sort(t);for(let a=0;a<s.length;a++)s[a].src&&(o+=s[a].src+`
`);return o}}();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",`
// NOTE: Include Spline's blending modes. This could be part of BlendNode
#define SPE_BLENDING_NORMAL 0
#define SPE_BLENDING_MULTIPLY 1
#define SPE_BLENDING_SCREEN 2
#define SPE_BLENDING_OVERLAY 3
vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
return mix( a, b, alpha );
}
vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
return mix( a, a * b, alpha );
}
vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
return mix( a, tmp, alpha );
}
vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
}
vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
return vec3( 1.0 );
}
`,"#include <packing>","#include <common>"].join(`
`),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
accumAlpha += (1.0 - accumAlpha) * alpha;
}`,""].join(`
`)},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.addVertexParsCode(II),this.addFragmentParsCode(RI),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let i=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+i+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+i+";"),this.addVertexFinalCode("vUv"+i+" = uv"+i+";")}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.needsJitter&&(this.addVertexFinalCode(LI),this.addFragmentFinalCode(BI)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return 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+`
`}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
`}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+`
`}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
`}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,i="varying",s="V",o=""){let a=this.getVars(i),l=a[t];if(!l){let c=a.length;l={name:r||"node"+s+c+(o?"_"+o:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,i){return this.getVar(t,e,r,this.shader,"T",i)}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(`
`)}getVarListCode(t,e){e=e??"";let r="";for(let i=0,s=t.length;i<s;++i){let o=t[i],a=o.type,l=o.name,c=o.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}];
`:r+=e+" "+u+" "+l+`;
`}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof nr?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,i,s,o){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new cm({type:e,size:r.size,name:i||"nodeUA"+l+(o?"_"+o:""),node:r,needsUpdate:s});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 cm({type:e,name:i||"nodeU"+l+(o?"_"+o:""),node:r,needsUpdate:s});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,i,s){return this.createUniform("vertex",t,e,r,i,s)}createFragmentUniform(t,e,r,i,s){return this.createUniform("fragment",t,e,r,i,s)}include(t,e,r){let i;if(t=typeof t=="string"?Ci.get(t):t,this.context.include===!1)return t.name;t instanceof Ee?i=this.includes.functions:t instanceof Ht?i=this.includes.consts:t instanceof Pd&&(i=this.includes.structs);let s=i[this.shader]=i[this.shader]||[];if(t){let o=s[t.name];if(o||(o=s[t.name]={node:t,deps:[]},s.push(o),o.src=t.build(this,"source")),t instanceof Ee&&e&&s[e.name]&&s[e.name].deps.indexOf(t)===-1&&(s[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&&(o.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 B7[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 Ya:case Xa:return new O0(r);case Yu:return new D0(new yn(r));default:return new yn(r)}else{if(r.isVector2)return new kr(r);if(r.isVector3)return new Wi(r);if(r.isVector4)return new On(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 N7[t]||t}getFormatByType(t){return F7[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return VI[t]}getIndexByElement(t){return VI.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=un,e===un&&this.context.gamma&&(e=at),e}};var $t=class extends sr{constructor(e=0,r,i,s){super("c");this.nodeType="Color";this.value=e instanceof mr?e:new mr(e||0,r,i,s)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i),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,i,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}generateReadonly(e,r,i,s,o,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",s,r)}};var Ot=class extends sr{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,i,s,o,a){return e.format(this.value.toString(),s,r)}};var Yr=class extends sr{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,i,s){return e.format(this.value?"true":"false",s,r)}};var qs=class extends sr{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 Rl=class extends sr{};var I0=class extends Rl{constructor(e){super("v3");this.image=e;this._value=new E}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var zc=class extends Rl{constructor(e,r,i=1008,s=1006){super("t");this.image=e;this.wrap=r;this.minFilter=i;this.magFilter=s}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}};var Rd=class extends sr{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new vr}generateReadonly(e,r,i,s,o,a){return e.format("mat3("+this.value.elements.join(", ")+")",s,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var qi=class extends sr{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new ce}generateReadonly(e,r,i,s,o,a){return e.format("mat4("+this.value.elements.join(", ")+")",s,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function zI(n,t,e,r=0){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0).premultiply(new vr().makeRotation(r*we.DEG2RAD))}var R0=class extends Rd{constructor(e,r,i=0){super(new vr);this.repeat=e;this.offset=r;this.rotation=i;zI(this.value,e,r,i)}updateMatrix(){zI(this.value,this.repeat,this.offset,this.rotation)}};var Ys=class extends sr{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Ke?new Array(e).fill(r):new Array(e).fill(new Ke(0))}};var Ld=class extends et{constructor(e,r,i,s){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=i,this.mode=s}generate(e,r){if(e.isShader("fragment")){let i=[];return i.push(this.a.build(e,"c")),i.push(this.b.build(e,"c")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),e.format("spe_blend("+i.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 PA=class extends et{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let i=e.include(PA.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.color.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Uc=PA;Uc.Nodes=function(){return{customColor:new Ee(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
float lalpha = alpha * mask;
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
accumAlpha += (1.0 - accumAlpha) * lalpha;
return color;
}`)}}();var _A=class extends et{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let i=e.include(_A.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.cnormal.build(e,"v3")),s.push("normal"),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.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)}},Bd=_A;Bd.Nodes=function(){return{customNormal:new Ee(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
vec3 normal = packNormalToRGB( norm ).rgb;
normal *= step( vec3(0.5), cnormal );
float lalpha = alpha * mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
return normal;
}`)}}();var Nd=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=i,this.projection=s,this.axis=o,this.side=a,this.size=l,this.blending=c,this.mat=u,this.isMask=f,this.alpha=h,this.mode=d,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 i=`g${this.uuid.toString().replace(/-/g,"")}`,s;switch(this.projection.value){case 3:s=e.include(Nd.Nodes.cylindrical);break;case 2:s=e.include(Nd.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=["zy","xz","xy"][this.axis.value],c=new Ee(`
vec3 ${i}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
vec2 projected = (1. + (position.${l})) / 2.;
vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
writeUv = uvs;
vec4 tmp = texture2D( tex, uvs );
vec3 col = tmp.rgb;
float lalpha = alpha * tmp.a;
${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, ${a}));`}
if ( crop > 0.5 ) {
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
lalpha = 0.0;
}
}
lalpha *= mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return col;
}`);s=e.include(c);break;case 4:s=e.include(Nd.Nodes.triplanar);break;default:s=e.include(Nd.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let o=[];if(o.push("normal"),o.push(this.texture.generate(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.blending.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.projection.value===4){let a=`${i}_writeUvs`,l=a+"0",c=a+"1",u=a+"2",h=`${i}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(h,"vec3"),o.push(l),o.push(c),o.push(u),o.push(h)}else{let a=`${i}_writeUvs`;e.addFragmentVariable(a,"vec2"),o.push(a)}return e.format(s+"("+o.join(",")+")",this.getType(e),r)}},Ll=Nd;Ll.Nodes=function(){let e=new Ee(`
vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
vec3 posN = normalize(position);
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
float scaledHeight = position.y / (size.y * 0.5);
float v = (scaledHeight / 2.) + .5;
vec2 calculatedUv = vec2(u,v);
vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
writeUv = uvs;
vec2 df = fwidth(uvs);
if(df.x > 0.5) df.x = 0.;
#ifdef GL_EXT_shader_texture_lod
vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
#else
vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
#endif
vec3 col = tmp.rgb;
float lalpha = alpha * tmp.a;
if ( crop > 0.5 ) {
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
lalpha = 0.0;
}
}
lalpha *= mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return col;
}
`),r=new Ee(`
vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
vec3 posN = normalize(vPosition);
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
float v = 0.5 + asin(posN.y) / 3.1415;
vec2 calculatedUv = vec2(u,v);
vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
writeUv = uvs;
vec2 df = fwidth(uvs);
if(df.x > 0.5) df.x = 0.;
#ifdef GL_EXT_shader_texture_lod
vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
#else
vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
#endif
vec3 col = tmp.rgb;
float lalpha = alpha * tmp.a;
if ( crop > 0.5 ) {
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
lalpha = 0.0;
}
}
lalpha *= mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return col;
}
`),i=new Ee(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
writeUv = uvs;
vec4 tmp = texture2D( tex, uvs );
vec3 col = tmp.rgb;
float lalpha = alpha * tmp.a;
if ( crop > 0.5 ) {
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
lalpha = 0.0;
}
}
lalpha *= mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return col;
}`),s=new Ee(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
vec3 p = position;
vec2 uv0 = (1.0 + p.xy) / 2.0;
vec2 uv1 = (1.0 + p.zy) / 2.0;
vec2 uv2 = (1.0 + p.xz) / 2.0;
uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
// Range from 3 to 128 seems to be good
float exponent = (1.0 - blending) * 125.0 + 3.0;
vec3 n = vObjectNormal;
vec3 weights = abs(normalize(n));
weights = pow(weights, vec3(exponent));
weights /= dot(weights, vec3(1.0));
// Write out all sets of UVs that we generated
writeUvs0 = uv0;
writeUvs1 = uv1;
writeUvs2 = uv2;
writeWeights = weights;
// Derivatives for LOD
vec2 df0 = fwidth(uv0);
vec2 df1 = fwidth(uv1);
vec2 df2 = fwidth(uv2);
if (df0.x > 0.5) df0.x = 0.0;
if (df1.x > 0.5) df1.x = 0.0;
if (df2.x > 0.5) df2.x = 0.0;
#ifdef GL_EXT_shader_texture_lod
vec4 tmp =
texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
#else
vec4 tmp =
textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
#endif
vec3 col = tmp.rgb;
float lalpha = alpha * tmp.a;
// Apply cropping across all 3 planes
if ( crop > 0.5 ) {
if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {
lalpha = 0.0;
}
if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {
lalpha = 0.0;
}
if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {
lalpha = 0.0;
}
}
lalpha *= mask;
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return col;//n * 0.5 + 0.5;
}
`);return{cylindrical:e,spherical:r,uv:i,triplanar:s}}();var Fd=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=i,this.far=s,this.isVector=o,this.isWorldSpace=a,this.origin=l,this.direction=c,this.colors=u,this.steps=h,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new Ee(`vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
vec4 color = colors[0];
#ifdef ${i}_IS_VECTOR
#ifdef ${i}_LINEAR
#ifdef ${i}_WORLDSPACE
float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
#else
float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
#endif
#else
#ifdef ${i}_WORLDSPACE
float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
#else
float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
#endif
#endif
#else
float dist = length(vWPosition - cameraPosition);
float depth = ( dist - near ) / ( far - near );
#endif
float p;
#ifdef ${i}_SMOOTH
for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
}
#else
for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
color = mix(color, colors[i], p);
}
#endif
float lalpha = alpha * color.a * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return color.rgb;
}`,[Fd.Nodes.vectorLinearWorldSpaceDepth,Fd.Nodes.vectorLinearObjectSpaceDepth,Fd.Nodes.vectorSphericalObjectSpaceDepth,Fd.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${i}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${i}_SMOOTH`),this.isVector.value>.5&&e.define(`${i}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${i}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${i}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let o=e.include(s),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.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(o+"("+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)}},Vd=Fd;Vd.Nodes=function(){let e=new Ee(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
vec3 n = normalize(direction);
float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
return ( dist - near ) / ( far - near );
}`),r=new Ee(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
vec3 n = normalize(direction);
float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
return ( dist - near ) / ( far - near );
}`),i=new Ee(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
float dist = length(vWPosition - origin);
return ( dist - near ) / ( far - near );
}`),s=new Ee(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
float dist = length(position - origin);
return ( dist - near ) / ( far - near );
}`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:i,vectorSphericalObjectSpaceDepth:s}}();var hm=class extends et{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=i,this.intensity=s,this.factor=o,this.isMask=c,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 i=new Ee(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return color;
}`),s=e.include(i),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(s+"("+o.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)}};var DA=class extends et{constructor(e,r,i,s,o,a,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=i,this.steps=s,this.offset=o,this.morph=a,this.angle=l,this.isMask=u,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 i=e.include(DA.Nodes.gradient),s=[];return s.push(this.gradientType.build(e,"i")),s.push(this.smooth.build(e,"b")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.offset.build(e,"v2")),s.push(this.morph.build(e,"v2")),s.push(this.angle.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.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)}},zd=DA;zd.Nodes=function(){return{gradient:new Ee(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
vec4 color = colors[0];
vec2 m = morph / vUv.xy;
vec2 rot = vec2( 0.5 + m.x, m.y );
vec2 dt = vec2(
cos( angle ) * rot.x - sin( angle ) * rot.y,
sin( angle ) * rot.x + cos( angle ) * rot.y
);
vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
float t = dot( pt, dt ) / dot( dt, dt );
if ( gradientType == 1 ) {
t = distance (
( vUv + morph ) * 3.0,
( vUv + offset ) + 1.0
) + angle;
} else if ( gradientType == 2 ) {
float polar = atan(
vUv.x + morph.x - 0.5 + offset.x,
vUv.y + morph.y - 0.5 + offset.y
) * -1.0;
t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
}
float p;
if (smoothed) {
for ( int i = 1; i < GRAD_MAX; i++ ) {
p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
}
} else {
for ( int i = 1; i < GRAD_MAX; i++ ) {
p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
color = mix(color, colors[i], p);
}
}
float lalpha = alpha * color.a * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return color.xyz;
}`)}}();var OA=class extends et{constructor(e,r,i,s,o){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=s,this.alpha=r,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=o}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(OA.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let s=[];return s.push(this.texture.generate(e,"t")),s.push("normal"),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),s.push(this.rotation.build(e,"f")),e.format(i+"("+s.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)}},Ud=OA;Ud.Nodes=function(){return{matcap:new Ee(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) );
uv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;
uv = uv * 0.495 + 0.5;
vec4 matcapColor = texture2D( matcapTex, uv );
float lalpha = alpha * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return matcapColor.rgb;
}`)}}();var dm=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o.VORONOI="voronoi",o))(dm||{}),zi=function(){let t=new Ee(`vec3 random3(vec3 c) {
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
vec3 r;
r.z = fract(512.0*j);
j *= .125;
r.x = fract(512.0*j);
j *= .125;
r.y = fract(512.0*j);
return r-0.5;
}`),e=new Ee(`float simplex3d(vec3 p) {
vec3 s = floor(p + dot(p, vec3(F3)));
vec3 x = p - s + dot(s, vec3(G3));
vec3 e = step(vec3(0.0), x - x.yzx);
vec3 i1 = e*(1.0 - e.zxy);
vec3 i2 = 1.0 - e.zxy*(1.0 - e);
vec3 x1 = x - i1 + G3;
vec3 x2 = x - i2 + 2.0*G3;
vec3 x3 = x - 1.0 + 3.0*G3;
vec4 w, d;
w.x = dot(x, x);
w.y = dot(x1, x1);
w.z = dot(x2, x2);
w.w = dot(x3, x3);
w = max(0.6 - w, 0.0);
d.x = dot(random3(s), x);
d.y = dot(random3(s + i1), x1);
d.z = dot(random3(s + i2), x2);
d.w = dot(random3(s + 1.0), x3);
w *= w;
w *= w;
d *= w;
return dot(d, vec4(52.0));
}`,[t]);e.keywords.F3=new Ht("float F3 0.3333333"),e.keywords.G3=new Ht("float G3 0.1666667");let r=new Ee(`float simplex3dFractal(vec3 m) {
mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
return 0.5333333 * simplex3d(m * rot1)
+ 0.2666667 * simplex3d(2.0 * m * rot2)
+ 0.1333333 * simplex3d(4.0 * m * rot3)
+ 0.0666667 * simplex3d(8.0 * m);
}`,[e]),i=new Ee("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new Ee("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new Ee(`float simplexAshima(vec3 v) {
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + 1.0 * C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - 1. + 3.0 * C.xxx;
i = mod(i, 289.0 );
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
float n_ = 1.0/7.0; // N=7
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}`,[i,s]),a=new Ee("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new Ee("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new Ee(`float noise(vec3 p){
vec3 a = floor(p);
vec3 d = p - a;
d = d * d * (3.0 - 2.0 * d);
vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
vec4 k1 = perm(b.xyxy);
vec4 k2 = perm(k1.xyxy + b.zzww);
vec4 c = k2 + a.zzzz;
vec4 k3 = perm(c);
vec4 k4 = perm(c + 1.0);
vec4 o1 = fract(k3 * (1.0 / 41.0));
vec4 o2 = fract(k4 * (1.0 / 41.0));
vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
return o4.y * d.y + o4.x * (1.0 - d.y);
}`,[l]),u=new Ee(`float fbm(vec3 x) {
float v = 0.0;
float a = 0.5;
vec3 shift = vec3(100);
for (int i = 0; i < NUM_OCTAVES; ++i) {
v += a * noise(x);
x = x * 2.0 + shift;
a *= 0.5;
}
return v;
}`,[c]);u.keywords.NUM_OCTAVES=new Ht(`int NUM_OCTAVES ${5}`);let h=new Ee("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new Ee(`float perlin(vec3 P){
vec3 Pi0 = floor(P);
vec3 Pi1 = Pi0 + vec3(1.0);
Pi0 = mod(Pi0, 289.0);
Pi1 = mod(Pi1, 289.0);
vec3 Pf0 = fract(P);
vec3 Pf1 = Pf0 - vec3(1.0);
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;
vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);
vec4 gx0 = ixy0 / 7.0;
vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
gx0 = fract(gx0);
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
vec4 sz0 = step(gz0, vec4(0.0));
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
gy0 -= sz0 * (step(0.0, gy0) - 0.5);
vec4 gx1 = ixy1 / 7.0;
vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
gx1 = fract(gx1);
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
vec4 sz1 = step(gz1, vec4(0.0));
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
gy1 -= sz1 * (step(0.0, gy1) - 0.5);
vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
float n111 = dot(g111, Pf1);
vec3 fade_xyz = fade(Pf0);
vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}`,[i,s,h]),f=new Ee(`float hashwithoutsine13(vec3 p3)
{
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}`),p=new Ee(`vec3 hashwithoutsine33(vec3 p3)
{
p3 = fract(p3 * vec3(.1031, .1030, .0973));
p3 += dot(p3, p3.yxz+33.33);
return fract((p3.xxy + p3.yxx)*p3.zyx);
}`),m=new Ee(`float metric(in vec3 p)
{
// L2
return length(p);
// Chebyshev
// vec3 a = abs(p);
// return max(a.x, max(a.y, a.z));
}`),g=new Ee(`float smin( float a, float b, float k )
{
float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
float correction = k * h * (1.0 - h);
return mix(b, a, h) - correction;
}`),y=new Ee(`float smax( float a, float b, float k )
{
float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
float correction = k * h * (1.0 - h);
return mix(a, b, h) + correction;
}`),v=new Ee(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
// Compute width of each interval
float input_width = input_max - input_min;
float output_width = output_max - output_min;
// Convert input range into a 0-1 range
float scaled = (value - input_min) / input_width;
// Convert the 0-1 range into a value in output range
return output_min + (scaled * output_width);
}`),x=new Ee(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
{
// Integer and fractional parts of this point's coordinates
ivec3 p = ivec3(floor(x));
vec3 f = fract(x);
// Different variables that we will use to construct noise:
//
// f1: distance to the closest feature point
// f2: distance to the second closest feature point
// e: distance to the closest edge (cell boundary)
//
// We also compute "smooth" versions of all of the above quantites, essentially
// replacing "hard" minimums with "smooth" minimums (described by IQ)
float f1_smooth = 8.0;
float f1 = 8.0;
float f2_smooth = 8.0;
float f2 = 8.0;
float e_smooth = 8.0;
float e = 8.0;
// Variables stored from closest cell
ivec3 mb;
vec3 mr;
int steps = quality;
for (int x = -steps; x <= steps; x++)
for (int y = -steps; y <= steps; y++)
for (int z = -steps; z <= steps; z++)
{
ivec3 b = ivec3(x, y, z);
vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
float d = length(r);
f1_smooth = smin(d, f1_smooth, smoothness);
// Store un-smoothed distances too
if (d < f1)
{
f2 = f1;
f1 = d;
mb = ivec3(x, y, z);
mr = r;
}
else if (d < f2)
{
f2 = d;
}
}
float id = hashwithoutsine13(vec3(p + mb) + seed);
// Second pass for edge distance
for (int x = -steps; x <= steps; x++)
for (int y = -steps; y <= steps; y++)
for (int z = -steps; z <= steps; z++)
{
// Start search at the cell that contains the closest point to "x" (found in 1st pass)
ivec3 b = mb + ivec3(x, y, z);
vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version?
float d2 = dot(0.5 * (mr + r), normalize(r - mr));
e_smooth = smin(d1, e_smooth, smoothness);
e = min(e, d2);
// Also compute a smooth version of F2 in this pass
{
ivec3 b = ivec3(x, y, z);
if (b != mb)
{
vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
float d = length(r);
f2_smooth = smin(d, f2_smooth, smoothness);
}
}
}
// Different visualization modes
if (style == 0)
{
return f1_smooth;
}
if (style == 1)
{
return f2_smooth;
}
if (style == 2)
{
return f2_smooth - f1_smooth;
// "Pebbles" also cool
//return step(0.2, f2_smooth - f1_smooth);
}
if (style == 3)
{
// This one is really good for rock / stone effects
float a = f1;
float b = f2;
float k = 3.0;
float h = max(k - abs(a - b), 0.0) / k;
float final = min(a, b) - h * h * k * (1.0 / 4.0);
return final;
}
if (style == 4)
{
// Some random adjustments to make this style stand out more
return exp(5.0 * e_smooth);
}
if (style == 5)
{
return pow(f1_smooth, 3.0);
}
if (style == 6)
{
const float eps = 0.0125;
// Thicker lines as the user increases the smoothness slider
float thickness = smoothness * 0.25 + eps;
// Blurrier lines as the user increases the smoothness slider
float blur = pow(smoothness, 3.0) * 0.25 + eps;
return smoothstep(
thickness - thickness * blur,
thickness + thickness * blur,
e
);
}
if (style == 7)
{
return hashwithoutsine13(vec3(p + mb) + seed);
}
}
`,[f,p,m,g,y,v]);return{simplex:e,simplexFractal:r,simplexAshima:o,fbm:u,perlin:d,voronoi:x}}();var kd=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y,v,x,S){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=i,this.fA=s,this.fB=o,this.distortion=a,this.colorA=l,this.colorB=c,this.colorC=u,this.colorD=h,this.noiseType=f,this.voronoiStyle=m,this.highCut=g,this.lowCut=y,this.smoothness=v,this.seed=x,this.quality=S,this.isMask=p,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,i,s,o){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(dm)[this.noiseType.value],l=a=="voronoi"?`
float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);
// Apply clipping to colors
v = remap(v, lowCut, highCut, 0.0, 1.0);
v = smax(v, 0.0, smoothness * 0.25);
v = smin(v, 1.0, smoothness * 0.25);
// Note that the voronoi mode only uses colors "A" and "C" from the UI
vec4 color = mix(colorA, colorC, v);
`:`
vec3 q = vec3(${a}(st),
${a}(st + vec3(1.0)),
${a}(st + vec3(1.0)));
vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
${a}(st * q));
float f = ${a}(st + r);
vec4 color;
color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
`,c=new Ee(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
{
// Prevent scale of zero
scale = max(abs(scale), 0.001);
vec3 st = position / size;
st /= scale;
${l}
float lalpha = alpha * color.a * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return clamp(color, 0.0, 1.0).rgb;
}`,[zi.simplex,zi.simplexFractal,zi.simplexAshima,zi.fbm,zi.perlin,zi.voronoi]),u=e.include(c),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.voronoiStyle.build(e,"i")),h.push(this.highCut.build(e,"f")),h.push(this.lowCut.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.seed.build(e,"f")),h.push(this.quality.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(u+"("+h.join(",")+")",this.getType(e),r)}};kd.numOctaves=5;var IA=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=i,this.contourWidth=s,this.contourThreshold=o,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=h,this.compensation=d,this.resolution=f,this.normalMap=p,this.depthMap=m,this.pixelRatio=g,this.alpha=y,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let i=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${i}_offset`),this.firstTime){let s=this.outlineWidth.build(e,"f"),o=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(s,"uniform float"),e.addVertexParsVariable(o,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
vID = randomColor.r;
vec2 ${i}_offset = vec2(0.0);
if (${a}) {
vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
// NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
// normals face the camera directly. So we hackily fix this by offsetting the normal
// by a tiny amount.
vec3 ${i}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
${i}_offset = normalize(${i}_clipNormal.xy) / ${o} * (${s} / 2.0) * ${i}_clipPosition.w * 2.0 * ${l};
${i}_clipPosition.xy += ${i}_offset;
// TODO(MAX): To handle multiple outline layers, we only want to extrude
// if this offset is the biggest of all the potential offsets
gl_Position = ${i}_clipPosition;
}
`)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=e.include(IA.Nodes.outline),o=[];return o.push(this.outlineColor.build(e,"c")),o.push(this.contourColor.build(e,"c")),o.push(this.outlineWidth.build(e,"f")),o.push(this.contourWidth.build(e,"f")),o.push(this.contourThreshold.build(e,"f")),o.push(this.outlineThreshold.build(e,"f")),o.push(this.contourFrequency.build(e,"f")),o.push(this.outlineSmoothing.build(e,"f")),o.push(this.contourDirection.build(e,"v3")),o.push(this.positionalLines.build(e,"b")),o.push(this.resolution.build(e,"v2")),o.push(this.normalMap.getTexture(e,"t")),o.push(this.depthMap.getTexture(e,"t")),o.push(this.pixelRatio.build(e,"f")),o.push(this.compensation.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(s+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Gd=IA;Gd.Nodes=function(){let e=new Ee(`
float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
{
vec2 halton = haltonSequence[frameIndex];
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
float temporalAngle = temporalOffset * PI2;
vec2 texelSize = (vec2(1.0) / resolution);
vec2 offsetSize = texelSize * outlineWidth * pixelRatio;
vec2 uvSamples[9];
vec4 normalSamples[9];
uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);
uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);
uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);
uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);
uvSamples[4] = uv;
uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);
uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);
uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);
uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);
normalSamples[0] = texture2D(t, uvSamples[0]);
normalSamples[1] = texture2D(t, uvSamples[1]);
normalSamples[2] = texture2D(t, uvSamples[2]);
normalSamples[3] = texture2D(t, uvSamples[3]);
normalSamples[4] = texture2D(t, uvSamples[4]);
normalSamples[5] = texture2D(t, uvSamples[5]);
normalSamples[6] = texture2D(t, uvSamples[6]);
normalSamples[7] = texture2D(t, uvSamples[7]);
normalSamples[8] = texture2D(t, uvSamples[8]);
float depthBias = 0.0001;
// TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?!
if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {
float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;
if (gl_FragCoord.z > depthAtSample) {
return 0.0;
}
}
vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);
vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);
float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
return edgeNormal;
}
`);return{outline:new Ee(`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 mask, float alpha, out float calpha) {
vec3 result = outlineColor;
float resultAlpha = 0.0;
vec3 N = normalize(vWNormal);
vec2 nuv = (gl_FragCoord.xy / resolution);
float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);
//resultAlpha = 1.0;
//result = vec3(sobelSample);
float t = 1.0 - contourThreshold;
if(positionalLines) {
vec3 NDir = position * contourDirection;
float NT = NDir.x + NDir.y + NDir.z;
float f = fract(NT * contourFrequency * 0.01);
float df = fwidth(NT * contourFrequency);
float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);
if (g < 1.0 && resultAlpha == 0.0) {
result = contourColor;
resultAlpha = 1.0;
}
}
else {
vec3 NDir = N * contourDirection;
float NT = NDir.x + NDir.y + NDir.z;
float df = fwidth(NT * contourThreshold);
float f = sin(NT * 1.0 * contourFrequency);
float g = smoothstep(0.0, df * contourWidth, 1.0 - f);
if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {
result = contourColor;
resultAlpha = 1.0 - g;
}
}
float lalpha = alpha * resultAlpha * mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
return result;
}`,[e])}}();var Io=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d,f,p,m,g,y,v,x){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=i,this.blending=s,this.offset=o,this.colorA=a,this.colorB=l,this.frequency=c,this.size=u,this.variation=h,this.smoothness=d,this.zigzag=f,this.rotation=p,this.vertical=m,this.horizontal=g,this.sides=y,this.isMask=x,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let i;switch(this.style.value){case 0:i="circle";break;case 1:i="ring";break;case 2:i="polygon";break;case 3:i="xcross";break;case 4:i="diamond";break;case 5:i="checkerboard";break;case 6:i="line";break;case 7:i="wave";break;default:i="circle";break}let s=`g${this.uuid.toString().replace(/-/g,"")}`,o=new Ee(`float hashwithoutsine12(vec2 p)
{
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}`),a=new Ee(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
{
const float mid = 0.5;
float radians = a * (PI / 180.0);
vec2 rotated = vec2(
cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,
cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid
);
return repeat ? fract(rotated): rotated;
}`),l="";if(this.projection.value===4){let d=this.style.value===2?`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f=this.style.value===2?`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,p=this.style.value===2?`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;l=`
vec3 p = position;
float factor = 0.0125;
vec2 uv0 = fract(p.xy * factor);
vec2 uv1 = fract(p.zy * factor);
vec2 uv2 = fract(p.xz * factor);
uv0 = rotate_uv(uv0 + offset, rotation, true);
uv1 = rotate_uv(uv1 + offset, rotation, true);
uv2 = rotate_uv(uv2 + offset, rotation, true);
float d0 = ${d};
float d1 = ${f};
float d2 = ${p};
// Range from 3 to 128 seems to be good
float exponent = (1.0 - blending) * 125.0 + 3.0;
vec3 n = vObjectNormal;
vec3 weights = abs(normalize(n));
weights = pow(weights, vec3(exponent));
weights /= dot(weights, vec3(1.0));
d0 *= weights.z;
d1 *= weights.x;
d2 *= weights.y;
float draw = d0 + d1 + d2;
vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;
`}else{let d=this.style.value===2?`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f="";this.axis.value===0?f=`float radius = length(p);
float theta = atan(p.y, p.z);
float phi = acos(p.x / radius);`:this.axis.value===1?f=`float radius = length(p);
float theta = atan(p.x, p.z);
float phi = acos(p.y / radius);`:(this.axis.value,f=`float radius = length(p);
float theta = atan(p.y, p.x);
float phi = acos(p.z / radius);`);let p="";switch(this.projection.value){case 0:p="custom_uv = vUv.st;";break;case 1:break;case 2:p=`
vec3 p = position;
${f}
custom_uv = vec2(theta, phi);
custom_uv /= PI;
`;break;case 3:break;default:break}l=`
vec2 custom_uv;
${p}
custom_uv += offset;
custom_uv = fract(custom_uv);
custom_uv = rotate_uv(custom_uv, rotation, true);
float draw = ${d};
`}let c=new Ee(`vec3 ${s}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
const float TWO_PI = PI * 2.0;
float smoothness_remapped = pow(smoothness, 5.0);
${l}
// Construct final output color
vec4 color = mix(colorA, colorB, draw);
color.a = clamp(color.a, 0.0, 1.0);
// Apply cuts
color.a *=
step(vertical.x, custom_uv.y) *
step(custom_uv.y, vertical.y);
color.a *=
step(horizontal.x, abs(custom_uv.x)) *
step(abs(custom_uv.x), horizontal.y);
// Accumulate alpha
float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return clamp(color, 0.0, 1.0).rgb;
}`,[a,o,Io.DrawFunctions.circle,Io.DrawFunctions.ring,Io.DrawFunctions.polygon,Io.DrawFunctions.cross,Io.DrawFunctions.diamond,Io.DrawFunctions.checkerboard,Io.DrawFunctions.line,Io.DrawFunctions.wave]),u=e.include(c),h=[];return h.push("normal"),h.push(this.blending.build(e,"f")),h.push(this.style.build(e,"i")),h.push(this.offset.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.frequency.build(e,"v2")),h.push(this.size.build(e,"f")),h.push(this.variation.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.zigzag.build(e,"f")),h.push(this.rotation.build(e,"f")),h.push(this.vertical.build(e,"v2")),h.push(this.horizontal.build(e,"v2")),h.push(this.sides.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(u+"("+h.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},jd=Io;jd.DrawFunctions=function(){let e=new Ee(`float hashwithoutsine12(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}`),r=new Ee(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
// Create tiles in UV-space
uv *= frequency;
// Integer coords
vec2 i = floor(uv);
// Offset every other row based on zigzag param, then compute fractional coords
float row_offset = mod(i.y, 2.0);
uv.x += row_offset * zigzag;
vec2 f = fract(uv);
// Rotate the tile itself:
// const float mid = 0.5;
// f = vec2(
// cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid,
// cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid
// );
// f = fract(f);
f = f * 2.0 - 1.0;
// Recompute integer coords after shifting - then, random value per tile
i = floor(uv);
float rand = (hashwithoutsine12(i) * 5.0 + 1.0);
float jitter = mix(1.0, rand, variation);
f *= jitter;
return f;
}`,[e]),i=new Ee(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
return smoothstep(
-smoothness,
smoothness,
length(f) - size
);
}`,[r]),s=new Ee(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
float d = length(f);
const float inner_width = 0.5;
float outer = smoothstep(-smoothness, smoothness, d - size);
float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
return outer + (1.0 - inner);
}`,[r]),o=new Ee(`float sdf_ngon(in vec2 p, in float r, in int n) {
float an = (PI * 2.0) / float(n);
float he = r * tan(0.5 * an);
// Rotate to first sector
p = -p.yx;
float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);
vec2 cs = vec2(cos(bn), sin(bn));
p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;
// Side of polygon
return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);
}
float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
}`,[r]),a=new Ee(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
p = abs(p);
p = (p.y > p.x) ? p.yx : p.xy;
vec2 q = p - b;
float k = max(q.y, q.x);
vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);
return sign(k) * length(max(w, 0.0)) + r;
}
// Avoid namespace conflicts
float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
}`,[r]),l=new Ee(`float ndot(vec2 a, vec2 b) {
return a.x*b.x - a.y*b.y;
}
float sdf_diamond(in vec2 p, in vec2 b) {
p = abs(p);
float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);
float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));
return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);
}
float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
}`,[r]),c=new Ee(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
uv *= frequency;
vec2 i = floor(uv);
float offset = mod(i.y, 2.0);
uv.x += offset + zigzag * offset;
float x = floor(uv.x);
return mod(x, 2.0);
}`),u=new Ee(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
// Different approach for variation param here
float row = floor(uv * frequency).y;
float rand = hashwithoutsine12(vec2(row));
float s = mix(size, size * rand, variation);
return smoothstep(
s - smoothness,
s + smoothness,
abs(f.y)
);
}`,[r]),h=new Ee(`// Uses bisection
float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
// Convert all data to a primitive cosine wave
p = c * (p - vec2(d, a));
const float TWO_PI = PI * 2.0;
// Reduce to principal half cycle
p.x = mod(p.x, TWO_PI);
if (p.x > PI) {
p.x = TWO_PI - p.x;
}
// Find zero of derivative (minimize distance)
float xa = 0.0;
float xb = TWO_PI;
// 24 bit precision
for (int i = 0; i < 24; i++) {
float x = 0.5 * (xa + xb);
float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));
if (y < 0.0) xa = x;
else xb = x;
}
float x = 0.5 * (xa + xb);
// Compute distance
vec2 q = vec2(x, b * c * cos(x));
return length(p - q) / c;
}
float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
float repeat = frequency.x;
uv *= repeat;
vec2 i = floor(uv);
float row_offset = mod(i.y, 2.0);
uv.x += row_offset * zigzag;
vec2 f = vec2(uv.x, fract(uv.y));
// Generalized cosine: y(x) = a + b * cos(cx + d)
const float amplitude = 0.125;
float wave_frequency = frequency.y * 0.1;
float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);
// Different approach for variation param here
float rand = hashwithoutsine12(vec2(i.y));
float s = mix(size, size * rand, variation);
return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
}`);return{tileAndCenter:r,circle:i,ring:s,polygon:o,cross:a,diamond:l,checkerboard:c,line:u,wave:h}}();var RA=class extends et{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=i,this.noiseStrength=s,this.noiseScale=o,this.offset=a,this.isMask=c,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 i=e.include(RA.Nodes.rainbow),s=[];return s.push(this.filmThickness.build(e,"f")),s.push(this.movement.build(e,"f")),s.push(this.wavelengths.build(e,"v3")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.offset.build(e,"v3")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.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)}},Hd=RA;Hd.Nodes=function(){let e=new Ee(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
vec3 st = position / noiseScale;
vec3 q = vec3(simplex3d(st),
simplex3d(st + vec3(1.0)),
simplex3d(st + vec3(1.0)));
vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
simplex3d(st * q));
float noise = simplex3d(st + r);
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);
}`,[zi.simplex]);return{rainbow:new Ee(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
float lalpha = alpha * rainbowContribution * mask;
calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
return res;
}`,[e])}}();var LA=class extends et{constructor(e,r,i,s,o,a,l,c,u,h){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=i,this.source=s,this.isWorldSpace=o,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=h,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 i=e.include(LA.Nodes.toon),s=[];return s.push(this.positioning.build(e,"i")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.source.build(e,"v3")),s.push(this.isWorldSpace.build(e,"b")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.shadowColor.build(e,"v4")),s.push(this.offset.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.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)}},Wd=LA;Wd.Nodes=function(){let e=new Ee(`float rand(float n) {
return fract(sin(n) * 43758.5453123);
}`),r=new Ee(`float hash1(float p) {
p = fract(p * 0.011);
p *= p + 7.5;
p *= p + p;
return fract(p);
}`),i=new Ee(`float valueNoise(vec3 x) {
const vec3 step = vec3(110, 241, 171);
vec3 i = floor(x);
vec3 f = fract(x);
// For performance, compute the base input to a 1D hash from the integer part of the argument and the
// incremental change to the 1D based on the 3D -> 1D wrapping
float n = dot(i, step);
vec3 u = f * f * (3.0 - 2.0 * f);
return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
}`,[r]),s=new Ee(`vec3 hash3(vec3 x) {
x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
dot(x,vec3(269.5, 183.3, 246.1)),
dot(x,vec3(113.5, 271.9, 124.6)));
return fract(sin(x)*43758.5453123);
}`),o=new Ee(`vec3 voronoiNoise(in vec3 x)
{
vec3 p = floor(x);
vec3 f = fract(x);
float id = 0.0;
vec2 res = vec2(100.0);
for(int k=-1; k<=1; k++)
for(int j=-1; j<=1; j++)
for(int i=-1; i<=1; i++)
{
vec3 b = vec3(float(i), float(j), float(k));
// Comment out the "+ hash(p + b);" part below to get "square" cells
vec3 r = vec3(b) - f + hash3(p + b);
float d = dot(r, r);
if (d < res.x)
{
id = dot(p + b, vec3(1.0, 57.0, 113.0));
res = vec2(d, res.x);
}
else if (d < res.y)
{
res.y = d;
}
}
return vec3(sqrt(res), abs(id));
}
`,[s]);return{toon:new Ee(`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 mask, float alpha, out float calpha) {
float t = 0.0;
float shadow = 1.0;
if (positioning == 0) {
// Can't do this mode if lighting is "none"
#if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
// Algorithm from Chapter 10 of Graphics Shaders
const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
vec3 lpos;
vec3 l;
float dproduct;
#if (NUM_POINT_LIGHTS > 0)
#if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
// Light positions are in view-space for some reason?
lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
l = normalize(lpos - worldPosition);
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
// TODO: we want to use "intensity" but it isn't available in the shader code
//dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
t = max(t, dproduct);
// Accumulate shadow contribution
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
shadow *= getPointShadow(
pointShadowMap[UNROLLED_LOOP_INDEX],
pointLightShadow.shadowMapSize,
pointLightShadow.shadowBias,
pointLightShadow.shadowRadius,
vPointShadowCoord[UNROLLED_LOOP_INDEX],
pointLightShadow.shadowCameraNear,
pointLightShadow.shadowCameraFar);
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
#if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
// Use the direction vector for directional lights instead
l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
t = max(t, dproduct);
// Accumulate shadow contribution
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
shadow *= getShadow(
UNROLLED_LOOP_INDEX,
directionalShadowMap[UNROLLED_LOOP_INDEX],
directionalLightShadow.shadowMapSize,
directionalLightShadow.shadowBias,
directionalLightShadow.shadowRadius,
vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
#if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
l = normalize(lpos - worldPosition);
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
t = max(t, dproduct);
// Accumulate shadow contribution
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
shadow *= getShadow(
UNROLLED_LOOP_INDEX,
spotShadowMap[UNROLLED_LOOP_INDEX],
spotLightShadow.shadowMapSize,
spotLightShadow.shadowBias,
spotLightShadow.shadowRadius,
vSpotLightCoord[UNROLLED_LOOP_INDEX]);
#endif
}
#pragma unroll_loop_end
#endif
t = clamp(t, 0.0, 1.0);
#endif
} else if (positioning == 1) {
vec3 origin = mix(position, worldPosition, float(isWorldSpace));
vec3 direction = normalize(source - origin);
t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
} else {
vec3 origin = worldPosition;
vec3 source = cameraPosition - offset;
vec3 direction = normalize(source - origin);
t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
}
if (noiseStrength > 0.0) {
// Distort with noise
vec3 st = position / noiseScale;
// Voronoi "smooth" noise
float noise = 1.0 - voronoiNoise(st).x;
// Voronoi cellular noise
//float noise = 1.0 - rand(voronoiNoise(st).z);
// Position warp noise
// vec3 offset = vec3(
// simplex3d(st),
// simplex3d(st + vec3(111.1, 143.89, 217.19)),
// simplex3d(st + vec3(171.1, 247.89, 117.23))
// );
// st += offset;
// float noise = valueNoise(st);
t += noise * noiseStrength;
}
t = clamp(t, 0.0, 1.0);
// Compute ramp color
float p;
vec4 color = colors[0];
for (int i = 1; i < COLORS_MAX; i++) {
p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
}
// Incorporate custom shadow color
if (positioning == 0) {
vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
color.rgb = mix(blendedShadow, color.rgb, shadow);
}
// Accumulate alpha as usual
float lalpha = alpha * color.a * mask;
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
accumAlpha += (1.0 - accumAlpha) * lalpha;
return color.xyz;
}`,[zi.simplex,e,i,o])}}();var UI=function(){return{textureBicubic:new Ee(`float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
// g0 and g1 are the two amplitude functions
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
// h0 and h1 are the two offset functions
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}`)}}();function kI(n,t){return n>=t?new U(t/n,1):new U(1,n/t)}var BA=class extends et{constructor(e,r,i,s,o,a,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=i,this.transmissionSamplerSize=s,this.transmissionSamplerMap=o,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",6),e.define("BLUR_SLOD",Math.pow(2,Ze.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let i=e.include(BA.Nodes.transmission),s=[];return s.push(this.thickness.build(e,"f")),s.push(this.ior.build(e,"f")),s.push(this.roughness.build(e,"f")),s.push(this.transmissionSamplerSize.build(e,"v2")),s.push(this.transmissionSamplerMap.getTexture(e,"t")),s.push(this.transmissionDepthMap.getTexture(e,"t")),s.push(this.aspectRatio.build(e,"v2")),s.push("normal"),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(i+"("+s.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)}},qd=BA;qd.Nodes=function(){let e=new Ee(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
// Slightly modified version of this:
// https://www.shadertoy.com/view/ltScRG
// Special case for blur == 0.0
if (lod == 0.0) {
#ifdef TEXTURE_LOD_EXT
return texture2DLodEXT( sp, U, 0.0).rgb;
#else
return textureLod( sp, U, 0.0).rgb;
#endif
}
vec2 texelSize = vec2(1.0) / resolution;
vec2 halton = haltonSequence[frameIndex];
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
float temporalAngle = temporalOffset * PI2;
vec3 res = vec3(0.0);
vec2 uv = vec2(0.0);
vec2 offset = vec2(0.0);
vec2 vogelSample = vec2(0.0);
for (int i = 0; i < NUM_SAMPLES; i++) {
vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;
offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20
uv = U + offset;
float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));
if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
uv = unrefractedU;
lod = lod > 4.0 ? lod : lod / 2.0;
}
res += textureLod(sp, uv, lod).rgb;
}
return res / float(NUM_SAMPLES);
}`),r=new Ee(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
// Direction of refracted light.
vec3 refractionVector = refract( -v, n, 1.0 / ior );
// Compute rotation-independant scaling of the model matrix.
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
// The thickness is specified in local space
return normalize( refractionVector ) * thickness * modelScale;
}`),i=new Ee(`float applyIorToRoughness( float roughness, float ior ) {
// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
// an IOR of 1.5 results in the default amount of microfacet refraction.
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}`),s=new Ee(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
// Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
// also the code in convertTransmission.ts, which runs during export
#ifdef IS_THREEJS_EXPORT
float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);
return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;
#else
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
float lod = applyIorToRoughness(roughness, ior);
return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
#endif
}`,[UI.textureBicubic,i,e]),o=new Ee(`vec3 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 ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
unrefractedCoords += 1.0;
unrefractedCoords /= 2.0;
// Sample framebuffer to get pixel the refracted ray hits.
return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
}`,[s,r]);return{transmission:new Ee(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
vec3 v = vec3(0.);
if (isOrthographic) {
v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
v = normalize(vWPosition - cameraPosition);
}
vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
float lalpha = alpha * mask;
calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * alpha;
return transmission;
}`,[o])}}();var NA=(e=>(e.NOISE="noise",e.MAP="map",e))(NA||{}),FA=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d){super("v3");this.displacementTypeIndex=new Ot(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(NA)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Rd(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=h,this.noiseFunctionIndex=d,this.voronoiStyle=s,this.smoothness=o,this.seed=a,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let i,s=[];switch(s.push("displaced_position"),s.push("displaced_normal"),Object.values(NA)[this.displacementTypeIndex.value]){case"map":{i=e.include(FA.Nodes.map),s.push(this.movementOrTexture.getTexture(e,"t")),s.push("uv"),s.push(this.cropOrOffset.build(e,"f")),this.mat&&s.push(this.mat.build(e,"mat3"));break}case"noise":{let a=Object.values(dm)[this.noiseFunctionIndex.value],l=new Ee(`vec3 orthogonal(vec3 v) {
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
}`),c=a=="voronoi"?`
float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
v = remap(v, lowCut, highCut, 0.0, 1.0);
v = smax(v, 0.0, smoothness * 0.25);
v = smin(v, 1.0, smoothness * 0.25);
return p + n * v * intensity;
`:`
return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
`,u=new Ee(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
${c}
}`,[zi.simplex,zi.simplexFractal,zi.simplexAshima,zi.fbm,zi.perlin,zi.voronoi]),h=new Ee(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
vec3 tangent1 = orthogonal(normal);
vec3 tangent2 = normalize(cross(normal, tangent1));
// TODO(Max): The distance to the neighbors was originally scaled by 0.1.
// This caused some small oval/circular visual artifacts in the lighting.
// For now, simply using neighbors further away betters the problem,
// but we should figure out the underlying cause when we have some time.
// Maybe its related to how we calculate the tangent and bitangent?
vec3 nearby1 = position + tangent1;
vec3 nearby2 = position + tangent2;
vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
return displaced_position;
}`,[u,l]);i=e.include(h),s.push(this.scale.build(e,"f")),s.push(this.cropOrOffset.build(e,"v3")),s.push(this.movementOrTexture.build(e,"f")),s.push(this.voronoiStyle.build(e,"i")),s.push(this.smoothness.build(e,"f")),s.push(this.seed.build(e,"f")),s.push(this.highCut.build(e,"f")),s.push(this.lowCut.build(e,"f")),s.push(this.quality.build(e,"i"));break}}return s.push(this.intensity.build(e,"f")),s.push("displaced_normal"),e.format(i+"("+s.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)}},Yd=FA;Yd.Nodes=function(){let e=new Ee(`vec3 orthogonal(vec3 v) {
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
}`),r=new Ee(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
vec4 tmp = texture2D(tex, uvs);
vec3 col = tmp.rgb;
if (crop > 0.5) {
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
return 0.0;
}
}
return col.r;
}`);return{map:new Ee(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
vec3 tangent1 = normalize(orthogonal(normal));
vec3 tangent2 = normalize(cross(normal, tangent1));
vec3 nearby1 = position + tangent1 * 0.1;
vec3 nearby2 = position + tangent2 * 0.1;
vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
return displaced_position;
}`,[e,r])}}();var Ze={normalRenderTarget:new yn,normalRenderTargetDepth:new yn,transmissionRenderTarget:new yn,aspectRatio:new kr,transmissionSize:new kr(2048,2048),transmissionRenderTargetDepth:new yn,aoRenderTarget:new yn,aoEnabled:new Yr,pixelRatioNode:new Fe(1),resolution:new kr,penumbraSize:new qs(5,.5),frameIndex:new Ot(0),transmissionLod:new Ot(2)};for(let n of Object.values(Ze))n.isRenderGlobal=!0;var L0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.7.6/build/ui.wasm"};var Ca=class extends nr{constructor(){super("basic");this.nodeType="Basic";this.color=new $t($r),this.shadingAlpha=new Fe(1),this.shadingBlend=new Ot(0),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({resolution:Ze.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
`));let s=["#include <beginnormal_vertex>",`
#if !defined( USE_LAYER_DISPLACE )
#include <defaultnormal_vertex>
#endif
vec3 displaced_position = position;
vec3 displaced_normal = normal;
#if defined( USE_LAYER_DISPLACE )
vec3 transformed;
vec3 transformedNormal;
#endif
`,"#include <normal_vertex>",`
#if !defined( USE_LAYER_DISPLACE )
#include <begin_vertex>
#endif /* !USE_LAYER_DISPLACE */
`];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
`)}else{this.color===void 0&&(this.color=new $t($r)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),s=this.alpha?this.alpha.flow(e,"f"):void 0,o=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=s!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
`));let l=["#include <normal_fragment_begin>",i.code];s&&l.push(s.code,"#ifdef ALPHATEST"," if ( "+s.result+" <= ALPHATEST ) discard;","#endif"),a?l.push(a.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${i.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),s?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${s.result} * ${c} );`):l.push("gl_FragColor = vec4("+i.result+", 1.0 );"),o&&l.push(`gl_FragColor.a *= ${o.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),r=l.join(`
`)}return r}};var fm=class extends nr{constructor(){super("lambert");this.nodeType="Lambert";this.color=new $t($r),this.emissive=new $t(0),this.emissiveIntensity=new Fe(1),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Ot(0),this.occlusion=new Yr(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({resolution:Ze.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog,De.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 <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
`));let s=["#include <beginnormal_vertex>",`
#include <skinbase_vertex>
#include <skinnormal_vertex>
#ifndef USE_LAYER_DISPLACE
#include <defaultnormal_vertex>
#endif
vec3 displaced_position = position;
vec3 displaced_normal = objectNormal;
#ifdef USE_LAYER_DISPLACE
vec3 transformed;
vec3 transformedNormal;
#endif
`,"#include <normal_vertex>",`
#ifndef USE_LAYER_DISPLACE
#include <begin_vertex>
#endif
`];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
`),s.push(`
GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
vLightBack = vec3( 0.0 );
vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
#ifdef DOUBLE_SIDED
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
#endif
#if NUM_POINT_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
getPointLightInfo( pointLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
getSpotLightInfo( spotLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
dotNL = dot( geometry.normal, directLight.direction );
directLightColor_Diffuse = directLight.color;
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
#ifdef DOUBLE_SIDED
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
#endif
}
#pragma unroll_loop_end
#endif
#if NUM_HEMI_LIGHTS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
#ifdef DOUBLE_SIDED
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
#endif
}
#pragma unroll_loop_end
#endif
`," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
`)}else{e.mergeUniform({penumbraSize:Ze.penumbraSize}),e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({aoMap:Ze.aoRenderTarget}),e.mergeUniform({aoEnabled:Ze.aoEnabled}),this.color===void 0&&(this.color=new $t($r)),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 i=this.color.flow(e,"c",{slot:"color"}),s=this.emissive.flow(e,"c",{slot:"emissive"}),o=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","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(`
`));let f=["#include <normal_fragment_begin>",`
// NOTE: gl_FrontFacing alternative using face normal estimation.
vec3 viewdx = dFdx(vViewPosition);
vec3 viewdy = dFdy(vViewPosition);
vec3 faceNormal = normalize(cross(viewdx, viewdy));
bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
`,"#include <clipping_planes_fragment>"];f.push(i.code,"vec3 diffuseColor = "+i.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.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();"),s&&f.push(s.code,"reflectedLight.directDiffuse += "+s.result+" * "+o.result+";"),f.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
if (outgoingLight != diffuseColor) {
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${c.result} );
outgoingLight *= ao;
}
`),u&&f.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
`)}return r}};var Pa=function(){let n=new Ee(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
// Gradient of UVs w.r.t. X coordinate (in screen-space)
vec2 dSTdx = dFdx(bumpMapUv);
// Gradient of UVs w.r.t. Y coordinate (in screen-space)
vec2 dSTdy = dFdy(bumpMapUv);
// Forward differencing
float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);
float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;
float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;
return vec2( dBx, dBy );
}`),t=new Ee(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = dFdx( surf_pos.xyz );
vec3 vSigmaY = dFdy( surf_pos.xyz );
vec3 vN = surf_norm; // normalized
vN = normalize(vN);
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
R1 = normalize(R1);
R2 = normalize(R2);
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * vN - vGrad );
}`);return{dHdxy:n,perturbNormalArb:t}}();var pm=class extends nr{constructor(){super("phong");this.nodeType="Phong";this.color=new $t($r),this.specular=new $t(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Ot(0),this.occlusion=new Yr(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({resolution:Ze.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog,De.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
`));let s=["#include <beginnormal_vertex>",`
#include <skinbase_vertex>
#include <skinnormal_vertex>
#ifndef USE_LAYER_DISPLACE
#include <defaultnormal_vertex>
#endif
vec3 displaced_position = position;
vec3 displaced_normal = objectNormal;
#ifdef USE_LAYER_DISPLACE
vec3 transformed;
vec3 transformedNormal;
#endif
`,"#include <normal_vertex>",`
#ifndef USE_LAYER_DISPLACE
#include <begin_vertex>
#endif
`];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
`)}else{e.mergeUniform({penumbraSize:Ze.penumbraSize}),e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({aoMap:Ze.aoRenderTarget}),e.mergeUniform({aoEnabled:Ze.aoEnabled}),this.color===void 0&&(this.color=new $t($r)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let s=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),a=this.shininess.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,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
`));let f=["#include <normal_fragment_begin>",`
// NOTE: gl_FrontFacing alternative using face normal estimation.
vec3 viewdx = dFdx(vViewPosition);
vec3 viewdy = dFdy(vViewPosition);
vec3 faceNormal = normalize(cross(viewdx,viewdy));
if (dot(normal, faceNormal) < 0.0) {
normal *= -1.0;
}
`," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(Pa.dHdxy),e.include(Pa.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),g=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",v="";this.bumpMap.projection.value===4?v=`
vec3 bumpNormal = vec3(0.0);
{
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
vec2 grad0 = dHdxy(${m.result}, uv0, ${y});
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
vec2 grad1 = dHdxy(${m.result}, uv1, ${y});
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
vec2 grad2 = dHdxy(${m.result}, uv2, ${y});
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
bumpNormal = normalize(bumpNormal);
}
normal = bumpNormal;
`:v=`
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
vec2 grad = dHdxy(${m.result}, bumpMapCachedUv, ${y});
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
`,f.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
${g.result};
${v}
`)}f.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.push("material.diffuseColor = diffuseColor;"),f.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),f.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
if (outgoingLight != diffuseColor) {
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${c.result} );
outgoingLight *= ao;
}
`),u&&f.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
`)}return r}};var mm=class extends nr{constructor(){super("standard");this.nodeType="Standard";this.color=new $t($r),this.roughness=new Fe(.3),this.metalness=new Fe(0),this.reflectivity=new Fe(.5),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Ot(0),this.occlusion=new Yr(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({resolution:Ze.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog,De.lights])),De.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 <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
`));let s=["#include <beginnormal_vertex>",`
#include <skinbase_vertex>
#include <skinnormal_vertex>
#if !defined( USE_LAYER_DISPLACE )
#include <defaultnormal_vertex>
#endif
vec3 displaced_position = position;
vec3 displaced_normal = objectNormal;
#if defined( USE_LAYER_DISPLACE )
vec3 transformed;
vec3 transformedNormal;
#endif
`,"#include <normal_vertex>",`
#if !defined( USE_LAYER_DISPLACE )
#include <begin_vertex>
#endif /* !USE_LAYER_DISPLACE */
`];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
`)}else{e.mergeUniform({penumbraSize:Ze.penumbraSize}),e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({aoMap:Ze.aoRenderTarget}),e.mergeUniform({aoEnabled:Ze.aoEnabled});let i={gamma:!0};this.color===void 0&&(this.color=new $t($r)),this.color.analyze(e,{slot:"color",context:i}),this.roughness.analyze(e),this.metalness.analyze(e);let s=this.occlusion.flow(e,"b",{slot:"occlusion"});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 o=this.color.flow(e,"c",{slot:"color",context:i}),a=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
`));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
// NOTE: gl_FrontFacing alternative using face normal estimation.
vec3 viewdx = dFdx(vViewPosition);
vec3 viewdy = dFdy(vViewPosition);
vec3 faceNormal = normalize(cross(viewdx,viewdy));
if (dot(normal, faceNormal) < 0.0) {
normal *= -1.0;
}
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(Pa.dHdxy),e.include(Pa.perturbNormalArb);let y=this.bumpMap.texture.flow(e,"t"),v=this.bumpMap.flow(e,"v3"),x=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",S="";this.bumpMap.projection.value===4?S=`
vec3 bumpNormal = vec3(0.0);
{
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
vec2 grad0 = dHdxy(${y.result}, uv0, ${x});
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
vec2 grad1 = dHdxy(${y.result}, uv1, ${x});
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
vec2 grad2 = dHdxy(${y.result}, uv2, ${x});
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
bumpNormal = normalize(bumpNormal);
}
normal = bumpNormal;
`:S=`
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
vec2 grad = dHdxy(${y.result}, bumpMapCachedUv, ${x});
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
${v.result};
${S}
`)}if(m.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){let y=this.roughnessMap.texture.flow(e,"t"),v=this.roughnessMap.flow(e,"v3"),x="";this.roughnessMap.projection.value===4?x=`
float roughnessChange = 1.0;
{
vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
float r0 = luminance(texture(${y.result}, uv0).rgb) * roughnessScale;
float r1 = luminance(texture(${y.result}, uv1).rgb) * roughnessScale;
float r2 = luminance(texture(${y.result}, uv2).rgb) * roughnessScale;
roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
}
float roughnessFactor = roughnessChange * ${a.result};
`:x=`
vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
vec4 vals = texture(${y.result}, roughnessMapCachedUv);
float roughnessFactor = luminance(vals.rgb) * ${a.result};
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
${v.result};
const float roughnessScale = 1.0;
${x}
`)}else m.push(a.code," float roughnessFactor = "+a.result+";");d&&m.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.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?m.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let g="1.0";this.mask&&(this.mask.analyze(e),g=`luminance(${this.mask.flow(e,"v3").result})`),m.push(`
if (outgoingLight != diffuseColor) {
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${g} * lightAccu;
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${g}, ${u.result} );
outgoingLight *= ao;
}
`),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
`)}return r}};var gm=class extends nr{constructor(){super("toon");this.nodeType="Toon";this.color=new $t($r),this.specular=new $t(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Ot(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({resolution:Ze.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Bs.merge([De.fog,De.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
`));let s=["#include <beginnormal_vertex>",`
#include <skinbase_vertex>
#include <skinnormal_vertex>
#ifndef USE_LAYER_DISPLACE
#include <defaultnormal_vertex>
#endif
vec3 displaced_position = position;
vec3 displaced_normal = objectNormal;
#ifdef USE_LAYER_DISPLACE
vec3 transformed;
vec3 transformedNormal;
#endif
`,"#include <normal_vertex>",`
#ifndef USE_LAYER_DISPLACE
#include <begin_vertex>
#endif
`];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
`)}else{e.mergeUniform({penumbraSize:Ze.penumbraSize}),e.mergeUniform({frameIndex:Ze.frameIndex}),e.mergeUniform({aoMap:Ze.aoRenderTarget}),e.mergeUniform({aoEnabled:Ze.aoEnabled}),this.color===void 0&&(this.color=new $t($r)),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 i=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),o=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,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","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>",`
varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
#define Material_LightProbeLOD( material ) (0)
`,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
`));let d=["#include <normal_fragment_begin>",`
// NOTE: gl_FrontFacing alternative using face normal estimation.
vec3 viewdx = dFdx(vViewPosition);
vec3 viewdy = dFdy(vViewPosition);
vec3 faceNormal = normalize(cross(viewdx,viewdy));
if (dot(normal, faceNormal) < 0.0) {
normal *= -1.0;
}
`," ToonMaterial material;"];if(this.bumpMap){e.include(Pa.dHdxy),e.include(Pa.perturbNormalArb);let p=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",y="";this.bumpMap.projection.value===4?y=`
vec3 bumpNormal = vec3(0.0);
{
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
vec2 grad0 = dHdxy(${p.result}, uv0, ${g});
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
vec2 grad1 = dHdxy(${p.result}, uv1, ${g});
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
vec2 grad2 = dHdxy(${p.result}, uv2, ${g});
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
bumpNormal = normalize(bumpNormal);
}
normal = bumpNormal;
`:y=`
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
vec2 grad = dHdxy(${p.result}, bumpMapCachedUv, ${g});
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
`,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
${m.result};
${y}
`)}d.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," vec3 specular = "+s.result+";",o.code," float shininess = max( 0.0001, "+o.result+" );"," float specularStrength = 1.0;"),u&&d.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
if (outgoingLight != diffuseColor) {
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${f} * lightAccu;
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${f}, ${l.result} );
}
`),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&d.push(`gl_FragColor.a *= ${h.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
`)}return r}};var B0=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var zA=class extends B0{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},VA;function GI(n){return typeof n=="string"?n:(VA||(VA=new zA),VA.load(n))}var N0=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},F0=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Xd=class extends N0{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let s of Object.values(this._cache))for(let o of Object.values(s))for(let a of Object.values(o))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let s;await new Promise(o=>{i.onloadend=a=>{s=a.target?.result,o(null)}}),this.img.src=s}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=GI(e),this.img.onload=r}getTexture(e,r=1008,i=1006){let s=this._cache[e]?.[r]?.[i];if(s)return s;{let o;return this.isBuffer?o=this.img.texture:this.isVideo?o=new ny(this.img,void 0,e,e):o=new Jt(this.img,void 0,e,e,i,r),this.loaded&&(o.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][i]=o,o}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let i of Object.values(r))for(let s of Object.values(i))s&&(s.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[i,s]of Object.entries(r))for(let[o,a]of Object.entries(s))a?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][o]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Jn=class extends Xd{};function kA(n,t){var e=k7(t);return e.formatToParts?z7(e,n):U7(e,n)}var V7={year:0,month:1,day:2,hour:3,minute:4,second:5};function z7(n,t){try{for(var e=n.formatToParts(t),r=[],i=0;i<e.length;i++){var s=V7[e[i].type];s>=0&&(r[s]=parseInt(e[i].value,10))}return r}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function U7(n,t){var e=n.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(e);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var UA={};function k7(n){if(!UA[n]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),e=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";UA[n]=e?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return UA[n]}function V0(n,t,e,r,i,s,o){var a=new Date(0);return a.setUTCFullYear(n,t,e),a.setUTCHours(r,i,s,o),a}var jI=36e5,G7=6e4,GA={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function ym(n,t,e){var r,i;if(!n||(r=GA.timezoneZ.exec(n),r))return 0;var s;if(r=GA.timezoneHH.exec(n),r)return s=parseInt(r[1],10),HI(s)?-(s*jI):NaN;if(r=GA.timezoneHHMM.exec(n),r){s=parseInt(r[1],10);var o=parseInt(r[2],10);return HI(s,o)?(i=Math.abs(s)*jI+o*G7,s>0?-i:i):NaN}if(W7(n)){t=new Date(t||Date.now());var a=e?t:j7(t),l=jA(a,n),c=e?l:H7(t,l,n);return-c}return NaN}function j7(n){return V0(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds())}function jA(n,t){var e=kA(n,t),r=V0(e[0],e[1]-1,e[2],e[3]%24,e[4],e[5],0).getTime(),i=n.getTime(),s=i%1e3;return i-=s>=0?s:1e3+s,r-i}function H7(n,t,e){var r=n.getTime(),i=r-t,s=jA(new Date(i),e);if(t===s)return t;i-=s-t;var o=jA(new Date(i),e);return s===o?s:Math.max(s,o)}function HI(n,t){return-23<=n&&n<=23&&(t==null||0<=t&&t<=59)}var WI={};function W7(n){if(WI[n])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:n}),WI[n]=!0,!0}catch{return!1}}var tR=Ko(YI(),1),qA=Ko(QI(),1);var X7=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,KI=X7;var HA=36e5,ZI=6e4,Q7=2,vn={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:KI};function YA(n,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(n===null)return new Date(NaN);var e=t||{},r=e.additionalDigits==null?Q7:(0,tR.default)(e.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]")return new Date(n.getTime());if(typeof n=="number"||Object.prototype.toString.call(n)==="[object Number]")return new Date(n);if(!(typeof n=="string"||Object.prototype.toString.call(n)==="[object String]"))return new Date(NaN);var i=K7(n),s=Z7(i.date,r),o=s.year,a=s.restDateString,l=J7(a,o);if(isNaN(l))return new Date(NaN);if(l){var c=l.getTime(),u=0,h;if(i.time&&(u=$7(i.time),isNaN(u)))return new Date(NaN);if(i.timeZone||e.timeZone){if(h=ym(i.timeZone||e.timeZone,new Date(c+u)),isNaN(h))return new Date(NaN)}else h=(0,qA.default)(new Date(c+u)),h=(0,qA.default)(new Date(c+u+h));return new Date(c+u+h)}else return new Date(NaN)}function K7(n){var t={},e=vn.dateTimePattern.exec(n),r;if(e?(t.date=e[1],r=e[3]):(e=vn.datePattern.exec(n),e?(t.date=e[1],r=e[2]):(t.date=null,r=n)),r){var i=vn.timeZone.exec(r);i?(t.time=r.replace(i[1],""),t.timeZone=i[1].trim()):t.time=r}return t}function Z7(n,t){var e=vn.YYY[t],r=vn.YYYYY[t],i;if(i=vn.YYYY.exec(n)||r.exec(n),i){var s=i[1];return{year:parseInt(s,10),restDateString:n.slice(s.length)}}if(i=vn.YY.exec(n)||e.exec(n),i){var o=i[1];return{year:parseInt(o,10)*100,restDateString:n.slice(o.length)}}return{year:null}}function J7(n,t){if(t===null)return null;var e,r,i,s;if(n.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(e=vn.MM.exec(n),e)return r=new Date(0),i=parseInt(e[1],10)-1,$I(t,i)?(r.setUTCFullYear(t,i),r):new Date(NaN);if(e=vn.DDD.exec(n),e){r=new Date(0);var o=parseInt(e[1],10);return rY(t,o)?(r.setUTCFullYear(t,0,o),r):new Date(NaN)}if(e=vn.MMDD.exec(n),e){r=new Date(0),i=parseInt(e[1],10)-1;var a=parseInt(e[2],10);return $I(t,i,a)?(r.setUTCFullYear(t,i,a),r):new Date(NaN)}if(e=vn.Www.exec(n),e)return s=parseInt(e[1],10)-1,eR(t,s)?JI(t,s):new Date(NaN);if(e=vn.WwwD.exec(n),e){s=parseInt(e[1],10)-1;var l=parseInt(e[2],10)-1;return eR(t,s,l)?JI(t,s,l):new Date(NaN)}return null}function $7(n){var t,e,r;if(t=vn.HH.exec(n),t)return e=parseFloat(t[1].replace(",",".")),WA(e)?e%24*HA:NaN;if(t=vn.HHMM.exec(n),t)return e=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),WA(e,r)?e%24*HA+r*ZI:NaN;if(t=vn.HHMMSS.exec(n),t){e=parseInt(t[1],10),r=parseInt(t[2],10);var i=parseFloat(t[3].replace(",","."));return WA(e,r,i)?e%24*HA+r*ZI+i*1e3:NaN}return null}function JI(n,t,e){t=t||0,e=e||0;var r=new Date(0);r.setUTCFullYear(n,0,4);var i=r.getUTCDay()||7,s=t*7+e+1-i;return r.setUTCDate(r.getUTCDate()+s),r}var eY=[31,28,31,30,31,30,31,31,30,31,30,31],tY=[31,29,31,30,31,30,31,31,30,31,30,31];function rR(n){return n%400===0||n%4===0&&n%100!==0}function $I(n,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var r=rR(n);if(r&&e>tY[t]||!r&&e>eY[t])return!1}return!0}function rY(n,t){if(t<1)return!1;var e=rR(n);return!(e&&t>366||!e&&t>365)}function eR(n,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function WA(n,t,e){return!(n!=null&&(n<0||n>=25)||t!=null&&(t<0||t>=60)||e!=null&&(e<0||e>=60))}function k0(n,t,e){var r=YA(n,e),i=ym(t,r,!0),s=new Date(r.getTime()-i),o=new Date(0);return o.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),o.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),o}function Yi(n,t){return t.color(n)}function XA(n=new Date,t){let e=t.format,r=n.getSeconds(),i=n;t&&t.timeZone!==null&&(i=k0(new Date,t.timeZone));let s=i.getHours(),o=i.getMinutes(),a;t.format12h24h==="12ampm"&&(a=s>=12?"PM":"AM");let l=s;t.format12h24h!=="24"&&(l=s%12,l===0&&(l=12));let c,u;switch(e){case"HH:mm:ss":c=[l,o,r];break;case"HH:mm":c=[l,o];break;case"HH":c=[l],a=void 0;break;case"mm":c=[o],a=void 0;break;case"ss":c=[r],a=void 0;break;case"year":u=i.getFullYear();break;case"month":u=i.getMonth()+1;break;case"dayOfYear":u=Math.floor((i.getTime()-new Date(i.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=i.getDate();break;case"secondOfDay":u=s*60*60+o*60+r;break;default:console.error("Unknown time format",e),u=0;break}return c!==void 0?{textValue:c,suffix:a}:u}function iR(n,t){switch(n.type){case"fresnel":return sY(n,t);case"gradient":return oY(n,t);case"depth":return aY(n,t);case"normal":return lY(n,t);case"noise":return cY(n,t);case"rainbow":return uY(n,t);case"toon":return hY(n,t);case"outline":return dY(n,t);case"transmission":return fY(n,t);case"color":return nY(n,t);case"pattern":return pY(n,t)}}function iY(n){return{type:n.type}}function Xs(n,t){let{alpha:e,mode:r,isMask:i}=n,s=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...iY(n),alpha:s,mode:r,isMask:i}}function nY(n,t){return{...Xs(n,t),color:Yi(n.color,t)}}function sY(n,t){let{bias:e,scale:r,intensity:i,factor:s,color:o}=n;return{...Xs(n,t),color:Yi(o,t),bias:e,scale:r,intensity:i,factor:s}}function oY(n,t){let{gradientType:e,smooth:r,colors:i,steps:s,angle:o,offset:a,morph:l}=n;return{...Xs(n,t),gradientType:e,smooth:r,colors:i.map(c=>new Ke(c[0],c[1],c[2],c[3])),num:i.length,steps:s,offset:new U(...a),morph:new U(...l),angle:o}}function aY(n,t){let{gradientType:e,near:r,far:i,isVector:s,isWorldSpace:o,origin:a,direction:l,colors:c,steps:u,smooth:h}=n;return{...Xs(n,t),gradientType:e,near:r,far:i,isVector:s,isWorldSpace:o,origin:new E(...a),direction:l?new E(...l):new E(1,0,0),colors:c.map(d=>d!==void 0?new Ke(d[0],d[1],d[2],d[3]):new Ke(0,0,0,0)),steps:u.slice(0,c.length),smooth:h}}function lY(n,t){let{cnormal:e}=n;return{...Xs(n,t),cnormal:new E(e[0],e[1],e[2])}}function cY(n,t){return{...Xs(n,t),scale:n.scale,move:n.move,fA:new U(...n.fA),fB:new U(...n.fB),size:new E(...n.size),distortion:new U(...n.distortion),colorA:Yi(n.colorA,t),colorB:Yi(n.colorB,t),colorC:Yi(n.colorC,t),colorD:Yi(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function uY(n,t){return{...Xs(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new E(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new E(...n.offset)}}function hY(n,t){return{...Xs(n,t),positioning:n.positioning,colors:n.colors.map(e=>new Ke(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new E(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Yi(n.shadowColor,t),offset:new E(...n.offset)}}function dY(n,t){return{...Xs(n,t),outlineColor:Yi(n.outlineColor,t),contourColor:Yi(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new E(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function fY(n,t){return{...Xs(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function pY(n,t){return{...Xs(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new U(...n.offset),colorA:Yi(n.colorA,t),colorB:Yi(n.colorB,t),frequency:new U(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new U(...n.vertical),horizontal:new U(...n.horizontal),sides:n.sides}}var Bl=class extends mr{};var mY={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},gY={depth:["colors"]};function yY(n,t,e){if(t==="isMask")return!0;let r=mY[n.type],i=gY[n.type];if(i!==void 0){let s=n.color;if(i.includes(t)){let o=s[t]?.value?.length;if(o!==void 0&&o!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function QA(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let i=!1,s=n;if("image"in s){let o=s.image,a=t.image(o),l=r;l.image instanceof Jn||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=r;l.image instanceof Jn||l.image.deref(),l.image=a}if("wrapping"in s){let o=r;o.wrap=s.wrapping}if("minFilter"in s){let o=r;o.minFilter=s.minFilter}if("magFilter"in s){let o=r;o.magFilter=s.magFilter}if("rotation"in s&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(s.rotation??0)*we.DEG2RAD,i;if("repeat"in s||"offset"in s||"rotation"in s){let o="mat",a=e.uniforms[`f${e.id}_${o}`];"repeat"in s&&(a.repeat=s.repeat),"offset"in s&&(a.offset=s.offset),"rotation"in s&&(a.rotation=s.rotation??0),a.updateMatrix()}return i}function nR(n,t,e,r){let i=!1;for(let[s,o]of Object.entries(n)){if(s==="bumpMap"||s==="roughnessMap"){i=!0;continue}if(!s||o===void 0)continue;if(KA(s,e,r,t)){s==="visible"&&e.type==="light"&&(i=!0);continue}e.visible=r.visible;let a=e.uniforms[`f${e.id}_${s}`];if(!!a&&!(a instanceof Rl))switch(i=i||yY(e,s,o),a.constructor){case $t:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Bl?a.value=new mr(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case On:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Bl?a.value=new mr(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case kr:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]);break}case Wi:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case yn:{QA(o,t,e);break}case Ys:{a.value=o.map(l=>new Ke(...l));break}default:{a.value=o;break}}}return i}var Nl=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Fl=class{constructor(t,e,r,i,s){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let o in i)this.uniforms[`f${this.id}_${o}`]=i[o];for(let o in r)KA(o,this,r,s)}get type(){return this.data.type}static create(t,e,r,i){if(r.type==="light")return xn.createLigherLayer(t,e,r,i);if(r.type==="texture"||r.type==="video"){let s=r.type==="texture"?i.uiBuffer(r.texture.image)??i.image(r.texture.image):i.video(r.texture.video),o=new zc(s,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),a=new I0(s),l=new R0(r.texture.repeat,r.texture.offset,r.texture.rotation??0),c=new Fe(r.crop?1:0),u=new Ot(r.projection??0),h=new Ot(["x","y","z"].indexOf(r.axis)??0),d=new Ot(r.side??0),f=new kr(r.size?new U(r.size[0],r.size[1]):new U(100,100)),p=new Fe(r.blending??0),m=new Fe(Nl(r.alpha,i)),g=new Ot(r.mode??0),y=new Yr(r.isMask??!1),v=new Ll(o,a,c,u,h,d,f,p,l,m,g,y),x=new qt(v.calpha,"f");return new _r(t,e,r,{texture:o,textureSize:a,crop:c,projection:u,axis:h,side:d,size:f,blending:p,mat:l,alpha:m,mode:g,isMask:y},v,g,x,y,i)}else if(r.type==="matcap"){let s=i.image(r.texture.image),o=new zc(s,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),a=new Fe(Nl(r.alpha,i)),l=new Ot(r.mode??0),c=new Yr(r.isMask??!1),u=new Fe((r.texture.rotation??0)*we.DEG2RAD),h=new Ud(o,a,l,c,u),d=new qt(h.calpha,"f");return new _r(t,e,r,{texture:o,alpha:a,mode:l,isMask:c,rotation:u},h,l,d,c,i)}else if(r.type==="displace")if(r.displacementType==="noise"){let s=new Wi(new E(...r.offset)),o=new Fe(r.scale??10),a=new Fe(r.intensity??8),l=new Fe(r.movement??1),c=new Ot(r.noiseType??0),u=new Ot(r.voronoiStyle??0),h=new Fe(r.smoothness??.5),d=new Fe(r.seed??0),f=new Fe(r.highCut??1),p=new Fe(r.lowCut??0),m=new Ot(r.quality??1),g=new Yd(a,l,s,u,h,d,f,p,m,o,c);return new vm(t,e,r,{offset:s,scale:o,intensity:a,movement:l,noiseType:c,voronoiStyle:u,smoothness:h,seed:d,highCut:f,lowCut:p,quality:m},g,i)}else throw new Error;else return bY(t,e,r,i)}updateByOp(t,e,r){let i=t;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props||"visible"in i.props?(r.scene.markNeedsUpdateRendererDirty(),!0):nR(i.props,r.shared,this,e)}else if(i.path[0]==="texture")return"texture"in e||"video"in e?QA(i.props,r.shared,this):!0;return!1}dispose(){if(vY(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Jn||e.image.deref()}}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}},_r=class extends Fl{constructor(e,r,i,s,o,a,l,c,u){super(e,r,i,s,u);this.params=s;this.color=o;this.mode=a;this.alpha=l;this.isMask=c}},vm=class extends Fl{constructor(e,r,i,s,o,a){super(e,r,i,s,a);this.position=o}},xn=class extends Fl{constructor(e,r,i,s,o,a){super(e,r,i,o,a);this.node=s}static createLigherLayer(e,r,i,s){let o,a=new Fe(Nl(i.alpha,s)),l=new Ot(i.mode),c=new Fe(i.bumpMapIntensity),u=new Fe(Nl(i.alphaOverride,s)),h;if(!i.visible)o=new Ca,h={};else if(i.category==="lambert"){o=new fm;let d=new $t(s.color(i.emissive)??0),f=new Yr(i.occlusion??!0);h={emissive:d,occlusion:f},o.emissive=d,o.occlusion=f}else if(i.category==="toon"){o=new gm;let d=new Fe(i.shininess??30),f=new $t(s.color(i.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(i.category==="physical"){o=new mm;let d=new Fe(i.roughness??.3),f=new Fe(i.metalness??0),p=new Fe(i.reflectivity??.5),m=new Yr(i.occlusion??!0);h={roughness:d,metalness:f,reflectivity:p,occlusion:m},o.roughness=d,o.metalness=f,o.reflectivity=p,o.occlusion=m}else{o=new pm;let d=new Fe(i.shininess??30),f=new $t(i.specular!==void 0?s.color(i.specular)??1118481:1118481),p=new Yr(i.occlusion??!0);h={shininess:d,specular:f,occlusion:p},o.shininess=d,o.specular=f,o.occlusion=p}return o.alpha=new Fe(1),o.shadingAlpha=a,o.shadingBlend=l,o.bumpMapIntensity=c,o.alphaOverride=u,h.alpha=o.shadingAlpha,h.mode=o.shadingBlend,h.bumpMapIntensity=o.bumpMapIntensity,h.alphaOverride=o.alphaOverride,new xn(e,r,i,o,h,s)}get category(){return this.node.category}};function vY(n){let t=n instanceof Fl?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function gs(n){return{alpha:new Fe(n.alpha??1),mode:new Ot(n.mode??0),isMask:new Yr(n.isMask??!1)}}function xY(n,t,e,r,i){switch(n.type){case"color":{let s=new $t(r.color??$r),o=gs(r),a=new Uc(s,o.alpha),l=new qt(a.calpha,"f");return new _r(t,e,n,{color:s,...o},a,o.mode,l,o.isMask,i)}case"fresnel":{let s=new $t(r.color??16777215),o=new Fe(r.bias??.1),a=new Fe(r.scale??1),l=new Fe(r.intensity??2),c=new Fe(r.factor??1),u=gs(r),h=new hm(s,o,a,l,c,u.alpha,u.mode,u.isMask),d=new qt(h.calpha,"f");return new _r(t,e,n,{color:s,bias:o,scale:a,intensity:l,factor:c,...u},h,u.mode,d,u.isMask,i)}case"rainbow":{let s=new Fe(r.filmThickness??30),o=new Fe(r.movement??0),a=new Wi(r.wavelengths??new E(0,0,0)),l=new Fe(r.noiseStrength??0),c=new Fe(r.noiseScale??1),u=new Wi(r.offset??new E(0,0,0)),h=gs(r),d=new Hd(s,o,a,l,c,u,h.alpha,h.isMask),f=new qt(d.calpha,"f");return new _r(t,e,n,{filmThickness:s,movement:o,wavelengths:a,noiseStrength:l,noiseScale:c,offset:u,...h},d,h.mode,f,h.isMask,i)}case"transmission":{let s=new Fe(r.thickness??10),o=new Fe(r.ior??1.5),a=new Fe(r.roughness??.5),l=Ze.transmissionSize,c=Ze.transmissionRenderTarget,u=Ze.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new kr(d/h,1):new kr(1,h/d),p=gs(r),m=new qd(s,o,a,l,c,u,f,p.alpha),g=new qt(m.calpha,"f");return new _r(t,e,n,{thickness:s,ior:o,roughness:a,aspectRatio:f,...p},m,p.mode,g,p.isMask,i)}case"toon":{let s=new Ot(r.positioning??0),o;r.colors?o=new Ys(r.colors.length,r.colors):(o=new Ys(10,new Ke(0,0,0,1)),o.value[1]=new Ke(1,1,1,1));let a;r.steps?a=new qs(r.steps.length,r.steps):(a=new qs(10,1),a.value[0]=0);let l=new Wi(r.source??new E(0,0,0)),c=new Yr(r.isWorldSpace??!0),u=new Fe(r.noiseStrength??0),h=new Fe(r.noiseScale??1),d=new On(r.shadowColor),f=new Wi(r.offset??new E(0,0,0)),p=gs(r),m=new Wd(s,o,a,l,c,u,h,d,f,p.alpha),g=new qt(m.calpha,"f");return new _r(t,e,n,{positioning:s,colors:o,steps:a,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:h,shadowColor:d,offset:f,...p},m,p.mode,g,p.isMask,i)}case"outline":{let s=new $t(r.outlineColor??16777215),o=new $t(r.contourColor??16777215),a=new Fe(r.outlineWidth??.1),l=new Fe(r.contourWidth??.1),c=new Fe(r.outlineThreshold??.1),u=new Fe(r.contourThreshold??.1),h=new Fe(r.outlineSmoothing??.1),d=new Fe(r.contourFrequency??.1),f=new Wi(r.contourDirection??new E(0,1,0)),p=new Yr(r.positionalLines??!1),m=new Yr(r.compensation??!0),g=Ze.normalRenderTarget,y=Ze.normalRenderTargetDepth,v=Ze.pixelRatioNode,x=Ze.resolution,S=gs(r),w=new Gd(s,o,a,l,c,u,h,d,f,p,m,x,g,y,v,S.alpha),A=new qt(w.calpha,"f");return new _r(t,e,n,{outlineColor:s,contourColor:o,outlineWidth:a,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:p,compensation:m,...S},w,S.mode,A,S.isMask,i)}case"depth":{let s=new Ot(r.gradientType??0),o=new Yr(r.smooth??!1),a=new Fe(r.near??50),l=new Fe(r.far??200),c=new Fe(r.isVector??1),u=new Fe(r.isWorldSpace??0),h=new Wi(r.origin??new E),d=new Wi(r.direction??new E),f;r.colors?f=new Ys(r.colors.length,r.colors):(f=new Ys(2,new Ke(0,0,0,1)),f.value[1]=new Ke(1,1,1,1));let p;r.steps?p=new qs(r.steps.length,r.steps):(p=new qs(2,1),p.value[0]=0);let m=gs(r),g=new Vd(s,o,a,l,c,u,h,d,f,p,m.alpha,m.isMask),y=new qt(g.calpha,"f");return new _r(t,e,n,{gradientType:s,smooth:o,near:a,far:l,isVector:c,isWorldSpace:u,origin:h,direction:d,colors:f,steps:p,...m},g,m.mode,y,m.isMask,i)}case"noise":{let s=new Fe(r.scale??1),o=new Wi(r.size??new E(100,100,100)),a=new Fe(r.move??1),l=new kr(r.fA??new U(1.7,9.2)),c=new kr(r.fB??new U(8.3,2.8)),u=new kr(r.distortion??new U(1,1)),h=new On(r.colorA),d=new On(r.colorB),f=new On(r.colorC),p=new On(r.colorD),m=new Ot(r.noiseType??0),g=new Ot(r.voronoiStyle??0),y=new Fe(r.highCut??1),v=new Fe(r.lowCut??0),x=new Fe(r.smoothness??.5),S=new Fe(r.seed??.5),w=new Ot(r.quality??1),A=gs(r),M=new kd(s,o,a,l,c,u,h,d,f,p,A.alpha,m,A.isMask,g,y,v,x,S,w),b=new qt(M.calpha,"f");return new _r(t,e,n,{scale:s,size:o,move:a,fA:l,fB:c,distortion:u,colorA:h,colorB:d,colorC:f,colorD:p,noiseType:m,...A,voronoiStyle:g,highCut:y,lowCut:v,smoothness:x,seed:S,quality:w},M,A.mode,b,A.isMask,i)}case"normal":{let s=new Wi(r.cnormal??new E(1,1,1)),o=gs(r),a=new Bd(s,o.alpha),l=new qt(a.calpha,"f");return new _r(t,e,n,{cnormal:s,...o},a,o.mode,l,o.isMask,i)}case"gradient":{let s=new Ot(r.gradientType??0),o=new Yr(r.smooth??!1),a;r.colors?a=new Ys(r.colors.length,r.colors):(a=new Ys(10,new Ke(0,0,0,1)),a.value[1]=new Ke(1,1,1,1));let l;r.steps?l=new qs(r.steps.length,r.steps):(l=new qs(10,1),l.value[0]=0);let c=new kr(r.offset??new U(0,0)),u=new kr(r.morph??new U(0,0)),h=new Fe(r.angle??0),d=gs(r),f=new zd(s,o,a,l,c,u,h,d.alpha,d.isMask),p=new qt(f.calpha,"f");return new _r(t,e,n,{gradientType:s,smooth:o,colors:a,steps:l,offset:c,morph:u,angle:h,...d},f,d.mode,p,d.isMask,i)}case"pattern":{let s=new Ot(r.style??0),o=new Ot(r.projection??0),a=new Ot(["x","y","z"].indexOf(r.axis)??0),l=new Fe(r.blending??0),c=new kr(r.offset??new U(0,0)),u=new On(r.colorA),h=new On(r.colorB),d=new kr(r.frequency??new U(10,10)),f=new Fe(r.size??.5),p=new Fe(r.variation??0),m=new Fe(r.smoothness??.5),g=new Fe(r.zigzag??0),y=new Fe(r.rotation??0),v=new kr(r.vertical??new U(0,1)),x=new kr(r.horizontal??new U(0,1)),S=new Ot(r.sides??6),w=gs(r),A=new jd(s,o,a,l,c,u,h,d,f,p,m,g,y,v,x,S,w.alpha,w.isMask),M=new qt(A.calpha,"f");return new _r(t,e,n,{style:s,projection:o,axis:a,blending:l,offset:c,colorA:u,colorB:h,frequency:d,size:f,variation:p,smoothness:m,zigzag:g,rotation:y,vertical:v,horizontal:x,sides:S,...w},A,w.mode,M,w.isMask,i)}default:{let s=new $t(1,0,0,1),o=gs(r),a=new Uc(s,o.alpha),l=new qt(a.calpha,"f");return new _r(t,e,n,{color:s,...o},a,o.mode,l,o.isMask,i)}}}function bY(n,t,e,r){let i=iR(e,r);return xY(e,n,t,i,r)}function KA(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let i=t.uniforms[`f${t.id}_intensity`];return i?(i.value=e.intensity*(e.visible?1:0),i):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let i=t.uniforms[`f${t.id}_alpha`];if(!i)return;if(i.value=Nl(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=e.compensation&&e.visible)}return i}}function Gc(n,t){let e=0,r=n.layers.find(i=>i.data.type==="light");if(r){let i=r.data,s=Number(t.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?s/100:i.alphaOverride)<1)return!0}for(let i of n.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let s=i.data.visible?i.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let o of i.data.colors)if(o[3]<1){s=o[3];break}}else if(s===1&&i.data.type==="noise"){let o=t.color(i.data.colorA).a,a=t.color(i.data.colorB).a,l=t.color(i.data.colorC).a,c=t.color(i.data.colorD).a,u=Math.min(o,Math.min(a,Math.min(l,c)));u<1&&(s=u)}e+=(1-e)*s}}return e<1}var Rn=class extends st{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},G0=class extends Rn{constructor(e,r,i,s){super();this.flatShading=e;this.side=r;this.wireframe=i;this.root=s}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,i){return this.root.getFlavor(e,r,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,i){this.root.updateByOp(e,r,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},_a=class extends Rn{constructor(e,r,i=!0){super();this.data=e;this.allowVariableSaves=i;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,nr.startContext(this),this.reset0(e,r),nr.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,i){let s=i?6:(e?3:0)+r;if(s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let o=this.flavors[s];return o===void 0&&(o=new G0(e,r,i,this),o.needsJitter=this.needsJitter,this.flavors[s]=o,o.flatShading=e,o.side=r,o.updateAfterBuild()),o}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,i=!1){nr.startContext(this),(this.data!==e||i)&&this.reset0(e,r),nr.endContext(this)}reset0(e,r){this.data=e;let i=e.layers??ei.defaultTwoLayerData("phong").layers;try{this.layers=i.map(s=>Fl.create(this.layerIdGen++,s.id,s.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Gc(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,i){if(e[0]==="alphaOverride")this.transparent=Gc(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let s=e[1],o=e[2];if(s&&o){let a=this.layers.find(l=>l.uuid===s);a?.hasValue(o)&&(o==="alpha"?(this.transparent=Gc(this.data,i.shared),a.setValue(o,Math.max(0,Math.min(Number(r)/100,1)))):a.setValue(o,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(i=>i.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"])})}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 xn),this.lightLayer===void 0&&(this.lightLayer=new xn(0,"",{...zr.defaultData("light","phong"),visible:!1},new Ca,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(o=>o instanceof xn);if(!e)return;let r=e.data,i=r.bumpMap,s=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let o=0;o<this.layers.length;++o){let a=this.layers[o];a instanceof _r&&a.color instanceof Ll&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===s&&(e.node.roughnessMap=a.color))}}updateByOp(e,r,i){if(nr.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=Gc(r,i.shared),e.path[0]==="layers"){let s=i.shared,o=e.path[1];if(o===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(r,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(l=>l.uuid===o);if(a){let l=r.layers.data(o),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Nl(e.props.alpha,s,["material",this.uuid,"layer",o,"alpha"])}:c={...e.props,alphaOverride:Nl(e.props.alphaOverride,s,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,i)&&this.reset0(r,i)}}}else this.reset0(r,i);nr.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof _r?r.color.mask=void 0:r instanceof xn&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof _r&&r.isMask.value&&r.data.visible&&e>0){let i=e-1,s=this.layers[i];s instanceof xn?s.node.mask=new Fi(r.color,r.alpha,Fi.MUL):s instanceof _r&&(s.isMask.value||(s.color.mask=new Fi(r.color,r.alpha,Fi.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof _r),r=this.layers.findIndex(i=>i instanceof xn);if(e!==-1&&e<r){let i=this.layers[e].color;for(let s=e+1;s<r;++s){let o=this.layers[s];if(o instanceof _r){if(o.isMask.value)continue;i=new Ld(i,o.color,o.alpha,o.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new qt("outgoingLight","f"),r=this.layers.findIndex(i=>i instanceof xn);if(this.layers.length>r+1){for(let i=r+1;i<this.layers.length;++i){let s=this.layers[i];if(s instanceof _r){if(s.isMask.value)continue;e=new Ld(e,s.color,s.alpha,s.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof vm);if(e.length>0){let r=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(r=new Fi(r,e[i].position,Fi.ADD),r=new Fi(r,new Fe(.5).setReadonly(!0),Fi.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){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 i=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=i(s.uniforms[`f${s.id}_intensity`].value,e,r);s.uniforms[`f${s.id}_intensity`].value=o}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Id;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof _r){let r=e.params.texture;if(r instanceof zc&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Rn.prototype,{properties:{get:function(){return this.fragment.properties}}});var jc=class extends _a{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var sR=new Map;function oR(n){if(typeof n=="string")return n;let t=sR.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},sR.set(n,t)),t.url}var lR,cR=new Promise(n=>{lR=n}),aR=!1;var j0;function uR(){if(aR)return;if(j0)return j0;async function n(){await import("./howler.js"),lR(window!==void 0?window:global),aR=!0}return j0=n(),j0}var hR;cR.then(n=>hR=n);function dR(n){let t=!1;return n.scene.objects.traverse((e,r)=>{if(r.events===void 0||Array.isArray(r.events)===!1)return!0;let i=[];r.events.forEach(s=>{"dragDropActions"in s.data?(i.push(...s.data.dragDropActions.drag),i.push(...s.data.dragDropActions.drop)):"inActions"in s.data?(i.push(...s.data.inActions),i.push(...s.data.outActions)):"gameActions"in s.data?(i.push(...s.data.gameActions.idle),i.push(...s.data.gameActions.move),i.push(...s.data.gameActions.jump),i.push(...s.data.gameActions.run)):"breakpoints"in s.data?s.data.breakpoints.forEach(o=>{i.push(...o.data.actions)}):"actions"in s.data&&i.push(...s.data.actions),t=t||i.some(o=>o.data.type==="Audio")})}),t}var Da=class{constructor({src:t,volume:e,delay:r,loop:i}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof t=="string"?s={src:t}:s={src:oR(t),format:"wav"},this.sound=new hR.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var H0=class{constructor(){this.type="ShapePath";this.color=new We;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new mc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,i){return this.currentPath?.quadraticCurveTo(t,e,r,i),this}bezierCurveTo(t,e,r,i,s,o){return this.currentPath?.bezierCurveTo(t,e,r,i,s,o),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function i(m,g,y,v){let x=m.x,S=g.x,w=y.x,A=v.x,M=m.y,b=g.y,T=y.y,C=v.y,P=(A-w)*(M-T)-(C-T)*(x-w),D=(S-x)*(M-T)-(b-M)*(x-w),_=(C-T)*(S-x)-(A-w)*(b-M),O=P/_,L=D/_;if(_===0&&P!==0||O<=0||O>=1||L<0||L>1)return null;if(P===0&&_===0){for(let j=0;j<2;j++)if(s(j===0?y:v,m,g),r.loc===e.ORIGIN){let V=j===0?y:v;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(x+r.t*(S-x)).toPrecision(10),H=+(M+r.t*(b-M)).toPrecision(10);return{x:V,y:H,t:r.t}}return null}else{for(let H=0;H<2;H++)if(s(H===0?y:v,m,g),r.loc===e.ORIGIN){let W=H===0?y:v;return{x:W.x,y:W.y,t:r.t}}let j=+(x+O*(S-x)).toPrecision(10),V=+(M+O*(b-M)).toPrecision(10);return{x:j,y:V,t:O}}}function s(m,g,y){let v=y.x-g.x,x=y.y-g.y,S=m.x-g.x,w=m.y-g.y,A=v*w-S*x;if(m.x===g.x&&m.y===g.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===y.x&&m.y===y.y){r.loc=e.DESTINATION,r.t=1;return}if(A<-Number.EPSILON){r.loc=e.LEFT;return}if(A>Number.EPSILON){r.loc=e.RIGHT;return}if(v*S<0||x*w<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+x*x)<Math.sqrt(S*S+w*w)){r.loc=e.BEYOND;return}let M;v!==0?M=S/v:M=w/x,r.loc=e.BETWEEN,r.t=M}function o(m,g){let y=[],v=[];for(let x=1;x<m.length;x++){let S=m[x-1],w=m[x];for(let A=1;A<g.length;A++){let M=g[A-1],b=g[A],T=i(S,w,M,b);T!==null&&y.find(C=>C.t<=T.t+Number.EPSILON&&C.t>=T.t-Number.EPSILON)===void 0&&(y.push(T),v.push(new U(T.x,T.y)))}}return v}function a(m,g,y){let v=new U;g.getCenter(v);let x=[];return y.forEach(S=>{S.boundingBox.containsPoint(v)&&o(m,S.points).forEach(A=>{x.push({identifier:S.identifier,isCW:S.isCW,point:A})})}),x.sort((S,w)=>S.point.x-w.point.x),x}function l(m,g,y,v,x){(x==null||x==="")&&(x="nonzero");let S=new U;m.boundingBox.getCenter(S);let w=[new U(y,S.y),new U(v,S.y)],A=a(w,m.boundingBox,g);A.sort((D,_)=>D.point.x-_.point.x);let M=[],b=[];A.forEach(D=>{D.identifier===m.identifier?M.push(D):b.push(D)});let T=M[0].point.x,C=[],P=0;for(;P<b.length&&b[P].point.x<T;)C.length>0&&C[C.length-1]===b[P].identifier?C.pop():C.push(b[P].identifier),P++;if(C.push(m.identifier),x==="evenodd"){let D=C.length%2===0,_=C[C.length-2];return{identifier:m.identifier,isHole:D,for:_}}else if(x==="nonzero"){let D=!0,_=null,O=null;for(let L=0;L<C.length;L++){let j=C[L];g[j]&&(D?(O=g[j].isCW,D=!1,_=j):O!==g[j].isCW&&(O=g[j].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:_}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let c=0,u=999999999,h=-999999999,d=[];this.subPaths.forEach(m=>{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,S=999999999;for(let w=0;w<g.length;w++){let A=g[w];A.y>y&&(y=A.y),A.y<v&&(v=A.y),A.x>x&&(x=A.x),A.x<S&&(S=A.x)}h<=x&&(h=x+1),u>=S&&(u=S-1),g.length&&d.push({curves:m.curves,points:g,isCW:Bu.isClockWise(g),identifier:c++,boundingBox:new qu(new U(S,v),new U(x,y))})});let f=d.map(m=>l(m,d,u,h,this.userData?.style.fillRule)),p=[];return d.forEach(m=>{let g=f[m.identifier];if(g&&!g.isHole){let y=new sa;y.curves=m.curves,f.filter(x=>x?.isHole&&x.for===m.identifier).forEach(x=>{if(x){let S=d[x.identifier],w=new mc;w.curves=S.curves,y.holes.push(w)}}),p.push(y)}}),p}};var ZA=!1,pR,JA=new Promise(n=>{pR=n}),fR=!1;var W0;function mR(){if(ZA=!0,fR)return;if(W0)return W0;async function n(){let e=await import("./opentype.js");pR(e),fR=!0}return W0=n(),W0}var xm=class{async load(t,e,r=()=>{}){let{load:i}=await JA;i(t,(s,o)=>{s||!o?r(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:r}=await JA;try{let i=e(t),s=new r,o=a=>i.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(i,i.defaultRenderOptions.features),{font:i,bidi:s}}catch(i){console.error(i)}}};async function SY(n){return await(await fetch(n)).arrayBuffer()}var wY=new xm;async function $A(n){let t,e,r=!1;if(n.url?(t=await SY(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(ZA){let i=await wY.parse(t);if(i)return{font:i.font,url:e,intercepted:r,arr:t,bidi:i.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}function AY(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var q0=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=$A(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=$A(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let i=this._bidi;i.getTextGlyphs(e);let s=i.tokenizer.tokens,o=[],a=0,l=r.length===s.length;for(let c=0;c<r.length;c++){let u=r[c].index,h=String.fromCharCode(r[c].unicode),d=s[a];if(AY(u,d)||l)o.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let f=d.char,p="",m=[d.state.glyphIndex],g=[],y=!1;for(;!y;)a++,p=e.charAt(a),f+=p,m.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(f),g.length===1&&g[0].index===u&&(y=!0),a>e.length&&(y=!0);o.push({char:h,index:u,replacements:m,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,i=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
`,e),c=e.horizontalAlign===1?l:0,u=this.computeSpaceWidthForLine(t,0,e),h=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),d=this.getLineInitialOffsetY(s,t.length,e.height,i,e.verticalAlign),f=[],p=t.map(v=>[]),m=t.map(v=>[]),g;for(let v=0;v<t.length;v++){let x=t[v],S={features:{liga:!0}},w=[];try{w=r.stringToGlyphs(x,S)}catch(M){console.warn(M)}h=this.getLineInitialOffsetX(o[v],a,e.horizontalAlign,x,l);let A=[];try{A=this.reverseLigaturesTable(r,x,w)}catch(M){console.warn(M)}u=this.computeSpaceWidthForLine(t,v,e);for(let M=0;M<w.length;M++){let b=w[M],T=b.index===0?`
`:b.unicode?String.fromCharCode(b.unicode):void 0,C=A[M],P=0,D=0;M===0&&e.horizontalAlign===2&&b.leftSideBearing!==void 0&&(D=-b.leftSideBearing*i),g&&(P=r.getKerningValue(b,g)*i),h+=D+P;let _=0;if(T===`
`)_=c;else if(T===" ")_=u;else{let O=this.createPath(b,i,h,d,e);O&&(_=O.offsetX-(P+D),f.push(O.path))}if(C.replacements.length===1)m[v].push([h,d]),p[v].push(_);else{let O=C.replacements.map(H=>(r.glyphs.get(H).advanceWidth??0)*i),L=O.reduce((H,W)=>H+=W,0),j=O.map(H=>H/L),V=h;for(let H=0;H<j.length;H++){let W=_*j[H];m[v].push([V,d]),p[v].push(W),V+=W}}h+=_,g=b}d-=s}let y=[];for(let v=0,x=f.length;v<x;v++)y.push(...f[v].toShapes());return{shapes:y,charWidths:p,lineWidths:o,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,i,s){return(r===3||r===2)&&i.indexOf(`
`)>=0&&(t-=s),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,i,s){let o=e*t,a=Math.abs(this.ascender-this.descender)*i,l=t-a,c=-this.ascender*i-l/2;return s===3?-(r-o-c):s===2?-(r*.5-o*.5-c):c}createPath(t,e,r,i,s){let o=t.getPath(r,-i,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new H0,l=(t.advanceWidth??1)*e;if(t)for(let c of o.commands){let u=a.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":a.moveTo(c.x,-c.y);break;case"L":a.lineTo(c.x,-c.y);break;case"Q":a.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":a.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return a.subPaths.forEach(c=>{let u=EY(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let i=this.getCharWidth(" ",r),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&o){let a=r.width,l=this.getTextWidth(s,r);return(a-(l-o*i))/o}}return i}countSpaces(t){return(t.match(/ /g)||[]).length}};function EY(n){if(n.length){let t=n[0];if(t instanceof rn)return t.v1;if(t instanceof tn||t instanceof qn)return t.v0}}var eE=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let i=this.objects.get(t);return i===void 0?(i=this.createObject(t,e,r),this.objects.set(t,i)):i.isShared=!0,i}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},bm=class extends eE{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let s=Ma(e,r,this.flatShading,i);return s.computeBoundingSphere(),s}};var gR={markNeedsUpdateRendererDirty:()=>{}};function Y0(n){return"variable_"+n}var tE=class extends F0{constructor(e){super();this.shared=e}create(e){return new Xd(e,this.shared)}},Hc=class{constructor(t,e={},r=!0,i=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=i;this.geometryCache=new bm(!0);this.geometryCache2=new bm(!1);this.imageHolderCache=new tE(this);this.thisContext={scene:gR,shared:this};this.deletedMaterial=new jc(ei.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Jn(jv.emptyImage,this);this.deletedVideo=new Jn(Bh.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[s,o]of Object.entries(e.images))this.addImage(s,o);if(e.videos)for(let[s,o]of Object.entries(e.videos))this.addVideo(s,o);if(e.audios)for(let[s,o]of Object.entries(e.audios))this.addAudio(s,o);if(e.particles)for(let[s,o]of Object.entries(e.particles))this.addParticle(s,o);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.data=t,this.resetLib(t.lib);for(let{id:r,data:i}of t.variables)this.addVariableHolder(r,i),e&&this.updateVariableHolder(r,i);for(let[r,i]of Object.entries(t.images))this.addImage(r,i);for(let[r,i]of Object.entries(t.videos))this.addVideo(r,i);for(let[r,i]of Object.entries(t.colors))this.addColor(r,i);for(let[r,i]of Object.entries(t.materials))this.addMaterial(r,i);for(let[r,i]of Object.entries(t.audios))this.addAudio(r,i);for(let[r,i]of Object.entries(t.particles))this.addParticle(r,i);for(let[r,i]of Object.entries(t.fonts))this.addFont(r,i)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new jc(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),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):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new _a(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Jn(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),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):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Jn(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Jn(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"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 Bl(e.r,e.g,e.b,e.a):this.colors[t]=new Bl(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();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 mr(0,0,0,0))}else return"a"in t?new mr(t.r,t.g,t.b,t.a):new mr(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Da)return e;{let r=new Da({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Da&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new q0(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Da&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let i=localStorage.getItem(Y0(t));r=i!==null?JSON.parse(i):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(Y0(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let i=this.entityOpContext.scene;for(let s=this.variables[t].locations.length-1;s>=0;s--){let o=this.variables[t].locations[s];if(o[0]==="material"){let a=o[1],l=r,c={scene:i,shared:this},u=o.slice(2);i.traverseMaterial(d=>{let f=d.root??d;f.uuid===a&&f.onVariableUpdate(u,l,c)});let h=this.materials[a];h&&h.onVariableUpdate(u,l,c)}else{let a=i.find(o[0]);if(a===void 0){this.variables[t].locations.splice(s,1);continue}if(o[1]!=="geometry"&&o[1]!=="particles"){for(let l=1;l<o.length-1;l++)a=a[o[l]];o[1]==="rotation"?a[o[o.length-1]]=r*we.DEG2RAD:a[o[o.length-1]]=r}if(a=i.find(o[0]),a.type==="ParticleEmitter"&&a.updateVariableState(r,o),yt.is(a)){if(o[1]==="position"||o[1]==="rotation"||o[1]==="scale")a.onVariableUpdate();else if(o[1]==="geometry"){let l=a;a.component&&(l=a.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(u=>{let h=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(h.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=we.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let i=this.variables[r],s=i.locations?.findIndex(o=>Or.equal(o,e));s!==void 0&&s!==-1&&i.locations.splice(s,1)}if(typeof t=="string"){let r=t,i=t;do{if(i=r,this.variables[r]===void 0)break;let s=this.variables[r].value;e&&this.variables[i]!==void 0&&this.variables[i].locations.push(e),r=s}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(Ir.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(Ir.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let i=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};i.update(s),i.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},UTe=new Hc(mn.emptyData());var ys=class extends dr{updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),j2(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[s,o]of Object.entries(e.props)){let a=i.shared.material(o);this.material[Number(s)]=a}else if(Lt(e.path,["material"])&&this.material instanceof Rn)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Ir.drop(e,1),r.material,i);else if(Lt(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&s<this.material.length){let o=r.materials[s];typeof o!="string"&&this.material[s].updateByOp(Ir.drop(e,2),o,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>r.shared.material(s).getFlavor(i.flatShading,i.side,i.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe)}disposeMaterial(){this.material&&Zy(this.material).forEach(e=>{e instanceof Rn&&(e instanceof jc||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var yR=new E,vR=new Ke,xR=new Ke,TY=new E,bR=new ce,ar=class extends ys{constructor(e,r,i){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ce().fromArray(r.bindMatrix),this.bindMatrixInverse=new ce)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof _e&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Hc){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Up.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Up.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Lt(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Ir.drop(e,1),r.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let u={...this.data.geometry,...s};this.localGeometry=Ma(u,r,this.data.flatShading,this)}let o,a,l;s.scaleBaked?[o,a,l]=s.scaleBaked:{width:o,height:a,depth:l}=s;let c=this.localGeometry.userData;c.sxPrev!==void 0&&am(this.localGeometry.attributes,o/c.sxPrev,a/c.syPrev,l/c.szPrev),c.sxPrev=o,c.syPrev=a,c.szPrev=l}else{let s={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Ma(s,r,this.data.flatShading,this)}}refreshAttachedClonersInteractions(){for(let e of this.attachedSurfaceCloners)e.update()}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,i){let s=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof ti&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(s=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),s||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Ke,i=this.geometry.attributes.skinWeight;for(let s=0,o=i.count;s<o;s++){r.fromBufferAttribute(i,s);let a=1/r.manhattanLength();a!==1/0?r.multiplyScalar(a):r.set(1,0,0,0),i.setXYZW(s,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let i=this.skeleton;if(i===void 0)return;let s=this.geometry;vR.fromBufferAttribute(s.attributes.skinIndex,e),xR.fromBufferAttribute(s.attributes.skinWeight,e),yR.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let o=0;o<4;o++){let a=xR.getComponent(o);if(a!==0){let l=vR.getComponent(o);bR.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(TY.copy(yR).applyMatrix4(bR),a)}}return r.applyMatrix4(this.bindMatrixInverse)}};function CY(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,i=e.normal.array,s=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=new E(i[o],i[o+1],i[o+2]);t.has(a)?t.get(a)?.normals.push(l):t.set(a,{normals:[l],result:new E})}t.forEach((o,a)=>{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=t.get(a)?.result;l&&(s[o]=l.x,s[o+1]=l.y,s[o+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new Te(s,3))}function PY(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=new E;for(let s=0;s<e.length;s+=3)i.set(e[s],e[s+1],e[s+2]).normalize(),r[s]=i.x,r[s+1]=i.y,r[s+2]=i.z;n.geometry.setAttribute("extrudeNormal",new Te(r,3))}function Qd(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Rn)||n.material.getLayersOfType("outline").length===0)return;n instanceof ar&&n.is2DAndNoDepth?PY(n):CY(n)}function Kd(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=parseInt(n.uuid.replace(/\D/g,"")),s=[we.seededRandom(i),we.seededRandom(i+1e4),we.seededRandom(i+2e4)];for(let o=0;o<e.length;o++)r[o]=s[o%3];n.geometry.setAttribute("randomColor",new Xe(r,3))}var Ro=new Gt,Sm=new E;function SR(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Qs=class extends ar{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new ce;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=ti.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Qd(this),Kd(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(s=>s.getFlavor(!1,s.side,s.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){ti.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&ti.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=ti.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=ti.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,dr.prototype.raycast.call(this,e,r),this.localGeometry=i}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Dr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;Ro.setFromBufferAttribute(r),Ro.getCenter(i),e.boundingSphere.radius=i.distanceTo(Ro.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ro.getSize(Sm),this.hasNonUniformScale&&Sm.divide(this.scale);let s={width:Sm.x,height:Sm.y,depth:Sm.z};return this.geometry.userData.parameters=s,s}updateBoundingSphere(e){let r=this.originalGeometry;Ro.min.set(e[0],e[2],e[4]),Ro.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Ro.min.applyMatrix4(this.shearScaleInv),Ro.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Dr);let i=r.boundingSphere.center;Ro.getCenter(i),r.boundingSphere.radius=i.distanceTo(Ro.max)}freeSubdivPointer(){this.subdivPointer&&(ti.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),this.localGeometry&&this.createGeometryByControls(r)}};var wR=-1,_Y=1,AR={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},ER={polygon_center:0,edge:1,vertex:2},wm=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,vt=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-wR)*(e-r)/(_Y-wR)+r};function MR(n){let t=[],e={};for(var r=0,i=n.length;r<i;r++){var s=JSON.stringify(n[r].pos.map(o=>Math.round(o*1e4)/1e4));e[s]||(t.push(n[r]),e[s]=!0)}return t}var DY=new E,X0=new E,OY=new E,IY=new E;function Zd(n,t){let e=OY.fromArray(n),r=IY.fromArray(t);X0.copy(r).sub(e);let i=X0.length();return X0.normalize().multiplyScalar(i*.5),DY.copy(e).add(X0).toArray()}var vs=new Mr,Q0=new E,K0=new E,Wc=new E;function TR(n){let t=[];for(let e=0;e<=n.index.count;e++)if(Q0.fromArray(n.index.array,e*3),vs.setFromAttributeAndIndices(n.attributes.position,Q0.x,Q0.y,Q0.z),vs.getNormal(K0),vs.getMidpoint(Wc),!(isNaN(Wc.x)||isNaN(Wc.y)||isNaN(Wc.z))){let{a:r,b:i,c:s}=vs,o=r.toArray(),a=i.toArray(),l=s.toArray(),c=r.distanceTo(i),u=i.distanceTo(s),h=s.distanceTo(r),d=Zd(o,a),f=Zd(a,l),p=Zd(l,o),m=[c,u,h],g=Math.max(...m),y=m.filter(S=>Math.round(S)===Math.round(g)).length>1,v=[],x=vs.getMidpoint(Wc).toArray();g===c&&!y&&(v=[f,p,p],x=d),g===u&&!y&&(v=[d,p,p],x=f),g===h&&!y&&(v=[d,f,f],x=p),y&&(v=[d,f,p]),t.push({vertices:[o,a,l],faceCenters:v,midpoint:x,norm:vs.getNormal(K0).toArray()})}return t}function CR(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){vs.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),vs.getNormal(K0),vs.getMidpoint(Wc);let i=vs.a.toArray(),s=vs.b.toArray(),o=vs.c.toArray();t.push({vertices:[i,s,o],faceCenters:[Zd(i,s),Zd(s,o),Zd(o,i)],midpoint:Wc.toArray(),norm:K0.toArray()})}return t}var RY=4,LY=.5,rE=n=>.5*(1-Math.cos(n*Math.PI)),iE=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let i=Math.floor(t),s=Math.floor(e),o=Math.floor(r),a=t-i,l=e-s,c=r-o,u,h,d=0,f=.5,p,m,g;for(let y=0;y<RY;y++){let v=i+(s<<4)+(o<<8);u=rE(a),h=rE(l),p=this.perlin[v&4095],p+=u*(this.perlin[v+1&4095]-p),m=this.perlin[v+16&4095],m+=u*(this.perlin[v+16+1&4095]-m),p+=h*(m-p),v+=256,m=this.perlin[v&4095],m+=u*(this.perlin[v+1&4095]-m),g=this.perlin[v+16&4095],g+=u*(this.perlin[v+16+1&4095]-g),m+=h*(g-m),p+=rE(c)*(m-p),d+=p*f,f*=LY,i<<=1,a*=2,s<<=1,l*=2,o<<=1,c*=2,a>=1&&(i++,a--),l>=1&&(s++,l--),c>=1&&(o++,c--)}return d}noiseSeed(t){let e=(()=>{let o,a;return{setSeed(l){a=o=(l??Math.random()*4294967296)>>>0},getSeed(){return o},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},PR=iE;var _R=new E,DR=new ce,OR=new Rs;function nE(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Jd=class extends ar{constructor(e,r,i){super(e,r,i);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(DR.copy(i).invert(),OR.copy(e.ray).applyMatrix4(DR),OR.intersectBox(this.singleBBox,_R))){let s=_R.applyMatrix4(i),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var bn=1e-4,Lo,LR,BR,NR,IR=new E,RR=new E;M0.then(n=>{Lo=n,LR=[Lo.get_face_center,Lo.get_edge_midpoint,Lo.get_vertex_position],BR=[Lo.get_face_normal,Lo.get_edge_normal,Lo.get_vertex_normal],NR=[Lo.face_count,Lo.edge_count,Lo.vertex_count]});var BY=new ce,NY=new ce,Vl=new E,Z0=new E,Am=new E,sE=new E,FY=new E,VY=new E;var Oa=new PR,Ui=class extends cd(Et){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof Rr&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof Rr&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}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);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let s=0,o=this.children.length;s<o;++s)this.remove(this.children[0]);let i=this.children;if(i.length===r)return;if(i.length<r)for(let s=0,o=r-i.length;s<o;++s){let a=new Rr(this.object);a.expand(),this.add(a)}else for(let s=0,o=i.length-r;s<o;++s)this.remove(i[s])}else{if(this.children.length===r)return;if(this.children.length<r)for(let i=0,s=r-this.children.length;i<s;++i){let o=new Rr(this.object);o.expand(),this.add(o)}else for(let i=0,s=this.children.length-r;i<s;++i)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,i=r.start*we.DEG2RAD,s=r.end*we.DEG2RAD,o=i-s,a=new rr(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new E(0,0,1);break;case"y":l=new E(0,1,0);break;default:case"x":l=new E(1,0,0);break}let c=e.randomnessObject??wo.defaultData([1,1,1]).randomnessObject,u=c.noiseType==="perlin";Oa.noiseSeed(c.seed);let h=o0((0,$d.default)(c.seed)),d=wm(c.strength,this.parameters.randomness);for(let[f,p]of this.children.entries()){let m=f*(c.freqScale/10)+c.movement,g=u?Oa.noise(m):h(m,m),y=f+1;p.scale.x=r.scale[0]+d(y,vt(g,c.scale[0]))||bn,p.scale.y=r.scale[1]+d(y,vt(g,c.scale[1]))||bn,p.scale.z=r.scale[2]+d(y,vt(g,c.scale[2]))||bn,p.position.setScalar(0);let v=o/e.count*f-i;switch(r.axis){case"x":p.rotation.set(0,v,0);break;case"y":p.rotation.set(0,0,v);break;case"z":p.rotation.set(v,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0]+d(y,vt(g,c.position[0])),p.position.y+=r.position[1]+d(y,vt(g,c.position[1])),p.position.z+=r.position[2]+d(y,vt(g,c.position[2]));let x=d(y,vt(g,c.rotation[0])),S=d(y,vt(g,c.rotation[1])),w=d(y,vt(g,c.rotation[2]));r.alignment===!0?(p.rotation.x+=a.x+x,p.rotation.y+=a.y+S,p.rotation.z+=a.z+w):p.rotation.set(a.x+x,a.y+S,a.z+w)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,i=new rr(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??wo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";Oa.noiseSeed(s.seed);let a=o0((0,$d.default)(s.seed)),l=wm(s.strength,this.parameters.randomness);for(let[c,u]of this.children.entries()){let h=c*(s.freqScale/10)+s.movement,d=o?Oa.noise(h):a(h,h),f=c+1,p=l(f,vt(d,s.rotation[0])),m=l(f,vt(d,s.rotation[1])),g=l(f,vt(d,s.rotation[2]));u.scale.x=1+(r.scale[0]-1)*c+l(f,vt(d,s.scale[0]))||bn,u.scale.y=1+(r.scale[1]-1)*c+l(f,vt(d,s.scale[1]))||bn,u.scale.z=1+(r.scale[2]-1)*c+l(f,vt(d,s.scale[2]))||bn,u.rotation.x=i.x*c+p,u.rotation.y=i.y*c+m,u.rotation.z=i.z*c+g,u.position.x=r.position[0]*c+l(f,vt(d,s.position[0])),u.position.y=r.position[1]*c+l(f,vt(d,s.position[1])),u.position.z=r.position[2]*c+l(f,vt(d,s.position[2]))}}_updateGrid(e){let r=0,i=e.grid,s=e.randomnessObject??wo.defaultData([1,1,1]).randomnessObject,o=wm(s.strength,this.parameters.randomness),a=s.noiseType==="perlin";Oa.noiseSeed(s.seed);let l=yO((0,$d.default)(s.seed));if(i.useCenter===!0){let c={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},u=new E(i.size[0]*(i.count[0]-c.x)*.5,i.size[1]*(i.count[1]-c.y)*.5,i.size[2]*(i.count[2]-c.z)*.5);for(let h=0;h<i.count[0];h++)for(let d=0;d<i.count[1];d++)for(let f=0;f<i.count[2];f++){let p=[(h+1)*(s.freqScale/10)+s.movement,(d+1)*(s.freqScale/10)+s.movement,(f+1)*(s.freqScale/10)+s.movement],m=a?Oa.noise(...p):l(...p),g=this.children[r++];g.scale.x=1+o(r,vt(m,s.scale[0]))||bn,g.scale.y=1+o(r,vt(m,s.scale[1]))||bn,g.scale.z=1+o(r,vt(m,s.scale[2]))||bn;let y=o(r,vt(m,s.rotation[0])),v=o(r,vt(m,s.rotation[1])),x=o(r,vt(m,s.rotation[2]));g.rotation.set(y,v,x),g.position.x=i.size[0]*h-u.x+o(r,vt(m,s.position[0])),g.position.y=i.size[1]*d-u.y+o(r,vt(m,s.position[1])),g.position.z=i.size[2]*f-u.z+o(r,vt(m,s.position[2]))}}else for(let c=0;c<i.count[0];c++)for(let u=0;u<i.count[1];u++)for(let h=0;h<i.count[2];h++){let d=[(c+1)*(s.freqScale/10)+s.movement,(u+1)*(s.freqScale/10)+s.movement,(h+1)*(s.freqScale/10)+s.movement],f=a?Oa.noise(...d):l(...d),p=this.children[r++];p.scale.x=1+o(r,vt(f,s.scale[0]))||bn,p.scale.y=1+o(r,vt(f,s.scale[1]))||bn,p.scale.z=1+o(r,vt(f,s.scale[2]))||bn;let m=o(r,vt(f,s.rotation[0])),g=o(r,vt(f,s.rotation[1])),y=o(r,vt(f,s.rotation[2]));p.rotation.set(m,g,y),p.position.x=i.size[0]*c+o(r,vt(f,s.position[0])),p.position.y=-i.size[1]*u+o(r,vt(f,s.position[1])),p.position.z=-i.size[2]*h+o(r,vt(f,s.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,i=new rr(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??wo.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";Oa.noiseSeed(s.seed);let a=o0((0,$d.default)(s.seed)),l=wm(s.strength,this.parameters.randomness);if(!r.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Jd)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let c=this.getSubdivData(),u=[],h=y=>{let v=y.length,x=y.map(A=>A[0]).reduce((A,M)=>A+M,0),S=y.map(A=>A[1]).reduce((A,M)=>A+M,0),w=y.map(A=>A[2]).reduce((A,M)=>A+M,0);return[x/v,S/v,w/v]},d=y=>Math.round(y*1e6)/1e6;c.forEach(y=>{let v=c.filter(x=>d(y.pos[0])===d(x.pos[0])&&d(y.pos[1])===d(x.pos[1])&&d(y.pos[2])===d(x.pos[2]));v.length>1?u.push({pos:y.pos,norm:h(v.map(x=>x.norm))}):u.push(y)});let f=MR(u);if(f.length>0){let y=Math.round(f.length*r.count/100);this._updateCount(y)}else{let y=this.objectForSample.geometry.getAttribute("position");if(!y||isNaN(y.count)||y.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let p=new a0(this.objectForSample).build(),m=AR[r.axis],g=this.children;p.setRandomGenerator((0,$d.default)(this.object.uuid+r.seed));for(let[y,v]of g.entries()){let x=y*(s.freqScale/10)+s.movement,S=o?Oa.noise(x):a(x,x),w=y+1,A=l(w,vt(S,s.rotation[0])),M=l(w,vt(S,s.rotation[1])),b=l(w,vt(S,s.rotation[2]));r.spreadType==="random"?p.sample(Am,sE):(f.length&&(Am.fromArray(f[y].pos),sE.fromArray(f[y].norm)),this.objectForSample instanceof Qs&&Am.applyMatrix4(BY.copy(this.objectForSample.matrixWorld).invert())),Am.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Am),Vl.fromArray(m);let T=r.align==="normal"?sE:this.object.getWorldDirection(VY),C=Z0.fromArray(r.position);Z0.x+=l(w,vt(S,s.position[0])),Z0.y+=l(w,vt(S,s.position[1])),Z0.z+=l(w,vt(S,s.position[2]));let P=Math.acos(T.dot(Vl)),D=FY.crossVectors(Vl,T).normalize(),_=NY.makeRotationAxis(D,P),O=T.clone().cross(this.object.up).normalize(),L=O.clone().cross(T).normalize(),j=new ce().makeBasis(O,T,L),V=new E(Vl.y,Vl.z,Vl.x).normalize(),H=V.clone().cross(Vl).normalize(),W=new ce().makeBasis(V,Vl,H).invert(),q=new ce().multiplyMatrices(j,W);v.rotation.setFromRotationMatrix(q),C.applyMatrix4(_),v.position.add(C),v.rotation.x=v.rotation.x+i.x+A,v.rotation.y=v.rotation.y+i.y+M,v.rotation.z=v.rotation.z+i.z+b,v.scale.setScalar(1),v.scale.x=v.scale.x+r.scale[0]+l(w,vt(S,s.scale[0]))||bn,v.scale.y=v.scale.y+r.scale[1]+l(w,vt(S,s.scale[1]))||bn,v.scale.z=v.scale.z+r.scale[2]+l(w,vt(S,s.scale[2]))||bn,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Qs){let r=this.objectForSample,i=ER[e],s=NR[i],o=LR[i],a=BR[i],l=[],c=s(r.subdivPointerNew);for(let u=0;u<=c-1;u++){let h=o(r.subdivPointerNew,u),d=a(r.subdivPointerNew,u);IR.fromArray(h).applyMatrix4(r.matrixWorld),RR.fromArray(d),l.push({pos:IR.toArray(),norm:RR.toArray()})}return l}else return(this.objectForSample.geometry.index?TR(this.objectForSample.geometry):CR(this.objectForSample.geometry)).map((i,s)=>e==="polygon_center"?{pos:i.midpoint,norm:i.norm}:e==="vertex"?[{pos:i.vertices[0],norm:i.norm},{pos:i.vertices[1],norm:i.norm},{pos:i.vertices[2],norm:i.norm}]:e==="edge"?[{pos:i.faceCenters[0],norm:i.norm},{pos:i.faceCenters[1],norm:i.norm},{pos:i.faceCenters[2],norm:i.norm}]:[]).flat()}updateState(e,r){if(this.parameters=ha(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let i=r.find(this.parameters.toObject.object);i instanceof dr?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new ce,this.hiddenMatrix=new ce,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var Bo=n=>{var t;return t=class extends n{},t.geometryHelper=new hi(30,30,30),t};var J0=new Rs,oE=new Dr,FR=new ce,No=(n,t,e,r,i=!1,s=n)=>{let o=t,a=s.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),oE.copy(o.boundingSphere),oE.applyMatrix4(a),e.ray.intersectsSphere(oE)===!1||(FR.copy(a).invert(),J0.copy(e.ray).applyMatrix4(FR),o.boundingBox!==null&&J0.intersectsBox(o.boundingBox)===!1))return;let l,c,u,h,d=o.index,f=o.attributes.position,p=o.drawRange,m,g;if(i===!1){let v=Math.max(0,p.start),x=Math.min(d.count,p.start+p.count);for(m=v,g=x;m<g;m+=3)if(c=d.getX(m),u=d.getX(m+1),h=d.getX(m+2),l=y(n,e,J0,f,c,u,h),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let x=o.attributes.position,S=new E,w=new E,A=new E,M=new E,b=2,C=1/((s.scale.x+s.scale.y+s.scale.z)/3),P=C*C,D=Math.max(0,p.start),_=Math.min(x.count,p.start+p.count);for(let O=D,L=_-1;O<L;O+=b){if(S.fromBufferAttribute(x,O),w.fromBufferAttribute(x,O+1),J0.distanceSqToSegment(S,w,M,A)>P)continue;M.applyMatrix4(s.matrixWorld);let V=e.ray.origin.distanceTo(M);V<e.near||V>e.far||r.push({distance:V,point:A.clone().applyMatrix4(s.matrixWorld),object:n})}}function y(v,x,S,w,A,M,b){let T=new E,C=new E,P=new E,D=new E,_=new E;if(T.fromBufferAttribute(w,A),C.fromBufferAttribute(w,M),P.fromBufferAttribute(w,b),S.intersectTriangle(T,C,P,!1,D)===null)return null;_.copy(D),_.applyMatrix4(v.matrixWorld);let L=x.ray.origin.distanceTo(_);return L<x.near||L>x.far?null:{faceIndex:1,distance:L,point:_.clone(),object:v}}};var $0=new E,xs=new Wn,aE=class extends Ja{constructor(e){let r=new _e,i=new ss({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new We(15711266),c=new We(15711266),u=new We(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",c),h("p","n2",c),h("p","n3",c),h("p","n4",c),h("u1","u2",u),h("u2","u3",u),h("u3","u1",u);function h(f,p,m){d(f,m),d(p,m)}function d(f,p){s.push(0,0,0),o.push(p.r,p.g,p.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}r.setAttribute("position",new Te(s,3)),r.setAttribute("color",new Te(o,3));super(r,i);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,i=!0;xs.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Ks("n1",r,e,xs,-s,-o,a),Ks("n2",r,e,xs,s,-o,a),Ks("n3",r,e,xs,-s,o,a),Ks("n4",r,e,xs,s,o,a);let l=a;Ks("f1",r,e,xs,-s,-o,l),Ks("f2",r,e,xs,s,-o,l),Ks("f3",r,e,xs,-s,o,l),Ks("f4",r,e,xs,s,o,l);let c=l,u=.5;Ks("u1",r,e,xs,s*.7*u,o*1.1,c),Ks("u2",r,e,xs,-s*.7*u,o*1.1,c),Ks("u3",r,e,xs,0,o*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ks(n,t,e,r,i,s,o){$0.set(i,s,o).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],$0.x,$0.y,$0.z)}}var ex=class extends Bo(aE){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){No(this.object,this.geometry,e,r,!0)}};var tx;(t=>t.is=e=>"objectHelper"in e)(tx||(tx={}));var bs=(n,t)=>class extends hd(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,s){this.objectHelper.raycast(i,s)}showGizmos(){for(let i in this.gizmos){let s=this.gizmos[i];s instanceof sl&&(s.visible=!0)}}updateEntityBoxSize(i,s){this.objectHelper.visible&&this.geometryHelper instanceof hi?(i.setScalar(0),s.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,s)}hideGizmos(){for(let i in this.gizmos){let s=this.gizmos[i];s instanceof sl&&(s.visible=!1)}}};var rx=790,ef=new E,lE=new E,cE=new Qe,uE=new E,Em=new E,hE=new E,xr=class extends bs(Wn,ex){constructor(e="",r={..._c.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=xl.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ce,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,s=this.height;this.orthoCamera=new Ka(i*-.5,i*.5,s*.5,s*-.5,-5e4,1e4),this.perspCamera=new Kr(45,i/s,50,1e4),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.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}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,r,i){typeof e=="number"&&(e=new E(e,r,i)),super.lookAt(e),this.getWorldPosition(ef),this.targetOffset=ef.distanceTo(e)}getTarget(e=new E){return this.getWorldDirection(lE),this.getWorldPosition(ef),lE.multiplyScalar(this.targetOffset),e.copy(ef).add(lE),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(ef),ef.distanceTo(e)}updateUp(){this.getWorldQuaternion(cE),uE.set(0,0,1).applyQuaternion(cE),Em.copy(Et.DEFAULT_UP),this.isUpVectorFlipped&&Em.negate(),Em.applyQuaternion(cE),hE.copy(Et.DEFAULT_UP).projectOnPlane(uE),this.angleOffsetFromUp=hE.angleTo(Em),this.angleOffsetFromUp*=hE.cross(Em).dot(uE)>=0?1:-1}updateTransformState(e,r){let i=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let r=e.getWorldPosition(new E),s=e.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new E,i=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,i=!1){if(this.aspect=e/r,i){let s=e>r?this.aspect:1,o=e>r?1:this.aspect;this.left=-rx*.5*s,this.right=rx*.5*s,this.top=rx*.5*(1/o),this.bottom=-rx*.5*(1/o)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){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.objectHelper&&this.objectHelper.update()}toPerspective(){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.objectHelper&&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,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,s,o,a):this.orthoCamera.setViewOffset(e,r,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}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.parent=e.parent,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 Ah(r,e)}updateCameraSubtype(e,r){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(i,r.zoom),r.near!==void 0&&this.setNear(i,r.near),r.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),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()}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var tf=new ce,UY=new ce;function dE(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var Ln=class extends ys{constructor(e,r,i){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new _e;this.onAfterRender=(e,r,i,s,o,a)=>{super.onAfterRender(e,r,i,s,o,a),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];o instanceof Ln&&o.dataPatched.visible===!0&&o.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(o instanceof dr&&o.dataPatched.visible===!0&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0&&o.booleanMeshSetAddress!==0){tf.multiplyMatrices(o.hiddenMatrix,o.matrix);try{if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=ms.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;ms.transformMeshSet(o.booleanMeshSetAddress,tf),o.booleanMatrixInvOld.copy(tf).invert(),o.booleanWasTransformed=!1}else o instanceof Ln&&o.needsTransformForDownstream===!0?(ms.transformMeshSet(o.booleanMeshSetAddress,tf),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(ms.transformMeshSet(o.booleanMeshSetAddress,UY.multiplyMatrices(tf,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(tf).invert(),o.booleanWasTransformed=!1)}catch(a){console.error(a),o.booleanMeshSetAddress=0,o.geometry.userData.booleanOperationDidFail=!0;continue}ms.hasOpenEdges(o.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(o.booleanMeshSetAddress),o.geometry.userData.booleanOperationDidFail=!1):o.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Te([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return ms.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new _e,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=ms.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Qd(this),Kd(this)}dispose(){super.dispose(),this.geometry.dispose()}};var ix;(t=>{function n(e){return yt.is(e)&&e instanceof il}t.is=n})(ix||(ix={}));var rf=(n,t)=>class extends bs(n,t){updateState_Light(r,i){this.updateState_Entity(r,i),r.color!==void 0&&(this.color=i.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var sn=n=>n instanceof dr,Sn=n=>n!==null&&n instanceof Ln,VR=n=>n instanceof xr,zR=n=>ix.is(n),Mm=n=>tx.is(n);var kY=new E(1,1,1),UR=new E,GY=new E,kR=new Qe,Ss=class extends Bo(xy){constructor(e,r=15){super(r);this.object=e;this.dummy=new En;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){No(this.object,Ss.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(UR,kR,GY),this.matrix.compose(UR,kR,kY),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var ws=class extends bs(En,Ss){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var zl=class extends bs(En,Ss){constructor(e,r,i){super();this.super_Entity(e,r),this.context=i,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var XR={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Tm="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var jY=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;uniform vec4 kernel64[32];varying vec2 vUv;void main(){
#ifdef FOREGROUND
vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale;
#else
float CoC=texture2D(cocBuffer,vUv).g*scale;
#endif
if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{
#ifdef FOREGROUND
vec2 step=texelSize*max(CoC,CoCNearFar.g*scale);
#else
vec2 step=texelSize*CoC;
#endif
vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0;}}`,nx=class extends st{constructor(n=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:n?"2":"1"},uniforms:{kernel64:new ue(null),kernel16:new ue(null),inputBuffer:new ue(null),cocBuffer:new ue(null),texelSize:new ue(new U),scale:new ue(1)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:jY,vertexShader:Tm}),this.toneMapped=!1,t&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}set cocBuffer(n){this.uniforms.cocBuffer.value=n}setCoCBuffer(n){this.uniforms.cocBuffer.value=n}get scale(){return this.uniforms.scale.value}set scale(n){this.uniforms.scale.value=n}getScale(n){return this.uniforms.scale.value=n}setScale(n){this.uniforms.scale.value=n}generateKernel(){let n=2.39996323,t=new Float32Array(128),e=new Float32Array(32),r=0,i=0;for(let a=0;a<80;++a){let l=a*n,c=Math.sqrt(a)/Math.sqrt(80),u=c*Math.cos(l),h=c*Math.sin(l);a%5===0?(e[i++]=u,e[i++]=h):(t[r++]=u,t[r++]=h)}let s=[],o=[];for(let a=0;a<128;)s.push(new Ke(t[a++],t[a++],t[a++],t[a++]));for(let a=0;a<32;)o.push(new Ke(e[a++],e[a++],e[a++],e[a++]));this.uniforms.kernel64.value=s,this.uniforms.kernel16.value=o}setTexelSize(n,t){this.uniforms.texelSize.value.set(n,t)}setSize(n,t){this.uniforms.texelSize.value.set(1/n,1/t)}};function GR(n,t,e){return n*(t-e)-t}function yE(n,t,e){return Math.min(Math.max((n+t)/(t-e),0),1)}var HY=`#include <common>
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}void main(){float depth=readDepth(vUv);
#ifdef PERSPECTIVE_CAMERA
float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
#else
float linearDepth=depth;
#endif
float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,WY=class extends st{constructor(n){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ue(null),focusDistance:new ue(0),focusRange:new ue(0),cameraNear:new ue(.3),cameraFar:new ue(1e3)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:HY,vertexShader:Tm}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(n)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,t=Ii){this.depthBuffer=n,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(n){this.uniforms.focusDistance.value=n}get worldFocusDistance(){return-GR(this.focusDistance,this.near,this.far)}set worldFocusDistance(n){this.focusDistance=yE(-n,this.near,this.far)}getFocusDistance(n){this.uniforms.focusDistance.value=n}setFocusDistance(n){this.uniforms.focusDistance.value=n}get focalLength(){return this.focusRange}set focalLength(n){this.focusRange=n}get focusRange(){return this.uniforms.focusRange.value}set focusRange(n){this.uniforms.focusRange.value=n}get worldFocusRange(){return-GR(this.focusRange,this.near,this.far)}set worldFocusRange(n){this.focusRange=yE(-n,this.near,this.far)}getFocalLength(n){return this.focusRange}setFocalLength(n){this.focusRange=n}adoptCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof Kr?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},qY=`#include <common>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25;
#include <encodings_fragment>
#include <dithering_fragment>
}`,YY="uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",jR=class extends st{constructor(n=new U){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new ue(null),texelSize:new ue(new U),halfTexelSize:new ue(new U),kernel:new ue(0),scale:new ue(1)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:qY,vertexShader:YY}),this.toneMapped=!1,this.setTexelSize(n.x,n.y)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.inputBuffer=n}get scale(){return this.uniforms.scale.value}set scale(n){this.uniforms.scale.value=n}getScale(){return this.uniforms.scale.value}setScale(n){this.uniforms.scale.value=n}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(n){this.uniforms.kernel.value=n}setKernel(n){this.kernel=n}setTexelSize(n,t){this.uniforms.texelSize.value.set(n,t),this.uniforms.halfTexelSize.value.set(n,t).multiplyScalar(.5)}setSize(n,t){let e=this.uniforms;e.texelSize.value.set(1/n,1/t),e.halfTexelSize.value.copy(e.texelSize.value).multiplyScalar(.5)}},XY=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;
#include <encodings_fragment>
}`,QY=class extends st{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new ue(null),opacity:new ue(1)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:XY,vertexShader:Tm}),this.toneMapped=!1}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}};var KY=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
#if THREE_REVISION < 143
#define luminance(v) linearToRelativeLuminance(v)
#endif
#if EDGE_DETECTION_MODE != 0
varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
#endif
#if EDGE_DETECTION_MODE == 1
#include <common>
#endif
#if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}
#elif PREDICATION_MODE == 2
uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);}
#endif
#if PREDICATION_MODE != 0
vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);}
#endif
#if EDGE_DETECTION_MODE != 0
uniform sampler2D inputBuffer;
#endif
void main(){
#if EDGE_DETECTION_MODE == 0
const vec2 threshold=vec2(DEPTH_THRESHOLD);
#elif PREDICATION_MODE != 0
vec2 threshold=calculatePredicatedThreshold();
#else
const vec2 threshold=vec2(EDGE_THRESHOLD);
#endif
#if EDGE_DETECTION_MODE == 0
vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0);
#elif EDGE_DETECTION_MODE == 1
float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
#elif EDGE_DETECTION_MODE == 2
vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
#endif
}`,ZY=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
#if EDGE_DETECTION_MODE != 0
varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
#endif
void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0);
#if EDGE_DETECTION_MODE != 0
vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0);
#endif
gl_Position=vec4(position.xy,1.0,1.0);}`,nf={DEPTH:0,LUMA:1,COLOR:2},JY={DISABLED:0,DEPTH:1,CUSTOM:2},$Y=class extends st{constructor(n=new U,t=nf.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:oa.replace(/\D+/g,""),LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new ue(null),depthBuffer:new ue(null),predicationBuffer:new ue(null),texelSize:new ue(n)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:KY,vertexShader:ZY}),this.toneMapped=!1,this.edgeDetectionMode=t}set depthBuffer(n){this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,t=Ii){this.depthBuffer=n,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(n){this.defines.EDGE_DETECTION_MODE=n.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(n){this.edgeDetectionMode=n}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(n){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=n.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(n){this.localContrastAdaptationFactor=n}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(n){this.defines.EDGE_THRESHOLD=n.toFixed("6"),this.defines.DEPTH_THRESHOLD=(n*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(n){this.edgeDetectionThreshold=n}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(n){this.defines.PREDICATION_MODE=n.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(n){this.predicationMode=n}set predicationBuffer(n){this.uniforms.predicationBuffer.value=n}setPredicationBuffer(n){this.uniforms.predicationBuffer.value=n}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(n){this.defines.PREDICATION_THRESHOLD=n.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(n){this.predicationThreshold=n}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(n){this.defines.PREDICATION_SCALE=n.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(n){this.predicationScale=n}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(n){this.defines.PREDICATION_STRENGTH=n.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(n){this.predicationStrength=n}setSize(n,t){this.uniforms.texelSize.value.set(1/n,1/t)}},eX=`#include <common>
#include <packing>
#include <dithering_pars_fragment>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;
#if THREE_REVISION < 143
#define luminance(v) linearToRelativeLuminance(v)
#endif
#if THREE_REVISION >= 137
vec4 sRGBToLinear(const 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.a);}
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
}FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0;
#ifdef ENCODE_OUTPUT
#include <encodings_fragment>
#endif
#include <dithering_fragment>
}`,tX="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}",Zs={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},vE=class extends st{constructor(n,t,e,r,i=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:oa.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new ue(null),depthBuffer:new ue(null),resolution:new ue(new U),texelSize:new ue(new U),cameraNear:new ue(.3),cameraFar:new ue(1e3),aspect:new ue(1),time:new ue(0)},blending:Zt,depthWrite:!1,depthTest:!1,dithering:i}),this.toneMapped=!1,n&&this.setShaderParts(n),t&&this.setDefines(t),e&&this.setUniforms(e),this.adoptCameraSettings(r)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,t=Ii){this.depthBuffer=n,this.depthPacking=t}setShaderParts(n){return this.fragmentShader=eX.replace(Zs.FRAGMENT_HEAD,n.get(Zs.FRAGMENT_HEAD)).replace(Zs.FRAGMENT_MAIN_UV,n.get(Zs.FRAGMENT_MAIN_UV)).replace(Zs.FRAGMENT_MAIN_IMAGE,n.get(Zs.FRAGMENT_MAIN_IMAGE)),this.vertexShader=tX.replace(Zs.VERTEX_HEAD,n.get(Zs.VERTEX_HEAD)).replace(Zs.VERTEX_MAIN_SUPPORT,n.get(Zs.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(n){for(let t of n.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(n){for(let t of n.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(n){this.extensions={};for(let t of n)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof Kr?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,t){let e=this.uniforms;e.resolution.value.set(n,t),e.texelSize.value.set(1/n,1/t),e.aspect.value=n/t}static get Section(){return Zs}};var rX=`#include <common>
#if THREE_REVISION < 143
#define luminance(v) linearToRelativeLuminance(v)
#endif
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef RANGE
uniform vec2 range;
#elif defined(THRESHOLD)
uniform float threshold;uniform float smoothing;
#endif
varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);
#ifdef RANGE
float low=step(range.x,l);float high=step(l,range.y);l*=low*high;
#elif defined(THRESHOLD)
l=smoothstep(threshold,threshold+smoothing,l);
#endif
#ifdef COLOR
gl_FragColor=vec4(texel.rgb*l,l);
#else
gl_FragColor=vec4(l);
#endif
}`,iX=class extends st{constructor(n=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:oa.replace(/\D+/g,"")},uniforms:{inputBuffer:new ue(null),threshold:new ue(0),smoothing:new ue(1),range:new ue(null)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:rX,vertexShader:Tm}),this.toneMapped=!1,this.colorOutput=n,this.luminanceRange=t}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},nX=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef MASK_PRECISION_HIGH
uniform mediump sampler2D maskTexture;
#else
uniform lowp sampler2D maskTexture;
#endif
#if MASK_FUNCTION != 0
uniform float strength;
#endif
varying vec2 vUv;void main(){
#if COLOR_CHANNEL == 0
float mask=texture2D(maskTexture,vUv).r;
#elif COLOR_CHANNEL == 1
float mask=texture2D(maskTexture,vUv).g;
#elif COLOR_CHANNEL == 2
float mask=texture2D(maskTexture,vUv).b;
#else
float mask=texture2D(maskTexture,vUv).a;
#endif
#if MASK_FUNCTION == 0
#ifdef INVERTED
mask=step(mask,0.0);
#else
mask=1.0-step(mask,0.0);
#endif
#else
mask=clamp(mask*strength,0.0,1.0);
#ifdef INVERTED
mask=1.0-mask;
#endif
#endif
#if MASK_FUNCTION == 2
gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
#else
gl_FragColor=mask*texture2D(inputBuffer,vUv);
#endif
}`,QR={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},sX=class extends st{constructor(n=null){super({name:"MaskMaterial",uniforms:{maskTexture:new ue(n),inputBuffer:new ue(null),strength:new ue(1)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:nX,vertexShader:Tm}),this.toneMapped=!1,this.setColorChannel(XR.RED),this.setMaskFunction(QR.DISCARD)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}set maskTexture(n){this.uniforms.maskTexture.value=n,delete this.defines.MASK_PRECISION_HIGH,n.type!==Cr&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(n){this.maskTexture=n}set colorChannel(n){this.defines.COLOR_CHANNEL=n.toFixed(0),this.needsUpdate=!0}setColorChannel(n){this.colorChannel=n}set maskFunction(n){this.defines.MASK_FUNCTION=n.toFixed(0),this.needsUpdate=!0}setMaskFunction(n){this.maskFunction=n}get inverted(){return this.defines.INVERTED!==void 0}set inverted(n){this.inverted&&!n?delete this.defines.INVERTED:n&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(n){this.inverted=n}get strength(){return this.uniforms.strength.value}set strength(n){this.uniforms.strength.value=n}getStrength(){return this.strength}setStrength(n){this.strength=n}};var oX=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
#if __VERSION__ < 300
#define round(v) floor(v + 0.5)
#endif
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x>end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x<end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.y>end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;i++){if(!(texCoord.y<end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
#if !defined(DISABLE_CORNER_DETECTION)
vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0);
#endif
}void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
#if !defined(DISABLE_CORNER_DETECTION)
vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0);
#endif
}void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){
#if !defined(DISABLE_DIAG_DETECTION)
weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){
#endif
vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d);
#if !defined(DISABLE_DIAG_DETECTION)
}else{e.r=0.0;}
#endif
}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,aX="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",lX=class extends st{constructor(n=new U,t=new U){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new ue(null),searchTexture:new ue(null),areaTexture:new ue(null),resolution:new ue(t),texelSize:new ue(n)},blending:Zt,depthWrite:!1,depthTest:!1,fragmentShader:oX,vertexShader:aX}),this.toneMapped=!1}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(n){this.uniforms.searchTexture.value=n}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(n){this.uniforms.areaTexture.value=n}setLookupTextures(n,t){this.searchTexture=n,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(n){let t=Math.min(Math.max(n,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(n){this.orthogonalSearchSteps=n}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(n){let t=Math.min(Math.max(n,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(n){this.diagonalSearchSteps=n}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(n){n?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(n){this.diagonalDetection=n}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(n){let t=Math.min(Math.max(n,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(n){this.cornerRounding=n}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(n){n?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(n){this.cornerDetection=n}setSize(n,t){let e=this.uniforms;e.texelSize.value.set(1/n,1/t),e.resolution.value.set(n,t)}};var cX=new Wn,Ul=null;function uX(){if(Ul===null){let n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);Ul=new _e,Ul.setAttribute!==void 0?(Ul.setAttribute("position",new Xe(n,3)),Ul.setAttribute("uv",new Xe(t,2))):(Ul.addAttribute("position",new Xe(n,3)),Ul.addAttribute("uv",new Xe(t,2)))}return Ul}var pi=class{constructor(n="Pass",t=new bi,e=cX){this.name=n,this.renderer=null,this.scene=t,this.camera=e,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(n){if(this.rtt===n){let t=this.getFullscreenMaterial();t!==null&&(t.needsUpdate=!0),this.rtt=!n}}setRenderer(n){this.renderer=n}isEnabled(){return this.enabled}setEnabled(n){this.enabled=n}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(n){let t=this.screen;t!==null?t.material=n:(t=new Xt(uX(),n),t.frustumCulled=!1,this.scene===null&&(this.scene=new bi),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(n){this.fullscreenMaterial=n}getDepthTexture(){return null}setDepthTexture(n,t=Ii){}render(n,t,e,r,i){throw new Error("Render method not implemented!")}setSize(n,t){}initialize(n,t,e){}dispose(){for(let n of Object.keys(this)){let t=this[n];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof bi||t===this.renderer)continue;this[n].dispose()}}}},Cm=class extends pi{constructor(n,t=!0){super("CopyPass"),this.fullscreenMaterial=new QY,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new dt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=t}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,t,e,r,i){this.fullscreenMaterial.inputBuffer=t.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,t){this.autoResize&&this.renderTarget.setSize(n,t)}initialize(n,t,e){e!==void 0&&(this.renderTarget.texture.type=e,e!==Cr?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n.outputEncoding===at&&(this.renderTarget.texture.encoding=at))}};var KR=class extends pi{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,t,e,r,i){let s=n.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},fE=new We,xE=class extends pi{constructor(n=!0,t=!0,e=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=t,this.stencil=e,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,t,e){this.color=n,this.depth=t,this.stencil=e}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,t,e,r,i){let s=this.overrideClearColor,o=this.overrideClearAlpha,a=n.getClearAlpha(),l=s!==null,c=o>=0;l?(fE.copy(n.getClearColor(fE)),n.setClearColor(s,c?o:a)):c&&n.setClearAlpha(o),n.setRenderTarget(this.renderToScreen?null:t),n.clear(this.color,this.depth,this.stencil),l?n.setClearColor(fE,a):c&&n.setClearAlpha(a)}},kl=-1,Nn=class extends hr{constructor(n,t=kl,e=kl,r=1){super(),this.resizable=n,this.base=new U(1,1),this.preferred=new U(t,e),this.target=this.preferred,this.s=r}get width(){let{base:n,preferred:t,scale:e}=this,r;return t.width!==kl?r=t.width:t.height!==kl?r=Math.round(t.height*(n.width/Math.max(n.height,1))):r=Math.round(n.width*e),r}set width(n){this.preferredWidth=n}get height(){let{base:n,preferred:t,scale:e}=this,r;return t.height!==kl?r=t.height:t.width!==kl?r=Math.round(t.width/Math.max(n.width/Math.max(n.height,1),1)):r=Math.round(n.height*e),r}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferred.setScalar(kl),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.base.width}set baseWidth(n){this.base.width!==n&&(this.base.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(n){this.base.width!==n&&(this.base.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(n){this.base.height!==n&&(this.base.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,t){(this.base.width!==n||this.base.height!==t)&&(this.base.set(n,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(n){this.preferred.width!==n&&(this.preferred.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferred.height}set preferredHeight(n){this.preferred.height!==n&&(this.preferred.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,t){(this.preferred.width!==n||this.preferred.height!==t)&&(this.preferred.set(n,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(n){this.base.set(n.getBaseWidth(),n.getBaseHeight()),this.preferred.set(n.getPreferredWidth(),n.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return kl}},pE=!1,HR=class{constructor(n=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(n),this.meshCount=0,this.replaceMaterial=t=>{if(t.isMesh){let e;if(t.material.flatShading)switch(t.material.side){case ji:e=this.materialsFlatShadedDoubleSide;break;case ui:e=this.materialsFlatShadedBackSide;break;default:e=this.materialsFlatShaded;break}else switch(t.material.side){case ji:e=this.materialsDoubleSide;break;case ui:e=this.materialsBackSide;break;default:e=this.materials;break}this.originalMaterials.set(t,t.material),t.isSkinnedMesh?t.material=e[2]:t.isInstancedMesh?t.material=e[1]:t.material=e[0],++this.meshCount}}}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){let t=this.materials=[n.clone(),n.clone(),n.clone()];for(let e of t)e.uniforms=Object.assign({},n.uniforms),e.side=Gn;t[2].skinning=!0,this.materialsBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},n.uniforms),r.side=ui,r}),this.materialsDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},n.uniforms),r.side=ji,r}),this.materialsFlatShaded=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},n.uniforms),r.flatShading=!0,r}),this.materialsFlatShadedBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},n.uniforms),r.flatShading=!0,r.side=ui,r}),this.materialsFlatShadedDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},n.uniforms),r.flatShading=!0,r.side=ji,r})}}render(n,t,e){let r=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,pE){let i=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),n.render(t,e);for(let s of i)s[0].material=s[1];this.meshCount!==i.size&&i.clear()}else{let i=t.overrideMaterial;t.overrideMaterial=this.material,n.render(t,e),t.overrideMaterial=i}n.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of n)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return pE}static set workaroundEnabled(n){pE=n}},hX=class extends pi{constructor(n,t,e=null){super("RenderPass",n,t),this.needsSwap=!1,this.clearPass=new xE,this.overrideMaterialManager=e===null?null:new HR(e),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){let n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){let t=this.overrideMaterialManager;n!==null?t!==null?t.setMaterial(n):this.overrideMaterialManager=new HR(n):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,t,e,r,i){let s=this.scene,o=this.camera,a=this.selection,l=o.layers.mask,c=s.background,u=n.shadowMap.autoUpdate,h=this.renderToScreen?null:t;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(n,t),n.setRenderTarget(h),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,s,o):n.render(s,o),o.layers.mask=l,s.background=c,n.shadowMap.autoUpdate=u}},bE=class extends pi{constructor(n,t,{resolutionScale:e=1,width:r=Nn.AUTO_SIZE,height:i=Nn.AUTO_SIZE,renderTarget:s}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new hX(n,t,new lp({depthPacking:lw}));let o=this.renderPass;o.skipShadowMapUpdate=!0,o.ignoreBackground=!0;let a=o.getClearPass();a.overrideClearColor=new We(16777215),a.overrideClearAlpha=1,this.renderTarget=s,this.renderTarget===void 0&&(this.renderTarget=new dt(1,1,{minFilter:Vt,magFilter:Vt,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new Nn(this,r,i,e);l.addEventListener("change",c=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,t,e,r,i){let s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,s)}setSize(n,t){let e=this.resolution;e.setBaseSize(n,t),this.renderTarget.setSize(e.width,e.height)}};var W_e=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var Ct={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},dX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",fX="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",pX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",mX="float blend(const in float x,const in float y){return(y==0.0)?y:max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",gX="float blend(const in float x,const in float y){return(y==1.0)?y:min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",yX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",vX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",xX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",bX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",SX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",wX="float blend(const in float x,const in float y){return(y>0.0)?min(x/y,1.0):1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",AX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",EX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",MX="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",TX="float blend(const in float x,const in float y){return(y==1.0)?y:min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",CX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",PX="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",_X="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",DX=new Map([[Ct.SKIP,null],[Ct.ADD,dX],[Ct.ALPHA,fX],[Ct.AVERAGE,pX],[Ct.COLOR_BURN,mX],[Ct.COLOR_DODGE,gX],[Ct.DARKEN,yX],[Ct.DIFFERENCE,vX],[Ct.EXCLUSION,xX],[Ct.LIGHTEN,bX],[Ct.MULTIPLY,SX],[Ct.DIVIDE,wX],[Ct.NEGATION,AX],[Ct.NORMAL,EX],[Ct.OVERLAY,MX],[Ct.REFLECT,TX],[Ct.SCREEN,CX],[Ct.SOFT_LIGHT,PX],[Ct.SUBTRACT,_X]]),OX=class extends hr{constructor(n,t=1){super(),this.f=n,this.opacity=new ue(t)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this.f}set blendFunction(n){this.f=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return DX.get(this.blendFunction)}},Fo={NONE:0,DEPTH:1,CONVOLUTION:2};var Vo=class extends hr{constructor(n,t,{attributes:e=Fo.NONE,blendFunction:r=Ct.SCREEN,defines:i=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=n,this.renderer=null,this.attributes=e,this.fragmentShader=t,this.vertexShader=a,this.defines=i,this.uniforms=s,this.extensions=o,this.blendMode=new OX(r),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,t=Ii){}update(n,t,e){}setSize(n,t){}initialize(n,t,e){}dispose(){for(let n of Object.keys(this)){let t=this[n];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof bi||t===this.renderer)continue;this[n].dispose()}}}};function WR(n,t,e){for(let r of t){let i="$1"+n+r.charAt(0).toUpperCase()+r.slice(1),s=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let o of e.entries())o[1]!==null&&e.set(o[0],o[1].replace(s,i))}}function IX(n,t,e,r,i,s,o){let a=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=a.get("fragment")!==void 0&&/mainImage/.test(a.get("fragment")),c=a.get("fragment")!==void 0&&/mainUv/.test(a.get("fragment")),u=[],h=[],d=!1,f=!1;if(a.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(c&&(o&Fo.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(!l&&!c)console.error("The fragment shader contains neither a mainImage nor a mainUv function",t);else{let p=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,m=vE.Section;if(c){let y=` ${n}MainUv(UV);
`;e.set(m.FRAGMENT_MAIN_UV,e.get(m.FRAGMENT_MAIN_UV)+y),d=!0}if(a.get("vertex")!==null&&/mainSupport/.test(a.get("vertex"))){let y=` ${n}MainSupport(`;y+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a.get("vertex"))?`vUv);
`:`);
`,e.set(m.VERTEX_MAIN_SUPPORT,e.get(m.VERTEX_MAIN_SUPPORT)+y),u=u.concat([...a.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(v=>v[1])),h=h.concat(u).concat([...a.get("vertex").matchAll(p)].map(v=>v[1]))}h=h.concat([...a.get("fragment").matchAll(p)].map(y=>y[1])),h=h.concat([...t.defines.keys()].map(y=>y.replace(/\([\w\s,]*\)/g,""))),h=h.concat([...t.uniforms.keys()]),t.uniforms.forEach((y,v)=>s.set(n+v.charAt(0).toUpperCase()+v.slice(1),y)),t.defines.forEach((y,v)=>i.set(n+v.charAt(0).toUpperCase()+v.slice(1),y)),WR(n,h,i),WR(n,h,a);let g=t.blendMode;if(r.set(g.blendFunction,g),l){let y=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,v=`${n}MainImage(color0, UV, `;(o&Fo.DEPTH)!==0&&y.test(a.get("fragment"))&&(v+="depth, ",f=!0),v+=`color1);
`;let x=n+"BlendOpacity";s.set(x,g.opacity),v+=`color0 = blend${g.blendFunction}(color0, color1, ${x});
`,e.set(m.FRAGMENT_MAIN_IMAGE,e.get(m.FRAGMENT_MAIN_IMAGE)+v),v=`uniform float ${x};
`,e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+v)}e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+a.get("fragment")+`
`),a.get("vertex")!==null&&e.set(m.VERTEX_HEAD,e.get(m.VERTEX_HEAD)+a.get("vertex")+`
`)}return{varyings:u,transformedUv:d,readDepth:f}}var qc=class extends pi{constructor(n,...t){super("EffectPass"),this.fullscreenMaterial=new vE(null,null,null,n),this.effects=t.sort((e,r)=>r.attributes-e.attributes),this.skipRendering=!1,this.uniformCount=0,this.varyingCount=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){let t=this.fullscreenMaterial;t.dithering=n,t.needsUpdate=!0}verifyResources(){let n=this.renderer.capabilities,t=Math.min(n.maxFragmentUniforms,n.maxVertexUniforms);this.uniformCount>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniformCount+" were defined"),t=n.maxVaryings,this.varyingCount>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let n=vE.Section,t=new Map([[n.FRAGMENT_HEAD,""],[n.FRAGMENT_MAIN_UV,""],[n.FRAGMENT_MAIN_IMAGE,""],[n.VERTEX_HEAD,""],[n.VERTEX_MAIN_SUPPORT,""]]),e=new Map,r=new Map,i=new Map,s=new Set,o=0,a=0,l=0,c=!1,u=!1;for(let d of this.effects)if(d.blendMode.blendFunction===Ct.SKIP)l|=d.getAttributes()&Fo.DEPTH;else if((l&d.getAttributes()&Fo.CONVOLUTION)!==0)console.error("Convolution effects cannot be merged",d);else{l|=d.getAttributes();let f="e"+o++,p=IX(f,d,t,e,r,i,l);if(a+=p.varyings.length,c=c||p.transformedUv,u=u||p.readDepth,d.extensions!==null)for(let m of d.extensions)s.add(m)}let h=/\bblend\b/g;for(let d of e.values()){let f=d.getShaderCode().replace(h,`blend${d.blendFunction}`);t.set(n.FRAGMENT_HEAD,t.get(n.FRAGMENT_HEAD)+f+`
`)}if((l&Fo.DEPTH)!==0){if(u){let d=`float depth = readDepth(UV);
`;t.set(n.FRAGMENT_MAIN_IMAGE,d+t.get(n.FRAGMENT_MAIN_IMAGE))}this.needsDepthTexture=this.getDepthTexture()===null}else this.needsDepthTexture=!1;if(c){let d=`vec2 transformedUv = vUv;
`;t.set(n.FRAGMENT_MAIN_UV,d+t.get(n.FRAGMENT_MAIN_UV)),r.set("UV","transformedUv")}else r.set("UV","vUv");t.forEach((d,f,p)=>p.set(f,d.trim().replace(/^#/,`
#`))),this.uniformCount=i.size,this.varyingCount=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(t).setExtensions(s).setUniforms(i).setDefines(r)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,t=Ii){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=t;for(let e of this.effects)e.setDepthTexture(n,t)}render(n,t,e,r,i){for(let s of this.effects)s.update(n,t,r);if(!this.skipRendering||this.renderToScreen){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,s.time+=r,n.setRenderTarget(this.renderToScreen?null:e),n.render(this.scene,this.camera)}}setSize(n,t){this.fullscreenMaterial.setSize(n,t);for(let e of this.effects)e.setSize(n,t)}initialize(n,t,e){this.renderer=n;for(let r of this.effects)r.initialize(n,t,e),r.addEventListener("change",i=>this.handleEvent(i));this.updateMaterial(),this.verifyResources(),e!==void 0&&e!==Cr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let n of this.effects)n.dispose()}handleEvent(n){switch(n.type){case"change":this.recompile();break}}},RX=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],ox=class extends pi{constructor({resolutionScale:n=.5,width:t=Nn.AUTO_SIZE,height:e=Nn.AUTO_SIZE,kernelSize:r=Pm.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new dt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let i=this.resolution=new Nn(this,t,e,n);i.addEventListener("change",s=>this.setSize(i.baseWidth,i.baseHeight)),this.blurMaterial=new jR,this.ditheredBlurMaterial=new jR,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=r}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get scale(){return this.blurMaterial.scale}set scale(n){this.blurMaterial.scale=n}getScale(){return this.blurMaterial.scale}setScale(n){this.blurMaterial.scale=n}getKernelSize(){return this.kernelSize}setKernelSize(n){this.kernelSize=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,t,e,r,i){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,c=RX[this.kernelSize],u=this.blurMaterial,h=t,d,f;for(this.fullscreenMaterial=u,d=0,f=c.length-1;d<f;++d){let p=(d&1)===0?a:l;u.kernel=c[d],u.inputBuffer=h.texture,n.setRenderTarget(p),n.render(s,o),h=p}this.dithering&&(u=this.ditheredBlurMaterial,this.fullscreenMaterial=u),u.kernel=c[d],u.inputBuffer=h.texture,n.setRenderTarget(this.renderToScreen?null:e),n.render(s,o)}setSize(n,t){let e=this.resolution;e.setBaseSize(n,t);let r=e.width,i=e.height;this.renderTargetA.setSize(r,i),this.renderTargetB.setSize(r,i),this.blurMaterial.setSize(r,i),this.ditheredBlurMaterial.setSize(r,i)}initialize(n,t,e){e!==void 0&&(this.renderTargetA.texture.type=e,this.renderTargetB.texture.type=e,e!==Cr?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):n.outputEncoding===at&&(this.renderTargetA.texture.encoding=at,this.renderTargetB.texture.encoding=at))}static get AUTO_SIZE(){return Nn.AUTO_SIZE}};var LX=class extends pi{constructor({width:n=Nn.AUTO_SIZE,height:t=Nn.AUTO_SIZE,renderTarget:e,luminanceRange:r,colorOutput:i}={}){super("LuminancePass"),this.fullscreenMaterial=new iX(i,r),this.needsSwap=!1,this.renderTarget=e,this.renderTarget===void 0&&(this.renderTarget=new dt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1);let s=this.resolution=new Nn(this,n,t);s.addEventListener("change",o=>this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,t,e,r,i){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,t){let e=this.resolution;e.setBaseSize(n,t),this.renderTarget.setSize(e.width,e.height)}initialize(n,t,e){e!==void 0&&e!==Cr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},ZR=class extends pi{constructor(n,t){super("MaskPass",n,t),this.needsSwap=!1,this.clearPass=new xE(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,t,e,r,i){let s=n.getContext(),o=n.state.buffers,a=this.scene,l=this.camera,c=this.clearPass,u=this.inverted?0:1,h=1-u;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,u,4294967295),o.stencil.setClear(h),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?c.render(n,null):(c.render(n,t),c.render(n,e))),this.renderToScreen?(n.setRenderTarget(null),n.render(a,l)):(n.setRenderTarget(t),n.render(a,l),n.setRenderTarget(e),n.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}};var Bn=class extends pi{constructor(n,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=n,this.inputBufferUniform=null,this.setInput(t)}setInput(n){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let t=this.fullscreenMaterial.uniforms;t!==void 0&&t[n]!==void 0&&(this.inputBufferUniform=t[n])}}render(n,t,e,r,i){this.inputBufferUniform!==null&&t!==null&&(this.inputBufferUniform.value=t.texture),n.setRenderTarget(this.renderToScreen?null:e),n.render(this.scene,this.camera)}initialize(n,t,e){e!==void 0&&e!==Cr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},mE=1/1e3,BX=1e3,JR=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(n){return this.fixedDeltaEnabled=n,this}isAutoResetEnabled(n){return this.autoReset}setAutoResetEnabled(n){return typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=n),this}getDelta(){return this.delta*mE}getFixedDelta(){return this.fixedDelta*mE}setFixedDelta(n){return this.fixedDelta=n*BX,this}getElapsed(){return this.elapsed*mE}getTimescale(){return this.timescale}setTimescale(n){return this.timescale=n,this}update(n){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=n!==void 0?n:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(n){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}};var Pm={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var NX=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D map;
#else
uniform lowp sampler2D map;
#endif
uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`,$R=class extends Vo{constructor({blendFunction:n=Ct.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:e=.025,resolutionScale:r=.5,intensity:i=1,width:s=Nn.AUTO_SIZE,height:o=Nn.AUTO_SIZE,kernelSize:a=Pm.LARGE}={}){super("BloomEffect",NX,{blendFunction:n,uniforms:new Map([["map",new ue(null)],["intensity",new ue(i)]])}),this.renderTarget=new dt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.luminancePass=new LX({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=e,this.blurPass=new ox({resolutionScale:r,width:s,height:o,kernelSize:a});let l=this.blurPass.getResolution();l.addEventListener("change",c=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(n){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(n){this.uniforms.get("intensity").value=n}getIntensity(){return this.intensity}setIntensity(n){this.intensity=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}update(n,t,e){let r=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(n,t,r),this.blurPass.render(n,r,r)):this.blurPass.render(n,t,r)}setSize(n,t){let e=this.resolution;e.setBaseSize(n,t),this.renderTarget.setSize(e.width,e.height),this.luminancePass.resolution.copy(e)}initialize(n,t,e){this.blurPass.initialize(n,t,e),e!==void 0&&(this.renderTarget.texture.type=e,n.outputEncoding===at&&(this.renderTarget.texture.encoding=at))}};var FX="uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}",e3=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,brightness:t=0,contrast:e=0}={}){super("BrightnessContrastEffect",FX,{blendFunction:n,uniforms:new Map([["brightness",new ue(t)],["contrast",new ue(e)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(n){this.uniforms.get("brightness").value=n}getBrightness(n){return this.brightness}setBrightness(n){this.brightness=n}get contrast(){return this.uniforms.get("contrast").value}set contrast(n){this.uniforms.get("contrast").value=n}getContrast(n){return this.contrast}setContrast(n){this.contrast=n}},VX="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",t3=class extends Vo{constructor(n=Ct.NORMAL){super("ColorAverageEffect",VX,{blendFunction:n})}};var zX="varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}",UX="uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vUvR=uv+shift;vUvB=uv-shift;}",r3=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,offset:t=new U(.001,5e-4)}={}){super("ChromaticAberrationEffect",zX,{vertexShader:UX,blendFunction:n,attributes:Fo.CONVOLUTION,uniforms:new Map([["offset",new ue(t)]])})}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}};var kX=`#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
#else
uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
#endif
uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,i3=class extends Vo{constructor(n,{blendFunction:t=Ct.NORMAL,worldFocusDistance:e,worldFocusRange:r,focusDistance:i=0,focalLength:s=.1,focusRange:o=s,bokehScale:a=1,width:l=Nn.AUTO_SIZE,height:c=Nn.AUTO_SIZE}={}){super("DepthOfFieldEffect",kX,{blendFunction:t,attributes:Fo.DEPTH,uniforms:new Map([["nearColorBuffer",new ue(null)],["farColorBuffer",new ue(null)],["nearCoCBuffer",new ue(null)],["scale",new ue(1)]])}),this.camera=n,this.renderTarget=new dt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new Bn(new WY(n));let u=this.cocMaterial;u.focusDistance=i,u.focusRange=o,e!==void 0&&(u.worldFocusDistance=e),r!==void 0&&(u.worldFocusRange=r),this.blurPass=new ox({kernelSize:Pm.MEDIUM,width:l,height:c});let h=this.blurPass.getResolution();h.addEventListener("change",f=>this.setSize(h.getBaseWidth(),h.getBaseHeight())),this.maskPass=new Bn(new sX(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=QR.MULTIPLY,d.colorChannel=XR.GREEN,this.bokehNearBasePass=new Bn(new nx(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new Bn(new nx(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new Bn(new nx(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new Bn(new nx(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=a}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(n){let t=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let e of t)e.fullscreenMaterial.setScale(n);this.maskPass.fullscreenMaterial.setStrength(n),this.uniforms.get("scale").value=n}getBokehScale(){return this.bokehScale}setBokehScale(n){this.bokehScale=n}getTarget(){return this.target}setTarget(n){this.target=n}calculateFocusDistance(n){let t=this.camera,e=t.position.distanceTo(n);return yE(-e,t.near,t.far)}setDepthTexture(n,t=Ii){this.circleOfConfusionMaterial.depthBuffer=n,this.circleOfConfusionMaterial.depthPacking=t}update(n,t,e){let r=this.renderTarget,i=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let a=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=a}this.cocPass.render(n,null,i),this.blurPass.render(n,i,s),this.maskPass.render(n,t,o),this.bokehFarBasePass.render(n,o,r),this.bokehFarFillPass.render(n,r,this.renderTargetFar),this.bokehNearBasePass.render(n,t,r),this.bokehNearFillPass.render(n,r,this.renderTargetNear)}setSize(n,t){let e=this.resolution;e.setBaseSize(n,t);let r=e.width,i=e.height,s=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];s.push(this.renderTargetCoC,this.renderTargetMasked),s.forEach(a=>a.setSize(n,t)),s=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],s.forEach(a=>a.setSize(r,i)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.fullscreenMaterial.setSize(r,i))}initialize(n,t,e){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(i=>i.initialize(n,t,e)),this.blurPass.initialize(n,t,Cr),e!==void 0&&(this.renderTarget.texture.type=e,this.renderTargetNear.texture.type=e,this.renderTargetFar.texture.type=e,this.renderTargetMasked.texture.type=e,n.outputEncoding===at&&(this.renderTarget.texture.encoding=at,this.renderTargetNear.texture.encoding=at,this.renderTargetFar.texture.encoding=at,this.renderTargetMasked.texture.encoding=at))}};var i2e=new E,n2e=new ce;var GX="uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",n3=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,hue:t=0,saturation:e=0}={}){super("HueSaturationEffect",GX,{blendFunction:n,uniforms:new Map([["hue",new ue(new E)],["saturation",new ue(e)]])}),this.hue=t}get saturation(){return this.uniforms.get("saturation").value}set saturation(n){this.uniforms.get("saturation").value=n}getSaturation(){return this.saturation}setSaturation(n){this.saturation=n}get hue(){let n=this.uniforms.get("hue").value;return Math.acos((n.x*3-1)/2)}set hue(n){let t=Math.sin(n),e=Math.cos(n);this.uniforms.get("hue").value.set((2*e+1)/3,(-Math.sqrt(3)*t-e+1)/3,(Math.sqrt(3)*t-e+1)/3)}getHue(){return this.hue}setHue(n){this.hue=n}};var a2e=new We;var jX=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));
#ifdef PREMULTIPLY
outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
#else
outputColor=vec4(noise,inputColor.a);
#endif
}`,s3=class extends Vo{constructor({blendFunction:n=Ct.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",jX,{blendFunction:n}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(n){this.premultiply!==n&&(n?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(n){this.premultiply=n}};var HX="uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}",o3=class extends Vo{constructor(n=30){super("PixelationEffect",HX,{uniforms:new Map([["active",new ue(!1)],["d",new ue(new U)]])}),this.resolution=new U,this.d=0,this.granularity=n}get granularity(){return this.d}set granularity(n){let t=Math.floor(n);t%2>0&&(t+=1),this.d=t,this.uniforms.get("active").value=t>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(n){this.granularity=n}setSize(n,t){this.resolution.set(n,t),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};var u2e=Math.PI*.5,h2e=new E,d2e=new E;var qR="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",YR="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8AcC2AhRIoDXbsYb48dl5WkVFTE3LGDcC9m4CZCWBuFFgeAZaGAYJQQCRqDHT+McJrVb8zwATUXH02MHYfMHEIGFsAxgjApQqACYQORjtd/B7Axt/z79sC0+cMPgjjlwPwVwHcA+DfAHzTxcVgWBroqMN8+cYBeM71wH0TwKExYHYUWCIAHYRLTlkCYgcIBcAgU/n3qy8GRu4HRgnAOWBkERhddPAJhGJDBxkvw7cqimr+zFM/ZLnZF64cgL8BYD+AWwB8x/dlWuWagHiYL984AJ/0RWBy1AE4AizyM1yxYAcTigW55xMbAkxEiwEdkJ/ZCQxPAiOHgBECcKEC4TBZcKkSv+mTieNcNPNC26mLNsj45QD8LQDTAO4GcJt/7iw2bfoG4WG+vAGwm9ExiEg69zpg/wgwPQLMjgALzn4E4aIzoJjQ9g4024uygkj+pyuAoX0VAIfngOH5NgCHMhAm8Sv2y3XDZeBhNIp8OzJE8OsBzAKYBHAXgDt8/4O+MVT0j4f58o0D8Pxrgf3DwMwIMEPQEYRkNwfgsuuDZLskip0No0gWMD/9HGDoADAkAC4Aw/wsAgZAgs2Z0ABI0GU6IVmKv+f28KDnHxkA/G0A8y6G73N9kOCjXnh/Ebb6OvgwX75xAF5wLTA1VIHPADgMLDj4yIA5AAm6aCUnv4oz46eeDwxNAUMzwJAz4BABSNDFTwSfg7DDKHE23MG5PqIY8A1u/dINs9dBdy8AgnGPM2NfUBrsnw7z5RsH4IXXAAcJviFgluAbygBINnSLWOAjGxJ4pgOKDV0v/OSLKp8iGXBovhLBBOCQM2ACoTOhnYrAdItYbCij5JFzRyIAqRccAnDAQUjg6UNQ7hsMXP0cRQAexss3DsCLCECCLwCQzMcPwUi2MwAScAKbfnY/YRLFQ8DHX+IAJAMSfDkAF13kLvleIjhjQQHxUVS3jjgGpKeeNzYVQEjgUS8k+PghONdhIwAP4+XXBYCHKIJbwJyDTgaIAdCBJx3Q2M8tYAHP9m4df/ylQOsQ0JqtRLCx30K1wtLBggScQOgsKBGcWHAJeOwRC0BSM1mQIKRbhh+Bj98JQP6t4U0APEyXXxcAEnxkQAFwoVUxID9kvQg+c1C7vidRbIDkc24B//hTQGumDcCWA5DgMxASdNIFBUI5pCML8v8API5zfEQx4BudgqiczviSnJhQwCP4BMCGl+wO8+U7AJi/W4O4YS6+pmK/2ciADsAOBhTIIiAJnPB7AvNjP+0AnANaYkAHX2JBAc+tYaJXOqBZv24Vc386XW5dtkHGW+4HFAJonpOe+YYQZAShgKjv3PNvPQaxVoI8zJdfFwASfPzMUwS3Kt1v0UFIlos6oDFdAGFcliMAP/ryAEAGNwQRnDOgLbdlIEwrIs6AZ/QgkMMHQF6ZAKQcJAsSYPwIeAIk9wJgoPK1gi7+PwF4GC/fOAAvIQPSs0URTPBJ/Pp3GSEGRHfBCIQ0xowBtUbcAj7ys5X4Jfu1HIAGQrIgQRXEsAFQIORDFhiDY/rMHmrU4QUgR08AkgUjCAW6CD6CkwBsAIQC4GG6fPMA3OXiNzCg2I9gNCMksmAAoemDzoimFwL48M85AKkiuQVMAAp8CYRRDAt8GQiJ67N6GJODAXAHlsGguscA2AJg1IPGYmxOpBxFWkRN9LsATgIwXnNs/v/5z/9XCf8BO3YAtxbc/46/KDt+5+ea1Yku2VUxHz/z0v24FwMGK1gWsK2OUUxHHdCBeRUB6OxHABr4ZICIBd0QWSF+XRdMTAjgCdTrG9cBNwE4F8CpDkICyYLGsuhFt6zs+gISwUen8zEAjgMw4cfx2H6O/90yAFo84Cbg4ID3/9TfLTt+5+ebnRABkODjx0SwPi5ec/FrYpmqSAxM8Dn60CsqAFI6GfhqAMiDE/gokmvEr0C4PgDkBQm40wE8zMFEUDKEVoxIMLl/KS73mE7H9d+vcKHQQcjwW0Yu9nP8m8sAmOIBuWY6wP2/4s0ezjjg8TuvaR6ABJ70vxUApGrm7EbGE+i472BAB+WHfqHS/eoAaEwY2E9+wLSXTqhI7CXgnB6LCoOJ4BiST+hTnG0HcCwAglCx3ARoZEVFXnBPp/O/A/hXACc7CPs9/i1lAOyIB+RDX+P9/+pbQjjjAMfv/PL6AFDs1wFAgs/9fgKfgdE/ZEpuiQlbwAde6QAMBgiRmsSwA9BY0JfjovGRDBMH4TlcXGhcBOc6HkF0gjPhZgchxTLZMAci/04W/B6Ab3t09EPXcPyflgFwRTwgJ2MN9/8bf5qFM67x+B/aW4XQz42FeL0YrRyikztUFw0704mf9kXgxhOAqc3AAsPyRxxQCs/PdXOFY0W1KHy3QIUGtx+6vdnx1vsB+dsTncm2AogglFgVEAlUWrOMB2RyEmMCGQ/Y7/HvKns6tfGAnJQ+r/9b76oJZ1zD8WdyQjYBh8aBhVEHjELouQ8ukQ7VRSCJAALwkr+sALhnGzDD3JAJYJHg9uhoi4bx8ytkWUtvHT/7+Zc4dw1uZ3612fH2dkQf7yxIEEockwkJQn4IQoq8unhAhmPRKKFx0uv4K8ueTs94wD7u//VX9ghn7OP4c+4G7h8HpseB+dF2AKlFLwuAIZ8jD6NPrOhAffmfA9/ZBuzZCkyRWSeqBCWyoYGQ5yQrBpDbum/ME1HoPo0XEkSD2zlfbna8q6+EUJcTCxKEtHL5EQjP6BEPyIgYAZBvYt3xHyx7OqvGA65y/7/9wVXCGVc5/sl7qxD66dEqiYgRzAqhN1A4CBNAAlDyAFI+iZ9/N3DLJuC+jcDUBmCWyUnOrmTYCMIOkNclLg0B8/RsNLg9+UvNjnd1APLmmQpFHyEBROuWACQT8nN+H/GAvY7/VNnT6SsesMf13/CpahGnZzhjj+PPmwX2MYdDIfQexWyBAwEUOQDrRDN/98p3A7dvAO6fAA5sqHJDBEAyoUVGkwEd6HR12XU4kwzfl6fCXTZzjy57vvnR513X7Hj7AyDvggAUi9EyFgiZqNxPQF6345nOWbD1HQ/Y5fpvuLa/2+82/vNHgAPDFQDnhoF5j2C2qBWCI8bw1eRw5CL5l94L3DEOTI4DB8Y9OWmsEu/zBJ3rgsaybqBob/7A4C7jtWcooRrczr+u2fH2D0AOQgAUCxKEP7aGgLy64+m6KdjWFA9Yc/03/Osa4glrjr+AupqHz1sEs0cxG0BC9HIePLoit9eNkVf9L+DuUWByDJgaq4ybGYLPAWgiXmLedUE7dwC7saL7CqfPKXi4NYdaykCD410bAHlDEsNiwZ9wAPYbkJcfz6T2gm3N8YDZ9d/wHxUA+739fPwXPrSKYGb+BuP3jAFDElFH9HIWwbzCIGkBr/or4J4RYO8oMOW6ZVcAuvi1Cgoha04BCwT5gfMKHm7NoRde2+x41w5A3hQZkADk5+cGiAeMx3+/7AENFA8Yrv/G71cAXFM4Yzj+otOAaQLQA0gZxaIIZtMDFTigKJV8H9Iq6aZ59ZXAvSPAvpEKgBTtBODcSCWCZeRYtpzrmLyeGNCAyFl1v+Hei8qeb370Rdc2O97BAMi7EgB/2QG41nhAHU9LuWAbOB7Qr//GPRUA13r7Gv9FZwIMoVcEswEwfDoimEP0shKKtIphaZQAXv1+YM+wA3DEdcvRKkGJADQQEsQuhi1Tjt95vBsh5nx2IO59SsHDrTmUOStNjndwAAqEry0IyCMICkOyiuIBNwBvPFQQT7gBuPjc9oRYAIHyOEL4vIFEYVNaOou5vCGE/tV/A0wOVcnpzI47NOri3QFIBpSeaSDUdYLOSWvYImSGgftpJDa4MWJbAGxivGUA5MAOc0Be6eVLj7/4Mk+hzCOYPYpZDBiNkLh+G/M3yFyv/ltgL3W3YQfgcFUhgRY2PwY+Z7/EhAR1SFyXCOb57r28QfQBsJQBMn5D4y0HYLPje9Cd7RIC0PM3EiMofF4gVCBp1P840ix/gyz56r+vAMjk9Gl375iB4+CzveuZdLkkEPJ8ZEfX/6R73vOjzT5Si9hucLxHAVg4PwJgRwh9CKOXK8YA4ZEqKZXSQWh5P+5AftXfA/uGKvYjCKn72cctbFrZNECka5L5CPwIPtMH3TVz17MLB5gdLgA2Nd6jACycHwLQxFEUSR5ASvARDB0h9AQb9bXIgCGk6lUfAPYTgEPAITKgg1BObk58srTJgG58WMkWMaAbQQT1nc8rHGANAJsc71EAFs4PAagQestgC1lsBJ4BMCSOK6dDUcwqqaFiQr/0QeAAAdjy+jBiQQeeMSBZT3nCPUDIa9z+/MIB1gCwyfEeBWDh/BCAeQSzgkjFfGLBBD5nxQ4DxN0wv3hVxX5TBGDwL5obxvVA5YqYL5BeMLd66YYxJpRB0gK+96LCAdYAsMnxHgVg4fwIgMrhUPKQ2C+Bz0PmBTqBMQehAbDlIjj4F80KJguSVZ0FuXpjoCOgXawLjALhbT9eOMAuAGxqvEcBWDg/l1IE05Ed0ygZnyHdz0VwCqEPIfNyx0QQvvLDFQCp+8nfZk5und8tXwIgWcHSNX0N2CJmnAl3v6RwgNnhl17T7HiPArBwfghAS7mV/hey2JS9FvM3BLpUUi1YwDRMXvkRYJoAlAh2l0dcZ04s6JUTDIjyBcrl4yDc/dLCAdYAsMnxHgVg4fxwKVwJgGEJNmWtxpQMpX9on2eRhVA+O56AjMfnP+e3Xvf3NwG4xIPTleiY55bpGh6UbafNU0l0z0p+5Jh5HqYJ6b51nP6XP8cx12XNHQVgIQB/bFPVg2OC7Q+WgVFWng/FvtWLI06uWh5oguKEcXVS/9sEAF//VGD7t4ETDgJbF4CNi8CGZWBs2fPL/H6Vwp2KEtVk4fJ+v/EIYPN9wKa5qu+IncfPwXHVZe/aOL3EbwS7xv8A1rQvnO0j8PArTgTGZ4BxFv9mIxhOCGsv+0OPYDRghcLfkWkEuq0+G00x4OtfDGz+d2DbHmDLjL8si8AYP/7CGIAiEEMTG92zXqSbH+d9R2aA0XnvO+JjthiIrOVDHHPOkBrzUQAWAPsZp3oPDpa/Xag6EVkLBK+5rAnJC3/nYk/APD704WiEAV8OTHwX2LQH2DgFbJgFNrBhjd8r79deGoEwsllgNBOzy8CdjweG9wBj08AIAci2D6HafmyAk4/Z7SJ72hGYRwFYAMDLTwOGp4FRFgD3HhzqRGQiyeurqOdG6r0Rm8IEZjzRlkiqCWoEgK8Axm4BJu4HJhyAbFhDxmbDGnZO4j0SgLGDkpibgEq66TJw/1nA0F5gdLpq+zDqFfd5LMeWqu5HNST0uJOIllg+qgMWgI+HPv0xwLA3gWHpW2sC441gCECbmKziaGrnUdMO4aHeh6MxAP4SMHI7ML4HGD8AjHvHJGNAgpDgY/ck3stipRemvVhc+uASMPUEYGh/9dIRgGx8Y+MNbR/00uVtH0wEx94j/v0oAxaA8Ed+GBieAYZZg5kADC0QWGOFzGJlcGPzl1BxNLXD8sk4xftwNAbA/wwM3wGMUmxOOQBnHXzetIYvibonmSiuYTNjriVg7glAiwBk0fNZH6+PmX9P6kfNmCXGpftJ7TgKwBIAnln14BAAYxMYm5C6RjCyCoOyr0qkD/c+HI0B8DXA8N3AyCQwesD1VQKH7EcASm1Q+y4CkN9pUKiVF5nLvy+fBbTUd8QBaH1HvNBROiZvfsNnrF4kcvPwpdsBLBeU18Nf7AB23Dp4ecHC8oBgUlJJecLS+7+WOpE3gbE+HKw+yoevCYkMGKqPJrdEKARutaFYRs1fiEZ0wP8CDN8LDO8FRqYq3W10pgKgfYLaYCzootgA6KXaTA90y374TKB1sBozy77xHFZ536utRgAmEaw6g5kUSFZwSXnA330qsOlfgHMPDlZesLA8IOjoLypPWHj/11EnCiVwkz7kAExtsGraYUWdSDX5TmsagL8KDBGA7Bd30JsW0oWivnEOQNP7yGTSBR101AlZSUtGyfgZDkCWY1HnJdcBVe6325hTvelg2CQjZNDygG/2An0j1wKnL6y9vGBheUC8prQ8YeH9X39OVQSc7Mc6fCaKvAeHdCIVf4yMYCynTpX+nb97NJmlSQb8r8DQHm9YOFUZTKOzoXGhs6AxF0HIexcLBvWBuiHN8s2ne98R3qc6L4Vyb2oBVjfm9MIFHbjDCh6kPOBbQoG+oW8CO5bWVl6wsDwgfr20PGHh/X/1iaEIuDcCTIW/1Q4rFv8OnYiW3c+W2iKwUjKbyjQNwL1uuR6sAEgDgq1brXOmV81PxhNB6DUDBSYzQJwFtz623XcktX1Q1VWKaTF/zZhVazBVYA1tX5MazsGvobwe/jQr0Ne6BTh5uf/ygoXlAfG60vKEhff/rSe1i4DnTWDUACY1guFTDqLYdCBvf6DJYSMYATBfOx1kLfj1v1axH10nQ3Sd0GUkBnTfpemtBJgseIKQAHLQcVxa2TnuMW0Aqui5es8xBIegVdVVE8VhzHnLh65WMB9An+X18K6aAn2tO4ETl6vqbKuVFywsDwhevqg8YeH93/Rk70JE90nowxZbIJjvS3WYNSGUwGHJTpPxwwcbBuBrgRYBeKACn7VtpdUu/c0NJxO9BIxcKu4TTODzbkonPLoaL0vyUQRb2y8HsL1ckfWzMeuFi40Qezqi+yiPhyt7FOjr6/gCFwgP7Xb5vssTFt7/nQRg6MGRWmDRoeyTlpgw68GRTwgZgo1gGmXAX6/8dtaylSKY/koyID9BhzML3q1gAos2AcOrZYSoq/pJp1VtODRm9Z3LS/7WjVkvXOzEtOpKyGrlAT+4SoG+VY8vBGCvy/dVnrDw/vee65NBJiAjBIVcAJQjOm+DkCZEeiGAMw6sAwDZsJrAdhFM9rPGhd4904Co5oVuCZPV6kD40Ec6+9W8dBTBsfdc3nkpvnB82fp2RPcs79dHgb51LA9ofsDV6vut5/3PnxcAmLVBiDqgevDaJLkYrpuQxzcNwN8AWgIgRbB8loEBzXDwl4cGiDGft58SCOWGedgjvOJ+bPvgRkiuA+ZjzhnQQOiFNVbloa7l/fos0LdO5QENgEXlCfs8Qbf7HyMA3QVjYihYhLENgjX9y/qwxQmRU/asfd0ZcLU2CHVGyusJQLKfVi98CS12T5f7iECkHpsMkAhCF8+nshWH2I/jXsOYO144GV/9ApAIrS3vt4YCfetQHtAA2G+/4PW4/2PPbzMgmUMi2NoeSCRxIt2/FvuxWURIWCXg357gfTjEDNIHnTRXRCpH5ugKwGl3HpMBXQc0v6WLYVm/5limj04rG762K2uYY9jBkr9+rI03NL5ZbczS/dJ+LQyoga4o77fGAn0NlwdMAOy3vl/T938KAcj121z8Bn+Y9eWQJRz8Y6kNagDh2ey5EvxjxQD8TWdAuneCCO4An1vw5vdzQMmdktwq7pLZQR+dM34+ZumAxvY1Y04uqOAJ6FsExzeto7zfAAX6GiwPaLWR1lrfr8n7f/Rl3QGzmsis+/uO71V9OFgP2gpPhgr7TGRqRUT6dyvr4aIs/pm/2zVUNbBSv6G8e5pEv0Cvec7Po7+bTtjlBRlkvAMBkDeQyvsNWKCvofKACYBrre/X1P0/oWEAnnFD1YdjhtXxR73mX10FfCHHE9pVWcGAI/S0gKsfA2y+twrFZw6Hxf/F0Pk8Ri/kpGSnMuDx5T0iACgQHioo0NdAecBUHW6QdsV2/cL7v/Cyqr5gnc42CCOcfX1VIZ/V8We9IDmTzVXwPDJiXuKXPxtDBma8+lzP4WAgKkPxCUAPE4v5GzEuMX0PYJPLhB6FJsc7MAMmkVxaYC/K9gG+F1++8AQ7Gwbgk78I7GFpXgIwFiRXOwaJZPUbiR0yCUDRk+cHf+YpwMj9HgfI8ClGPyvsSiH0WSKRuYlitLb/zHM/JOSs5C/YIC9cMQDZr/dwxgOW9gtGYUBi0wA8l304vDQvAchilFbpIBQhZ7Ejq6ZQ0/Yhil8y4j89Axie9DAsD6FX9HOK3QtROTFkviN83kG4felIY8DCeLrSeMDSfsEovAECUFsTjHD+tcB+tkFgcXKvBRir7qtFl9owmO4Xy/1G3bAFfPrZHorFNWBFwHjQAFctIghj2kBarw06If/+MM9ZqTN6DgsDojCerjQesLRfMApvoGkAWh8Ob/tgAPSKWCp8ngNQtadjmTdltvNvn3peFYhgQQgh+iUmEaUAUoXM1yRLmWuFLaE9Z+XIAWBhPF1pPGBpv2AU3kDTALzwmqo6qtVh9kJErAudABia38TC5wJgS2xIhAwBn3yhByL4EhzXfRXxYsDTJ4IvrNN2JFMxZcBzVo4cABbG05XGA5b2C0bhDTQNQLZBYH1AVsQSAAU+imI1obHyblnjG/kJk3U8BHz8xVUQAhnQIl5CyNgKAGp5LKSSCoAySh5Jj79vTagcxUaIBeRNe79g9gq+DXig4wGzy+PONfT7RWFA4noAkGXZVAhcBckJQgNgrLiaNb3paIDo1vHHX+oA9LQBi4DxJcOUPJUnTgU2NJUyROs8irGARxQAC+PpCtsFd40H/AEf0gMQkLgeACT41PiGoLOKqyrJq3K/Ya9mNyr5FusN/uPLPIeDa8Bc+w3rtyl4VFHaMZc3i9RWBM9jjzgAFsbTFbYLRmm/YBTeQNMAtD4cBKDXBTQGdAB2MGBo8SCLmEuS1AFVAJ3A/NhPt0PoCcA8bSDG76XI7aySg6JYuGfKwJHFgH0E5B3ueMCe/Y4L+xVHAOZ+9EHcEgQgwbeiEYx6jwTdz4qfu7EhEJqxGqruf/RnHIAEnxgwBM0aC8aUAYWNBRCmoIll4HTqO122QcZbrgMWxtMVtgvuOx6wa7/jwhtoGoDWh4MBJ16WN4lfr8AqI0TVV1O1fa9BbQzovkAy4Ed+NgCQUSxZCFWvCOaOFREXyUwZOPIA2GdA3uGOB6wPaOz+QPv5S+MA3OXiN9aclghW+d3IgupBF2pPqxcxGenDPxfSRh2ASiKKiVP2PaZScvAKoA0VDc6cOlIB2GdA3uGOB1zR77iwX/F6AFB9ONSOQW0frA50sILVcckWJyIDSgwPAVcJgFbYuZ3FJvAlEHbJ3IsgJLGedeBIA+AAAXmHOx6wo99xYb/i9QKg2iAIfDJEJHqj4SExbEty0gkdhB/6P9oZbBZIGiKYVb9GKaN50lRHBLOvhDxh/5EKwDUG5B3ueMB2QGM/grb7/6wHAPNGMAY+GSGUjC52VX2f2CD4+HO0gqkZfegXKgBaHkcWtS0AWii9xG1ImrLlN5XR8L8fmQD05BVrmEENmpYSP9QX+KHiqj2/82+HqqDWwnbBRfGATdzAegGwru2DpRq7Mzq2fpAf0Nq0Rl2wBXzglZ4yUAPAmDSVWDBPHQjLcgTqOZ6zUvdKHh4ruDCerox/Dnu7YqwXAC1NI/QcEQuK6WK/kdgCTGC0PYAP/KIDMBgglq+hIkrOfsaCviLSofcJgJ5AdM7kkSaCj/HqQKVIGvD4swF8bcBjmzjsaQ2H5D/6acBd9wALB4DFWWB5AVherMp4GKIYEOp7+26UF0aSfT/xYuDG7wDjrIpAERytXf2vajj7ueryQXSFl10K/ON3gIWDwCLvjfGB8Z54O+Ee4ve6513uB2R1yzsqC+twbC8HcNVhfAeaBuDP/TvwtS3A/ePAIfYFVlPq2HHTuyulZCTlhbjhETF5yxTQGgPGhoHhIWC4VSXGD3n0tLkMHXHxu+YyB+MlPwDuZs5K6FlsbCzdVO9DuKfkHM8AEkP7B8fOkwDcD+B7np42+JkGOvKdAL4E4K8P0zvQdET0b14D3DgB3D0B7B8HZka9WzrD88N6sFm+YcUjrn7E1ZDvMtF9DBgeAYaHgSGB0PNHCD4BLwLRsByAyX/ij0/dDUxuqlIG5hix7eFhvLcOVUAtyPSydAFmOQNe6EYGV/9ZESiKgIEgtbaD/gHALQC4ovY5r5KwtjOU/XfTAHzzLuCmIeDuMWDvKHBwpMoN0WQzNtAaYSs0K4ZlOSAjGG9kPjCBRwZ0ABKEBJexYAZEAU3A7Oi1BeDym4EDnjQ1TwCGWMW8MXcKks0YOyZNlQOQjcgYIUHllEzYQ0ktm+r6oz8G4F4AXwXwRd8/kO9A0wB8y65KmPxgGJgcqYJTKYpTv2CCzyddQJRDOjKivn+Deh8BF8BnwBtaCUA+YYEyAU8h+c6Az9gNHHRmrgOgmDA3jHQ+iWupCeUAvNSrA9HNwqx+muk9nJVNg/CTfrmbAPwbgK8D+PcHkIibjob5o13A3XypWsAkG1cPA9PDFQDZM1id0i1KxsWfOrKnAFXlifCFFMMRcASigOcs2MGAIfE9iWXplS6On7UbmPaUUTXQrgsVMzcRj5Folg2V5ayUA5BWYKwOxKUafnosWjcJwk+7W5F2EKvlE3xcXaNYfiCYsGkA/smuqug6hcleAnAImPbO6YwRpMgjCAVAm/yQmKTv5hNsAf/i7SyNBSl2a8Qv/4/M1yF+BZSYlNQCnnVrpbC+mToAACAASURBVJcaI7sOSEY2NpaDXLqpR+vE/OVksDgImgGgghHoYJbTWc7oJtFWc65/cg2AYvh2ALsB3AzgVv95nS/f4QdsIkT9T3cBrGtITWZfC5hqtQHInsEGQn3UDDvEDEY/ICf7SxMOrAg8T+c00JGkvHGd2DABUYZIAONzCUDppCFhSukCBsLQrFtZe/IixYQpSyEoJoqnuPWrVRAubQh83HNlZB23z7j1ywmj6CIIqUPxw2Xeu9bx2jx10wz4Z7sqTYZaDD8EIDuoE3hMVEphWg66JIp90k0sBxBcy+iPIIaT1RtEsHS/yIAqw+VSNPWQfe5tlVEk8auXgVa5BUsEJuT5uoliAbE5AGotmIAjCPnR9xDG3TQernYAUupTdBGEFMf83OkApHG+XlvTAPwfuyrgSZOhas3u6cwTsUBVn2gTwyFMi8wjHZAA1M9fYGHDULJD1m8Cpa8fRxDad+l+Ykf/3XNvd11U+qiL39SxXevSsshdDFvgbI1O2AwAtRZMZzTBRuDFjxe1Xg8QEIB8yyj5yYIUxfQIkfkIRnmHCM712JoG4FsdgHHp3ACoMH2G6jM4lWzoQarSvwQ6MSB/vporVaFkh+mCLlpVR8Z+dqDZLoDOpHSiQeAFDkBjPrlgCHgCUaFifg67H/9uYjn4Ai1vpTERTAASBaoQJBAKeNqHlL6mwPDZYAOROag/EYRkPX34MwHIvzW9rQcA+TLpI22G7EcQKlJGsYIJhC6ClUMiXfBTbFUQAej6nPS/OuAl9pOOqIc2BLzg++3VmWgIEUz82cRuCAtLIHQQm0gO52uOAb22sC3JEWgRfPpZf2sQBQIgLydPEIFGwPEj8MlF2bSbsulghLftqsCXq9HGgHysznrGgi5qzTUTFH8FLhAUn3hIJwCN0HLncw37qaF2zoYvuKNivmQIuUNc7GvWt6sHNs26twA6vhyq8NEMAHlyntFrDCcQehyaPTl+FwAbXDcmAKMRThakEk8Q8kPg8SPL0qzLBl+A9QCgR6uZGs3vfHz8TtBZvkgGQrEPBVAUg2Sij50QAOjiVKI3saADJRm7dSLYWfSFDkCem/dhZeMy9pPY5QvSDYQyUJoDIK8qMezh3wY6fSL49PcGgCAA8pScJLIgAUYQEmz8RPA17StvGoBv39W24eREiBoNQSgWNI1HBkdgxJSw1AI+dFIbgOYmkjimQ1r6XXC3rAbCHycAgytohf8vsB/r2KRaRq7zpZ+D37HMX0s3DDcCUGLYaw53MJ4YUODzusqlGCQAOQCejuxA8UULUkxIwAmMAp8Wa3qkN/R9W+sBwOhIEPjk5SLr8HeKFbTQfb77csPIMHGl/4MPbReslPhNe4+MiTpi9AFGV4nI7MfvagNQLh/pfrYnDAS8aJQ42A2w4em2cAyWQUuJVQTGWLs1uL7DG9J1RjhA+jvYk4t3KXeMqijpzrud4At9z3XtP16yGfjKZmCGooYh1tZzvv8xXPFl4PoJYC97k9FlwZWD+Azi/deMZWeP13eQCGEyoERudChIjbb3mJYwH7V0QIKuCwj/gfMj0asn2I0FXRSHXfL/iRkNgLyeVj8ccMY//J1fyxzTAXT2+xoQViKYD/1hDqLxPiYxTgSvQrphphG97tz4Slqafnj7uk1kIQDZrvWTw8B3jwEW+RLxPgSiCERdPwPR7+wCPg/gulFgfruDkOMQkFc5x84e708JAMmCuRNBXi4TIg5CGRzGiBGE/D4E/C2r2vcAYJoify62i0aJSMhB+2IHoNwu0fkcjQ85pu3ack5nIBREqneYFyWLkAXIJHESe00Cyx5QyeL6F/tyEcDcrOW2n7fX8df0mME+/vQ/PQjhoy3gzo3AISYf80MQaQx1peH9wb7v2mrtmCBkIMMejp3jIJD1MsaxaMZ8v5N/67INAsB3BAYU4JL4DSo1J15AFPAEwuQHZJzkKfUAtOHLJSOQRWndBYQvCQA01cfnNopfsaCJaD2baBn79QjSTiOEP1EcawIpkq2kegBTNgHWEpOKF8Uwq2NRFPM4AqCf46/rA2U9/uVDvurB01zvAJpiiwOl3fEeciCGF+Ij11f+QkbSfMPfIzqw57mEFZ9Dl3Ps5HXWAYByHJAJKV7N+s0cCQQhwSlfm4lGZ0KB8C/rABgZUS6ZHITBSEhCowUYAAksF7cStWREyxRwtuPpOlgw+5s9sq6OaIJIIlUgEhA1edoTgHxa9HVw5jibZNF+j/9yGQA/7pbujZ4bwv2+cWB6tFo0NzYnkxFA+cvEAo43VBoEo2e+48EMXEOmD9F6xhCE8RwZEJ80VblKvDlmzwicfqy93/o+8K8TwB2jVSgW138FrJQTXBNlnJgmrjZwanow9CBP/rL9wF0jwAGWDtFyoN9PHutnIHT05mPXz93dMGQAPniJsjiBXiTbxDZFMF9NLUPQxKR5qezz1Y6/YZDH0D6GkdAkYJIvRalAdHAMmPZoYhb6NhDWvEyf/ma737CXN7R1ZC7hUbPgcFgqt/ZZjADnM1xqEVhYBpb4CUk5UsL7jQvj///5buDrLeCOEeD+YQchYwG9VIfyg1NaZszFiCH6DkRGLze5/dgk8IMWcMCjdCiCzR8od1B8OTwvJM8JEShFut1fzMhi+eRJr6LI7hYP2M/xVLwKNoZjUTwRMAQQmYyhWGQxsSADOflZ4kukj7PhZ75bETjBpkAGahMkcrGgwhsXeCyBHBj1wmOBQwvAwqKzoFeRV8ZaerjKYAuirmPY/o9X7q5Cyr7fAvYMAftCPGAEoYlBiVtFwLjtp2U4irj7yOANbi+crHyrfCbTquJV44O0F1FrwQGIMZFqdQDyP/gGSZ8TC0ZRRsOlVzzgasd/u+zpMByLehAfCgMQCDyGZJHFCCgLZ2f8mgI5qauEcVx9e5vACTgCTwEMWr5TdIpWKJb5MvrnoocDswvAPAG4VLGg6UKeqmi4iuDz4er30oX0FP7u5moMvIf7W8B+jwlUNAzFnlZCIhvGFRCeWzrgXSSIBreXTFZSgVLHAp4UHOFuociEEsn2PJwl/XEk0dzfSojeerFg1IOo5BKAveIBex1P67lgUzgWQaJwLAKRH04i14ItgDKEtGsRnWx49b2Vkk9wUefTGrKCF7R0JxZMqxN8cmPAxWcAcxGABKEAKPA5u9lEaAbCmKMI+sDN1X3z+ro24wEZFc0VEE64ABgT180PF9ZdBcDb6JpqcPtPk+1ACbmKjJnllwyuILunEAWjZHkBsrsRUnfD0qEiC5IJfyisgMhzWhcP2O14Ro4WbASgAMQJ48SJwchmBCDFa8qpyBbSP7OvU4PQ0p2W7+LSnSJUFOrI4V7w5IoBTQQTfJ6oTSYk2mQcpGRyH2syGjIF6EM3V/fM++C1CfwUExhCsmzCaQT43lZC3e1hBpEHh36XEqrB7Scmq5dV0XZxmV8WuDFzAF9iwhow9seAGoBcGtKjqAc+1l9rLb/1igesO55ysmCrC8ei6IxRMAKTWNBi6Xw98xNTFUi0jEcmpYgRAPhddpVi9OIEPP5cYD4CcLkCooHPwaW9kV+iwWrQHT8uA1fd3F7DFvgUHUP2k8jTiogAqLoxFpDgbMj9jXSuN7i9dLIdaxzBp5XVBMIMgFEnFAPKT9qPd6A9BIGI7MfPmf4U+40HzI8nWgq2PBxL4FEkjKJixGRRFyQQPzzd1iAUzCAQas1YOmAEoFjwkecDC/PAwhKw6CxIkCXwOdVJLxTobMjBdyIgfvimNvNJ7Evf4jWtdnRYD1YNGVuG93VWuWs4Jf+mlZCCZxwP/cnJ6mXVKk2+tK8lQQVHRTGc64SDAZB3Ey3JcxyACkToJx4wHl+YwqloGDICmYmTFgMQFBET8yyYzyAG/AfWX8mCGQg0BTRoHwt9KVaPE/HQ890AIfgWK+CRAaMRYnVdxHbhdY8Wslw1V93UDsmPIj9GxgiAioRRMIJNvoti+SW/Ikd0gwAU8+XxJcbGITJPDvI6XdCFREFSknTB83xka40H1PGF9dnycCxFwygkK0bASJQSVAbAYeD98xUAe5U3jKIwBosSgNsuABYogl3/IwgFPrOIg1Xc4ZrpAsSrvruykl2ucykapkMMh4CExD5DwJfWAYAxwk4MKPAJgOIjGSEGwuCakRhemw6Yv0UUwRf7L00L9pnsNx6Qx4feY4O8pDEcixOjsoTKKpMYjSFYYjOC8Eq3Wnnr0YYS+0Tmi2HysrPGLqwASNYzBnT2Mz2QD91laxLB0gs12GAh81cf/o/OcHyJ+qj0S/zxnhUZbSyYWaL8+Rq2S29wowiWkJPan4MvgrDDGAlRe7KIywDIgR3meEDWg9HbJgApNTkXo8o0i7oVgxnEgFr8F7jEdnU5GvqfJQKQKyEOPlsNIQvyvupAGHS/Okv4qv9oh+PHxMLk8ggBCRxvAmEN+AiEzz2iQfQBeNmkh4K52hJBKOaNe/FSLobLRXCz43rQnu2yi9oMSMDxs2jo8303ERz1wsCGZECF4kd3DwEYYwJjhoNlQrgIjlYodbBPrwMAZfEmyzcIv27gs6XDzC/IR1DOgA9a6DRz4wZAsZ+LYXvQYsHoD4ziOFklna6YD3+nnU6dZ7bGDAcBUImIAmEUw/zbJ1i/scGNDJiLXmle3RhQ+l/aq57gUQCWzwwBKPeLsZ/LFrGg/ShRXAe64Ajkv30kALAjF8R11Dy3K7KRwJcsUTaqWScARou3w/INVnCH+A36n8RvM3nB5XP4oD6DATBYwGb5ajlOLOh6X8JaBKRG77+7ygGYp1bn+V25/01AzBnwQ1ypanD7KWfA1QDYC3zJIj7KgOUzc9nFbetX/r+O5biwNhyX5uSEDr5o0xsJwLp8/m4A7GaJUv/j3/5+HQFYJ3oFPPkho/hNeqBcMkcB2BAA6XrxmMBkfFAci/m0JpwzXw0TXvXtzrz+PKc/Ml/ugzM9MDqCAbz/keVjjGcQA/YLvjoguo1mRslRI6RwfsiA5nqhL5D6nscF8gfTdfxpS+/hLzvWfzMQCoB1Fq/8b3VWaPIDZqsRV64DALsZHVHs1gEvsqFAeBSApQC8pHK90Oql4UEAyvCwNeGcBXNLOPMLftgZsI75ouUr9ousp2TEyIJ/sU4AzC1e+WIFshyAHPZREVwItrrD3wGAhibTYBhxVpe/xePyrNBuWaoNp3DgFwC81O+RAepK/a5Lfe51jxr7JwA83nPXYgq1asl0yX5N48+f4VEGLATlK1vAo5YB1gBSRmsM+NFE57lcfPD5pPFWCJImtyvGgGfOAacBYO59zFglgHgPefZsXV6/gPXBYeC0RVgyJNOGYuJjPka9eHWgjL9bWzhWk0/n/wPn+k8bgFNmgYcsVflZnBRmIShtJM/m7JGibGBoOIIez9wKPP4AcNpylfbNlGfdI+9NjBjz8JVzppckZuJ+dBw4aQ44drk6j1LIY9JkPD7P4s2lwVEGLHwJnncscNIh4Nh5YMsSsHm5ndOu1BGFThJ8/K6JrZtoslST2+XHA6ftB05ZAE5crgAups5TfaL6EF+UyIif3gAcOwtsXep82eIYY9JkXpMgMp/AeZQBC2b8OduBYw8C2+aALQvARgJwGZhY7swEzbNa88IRvAVO1qkF91J36DNOBE7eD2yfB45fqphLnevzdGeBKBfL8UX5/CZgyyyweRHYsFwxYHzRNK6oetSBMDLjUQAWTPqPngpsnQK2zgKbCMAlYMMSME4ALrcnR6JYQIwsoUnjpDRstOLy7cBJB4CHUGwuAtuW2nUDVH1EFUhycSwWjGD64mZg0xywcaECoI0z5P3X5P6nWlHdgHgUgAUAfOYOYMtBYNMssHEe2LgITBCADkIzSJZXpCOnIg25uPrhgnupO/TyhwLHHwSOmwW2LVSik2pCrDsQskzNIBGIpBdGI+VfNgMb5oENCxX4yPRjPj4xaJ0+WGeEHRXBDUz2Mx4FbDoIbJypADixUAFwzAFI8KUJChMV2SUaAGc1cE/xFJef3FYRti64nkqWDrqqEhbrsm5zvZCdPCd8nHzJOLZuABRz9hTHZwPL7LnLnoNMIY2VyaKcjtZLHOAbNgNPngKe4BacfGF1pnydD+hphQ/8XV5UiEueLGnDN1tWXj/3/4cTwAUzwGPcRcFJiDpPt3FLmf5vjwE2HAQ2zPrEzDv7OQg5OSM+ScYQy5Xbo8465u/ZfLTJ7fKHAdumKxVh8wKwealSE6inEoSy2MWCdbUHIghv3AqMzwHji9VLZuDzD8cXxxWZs5c7apmW0fMBnIHKn5X7d6I5npvRz94O7LgXuGIReJSb+Xl1tzqflybwRwqf9i97BQRWomWJQ7oZVFtJoqDX/b/oGODsvcBTATB9gsfGqmzdjtVz+G+PAyamgYmZCoDjFE2anCVg1CeJwOMnTRB/DmUINVkkgia3y08BtkwDW+YqAFJFMD1VAAw6XG61R31O9/fdrcDYPDDmY0zjc1UjivBuAMx1QdMB+WAYXU8dhEU16dOSkppbcHFSrng8MHwnsGMPcN5ypURHp2xMIa7zDz2z8Gn/kVe0YomO0wEwBYKujL7v/zHA6C3AxfOVh58g5AsZxx4fZM7sf3h6BcDxWWeGBZ+cMEFiwGEHHRnDzun7ONHs/djkRgBunql0VDOSHIDU3cxSD4aEajhFXS4H4S1bgVGN0V8we7E0Fh9jVDG6Obr1LJMRwn+kOCaTEYT0dsfqZHXl/p7PrLi9wIY7gO0H2yAgCAWCWCowKrYE8nMLn/a7PQn9X7zIJPPkCcK+758y7x7guNsB6l98gZjLLYet3Ay5n0sv4R+fCYxPA2MOwLEAQLIDPyP8uBg2cRYmzFweAYilKkn+OC8/Fdh0CNhEA4nGA40kd6FES13WLO8v1qHKAfh9B+DoYjU2Ak/js/8NAIwg7OUb7LCC+WAfB4CpBJoIiTRNRmS1l13kqWh3Adv2A8cdqqp1MB+aIOSxWv6pq5D2kkIAvt8rF7BLJksN/jMqfa7v+7/Ak4B3A6ceqpasKMq5akAmlLWY37t8ZW97PDB2qALg2BxgAFwANEGcnI5JcrDZRPlkaXL4u1KJUAfAjbTQ59x6dSvdLPXAgGYshZWR6JIRaXB/NwFI8C1WwLMXzMeSwLfcXuKrA2G+wrLCDcN/IIg4ERRn0qvyySAQX6mG1XuA4fuAbTOVwktRRr2MLCoQyvEZ/UY/WwjAj3jtFJZkU79g1ghkgEBf98+0Umb/3A2M3lkBl/fOcdMok2EjkZyv8773LAfgHDDKjwNwxEUw9yailpwdxBAEYhBbAuGzG3aKkQEJwAkCkOCjlb7Y6SYyf2UwlAS+vKYnAXjfNmDEX7DEfA5CjUcsnzvbu1nDtUMmCDkRZEEyGdlAk6G6lQTSa6m0MP6HuY73AxNTlcJLZ6WOJYC5/CNxLpHMgdKIKNl69Qvu6/75AjHOiTU87gKOOViJb748BKCWrnK/maTA+58AjM0Ao7PA6Lx/xBAupoYDC9okBRAmPdBZ47lNA/DhwMRsxX7mPgl+SrmK5EaRNRslXFQ9CKB9DkADn79cZtkHFkysJ103eBbqlh97DpmTQTYgk9VNxu+xYbXKU3lhFoJPOgdFGY+lPkgQxokkgF9Xgj4AvfoFs84eX4Ke9x9fIC+tRfDxvvniif358sSir2LCj5wNjBKAc8CIi2AxxLCzIAGY9L7AhGIKgpATw4l8wToB0JjPrfTkp+SLQbHrOqm5jNyajS6VCMIpApDAWwQ4LrGgXqzIfnq5cv0vN0ZXHTInME5GBNLb1DGdOYQsI7AfGKFjlgqve8wJwG4T+fuFAFytXzCLb+VgWnH/fIGYfc46Hs7iHC8ZkPcdXx4VfVXJw8+cA4wIgM6AHSLKWZCTESfLfg7WsIyRF3ckiRQ+HACXkwHptyP4KHrpJvKVGnOhRF9eBF9wE0mUEogz2wC+WGI/vVxiQQIxAs9+rmHA6E1YFYB8DJwQMZl0OrLZ++i7sfT8zroYHLS9df4RACWKxSZvLXzG/fQLZqk2gqn2/vUCUQ9UZaM9wDaPeSPrC4A5C1KV+NITKwCS/SiCR/jRBDlLmP7nHynsxno1IPwJSyRpbiMADXzuPDYfZfBTEoAmcuVQdiaW0zwXwQsCYDYmMaDA1wG8TBSvaoR0G77EcGSET6hjOvVApfRPAUN0zjr45JzVcSqiTxD+VeGzXku/4Nr7JwDJOkxFIwt6j6+RqUrlkO4bXzp1gCAAv04AzgLDDsBhKugLFUvQUhTwCEKbnKCw14HwJ9cDgGQ9WegRgDI8XEcVEDvAl7lVlglAgi+I4CR+Zf1mLGgMmDFhBGFfDCicRJFERviSABjLS7FC0MFKMU+07wOPE0kGvaoQgGvtF9z1/iODkwn3VWoEXxres5ib9xx1wZufBAwLgAQexbAD0JiQwJOuJBA68/H3Zhk6+3CifqqwWNMKN8wjKgbk6gWJgC+FMaBb5vJVmsUbV2vCqo3cRWZcCIACoax53+ulkqNd7iqOcU1WcC9cxEm5kQBUdZ+sTnSL/jEtTWngi21jhJNJBivZBukXvOL+yYBkcOqxKjJ4AGgxzMrBVwdAMmHrZOAYF2l6y/mwV6xD17zmWo6MbRyeWtOHwxJ91IIhr6rqZS70DPPLXDVUrfBwzHKr1EUp6/h0T/6L/GcCqslt4IhoTcwdAqDSs7I60WQH6R329pHuFyuXDJmEjuOSbdB+wSvuP5bGUjmsA5XoUvcvBXKKAQnApUdXwah0b8jXR2YzJTsC0ZHB33FL+2yiX3h/1YeD1fFZGT81g/H6yqkVa9YEpqMhTADle8erHA6t7Mh6j4ZBXdBGjFyO4CSIm9wGBiBvgqxwIAJQlXIyEJLyI/i0SkAG/FbhaEr6BXfcv+5dLKhCg4z1C1HEBJ8+BODQGZXfk/quAZC6ketAZEQCTWAU8PIJt0fgwHzZvVWNaKqi7JLOmtDWFy42g1FxH/XfqGkII0C+a0tnDkfsGxQjn3VPsk7tXmuy+Xp0JhtoJosAaFcUAJUYKiYJxcqHqKAH9rPlG2cMrmCUbMX9guMLpGTcCMKDlZGhMK8IPnPIn1X5PA2AwegwEEYmDGBMjOI5whGQP3NPBT7VJlRNaKvF4t2IWHbDErtDlSk1p4lJ7/zd246tglGZryIfrFhQ7pU8WCAX0ZENG+57U14Z4YrCeLrSxXdev6TfLwrbxT7znMrfKQXfHLQCnyvmRIv0Q3430ezMmL98P393G3wqz6am1NYzzoGn+svqRmTAU2citctqAX/2EI8F9ACEmLHXLZGoFxtSl2xyK2bAYwrj6Xr12+1noL/jUTCD9vvFrn6u0v1/nvGkaoVBAQi0eummMAuXQHMWJAA7gCixG8U0gFfcXdlBKk4Z6zELgAJfZEKrxpC1xOIl/+Sk7jkcdYlSco90y9+gK6vJrRiADD0piad7RuFo3udNCgft94vCdrGXn+tujgV3QAcHLcFnroelivHkchEL8ue0uQ74S3eubAITS3IQhKkMRjBMokgWG3L//2z3VSnP4VDgQWxUEEUxAZFHL0eR3HDfm3IRbDHkBfF0zy4EIKNhSvr9goGEBdvTz/MIYQLQdVsTwRTFDj5jQmdArRDYJQNDSs961R3tPhx5NXoVgoxleHnarjohgLec3D2HI492yQNvIwvqO9fJm9zKGbAwnu6FhaP5pFuMg/b7tTbpBdvTz68cz/zI8azVj8iAHTqgmFHXDUB89R2dtaC7tUGw4kDOgFb0R2wYRDGZ8g9O8aU4XwPOczhiwGlMjqqLWiFYGu570wADFsbTvaxg8nkow7E8nM/atfKzln6/1mS4YHv6BQ4+Z0BbqHcd0NwwYbVD3+1yWhXJxPBrbq8AqE/XApSqAxiBV2MZ/54DMOZwKE00rnDUWcR5KiV/brjtSAMALIyn+/mCyeehjIYp6fdrvVELth8RAClyHXxmhPi6r1m8FM0ucgk8+y4RHC1kAK/5XgW+2hZYofafWcPq1B5AqDqEYsQ3nepR2gqhV2yiol1COkD0C+aOaoGx4aL7DQCwMJ7uVwomn4fm7VrX2u/XAlELth+5sHPtN+l/Ap6sX2dCsZ/phZkIJgv9l++1wbcq+2WFv2NXIjNKAPzuw7MUAV8DTuynFIEsQy83RgTAhiv+NgBABaQOGE/3mwWTLwAqHnaQfr9GnwUbARgDNBUlkpzQboyYCyYDYdILdf0l4NduW9kGoa4geNdazLElKoA3Prx7DofiETtC6XvE7hGEzJlpcis3Qgrj6d5UOJoYDcMglrX2+y0NPtl5UZUjkfx/Hqbecoe0OZzdF1gHQrln9Bhee4s3f3Zxm4MvAk9VSFdUIw0i+Q2PaBtISiBSSFgCYMjMW00MP7pwvvLDmwFgQTzdHxcOSGvBg/b7ZRZByWYAlOERluKM3Ra9CKWc0q73dTBhMFT4ZwIw9l5Lrpes+HjeBiGCUOKXeuBvPcKTiEIOR0f+RhDBMYi0Lhea4GTaa5NbOQAVDzhgPB1La5RssV3rIP1+7yy5OAADoAchEHBkFbKfGRpiweAPtMs5IFNokyOGk/7rAYC9OhBFwNXVY1at5tftCBHaWVS2AJdEcEinrDNC+Lumiyc1B8AB4+muLARAXTDCWvr93lR4/Z0Xt6ODFQkj8WtumEwHTKDLQejAfN3uds/dfjoQdatGLxb8jQBAYz6/boxiFgAVudzNIc2/s3xLk1szAORoB4yn+2DhaATAGJCtbpkCYq9+v4V+aBgAQ4i66XtaC85YkDog/zdZvzUgfN1N7a633Xqv6fe9msDIHfNaB6Ay2JRE1AHAEDIfI5nzZCLeN4Nbm9yaA+CA8XSsul6yqV0rJ2WQfr+splCyCYBR/HJyKX4phs0PKBZ0lqOYTpvniAiUAmAd+HKjo1cvDjHgr+3wPJQsVCymUZrPMuRsRBDG4AQCsunyJtFGHwAAIABJREFUcc0BUJlxQoH62q8ST8cggpKNAFRGwCD9fkuvbwAkyGgJE3C+Nz1P1q9/T3F1EZBxvZh50s6AEYC5yyUHXt5/Q8zI5/KrAmAIkkipkyGPYwXz1aRT8v5ZO6jJrRyAvKOvNXlLazsXs9bo/ztc29Pohgotp5J49Rcj/pzfIwGS//3OM4CNd1dpntQpFUmjEH4LYIgnyn/OLjL8FeDGhwJbNgFjI8DIEDA8BAy1PFK7FSKf43cNKrvHx+8C/vmxwMgmYHgEaA35J0StpvvzL/nP8RbLAfhyT207TChgDRiu/ZL9DsfWNABvYzbhCDBKoBAk/pEobGWTqp819hzQ1/0k0PoaMDEJbJjxVZFgDad0SaUO5LksWVj+XScDmw5UEUDJ6U4d0nVbC91S3ovfVHp5al64cgC+k7mZAP768KCA0WD3A/ieLz090CDceVmlAuhBljLgrfcAw6PAyDAwPFwBkCAbItM4a/FiNtERjBl76W9ffD2AbwJDdwFj+6syImRXrd5Y2FjIYcnzWPLEqnsfC0zsr6qBMQmfIDR/pyJ6xMhKyMrSDiKD2xja6TADTt0/AGAs1KcAUCFrOLF6tbtiRVFavT/wuMCa7MfVTlH098YBeBcwNAIMEYAUlS4uBULOmK3LCnwOPANlEIOSoF9+C4DvVoWXhvdWZVOYqWgi3vOXDUQhgieB0EElViMYJ08HxqeqnG8D4IIDkAzo51DKQQJvBKUmKACzbM4+5hUivwrgiwC4LzvjmgCh6nBcgiMTcv9Abo0D8E6g5eCjfpUA6AxoQIzgi8ALmWwC4z//DxcPPwBak8DQFDB8yJPpPZHeGCyC0KN5DFCByfh9/+OAsekKgEzCTwD047X0SCPM1IYQjCv2E/MJoGVwUUQoPboq0MdqkWVn7RtDDMahB4g+P6qhXFpjVtkDtRGA2nKjos7IyOyHFUbIrXe0FXsTuzIYfNb4O2M3ATGIYQOmPn6hG6gi3eUkQQAeAIYOAUOzALMVh2pAlESqGFBAXAYOMQVjxll03iO/yYKRAT0FQXkwZkjp1pz51LO2XAT3KtD3AIAwj4Wg05kfiuUHYlsXAJLVnP0INLM0OYFx78AzcRySeTsw2AJueI+Dj2Fne4EWKz5MA0MzDkCCkAByUWqsJzarEanzj2zXwjEGFHuGY+pYsMojzZL1G9EBexXou339IRBrC3lJGmNDuSHX+w7WC4Cm6wWxm8DngLTImgC8pBcGBuTXf/1fXnyTugnFwxTQOgi0CECyIFlsvvJfEnh0mhsYI/s5uxFYi1xZof7oOqSAawwYjRGBzYGXbtWXaCIrlvHUagX6SP/ruMVYCEbEqECXAMjfree2HgA0ESur1/0vtnNwGSsG0RsZME20/+/XWH6Mugk/yngPAGy5GDYALjiIHIgRUIrsZjM7Ax+BSx1S4pfffQVIep8dL7dMDsTGjJB+CvQxTHmdtrw4l0CovFruC2NOe975egDQsCXRK/eK634JhBK90q2C7I1i+Gt0jxF40k1cPJAB7UP2m3MGJAAFQrGei9iUTH9yBUDTHfU3B5+BOIKQ43BWtNtPcWIOzEZE8FoK9K0DCGNxLi3FqaKA9gTgeoFwPQAoI0OulWT11oEwiFz7cwbErzNxWtEYBB+VY76Vh4DWrH8IOoGQ7Ocg1CqMRLPltmxvs1/SHaP4dcAJePYyyUCRIzrTB8tE8FoL9DUMwl61kQQ87Rmy2PS2rgB0a1ci18RudEJH57OsY02y/+83/sZdBKr4FXQTApBvprGgQCg9UEAM+h9F6ugJDkC3gJPBEvRGrYoYCBX9IxEcS5K4i6cZAHIw8oXQ4mLBb35YH5d7OekadtTV1UZSjaEIPH4nQzYNwgjAHNwDuWGYpZc7lzPfX1cQur5oBorfzDf+zi0yVTuSkuxBI2Q+PhQDIUEnMLo1TBCZLufGw/ixbQa0KB8CTODjPohdY78IQmfDjmW7Yo/doAX6GqIiAtDHaYswSmeMubV81kp11L6hy2PdAcgblfslOKC1IiKRmyRxZgV/8++DS8BFrxXi5Hd/U6MeSKdqEsEKhpBRsgRMbAtuG4KU/+9ry5brzP/lPVMv1EPOQegharrVcgZUhVHFxNPcp9VFtlOWkL437C0WABWypFRGsV0sb5Hn2zYBwvUGoKl10v1knDgo0y7XA8Pfv0UACnjaK33Co9gJQAOe64FkNvtZAHQdjz9v2Nz2GSa3jYej2W3KGuZ9ixGdIVSoKT13B2s5AHkGheST6qn0erHv5AIgAAU+LVfw/wq3CEAV7clBKDDGZG9/5oVXx/oyYARczcqH5GyH8eFplTawFvAtrtXLGpNrQDGbejupB3omlIHQGc/ErzOcGSRs8zrhAbbuL1Tco/JfbLlNwHOmi2kIcs3owbdwNpYtynDQhsFcgvuG9/YapGFvYX22zZcAU0/GwA2LJ/4AmGF9mwEbBu98Y3cMF+uAGQCj2HVp3BbPuo3IlqxAy5wHAq4OfARmEBXGfNIBa0BIsG0ecwC67merHgRpZLwocrWaovuTxew/V0txJQ2DWeae3WAGbdhb2DB4+wRw7w5g8Qpv88liyGtoWHzMi4C9fAEHbBi8kwUKu2xNAdBxaGBLbJdZux1LwAGECYAEm6wyfpelJrEgFnRDxESwgyUxIUsVMwjVy5AYO0bG89Auu1/5BF38KqjBHlUAYXsteNCGwTeWNuwtk4JMkrlzGNizA1hm69g1Nix+zDOBW0aBeRZZGqBh8M4emfWNADDT+zqMjQyESdQFHfDbZECCLRgdHeCTe8CBaKJY1rDnBRCIAuGW4TYAZeFG8ZuMkGiQ1IEwGCJtHZBmy1obBsvVMnDD3jIAerti3LEBOMjGcOpa3WfD4ic9t6oveDtLfw7QMHjnH6wPAybW6yaG4+8D4HIQfvtDIVtLejpBFsVvUI7NIBHw3DUjRzL3rDVtsYPOkAScuX3coNDynT2VYJCkn+PjqvUD8hVbS8NgjphGxcANe8sAGNoVY/824BCBtIaGxRe8pLKZdpMkTvXiJ2toGHzSNHDPScAyq3er4qPyGaNc7JCRXWLT2TjwGmCOeQashq6+qSpZmp8vojQpheF58ncdZVjLnjWPHr4VWKTKxrHGUqq97qXu3jp0wPy+eEC/DYNZsZAO6IEb9pY9lNCuGPcNV830ZmkM9dmw+OKfbdcXvJMPdY0Ng0/7GnDXKcDMccBS7MwdKz8KCAKQIgY0MWGCtr4TOHAasMwOkTqf6unyuLykfd254nkb7qsw/iVg7jhgmSX31Vpd9yRHeLx+zRhjEGRbB6wDYT8NdymyubzDzCCGfpMJWfSRYfr9HP/aMgBm7YoxNQHMbQHm+ID6aFh8yS93tAvGQb7da2gYfPoXgbtPAqaPA+a3AEubgGU1RM6B060fgkRoCzj+TcD+04CFE4BldZdRc4/YxlxgjJMewSiwN1zWfsOngdljq3EmY08vm5i/7j5yIMqpvupKyGoNg9lngYosl9wY/0dZdrMzYl8Ne8sAWNOu2MA3zw/F2CoNiy99XbvftrcLriz6PhsGn3U9cM9xMODObQYWCMANwPJ49UliuW6SaqqBn/gGYP8pwPyJwNIxwDK76ahDeN6uXYCuYyABkEza4LbpY5WEWdSLxjF26/dQB0SJ6r4ByAN6NQxmkWcqrnQ00x1DEDJFjR8CcNWGvWVPp6ZdMQ6OVOCb3wAscPJ6NCy+7PerkP5Q3tBY1PrT9tEw+JwbgPu2AlNbgVkCcCOwtAFYcgAuiwWlM/XqDjMEbP9t4MB2YO54YJFMo/5gHIcALV1TRZ17FXOhPtvgtvkqf9H4kvHDlyKK4l6VzvVSBF22uwjOb7pbw+CfcwBSkyeFEHAUx/yw9JTyEbo27C17Ol3aFWNuAlgIn9QxO2tYfNlbK6MvaxeMRYquvL9rTcPgJ30TuH8LcHAzMOugX3QALo21WXBZLEHwRF1OgHS2eOgbgIPHA7PHAezNu7QFWFZ7JnXJ5rnqxHEulvlzwyVNN3+wern5Yovl7SXLGwvn4riLWO4fgMRJXcPd/+pmOymELEhRzBxJAo9gVL4kwVnbsLccgHEpWi3epocCAMeBRU5eTcPiy/6qtl0wpvhA+2gYfO7NwOQm4OBGYGaDs+5ExYDGgqP+ccAkINaVpB8GTv4d4OBxwNw2YGFrxYCmV0YxLNYheCXau7EhV3ga3Lb8g4+R45uoGLADgHWqhsBXA8K1AZADyRvuvtkBSArh+i9DsQhCOtf0UUgW/7aiYW/Z0+nRrhizoxXwFhyAi5y4rGHxU66qAFhT3rDSIVdpGHzencDejcDBDcDsBDBP1uX1CMJRwFiQIBzxieL3KIY1YW5MPOxNwLRb8gs0aghAss1GZ1O+SFHsdRPt0i/PLHu++dFb/x4mXfhcbWxhfCtYMFr/uWvKxfDaAcg7ipPCvFOVpuo3HrCjYW/ZA+rRrti6TS6MVQ+L4NPH2nx698GnXF0BsKa8Iab4dFZpGHz+JLBvApieqAA4J8CPOQuOBBAOV0CUYbIskRkAecrvAdNbXc/aDCxSpyT4CEIyTgRgneiLIp3nP6fs+a4A4N8B8/48CUC+ZGJA29fpuLmxJW+5h5kNFg2jiWHSi0r0Uv4pCoZsxw8DUfnhd4Vk0XGdGvaWPaBV2hVjdjgA0BlpkQ/K9bmn/HOVqtClvKEBqlfD4AtmgP3jDsBxB6DA7tdbcvYzJvQJkii2n4NOeMpbgJktbYPGACiF3wFoEx1ZMNe/4jnPLXu+KwD4t/5SO/iMBcXuesHylyACMBPDgzGg7opM8mEHIGdwrfGA1rC37AH10a64Yr4APvvOSdwEPOVbKxu+K2pdKRTmdI3dqkPPVgbSTBGAY8AsATjWniBdx0QxJylOFCcr6HBiw1P/CDgU3EgEIMW52M8YkLolQRddIN1AyKWiBretf9MJQN6HsaCPxe4rvgDdHOcOxDIAcmDFDXvLnk4f7Yqt63gEIB/Yoj+4p9xaAbBHeUPM8qF2aRh84QQwNQYcGgdmx4C50WqCFngNsgSvQ+Dxu4MuiawhwIAXVk1O+e/A7CZgThY1dcno1nHL2oDIyZULpBsAFTBZ9pjT0QQgn2V6ufRicS8QRgbs5ZYpEsENDejBfpoLrwAOjgIzZMBRZ0AHoUC+SOA56xJwNlEyTFw5FxBPeWvlzpnbANCdQ1eSGTRybMuydgMggVBsKmtYoC6Mt8znZxsZMLzAxoAOvsh+ydDqtXx4FIDl8L/omQ7A0QqA82S/ERdTI22mNfaTuBIIxR4BhKe+y61punQC+MytI/Zz/c9EuvyBeetLAfGZ5WOMZ9j2/gqABB1fMLsHAVBqhfTcyH5d9MByEdzs+B50Z7voGZX+NzNSsd8cwUcG5ASRKYbdHRNYwhhDIHRgGmO0gFP+HJh15jOXjnyKblVT5Cbfoq+yJOszF8P8+VnNPlICkMAzds/YLxlYznrJwIpO6egTPMqA5ZNDAB6iCCYAyYBcBqTRQ0e4630SxZyQJQIvMJ8mSeLrYe+p/GzGfnTpEIBy6US/out+K1wg+brs88rHmDOgAVCMnrEfxxMte1Mt6j7u9zzKgIXzczEBOJIB0BnCJoqgIfDEhM58SWzJEPGJe9hfVH42un/Mfxl9bgSiBySIBWnAJBDGEDAB8QWFA8wO3/a+wH4+rg4RLPYLul8tCI8CsJmJMQAOuwFC9qMI9g9Z0CxhZz65K0wfFBPqu7PEyVdWAOTHVlTcpxhXHZLz1w0ZA6EDLhkCskRf0sw4dRYC0PQ/vVSRAYPo7QCdj7GqVOSMeBSAzUzMxZcDMwLgcKX/zbv45SQlHXDIgagJc+bjZBqAWhUoH/Y+B2D0J7rFa6LYDRmzomsAaOeKqxEvbWacHQB08JkRIteSXiSBLYJOLB+X4xrzAzY7vgfd2S4RAKkDDgPzNEAIxMASSWF38WsgkuXLyXTRSRCe/DduSZMBMwe6ObTd8JBj24Aot07uDObPP9XsIzUGFPs5+JJ/M6oT4buxHv9X7BeY8KgOWDg/Z58GTC9Xq5FxTXOw9c3Cm6k5fPcjgbHbgAlvVG2tH1T3Oavoq6BlniZ+12n5u/2sDbOvasqoFg8x2Lnbcd1GdhSAhXN+7qMrAC4sA8sORJ6yHwD28z+Ft4fdv8UyqUDrDmCEBcpZ39kLS6aq9l4D2rLb/KYsFTPWdfbvh86vQu2s1K/K+zIjTsXIVQ9a59Egs4Y6sZfIA/EcSp/jEXv8BWcAhxaA+SVgSQAkGAMICcwVlNLlqTc9Gbv/HAA7MrL4+f1VlXwrUq7SvCoyGcrrWpGhuur2fNGYwM8YT67hT3s1LaZvqn5MLM0bzmHMmIFSgdFNj/mIBct63NhFZwEzDsBFgpDPeanNgATfCtGsX9TIKwNrg9tuVkhlng7TI/YArX1VkXKrEe1l2SynN1RCsFJsqnQv3UIMxhwIRjU5AGN9QUteVz3BUAvahuNgjC3HxLAND7nBp/cgONXF5wCz8xUDGgCjKPbvevlzcKUHH2ag6cnYzepYBB9Zi2FxDJdjoXJv1WDFiLJ6MKqKZUzoQFTfj2HmwTKcTpVWvcxHKm6kKgoORAEvVclPD6NdzLXpMT8IYNPcLV7yJGB2AVhYrAC4SNA5AxKM9ryDPE5fs6eeVKWGZ2M3S3MQfEyJUKV8L1ZpJXpVJ9pLilmlAxWkVJHKwIhjjD9TtVXVm1HdOy/pJiaMFRWM+bo0rWl4yM1N7oPhTJecC8wRgAttBjQWdBBGESwgSiV0Pb9DRgu0TY19N+M1mRKh8niqFx3rRDsLqjgl9yaGXT80vcL1wnE252PAZCzAHQCoiqoW3yYWFIt664fUpKaREr1NPakH6XkuOQ+YDwy4FMSwgU8GSRSz0UJx3Vx/5vFNbrs/EiLRY+v4ACITww6iJEodQKwBIyBRv9vwhKzUW6z66TUGEwhDS3ezqusAyNxnJn8xa1KRPSFts9YfFB/QDZcAm78CnDBT5U8rCqjfc3yh8Gn/hGd/MsKf1+QzYJ4891Jye13iy1cAE9cDJ+6FpYrEkidxDN3OtXR+FwBGMezoMmxJLOumAuD4J4rxJrfdH/XCoLGFVKiUbw+LAPQqWWaMMLrd6/+JycSIm85w9lOpt1j1MwAwFTiqAWEUxeYH5ENn/jInUVHeMXQ/f/jRePvCa4DhTwLHfBc4frGqqaNJzLPw6iZxV+HTplFGvZrXZT45N39+HW3TujlZv8D6fp8HRq8Dts9XIOR5YtakgBgdrrrt5Qsq8Ssd0BhQ4HMwmVitAWHAY/LbLDQNQDaTVJ8Q6W4qVB51OOqDZDPVB3TLOBepW5jmqaLbec3jGgBGMSxvvemDYkQ9GoKF1ShUCSKCqBeQrvmfVZPC1keBjXcCmw911tTJ8q5XgOLaQgA+x/OdWA2EGZ98gbjleTHdQHQN+2iwls3nK3/Zhj3VeQhovYzdxmArSwQgDRA3QiSCJUrTnjfl4KozRCSCCeYmt90EoJJbVCk/1+FiCwFZxLk4dRfLFia6x8LbYkD9v9cXtLG6+O4AYQRfrgPygVIcqyhTXcWFOJH8fh3rz7EKwnUArq8mcGwK2MCC1i7WY7Zenh56feHT/jE3yliE4TZncd636gPFCKWavGhcRx2J+cvs9MlSw0Ty3cCm+c7n0G0MExdW4BMIbTXE9UCynvyCCX+Ovm4gbByA/xisVgJPpXrzLj4EoRJjJIZrWHArS9iprK+KcefgiyB0XVKGjOmCmW9xhRVMUSyRFnNeFGEdI2q+/HFXclkp9WsAbgTG9wGj08CI64WxRk/OTDcUAvBHXSLQxcVCDMQSWbzv+1e7WVbz+k5w2tJtsbcCYV6WJY7hmAsDA7r1Sz3OgOgoM+KTOJbcjSI5yGIaNE1uuwlAAU/MF+tF5/0sIghVLdVdM2S0bSzHx2Mi+FTxXf8X925NC4BycK8QwfmgVX1LlcFiykEMcL2BndJJ7aQfijKfxLGDwAhByM7aC5U4qwPzNwufNnNuOH4VZaCPlPo2AahqFqoPVFc14ga2m+WEEL0cAz9kdPrOmMu8r1o/rTsXz7f9oswFs+jO6LAqkvC3Ggg5Fg6mwW03CUI6X12h8lyfcz3QHqr3DIl64DbqaQKc9mI87QXACD6vpJqY0EVxz2CEyCI5eMSGX2e7VtI5J4yTRyZhscrvt1nQuivOAaNLlYESwcySgiVbr37Bfd0/u31yEgg2FVaiPCeVOguqAfGov0iR0R9JABJ0bnwk9nMxw+fOh55EbgRhzozrBUA1polN9CLwok5HEEUQBjFMQB7D+j656PW+IrJ8O/bBCo4sGFdGejqiyYCx3mKe9/JtTiBvmI5OFiTisg9LtJFF7gZGDrUbHKs79+hyu5hSaUvh1foFr3r/6vZJCiXgCDwVVFJ7MVmRLsrGltuFCc68yFdACMDAflwR4QM3HPoKgIExt4gz42SuaQb8hBOE2oZmlu+KFlKR3QSssMJxDPWbbjpfLoJrxG8CYT8MKGZSVTCxYFTIb84nkCxCIPLDiby30gXFghaF4c2ReR466Uu2fvoFr3r/fKAEFxvpqMcd9yonIrkuK5LLV7MVCM+/uDJCyIC2J8a0z1iwqyESgMl15Sa33QKgmtPEBnp11mwuXgO70Ud4DHWzfgDYC3zBEOk7HlA6XKyHQzb8HgGoCSQLqsxorIy1Bxie7Wx0rFaf+wr9Xv32C+56/7HbJ5VHtRYT+GJrsehHcya57PyKAQk6+vBkBZPpjPEExlwU59awg3C24W6KBsC6tqHR+MidyVG3i3rdAnAsH2T093XT+zLr197MTA80h3SfsZP2UqpCrPQ46oF317VrpeiKXTJ9MhMLkgGdCacKG/mupV9w1/vnwyGgCDCKWzJe3lqsyzLWZWe6/kc/oKzgKH4jC7oolhdC4jiuzM0WPo+cPQ2AsX1obFCTO5Jzn566PwbReiwnfTWjI4KvDoh1juh+aT+WKSYD3i8Aql2rJk+VsVQly5kkddv2FvHT61icqO7Fr71/IkLNXOi0FQjV0046oBy6wZ922Q95ICqDEaL4XWw3COcf9Mw73DFB9AqE6wZAAS8XuzGQIDKf+oVkqxt00ttAc+YT0PJ9qRFSB8xoye5Xu1ZVeCSgCLbYLVNswoncHxoeLwCzBGjBNki/4BX3z9lXgUCyIIGmhova83cRgO5Te9yLgP3MfmsBS8xs8/U67ePQOqy9umBUruDchqo8sHSd3PMfT5ifo+ack8eFHI6QEcnT5GvdOnVdXof+ptJ+BVPWceiaRHA8Us/nkACo8mzqlqmWrbFDppT5A5UIZm7CPA2Vgm3QfsEd909kKIqB1qJAKCBG8ZstZz3xHOAAiwmpDIdng1maZQAkZzsHZ537YfQrwNyxoQ+HakrnS0h1mUA1C96TdJTmORyhC3oeqdwROi+GDhkFI6bYNrcNDEDeAkXwQizPRpmnIs3OdqZPSaRFUcbchHlgie6agq2kX7Dd/+d8lUJVXuUzk8ERmS+2vfd4uvN2VOV5rSwb0y3JhgIh9wJeN3YMQCIgR78Q+nDEVYBYZUrUpbXFnM7COSdf7N4IPvtDnT2BY/h8Chh10MXQeYGS+7GGjaQiABpuNIFiECnzdWJMIUHcazLptC7YivsF8/7FgLFMqpiQL5TuNbKfA/DC46rqqAbAwIKWK+timRUBEiNGsOQsyQm+Gpjd4n046hbT84KPuYjOmHHyp92gcgDS2OoIuVIeh/xyUkaVwyEWdLrewHE3uBUDcKIwnq40HpDXL+n3CzbaKdguel5VnFJl2awaghLQBTzteZ0cjLq2A2n0M6EPh2pC57Wg41poLzZsAZNso0Hw6eVR/J8bF9YjWGmVCpGKwQLBRCcrbiSxNLgVAxCF8XSl8YDHHFPW7xeFBRwv/rGqOKUBkODzqgdWPYAM53vTASMQu4Bx9J+69OHIF+N71F1O1gUB+AsBfFqKC+4Wi4BWX+CYgOTAU36wdMVNVKka3MoBWBhPxyiuko3xkSX9fvGMkqsDlzzHC1N6SQ4DoINOe7KelWWTheziObeKCdARApD1AdVnRH048gKUAmAEYi6Oh4DJV4VoGDWqjq4XLbO5o1jBoimEPhPJmwu9FvnTLgdgYTwd2wyXbMyRKen3i2eXXB245FlVYUpVxUpGiLtmGBlrTEhVUwV8dEkVKAq3MHJ1uzRbRx+OOgDWFX6MsXJU/36lJoEoA2AKvw8+uwTEDIBbStdOs8ddDsDCeDom7ZdszBIs6fcL9ror2C75US9IxJJsEsHdGFBil4yYuUwknofJgF4XcEUfjrz+X7fKo4EJJ//PkMORO6FrVjQMeL5kJhZMMXzLwNZCt1nzDFgYT8cQwpLt4hDON0i/X7ys5OrAJVe0S/ISgFY7j9ZvnQ7I3+lyqpYaL98CWp/N+nDkZdhi6bW8An1kP3fRTLKVWlwF6RZCH2L4zDDR0k1IqeTNb2OQSYNbOQMWxtMxeqtkY6I+ny9VEz6btfb7xc+XXB249AoXv85+tIBVgJJ6n4lf6oV+mfjdDJNMH0wAVFX90GMk1f5TxlS3Fggh92DyN0IORy5665KIfCktsl+K3VsGtpVOWOMiuDCerlSnjQ2rB+n3C+pIBdulz8wqonrNPLKgwKaC5B3s53qhXVq6oDNg6sOhqvqhEr3V2VNLBjmnSSNdrOLJ1zkAu6VPRjFcFz4fXDJ8i45hG94Gt3IGjOFYA8TTlQZ/qGH1oP1+8ZtlT1MAtHK8mQg25zOZUSCLIliWcbw8wfW5Ln04ssqnHX04euiCk6/3de66MPpuAQVZAEFkw2MKFw6a1wEL4+lSBvmAOMhD8vkOkFX77feLNw14YT/ssmc4A6oOdHBEkwXlgjH2k4Nal6wB4fIuX9LzZjAmorNeHMo5Tc0OewHwDTUh9HXxfGJsYkAbAAAgAElEQVS/uvCpoAcew6zBBrdyBlQwwoDxdLZWXLDFkHyF8xGE/fb7xR8XXByAAVC1oB18HQYIT+8uGfP75SCUs1o64he8v4j6cIQ+IqkPhxrBCHjdjBH6AblQkAeY1ondukSiELmsUPpjbyp7XuvDgAXxdNZVvWCLIfmKg6Bbhrjup98v3lVwcQLw8gqA5v9zC9jErutltg8gMxDWWMBaMVkmANWFyEV6R0uH2I1IzW7ypbkQOTP5f2ch9KsFkwp0kQlDAOmxzHpscGuGAQvi6VD4RgmAg/b7xZVlT5MATNXwqQc6KGwf2U2uGV2uzg3D4ua7fDnPwZcKgIdq9GaIBPZb0YdD7hgyIFWMXiH0eQ5vXS5HcMkc++9lz2t9GLAgns7KxxZsCkgdtN8vWD+vYDMAUpcja7lOR9eLVcIP4tcuob/3AOHCdW02VTX62ApB4Mv1v24gnPy9HiH03fJ366KYHYTHsgBBg1s5AxbG0+HLZaOp65i+ln6/YM5EwdYBwGj1cmUkE7+8THLNdAHhwrUOXtcrO/pwhF4cct2oN68BMDCfmsJM/n6PEPoYPp8bH3kCkbtjji2tJJA962YAWBBPZ0WBCrbYsFoOf9pDAiENk179fkuvf9nTXewKcBSjsn7ldonWbgQpx+26otaLIwAlfi2QQSJY3Yjy5i9dmsFM/oEDMM/Z7Uf0RiYUA7J+ToNbOQC3e0WBBm9qLad6HICG1ZK1XB5PoxnuOOIcxSXe/Of8xHV/P+FpwN47gKUpYHmuSve0pKZgCKSq5wqniWE1WZz/xouBm74KTMwBI17lVBXwtWSs+8/vL45Ff3vhpcAnvwos8d48DZX3M2hx9XIAnu0IIO0chu35AOgLL0yuG/jOmwbg028G/mNz1YWdETbm4I5BrFlov+EtD2wIo7l+Atg8D2xY7iw3V5diEqO54mnj6XdMAYcU+6gon7A3NSO2qFjlyZYDkAX6uD5Iam44YaUfVNDNxaJcLIPXcGGpfi6PnZdVD1wPspQBX/wl4OaNwN6Jqg+xwrxslcVFuYJblehkcYYZGPS3L20BxueBcS8nwg5H5kZkx6TQSbXFZcCQKadx5Cz5mPurAFxrRaa17pAR2PFC+ElSHKQ/0QjQcgCyGyM9v3SnsDBRJgL6msWCf6IfWeUJac8UFlpY8500DcCfvgb43hiwZwyYVhd2D/VSrKGAmIDnBkiafEcN9cprHgKMzgNjS1V7rRjRlceyrqif6KAkMgXIM+6tAnDl+zSL36O9+U8p9jGHQo285/2XA/AnXeNnKAorDXH/AILwbSvLEz6Ql2+cAf/3XcCdw8DkKHBwpOpFbE2wadzIdyh3jjNQirYWEwYq+/zJwMh8pf+xKNSwM6DZMmzNRRbM2K+2Ii6TlFrAWfd5V3i/F7IgT2LBF5LbIdkqxLPWvtzlAGQ3RpU3Y7AiixMxLOUB2t7pKQ8M0qCTnp8HkojJgNqaMEJesQv4AR3Iw8DB4QqAs+6SWRiqgJgY0HVDAdBA4Ba4xN7ndlSFAAjAYX4IPO5dBDMAdS2i+Jx7XTf1eEdTDfgAQnR34p/wQkRmjNAoByDT/ugFphXAmjAEn8qaPQAgZCs0lSckCNmVigEbFMsPBBE3DcBX7gLuawH7hoAD7EM8DMw48AhATrjtQwiXoqkTEwWd7LOneXNCbz6Tiq/TInb2M8ZzIFrTQbGiy92oGz7pXl/7jvdAJnb2470IbB3T77Sai+hyAP5voTqW6sKwFAc/TAdc5+3dvcsTrvPVYSK4SQb8xV3+6IaAqSHg0FDVh3iOIFTIFxtit9orL5Z/LD1Q4s+B8OnHVuXwhhdd5DoLGsgCCJ04q66X/Ju/vSaeAxDPvbdtmdtKDV90gVEPIl/xySkviOhmAEjrlzSkwj40SlQZYZ39I+8JBMx8mZryhOsKwqYB+KpdVSDFvhYwPVR9BD7uyX4SwRS59nNI+bRck/DzJ05v12M0nY8fAk8iWL5BB5qASPGRCi8EVjzv3mqpkC9ACrrwhKukB67GhpqRRowQMqCiYbj8oOoHeUWpdYIBAUj8c8WjrjyhNIJ1unzjDPjqXdUjJAAP8TMEzLYq9uOHICQALe/EwWe+QgddAqCzzD8+vgIgg0qp+5nYjaDzCgjmnCYone0klqP4JSgvvK+6LoFPoFMlkPGh+0rPWta4RHTNJJQz4M8EAGoNTPVU8opS64CC9zoAWTFChcq7lCdch6s3L4J/2QFIEBKA1P9mHIBmhPh3Ai354RyAAmWsR/PRs6vOR8Z8FMPS97yxtIlYgVB/I7jC0rIKSfLXF1EEB+BFFjQ3jCLA49OWsRTTEPzvzQEwry7VrZ5KwzAQAPssT9jw1dcHgCrORQCS/bgn+1HsCYQSveaHkzvGv1scgU/6R55Y1YIxhvOm1EZekQWl8wVDxJgwc88QiJc6AKX/meHDawX9z16M/Em7bO8Q08GBP/jEkAEVjMBoAFWXUjRA3KtNwOBXW3EkAZhrALktpC6lKtTV4OU7RHB+3kHWgv/zrnYZl2kCkF4uF8MGQGc+MqEYUCA0n1tkwxbw4ScHAHr71Q7W4++c8czwcBAmHVB/c7Bcek9b3FuwbdD/kjGWgzJjQ3thGmVA3jhfOyU+RxB6FamOFp8NrhsTgLy8Cpzm5QlVptAU+6CiNgXCaIQ0BcDYV8b0P4pi30vfIxD5+w72C9aliegW8MHzqrmh/meuFhYi0pKbs6D9fsh/n1XFMrYMbPgUByCZz6J+uEknDA9AornWFRb01WZEsACoHhOqyC7wdetT0QAK2KqOb5MCUvPyhLE0oQxzqaYNXL5xBvyVXe12vByLADjXAvgxBvSPGFGMIjCmJbEW8HfntxtQmxT0cmxp9UPAdKAZ1upA6EB7qgDo6oCUxXRtPVSpAwJpnUhuxAqWCCYK1MBExZljY5S8SYr+pxAFAuBayhNG26jw8usCQLX0SAAkwwcAEngyQizaXoziIli+Oe7/9kJvNk1LmBMe9ECO3XRB7aPeF0EYHNVPdT8gj016YBcWtBfBVYJuz7mF7VgGY/pO8f5WdQ1/7U67nIKNS7j0wIbDPFZsyNHHY7od/xdlEHj8CcC3TgCWHgGAPSxiSdt4312u/8SPAl8/Dlh4pDeZW2PD4J1c9+uyDaIDkgEJQKnTfG/N8nUAmu5HUnMW5ARbPfEuIHy/ACjRK7FL5pOR4RaxgTHofKl8r/S1ZWBnAGDKefbn3AFIPRPXB7sFiVQimKVgGdl5ooNwLQ1/1U+DQGSXQ9r5Evy1q9rZbP1lGQDZsPpzI8APHgXgod7qUx11YtBbFzC+/C+BL7SAWwhgdoLkONSLqy5oLogYft3ZI1F7EAC+phsAnekokhP4HIzml/PvthQWmPB9LJ7jxkcSr14jWj4/0wFlgJD5eoDw6fe4DzAYPHokWhHJZ3TFSkn4h7YOSOBwEtiMTv1aY0uktFYTmI2/43EMQmCuAJmUE0gmVD8EFdPpdnxhVhqzDr8F4NMtYM9Jfg98EVTeNu9Q2OFZBX7vr9vtgm/lcezczZ61ZNN8DCvilYCdPXqNDQpAlfGTKm0M6AA0PTAyoMSx64cRfPQHXsniOTI+fEWDFGp+Qb9BeySRBV2kpl0QxxGAlHDmkI56X6z+EP7UDYSdRgh/IouwIZ36lHabBE0GJ0r10Rgb/xA/tt/j/6aMAf+7R4CxzuBXWRGULwBfIrY6UNfpvLae7n0I+LO/reoLMqiVMbW38oUhkNkQIzZO7tIweGePcmWlAFTjAYHPVGwXxWoLYblEDkLuTT8MDPhXLJ4jALpaJB+ggU6xfgJknT7IKXIQXh4Y0FZCog+wxiUTwSkXUbSMV1rB/A31OXWuFpPUda/mRHKi1e6U+hA7Zq7l+A+UAfDtHg/LrptkQpZ727cRWOL9542Pa3rOvuOqagUltgtmJM08j4/PILbIDKz6w5PAHsbraTnMGdZWIwIzxIfeK0rn578J3LAVuH8CODRahV/FFQ/1IumIvXP1QudNfyNT8oVqcHviPcBd48A0g2RDuoDqHdb2SalZAdG9dnfDkAE0gXnH5ijWCDbKCq5/MRiV0QD8HgHQ63jG0hdsLGxA3x9Bw1Asli7hO3BwApgng/Gjvq01IHrXJ7q3Cz7E++YziF2rs1ZLZ+8H9jJsSoECWXj6igmR87aLgfbGq4GvbgLu2gjsHwdmCEIPSI1h+SkCRjpfUC3iNWcpoRrcnrYbuGsUOMBo7QBCxSTG/igxVcBIVGPWM1h1JYQPnyKNExGZMDIJ9b66eEBGxPDY1Y5nv+GCjfGAxD+DDpiawphABWZPjwNzNLAEIH4XCH0M7/5c93bBfI8Yk2cgVAdvdT10ifDkBWC/r9lGH51NhIsnsWHOfPmEUKT94WeAG8eAO8aAfWPAwVEHISNQlKQUglJjJExqC+H6Nq93kOpUg9szbwLuHa66QzFWkaFieXxi6hgVHOMCYGRuJ+5V4jYJIDKI9KlsAvFDq8QDrnb8NWVPh9EwdFkQ79TlSMIsN0Mi5s9MoOGno4U6f3YAvefL7Y7rvdoFLxOANSA8f7xSgWmd0kCQbmZ6mTLEnJ0UqWLhUkxlrBn6n3wWuGkYuGukCsufGq2iojnRFpafsU7MDxErJuZhYCsJosHtWTcBe1oeq+hxigJgXBrMmTBPnJKLrr+VED54ibHYvZos8sO+DNcrHrDX8YVVyglAKud0LtMjFPtNMz6QLDY7VomLJd671AEH4Xu+3g7nWq28ISvX58/hguOBg8vtFQvV/hEzxfqOevuTfpjri8vAWz8L3NYCfjBc6ZYHmBcitnFd06pxyb8W4gPlgonBqffTtdTg9pybqiVNBssyUsdUD7eGO9amnf3sXtxQipl7Wg/sD4A8AwHIyZMYky50Tp/xgN2OL8y051qw2hXzwRCEdT2nmck1RxHG+w5jeO9NFQBpR6ldMIMXlFWgVndqF2dVFsJzuOgRwMElB6DcI6rznemD0RnbwQiSRS3g7Z+tVIl7PC9kahiYZm6IizuLigliT/VoUog+p8P9l3wJ7qGEanB77k3VczroUToWLCsABud4ypaLCUoxf9i/9w9ADiICULrQRWuIB6w7nuZrwaZwLBGwClSqSyz3AhHbaRGEFGOmC44D72UVgjW2C2Z4lIF4ArjodODQcqUGqAxfcpG4mJVuVqcL5tbs2z/veV0tYK/nhTAqesYNHdO5PCJZos+WuzxHJIViuXFyJxupNLg976ZK2lizUKodilGUgzyGhokF8yw5Mf+qRkjdjfuDtwkkm7DTkNaBaQ2ox1q3eMD8+B6O3H6em8Kx1Ccx9ptWl9iYIUAAWrI3I3nHgPdOtsO5eOuxXXBdj0V1vOL/so3Cxef60tlSpYwveKf0pAu6ohfdJ8k4CUqgvr5jV6VGTBKALeCAh+VbZLTnh5gu6D44A6H8cVlkNK95O1WkBrfn31R5HSy+JCwPplAxRegE/2T+AloGncNmbQyogUQx/KwB4gHj8YWNTwRAOW0FIIIndoqNkTAxz/bd09XDGLBdMM6/pLKi5whAX60gCK2ujxzEAqGL2pQ1Jis5AJEAFHvTujYAKjRf+SEugm1d2COQLU/DAwQ44caEw8AtZzSIPgAvuKkdrWMM6M7xCMBoiBn4YpCE2NCfxWAA5MEuwvCCEICwlnhAHV+YORfDsWJGgPpMKwg1b9QpFnzHbD2BK2JGul9s8KkYW17vLALQRTCBpzXZpS4gtCXXMAkduuAy8E7PijPWprXJ5CR38ygw1fJDohh2BlRAgq2OeN7uTWc1D0AFNtmL54ESBsCaJcLkDajxj5ZXRiCIGA0waDwgjy8sk5+HY+X9ppUbJSCp6TnFCMXwny1WAFQ8rUAc2wUrRL6mXTAefWnFfnz3FpbagQKLAqAzoZjAKkkpXkNO5GCEvOMLFXOnnC4xIKOjnQGNdWSM+GqHQGd7JSsxUf+JzQLwhTdV4je1nQvr1MkPGtlf9yP2Dy+gAqZ6rQytfvdHSDxgLwBF8AmAYjHWluEDiKGMiqOVvtejXTBOuRSYJwDJAARgZAGWL9Nk+IM3SzgTydE4eec1nZHbtDaNAf1Dpd/SMx2END6kD0oXtFhBXmcY+OY6AFChnKnzl7NfdMR3qCAae2B+VVMYXASvDs3/X/zHJZcB84vuiqABEo0QPnhnwqQLyRURmZBPytnwHde0M1vN2lR6picoKULaxHDIEdHkW2iWg4/7b5zb7DSQAVd0/griV2JYojfpwRGEYsGBrOBmx/OgP5sAKANkcbFzNWTRnX/GSGImMYH/LYlk+gGvdT+bW+SWH+Ig1GqL5QeTtR2EYj5LVHfjw/ZDwL8yJ6TB7UU3VVoTjTYxYDK+Ivv7dzNAZIxpZSiU8jjKgIWTcykZkBawDBBnQdMr5QeTKI5iWCB09AmEb7+ucnOQ/aTPWn6wuzyS4u+R0Ob6CUGqJpIDA97AdqINbgRgBJ69CG4Jp6q/ckjXqB/RKla4WpkO2ODgHoynigA0JiLwaNiEt95YQKJ4FRC+7brKzRH9jZbN6iJYuSHm9I5iOAOhHNJfZkh+gxsBKPbLu3+JgaWDdojhMO5kkDWSlNTg4B6MpyIAjf3IggJgMD4MCARjFMU9QCgAykhSKnUCYHB9JB0wy5aTRUxmup4h+Q1uAmDs+hpXgFLnB6ULONOn5xACNJqxghsc3IPxVBGAiQG9aLeilWUJW1FvVXEN0TKp1C6At19TMSCBpz1dHtT/JH7N9yaxp6QkF73KBxYIr10nAMproB44qQGTj6sjUrtOFPtLeFQHLES9AdDFrq1E6M13MaxVCTNAXNFThIylLcor40zxtgDAPKuVwDMrOKw+SBTbtR2MND7sZwC7Qvm4wqHa4T/uIrhb+7n0EgbQdTijoyg+agWXT8llDsAFWr/B8qP1K7bT0pvtVwHhW6+t2C/m8svvZlawi2CKe37nhFtapkDnILRqBQA+v04AjMyn79EIkXO/DnzyCBwVweX4wxs9B4rRZgyPVFqykgDd+5JSpBU5r0vHyHz+jsc3ub0KABsZMCyQgeExKyFPVIz3lmcM6OfPAGCADYPE67Jfs6h7G0o+xvi7oyK4cLZfOgpsXwC2Lq9MwuuVERonKn4nSJrcXnQKcM7dwMMXgYcsVxkSebJgzOWPqdB1ad2f3gpsnwK2LXWeR9m3danUIV1lBSCPArBwtp+7DThuBti6UDWDmWA/DvXk8LRptfPtNUlihYZTOPCi04GH3wFsnwGOW6iAs5n3GeJJ+KLoE+9VDClQ8R6vOQHYegDYwuY3S6H/iJ8jb11ck0q9Qhoc9QMWgPBZJwFbpoFN88DGRWBiqQIgWyJY3lPozaGJ1KTEPh36zpTkJrcXPRE44S7g+Cng2DlgyyKwaclfFoIwvCwx9Zn3Q1DmIPx/2/sSaMuusszvjfXq1ZRUElJkKsBEGQyYhJCBSkUqAW1tsBdpuxEVaBzowXZqe1g90G2LotjQdmMjKqtBxQERdAWUAkUlZNBGkQRNyIAEMAkxpFKpqjfUG3t9//m/c/+737njPq9uVeqcte66b7jnnn32/s6///3v//++Tz0dmD0KzC4DM6vAFpd/0L3Gh6yTDgnvLwKzAWDGiH/ThcC2OWDrErB1pRgQisIQhAa+AED+HEEY6uNLyrRnZLSl6tSbrgLOeBQ44yiw8ziwfaV4UGbdegmA5QMTLFlqsfn7XecDW+eAmePAltXiXnkuZSBkRcm4UGXtU2uo3xsAZgz6y54JzMwDWzkgBOAqMMVBCSAUObh8QuN/CiTgcWAuyWhL1amvvBbY+VgxbW477paa7gIBqCnUrbUBiQuhAKDUot13IbBlDtiyBEyvtO5VDxvvVfxW/JkWNFrCeK8NAGsY7BsvKQC4hQCkJNaKy2LRIsg6SJ3IQSe1onKKC2CsOYMeN+0Dtj0ObDsGbFsEZmWp5S74g2Ir2uA22BScAJGA+dJFwPQ8ML0ETAUAkgDTPq9zdK/+sMWpPF19NxYwA4g3PtsHxAE4SQC6FdSgmGWRRIJLZJll8EGKjHiX1jwaN10HzD4BbD0GzC4WrsKMW2pNobZoCu6CLCDfCTqzgg6sr+wFphaAKQfgZHKvpRSYg7HN5XCL2AbAZwPrZGaj6ippXhgn0kqmU1woxnHedg5AATuWHig2FE1uVRwoxoX+Wcbg89S3AqCKPONcCi8oPtVP+9++G3j+oSK2xRBFDElUxbTS+3nvc4FpDsjxllXQoJg8FgdCQoGJJTTicLcQ6vPL6wbg9cDM4cJv27oAzFA5ky9/UOSvmg8oP86n0dICBn25JwjARWDSAUgBHN6vfdbv10AbARh8X91vDM2ss+NvAECKPVLCsHoyUgRqrlbnRwB933OBc+4DXrIC0IEmiLnE75di8HsyAcjzWUVGUi6uICMpVwwJVMXdeOk3XAxc+Hng+vV2esAYw+sWoP31r3eLcLwQBeQUrEHh4Jo2h4vDmJPuAyMLGAeEn7uqbgB+I7DlSWBGCwe31Gb9aL20kGDb/EGRxY6WTz8f2wtM8l4pgL1SgM8esHCvsuylME4nn9cfQLtldg6TZ0kUKorAfij23vAPCmqp3fcCl60XFINid1PlZrf41/dnApB6wSQjutUfIDJR8CGIQOwWEH7DywpKrWc8CFzqRLHkVYrB2jS2FQH5vkuBycXCAlIUUAAkCM2iRBA6+ARCe7DjYmQduLYTleiQ/XTTS4DpI+6nLhZW2nzVCEBaMLd+soIGqjD1ampdugiYWCpeBKA9bBJC9ActAk8LES26SqsftInLZ44dQif4Igdhym5WLrPDyuYH/7HTCNwDnPko8LXrBccjQaioe6BiKad3+QY/MGTH6rS3OBvCnQDuAIyqhiDkQ9RX+29yE3on8IwjxQPI8zkTiApGU3oVkD/4fGDieAuAdMw5MFQjEgg1DYsUku+a3uI0TGBfV7PotwHwaOEmbHEATvuDIutni6UAQoFRIFRYhfe/dhEw7tbe9Of0Si1g8HkrwRcevDajz07gIJ7n05rYyWIpb4ya/7vv8PRdFpj/LXDmkQLAnA4jCCOlTBRN/rFMAJKgkkVHpGUjySSBSFeg7/azqk8EgbSEq8UDRACLKDXSyaQ7Br//DcA4LSCtwnKhTEkQcmAIQhtM+Uaajl0uS9NatITXWzpzfcdNB4DpY+6nBgDaCtanYLN6fCj4u1ay0QIqtML/EYC61wSA9tAJeP6eWsAoDysFpg1eB0HIQRCIIkVeCqQf/05P3WCB+UPA+CPAzvmCaFWDKEuYcl1yMN+Y2dckqGTeHPEvvWDSNhOAfbefX0A6rS8CUw8X9066bFIfdqMHJID++DJgLACQumyc3gyAEYRRKFCLD1eu5ODLF6QvXedx0w3A1BwwxdAJLTXjd8seQnGrZ9bPFxLyA7WIKON63tYtCQBN/sv9QPm6BkLp0vl9t/m6ietR6fbyBA4gnXtORwRRpNnTtPpW6gWLH83lKqcOFTEnDiKtoHwy8RNFhrefyeztbnrBfbWfgttsP+kIyO32ELD1cHHvInrlvWs6TsnB7qAUlg/suFtAWkE55zYQ0QpqcALoNCXTEt7A3KoaDwGQfqoAOEUBa7fUbKctltwCajVbxvSiyvoasM0BaBKwwdKb9fN7NfcqBWGiSWykWXER0umeacUEonQgCKRfIgDFjya5yq8Wfsfs8dYgiuMxgpAg/vnMzu6mF0z6Zj5APdvPQec0TEosnvQosGOhaLuIYvnwEYSithE52F1XFAA0p5yigD4otCqygFKnpHUpLYP0OcKURYv6Mj4MNR433QhM0gL6QongawOg+6rl9CswKoSkEIxPyTsuAPigCYBmAXVfYcVf+n0SRYw6dP1YwNgHsgSajiJP429RrpWOM6cxDiJB6NINM4w7LbUGMQUwB/M9mZ3dSy+YVG0EoBiDBST5ddZ+PkCsAiIlQZDa3LVatJ0WXG2PbL98AB+4omB3oP/HgTUhmGgBfRqWf2TTrUSjExDSP/qWzQDgfAFAWyzR8rkFtDAKX75jo6nUguZxZ8NByHbvvqBQ36T1swcsBaBAGGRg40Ir+rt9WUDhQ5ZAU7Es2e9LLzglqHRxNkbeuW+oQRRls5jaMjnK0a9ecNf2R4LAwO829kQB3LTtEYQPUwzQAWgW0AGo8AQH0ljp/V17pm0KRcEifGuNOnocO1rACQbKPXhs8TtNwVr5uh+n6Zf3wDgu29g2FdMtOc8B6PdpFj08ZFrplw+ZA5FTvAQQ0/BT36FPDkRqBT9Jag7xYlQItY0f88j78sZzCcKPZlrAQfSCK9uvB4h577SCotUiEJ8opq8IQFl/PUBPEoBLxbRE62LSqG4dFB8r5bHcOtiOQSqT5T7RKzYDgJx+BUCCTxZQCwhaQc9oKcEnEBKknj5FsJ1LAPo9xoWWPWDy+6IIoqbeaO0VA+zHB0zxIQDKkn1GgtXiRxMIAx0Vn0Db+lkuFjLRCt5WEwD71Qvu2H5OfekD5FaciQay/GIbFgBXriwAyGmJADR1ck3DwTE3TQ4B0LetzBJErTYAr2BBSI3HTS8tLKBZPo/fWQDZp197Z3scjGb5BDp/L3+njMweB6B83Gj9wj3atOsPWin9WgXCFlVO/3ctf4iD8XkBkH5USlAZlNPZAQqARr5vxu1yjmH0givbX0UQKI63o0Wun/xHuR8E4VnPK5JQLd4VNttTBvK2uoiKOUf/f+GjwMNBh0NMV6J0c0NpcRv7mrYv3kh8/uHxYp+bVpwLp3R7sts2YzouSq3KGa+q7+x7Co4nazAerRKsVlV1QitF59dyyFZaYY0HMu9mWL3gtvZXMbymBIFMZ1ov2h0B+LTLisxgW+Eq5uU92iZ72ud9vvR+4JFp4NjkRh2ONi0OB1/UBCkvEYRhfuNs4OmhhiPKnFQlx6aAjMnSXJUAACAASURBVPjmz1w41nnwO4cCIBvBwZgTAOUHRq3gyDExD4zRGVYEnpm5LqmQc0M5esFt7acFl0SlHiBxuTkYxxdaihUC4QVXFu5FCUD5QtJl85sjGA0ziQxqeu/fem+hw0F2fLLQGxFlYMRvo7v1WmIVtpt1DFkXvOR7LwJ2HSkyoZmEypoVVe8p7b6qEMnidGG/Vl/L2aPOIwuA1pAIQE3DAmFa4j9f7CPaFpCHKujr5xzZesGdHqAqKz5X+FLRAl58le+jui+kTBALMcgZ73CDBkpN2/7+bfcWOhwUyCEAjQTcAVhKdjkPc2RajewKyu/n1//qJcA2uhBMRGXQOcn9U6JIOjXHQqSYOsVoQp1HNgAvz8yny80H5PVz9H6RqVd849WtXQ/zA0Ow2ayGLJ474L0G79vvbulwkJi8BGCg4S01SKqofoNvSIC+5zkhFUupV8rUTpJN06KpaBkFQm5M1HlkA3AyM5/u9Zl38zrk6f0iU6/4hmscgK5ISUtCTowyDqb7UxwsqFJW3fo/vbuIBJEZ1YRgyHwQKNi0KEl1OKTCZJdxtPDn//v8ooaDaVgqFyiTD2IKfcjZS4Fo+7g+HXOPv84jG4DIzKfLzQf8KVfI/FNKrQ6h94tfz+vOA9cGAAbrpylY2SDlVTTt+uCnV3/V3a7DQQAysJAwobZJgUXi78Qayhd812WeiOAZzEyUiAkHMeu5BF5FwZQAWLPwknkLQy9CrPMy8+lIHZFzvN3T+YbV+8X7c64OHHix74V6zIxB+RJ0wQ+UU992tYoFy3fcXcTDxQkoPsCUhFIczKVCegSg5B8A/PILN9ZwxBSxtiKiUAOi7JW0dLTustF8AGbm0/1o3vjjnSGdj+lYlGwdRO8XN+c1wABIoHk6k61yuSCJITq3jDY9Vx0BqK++uwAfX6JkI/hME0SC1EGguiQ+isqcQRLrF6/0jO2w+6FMnZhyZYsQ1W50qOHgPX1NXndtODsfgMwHzMin+0+ZN0S9YOllMzWfLwKQSS396P3iY3kNOLDPM1y065H4gOW3p4uTDkB8zWdb7FgbdDhEgJkCUDRvogTmd/vPv3BVAUBuvylNzAAYi4hisVQnEHoIqWblrxqm4Mx8ujfljT+YjsWBYgIOc0oJPsq1slCpH71fKybJOEoAuuVTRSCnYlmU6P/Z4iSJEcbLv+Yu9/1EAh7JKEXDKxq4ChUiKymRbwjgHdcUWTARgLYXHSr2LOU+BV7MVwzxwOfkOWybYAGZD5iRT0edjpxD6VhcOQ6j94tP51wdOHBdMeXa9OqWRcmWXA1XLUIUH6zyCwlAs3z+YBkfs1u+VIejJEF3ckrjI9T0y/aMA2+/tgAg08VURKT8vbKMUgAMIGzzAcOi5HknHQAz8+l+MW/829KxhtH7tTz+jIMAJPCYMULAWd6fvi+EY9ouoZBM/Kx/4LUBgFLgNC5o16FrE8JJVJgkiFhaQQBv3+dVbMrWVsC8UxFRkjjaVsW2DtRdOJ/vAyohVYK7A+bTvTdj8HlqTMcaRu/XxHkzjgNkIOWuDr8jnYYDKDutgpUhra0uAlAyCCUAK8BXcjBXgLCk/h0D/hcByDxFAdAzoFUqUBYRJTUcMWdPP7ONL6i5bLQeALJRQ+bT/W7G4AuAOXq/lsGdcRgAY+glLkYclJVTsa6ptCX3uQjAKINQstFrAZKIwWxQIhIJuovB/Nx+r2LzFCwlj8Y0evl/MYk0kieVtcvrwGUnHQCVjjVkPl3mItQsIPuElx9G79dOzDgMgGkAWlNyBJn8xKprBRC+zgEo4LWRgcdVcOCjjlNvmx84DrzNAahaFZWLygKWxUNibIhTcPD9BMLLa65bzreAMSGVoXvJ/Cgh1WUfO+XTZS5CDYDs9GH1fnOrIDcAkABTTDCCLYK0Cwi/586WcKJUiEpC8CCBYDsiiSplqUIUmOjf+o2tIiKVUJbgU5uSWl4DWwX4+PcXnrQATBNS+8yny1yEopdcay+930y5YhgAg+9n2OoUeI5TdQer+32fdhmGoOBZanBo+g1yEKU4dYgFSvqB//vZBIBt9RshkTbW8ZZZ2hUgvDL3iU3uux4LSBM0ZD7dPRnTH08VAIfV+2XAOucQAMuVcKfFSD/+IAABsEoGwYAoHZIKEEYxRIHwLS8pUuhjFVs6/ZZhIVWyxVKBBIRXnbQATBNS+8ynI4tBzkEACv+chlUVIKE/5cRGsWmlKfIzudc3APLQSlg3E2OCyVRc1kpU3DgBmKoQsWtlBcswjPu+nfTYtBL+GQdgOf16GCZW6pXlBCqWSgqJypoOAFfXXDifbwFJLvi5HAjlnUsiIe6AjOp4iQNQHRlT2PlgJCUbbc2s+v/hFwFb/q7gm6HlYpBbmTV2sscQyy/qFBj2v0/cAdz/HGD7NDA1AUyOOU+1CwWOewNjKj6/O03F1/WuugW4/XJgfBoYmwDGdH7IxB5kLPIB+I8AfNwZgga5ck2fJbEm8V9zNWPfrasbgMuPAcuseJ8Exsb9FdBhA+7gaQNKB6TfcgCYug+YJT+g89aoBDMmIMScP12uTKj13uDv8zsKig/uJ1uQOsnojm3qB5P5ACRBH3OhPuzzRN9DV88HqQLEWPJnvTy5nm/t/1s4BcuSpRZtGAu4fi+wtBVYEyccrYwn6hF8/FkJp9bKxAKVFsn/d8urgbHPA9NPOEOWl4+2cfoFHhfVrJTZPKHSj5daOtup6JyCpPx8rHWRVQ7WOlrYCMx8AHIzlxkALPD9c0VB+x/A3E/+E2fUYHXdF7KTGwdvTd0AHP9r4PgWYG0KWBdfsBdsMPfPrKKsoL9XAVLAvO2fFylCE4cKliyrDVZNcGS1CqEYhWFiAZV+XntaURdTLmpCEbpchTYLqi6NrkMCzLzt5Xc4HwyJmmkJ+Z73jQOh4NWeDUZiK1K08f0EXt7CMHVawIk7gaVpYJUA9LI1Ao8bzKX1cytoFtFfpdCIWz7rgzHgth8u0oPGDwETc8CEMySUzFaikgtlpW1Ta8JqNba7lVljSRgW+Q6ZP/57WQvj6fydBjXfAjKbgEvMLwWCvhNoipgNpnQshlS4IGFWzIk6ylWwAz93ETLxGWB5ClidLABoIOS7pmGfG+33YAG5mND0G8F4678vkiPJczNOAC4UyQm2N8w94kirFlfIAl7i402d6dbPWWAtrsjOFiuCvAJZOQE0pHTFsckHYDeCvhNgipQNxoAz8/8IPr5nbvH2jd+6AThJAE4AqwTdZKEBLDoDgU4+YVkPHIBoPwareOt/BkDexsMFAFnbzNJYm0IDnVwbt4uyur1kwL7Tp+iZM/08WT9Rc7DHUmuYTr/x+6o4ovvu9fjBbgR9JyA+omwwxvZI5ULg6ZW7y9FPf9QNwKm/CgCcKABovh8ByVy/UCtJq2f+X1yYJPGU27lIZLbuEWDsWBHesZeDz4iURLUWa1TE47LqK12fZmd3OXidFctqm92KatVs1jAEsNv6sdymaa2g8+xUL4I+Pn2beCgbLGWHI/h8G3oTr45iK86POlbBU9yKI/AcfLR+ouQwH9BfmmbLlTHboOnZ/T9+5vaf8FUaAThXsFOQ45mUcgZCWTAxe0UQ+urYMO1/37GtxQmoLCBtRSp30LrDp2SFdzYMgk/R+VNwvwR9mwQDsaspGSfJgYDYNTbp8psCQFJxEIBkQjDrxt8dXCUIY+COH5MVFPi8SOn2n/QYLZ9Gp0cxANIP5IvAkzVzxivRydnKNzBa8fddM84b6AFyAriMF2pajk9kYIeoClXmA3AQgr5NQEHMBqMVFMNaIOayNRL/vhlH3RZwmhbQQUcAasrVVGz4EtjCu/3dfb/ID3PbT7uKAZ/MhcIC0vqRTo4W0IBIEAmEtFwCYqjW03bcmdwBYeoWgetUbrR8snrloiR2drpACf+rD4D9EvTVjIJu7HBV+781X752Czj9lwUZkTEgcPoNPp5Nv4oBRhCG6dd+1DkMz1JIhR1BAHJ7zwqO3fIRRM5tmDK5CoQKsSgOeBYBKFZULTqcB9r6Ni5KYmd3WKDUA0BlhNLM8EbT1QBXBU72aI5ZjUcVOxz7WLkQ8d37vsart/uA6RcPsxNSAtAXHDYNC1AEpf9s01kKwuBwGU7HgVt/1jtD1e60fgQigSe/j5bQp+KYpGB+H62jT7P8/ZypBIC8Dhcx8eY9wF015abhmnoAyJ5WSrKeNgKO9SHxnT/LSasJBim5lRjWBEIVeROInKL1qunybRawLgASdEy74qjaNNzJCgqEEYzBGvK0297mAFSHEIB6ebKDgc8J1ksmV8t29f1en6L5v6cxIK5iK6Xne/5jCTiFcTqVn/r/tWDPWwXnEPTVgIKUHU7ljASawKefIwDpMdRxRB+wFgD+RREDJABpwSzz2c0LfxczVjkVKwaYgtBBezu3SvX08d39P5uO3QKahXMQciourZRAGKZWar/YZ1xXRPe8wQr2AUK7TvbOVTZBXx4MBECRnConUBSFEXT6mf/TK+/qmzAF/0UBOPqBZYF52HrTFCw2LH5G8UCzJEko5nZqmRnPh/uCXmpnVpDTsIPPwKApOaSA2QLDLSHf97iPx0tpISLfz7bl4iFfsUsnj+HZWEeOYDCDnDmCvZkEgedcCjxGseIhBYt3vx049HwMLRh8gA9gh2MoH9ABqKJzxf0McO7XlSAU4HzhYYFq+5D7hwBu/98OQLlIBCKnW39SlXNY+nqeiq2dkQg+gnGPb9/ZpT0lq6MV5D96gLCwgDmCwbdnCvZmCgY/dxy47xxg5SWuUjigYPHFbwA+fyGwfr2rXrMvPB+vp3L3GHCgi9JOHQCkRVPppeUBigXLFymyejYTB4YsgfA20ofRAlYB0FfAlvQqP0/TsX5PLOB5DNu471cmIwiBaRww/F01J+mz2pqChxUMZvpJlmBv3iTocsW4dzewfhkGFix+2febXDAeJO/YEILBB7pU1g8LQFo98QASVGYNQ6DZfEG3fnEqrgLhbf/HV15anbkFNCvohWSl9XPQ2XTM/2s3I4DwPIZwBEDfgitH0Ek6N6x+u/iD7T4g/YdBBYPpWHEaHlqwNw+AQa4Yj54JrJO+aQDB4pt+oCAyYvOPEIQDCgYfeF/9U3AbAMX7ItAlVtAspKZdz5SOlvA2pstxjES3wJ+92NgAGK2gwi78QoVfEhBeQACqNNP1RdoA18kKdgDhxkUI/zKIYDCnqyzB3jwAJnLFOEIW7QEEi1/1Y21ywVglCAcQDD5/Efj7M4CVrZ5AKlkhxeQUaxBI4nvFzxf8IfCVC4HV7cC6ZEX5nen3VX1vAGLZq8ysrvHY+QBwbGfI2E6JpLvdX+ksthpUvQrmX/sVDGZVUJZgb17vJHLFeGQcmCdVb5+Cxd/5xjZ6QzzMLOQBBIOfTV2Ps4HFHQ7CLQUQmUrV0rgKJMsCjsxGAqTn/hzw0EXA4tnAyg5gbTYBorKkUyLnkB9YVhTxu+kT13iccwtwdBewPAus+b2ar9xJAafqfgMQO4dh+J9+BHe5gqZZZzYok1JJUcpaR6bp93P+W/N6p0KuGIemgEWKgPQhWPxdP7NBLhiHKYHUp2DwpZ8rLOD8tmJQVplOLxAqmbRKC6EDYC7/CeCRPcCx3cDSrsISrs04CPm9ArZk55UvKAspYLqPaPdR4/H0g8DRHcDyVr/X6VabLHk2PhjpPVZY7d5xwF6CwS9y/4LbbVyQsEKIufGiKe0p2JvXOx3kinF0GjhOQY+oNRtljji9TQPf/fOV9IZY4Gq4D8Hgy/4W+Oo2YG5bUUy04vUcLCqSJVRWszJbNgxSmMau+q/Ao2cBR88EjtOqbgNWWaTkIFz3YiWrF4nAjtN0nBZrJnU+/8PA3CxwfMYB6LUra3oglL0tps6wlVha5rLiqd9AdDfB4Je6U0s/0BXTDYh80Sr2FOzNA2AXuWIszABL1JaKWq1R+nwGeM17OsoFY5XTVw/B4Cv+Djg0C8xvLYqJCECzgsxmZlq9T8e0XGUyaUizavPtxoFr/zvw2BnA0Z3A8e2FVV3x6c4sqwObckeyhiXAowUSADhD1XhceDMwx37lvU4XxVN2n3rJIocygkr/Vbs7fe+EdBLcfaXXQ3IPWIrpBB6XlnwpR76jYG9e7/SQKzarxM7qJFj8mg8UarMV9IZ4gvNDD8HgKx8HDs8A8zMFAFnPYQPDl0Co2g4fpDZLqKCxT0/7fhJ4fCdwbFvhRiwRgJruCOwUgCpeCvUjZmEFxhfk9W969kW/B8xvKQqnVgg+B6CB0MsI7P70AHgmd2n1NQ0rv7FvALIlVYK73MnQCDLThSGZoDpuP7uCeuX5n8zroB5yxThGnQ0CgyBMxY63Aq/5aBHG6EBviDlOLV0Eg1+0AByZLgbl+HRxnZXJoqqttA4ODovlJZVuSjTQFtq+NwNPbHMAzramdVpVs6wEoPtdNg37wJfvsYiJP9NFqvHY+7vAwjSwxAeNxVO8T6aNVRRRlT6hHrJ0Ovaw0WDJCKng7g86APvNB9wg2JvXO33IFWOBgn8EIf2nRLD4tbe1+AU7yAWbZeskGHwVdd2mgAUCcNKnJgLQrZ/V9/Jnn5JUYmnAE3hCmv3+t8AWQfSzyPK/POOgJgDdsgqA5nfJAvLdLV+bz0kK4RqPZ3wQWJxyAPqDVhZQyQr7gyaXI9axWCFVAGLvRUhV46PgLnUWBs0HbBPszeudPuWKsTRZAJDTo8l8ui/42juL5veQC7ZpsEow+OrZQlqVVuH4FLA8WVyDAOTAmHUQCAWQkOlsQAwDt/9/AE8SgPQpNa07+AhAA6HLXbb5Xr4IaAMfv/eGvP5NzyYA7UGjBWTWjh40v9fSyscHLtaxhJWxFVsNNAXH1khw983+DYPmA5aCvXkdNIBccemfceooAfhAAcA+6A2xLuAGucxrzgKOMexDfV9OwbS2BB/BEoqLSrBoYGgJ3E8qLcIEsP/ngCPuUy7S13L3wb6PU56/m/Xj4Ps0TKCXQA6AXuNeZY3HMz5QANAeND1kwcKXlj6wOZQ+b7R+Pi0PD0DeFAfk590CKg8qncfoFzIRVWVqfFfBhgn25vXOAHLFWCDbvPstBsJZ4LUPt+jdesgFg+qVptWq11bg2gtgfuLiRAAgQeg+oEmsOujsXb5SsAoCIN/3vx04OlNM6Yv0tdx1MKvK7/TFjVmeCD4HQQQhf159eV7/pmc/kwCcKABoeYvR0oept7SEoZQ0Tr1lPuPQFlAtO0nyAcWhpzw/FSjFzGjLx+RGvxzoSeC1hwsA9klvaFN5FAy+9mJgnhaQ0qqagglADo4c9AhCDpJPl5ZommQ8738HcGw6AJBW1VecZv0cePwOY0/wl1lAD/WUCx0mMlDLr8bjmb+Dwp3x4nkDYbD0thIO5aNtfmDi/xGEeRawxhs7Vb/q2huABQJwAlhyy2cC0xoggjAAUCWWAkksOiIY978TmOOqeqqwqAx3WGhHK06n7TDwOcAV/iipPAKjwgrZm2o8nkUA0gKmAHTrp+o9MTrEYvq44o9pZIOtgmu8mafCV72YAKT/RwAy5OPOuVlAAk9Oule6xQRTWUKlWtkU/IvAHAHti5oIwDK841ZPFtCmdr0U8PaC9hVultd4CIC8P2Ztt/m5/qC11TJXlJDGGpfGAmYODgFoCxACkLpuWh3KCgqE8gNVZK4KtxgjJAB/2X1Krao1rfN7CWZf3LSBT4uAEIyWBVpipL7GgwA0AW25GbGENBTRx3rm1M2w39mmrFVwjTd1Kn+VAZALEE5LtIDyMWUBvbLNLGHgd5H/V07BDp7r3uU+Jadgn3ptxekA5MBri0/Wp4wzBjDbCnkMWMqVpE8GJwLQqvfc0pqbkVj5aNk7gbCxgJno30cAjntowtXNaZ1suvSKNhsYTcVKmw9F5xGE+94dfEoP+JYhD/8OC8eIPUsUHokVVKB78XszbzAF4Pvd//PCKVGIpOAr78mn4DZOm8YC1jco+w6EFTDDPJqeCEBZBa5GffVbhmQ8DtZW5TYOvPhXip0GTuu22lTMLSw+aAVl9QhEWjurI/aQiLJkTMLsX9R3r/ymZ73fp1+37OU9hunXSkdl7T3QrhKCtlCM59k2i5CMMSIAGdqxEIwrmptzTsCEut5yilKoJLAcxCq3fe8tLCDBFwO+tKjyuxSCMdYEXoeDrHcHvu0tTwLzmwHA4N/Gh6zNCqqeOSxC2lb8tQSiMwbuqXIqAcjFh2JjBKGJyShQG6ygVbfJegULWBYcMR3rvb6oCRaQwFPgl1M5rR7/JtBZOIZWx/0+s4QeY5z/1/X2tFnAxPpFELaVkdLN8MWGVr4pCBsfMHN8bmTKfCjZ0Ncp456/x58zLzfw6Qf3ABd8pUgEYmqk5bGyek06IQl1bkXScnlN/u8L24Gdx1qVq91KQvrpgwaAAw9p+wnXPw1YjyWMGtDo2ASOFGMU7SIEUzdYD34vMPmXwLbHgdkFYAtlGiim6DpxJtvq9LtlVr/aWKEB8pUXAOOPAFPzwBTZ9r04vdQ9Ts4pAZ3cd+yHxgfMAOH+vcA69/9Uxijmz/AerYpdar1lNSMYzV+vWY/34I8DY58Gph8Bpo8A04vAFEFIknIHohGVR62QhFRSYjQE6qFri2z3iaPAhHNNlxKwArI0Q1IAxwfReacbC5gBPp66/5ICgLKCtqnsrKKlrFZUFPKOr7osMTtdsxzqQRZ93Q1MPARMPllohUxRqkEK6gShOP0S+dY2hlRv99y+ovRi7IiTnTvLqmg6xDPYpqAUgRgsoR7MxgJmgHD/c4E1FXu7FRRbvEgd7evXWlbPpp9EgUjiJpwe6zwOMlvpAWCMVusJYPIYMOlSDZRpoGiNxKzbdIQlXONMWJbGtw4svdgz3El47nzTRvPrrKptAJT6ZrzfintvAJgx4vsvdQvIXK5VYF3sUZxmJUvgA1FOvwF8spKyBtM1y6EepI4LqVMedbEaTp0EIKdPKh5FqYYqSxgo2jgFr13j6XXHnOiSZOeBVSvyC8qC2r05FVvVw9cAMAOA178AWPMp2LJaaekiCPXExwHw660n1oB/niGQazwOkkSepbJ/72I1x4CJ+cJ6lYI1riccrVicUuVSmIW82pkwnHHVOKbFsOozQGkFkwewnBES37ABYMaAX39ZAUCCb82nIlo+40p2gNnvsoKunxH1xGwA/LOzdQOQJPIuHzV2GBg7Cow7AI0l33XfjOsv6oVodes6ISbBsAZMX+kJxU56KY7pkmFVhOciuvTzSt05v0+ryuT/9gDrZNe4wPMsI7VJP3GcP7gUOOdvgL1rRYJ0ZI5IV3hV4/wrGYPPU3/AiRhYusy2K7mU999P+z90ObD7LuBZK0Xdkeq9NSX2+o4HLwfWlopFCC0fgciBMtAFC8CGrYXVoVjnU2G7rTXrzh4kfRzLY1kyGwBoeiGcPiXb5eAzdXWnazPCSScb4j3xfmav8Cx2p50lAMW0VXINitCogl2r9H2dcctWwQxQsn6ZTBbMNtcgdKIbiZj51VcBk38CXPxoQcfCUg8pjcYgZScw/momACnXyr4leBhs5QaBTHpf7X8dMPYJYO8XgAv9e8QJlAZZq8D4xSuANYKPJQn0AR2AHKy1MACKe9nfFI6IEqduEWoHIJ9wlsVKLekoMCa9EAegSTYQeM4TXco2SEMkAHEbBZoj4bbYtdyCVrFqGXgTSxgXYTZeHLi9AMjEQRCVUXP/n4KUaaT8vVTi+Rtg7GPAuYcAWlMCgUVkQfJ2Q12yBvPXMwHImhDWwf81imsTiLSEvHZkr+jY/p9CQRD4p8DOBwteItai05qn31FFdfLlFxYWgCDUIkRkj/TxbCEi/89jfPZ3X2VqYSJQbmUNQY3HQT7hbv2sLoerVwKQHNEEoCsm8R4MhPRjXUGzVEIKIoY7yaEYuY4dgGb5RXruoSgtSCLLarkICQ9f6QNykGjFdjsIBaI4kGlt8W+Rg5g0HJ8qAp47nihAzFpuWtPIMBZJlASILvR6fQ0DCVbJCkJOJCqnk4pGpb99tZ8MopyiKDX7WWDiwYKXiEQOehCrgKh+eJQ+EQHo1Lby/zRlyf8TIbf9XS5ftIb8I92YugH4ay2pLusorl7dAoonWtMwQSTdOFuQSLTGHyIC8kxSIQuA4hwU2WUAoO4/grBcDbsfWElSzg+JCoYDoEGM1ixSkHzgF/wG7y8sIa3J7JPAGWuFJSQIaU01iJHUiYP4e33BrPOHmG/JMaOfTZVYRhwGav87vWKPJ9/rSH4IOGO5sITqg/ggxXs4TOaBAECbeoOsgfl+DrQShFqcEIhyyt0MbMusEkx76iAZXKM8BvXiZAGlF+KaIbaadYpem4aDgpJZQz6YJABV5VcHAJZ0v4FxX6KG5UpYs0KnqjhRuagEVgPglYAl9ciHf8mdUrJh0Qx9vkDBzBywfbkYQIGwahA/kglATsHsDzKA0BATiPyZ4NEDwIeoa/uFYKKXL2f24nQoIgd9R3yQCMTFqwIAfdBWI7+yB5ZLECYLETd85YJl+2YAUNosLIel/xYlu4Jsl6bhNhD6it4WJCvA2Zc4Gxo73RcgJeOqFmGR6rcChLYACyGojmEYdj59KnZ+tIQRhH9IvWA2hiREjDeRI9Cly7fMF3EtWRFawhQIf5IJwE56wdTIYdt7tp9ys1K8JnoJvod9Wn682PNkP4hUy1ndWgstAtBDMLYN5/6PAc5DGNoF4SrZfN+4+IhT8jqwg2Cp8ThIJ5vfSWBXAVCrWN9SMxDK+skaOvhoAc8me654pmUB3f0wyt+E8FyRAGmPlOEoiSD2qgvmAKoOm52fAuiTDHSyIRxx+lI0QxxADubfF5vffMmSajrWlP7nmZ3dSy+4r/ZzAUEHnQ8R70HsXlK+PgJsW68G4XYGZj0EY2EYATCAT6tAhmE0DXcC4faapcwMgAIfLb0kuzT9Qmw5uwAAIABJREFUSi+EfeALkSrpBovbrQDnkm8wAo8/E3i+CCsZ98NCpAp8cUekZyBavI4ET/TnaAk/RQCyAXy6uNSPA0i+wMeB6ePA5HFgZq2wpNGK3FUDAHmv3fSCe7afX8CB4UNEEOolVi/3obastNwJ9cO5BOBKEQMsAcifHWzRAigWWAlCn5K2bQYAOe1KMjTIR2kRUhKVS7IrLia0v+3xwHMZMCbYNP0KfG79zAqK5DxOvyEuWu6VD5KSHy2YAEQAfpaRdl5UkuUctIpBnCIIl4psD03FtIIP1ADAlBuJM47EqqUX3LX9kSBQcuuyftK78xUkHyQ+RLqHZ3Fv1KcgLj5kAQ1s0Qo6IA1nHhNLQzA8ZxvBXuNx8DcS5UYpNnoYxsCnUIqvZo0F3wPTMa7Hv53HOJVbS/l+5bumX7d+5WLE44hxIRJB2NMCqj9ixwuE90svWCaIA6bAp959EKeWChAyA0PTOV2unGMQveCO7bfqHbcS4rJR7Ewqnw5AWhLuImg2uFQAXAVs8RGmntW4+g2hB3P79L/EJ9zGvqrxOPibiVihAOgrWQOf/EBfBcsPNBBqW9Hv6zzGqFzmoXz3B9AePgXiq6bgiv4YOB9QHS8AfpkAFMMjrWAcQA0iO9XJiQyAnos2vV7ESHOOQfWCO7Zf7F40mZFQScRKAYBaSU6vAVcTgN7xXHiUFpDTMK2dFh56912BTiDcvpkATIXzCL4g3WXTZ4jpGfjoF/oihL+fx+0yWUABLwIwtYKKIabgCzHQvi2ggBKn0McEQDaKT5cGkIOo6SuyYzEfjQB0EM5nZgAPoxe8of3sgSqCQM3jkdFLvpRvR13+7UVRuhUFSavNO6otwp88ZZ3+t4M6HLtch6OT9AG/q9cmtf//gV1JDYcnQ2zY6/YakfSrU+Pg1M45NqPt3IEtoM7WFHokyrWKkooglCMWLYjiUXMtK3g8Uzd1WL3gDe3vRRCoUEYCwGtYFxxqgA2E/jI20F5hhmQod98BHNnlxOTig1aGiDanO21yV4DygWuB8YeB6fnC9WEtiKVVKeE0ZGiXWczeJoWMIig5a9V5DA1ANoKDeDylZ9NSXxyAsiKawrQqmCv2HVf5e8aRoxfc1n7xs+khItAUvojvyWryxVcWJZksVSyZoQRA3dcAoHzax4Gj2wtu6FVKM7gMgti02jbV476oUJJs1j/AbA1mQ3Pm8eTRsoZDtR+xZKCiEKmMXTIeXHPGdhYArX8FwG4DGMEnAHIK4yvT58nWC2b73cexaZgWWaEKgU1gjNbPP7PvOYGsUSBkv3hBtmRWNzxjTk9RWktvxp6POj0vARjY9sWkFel8RWxegjIF4RjwAOnZWMPBTGjqvHmszxJOBUD3xyznL2bqROvoP3N3q84jG4C7M/PpcvMBef0cvV9k6hXv+2Yno5QfGArRbaCC0mWv2YtF3ecerNDhkNZIIsXQRv5dlTtGADJSz2gEE1EJQM//026HdIEZLC8B6A0tk0g1Ja8DuzJdphS82QBEZj5dbj7gxZN5er/IZI+67pscgE7QaDOUMyC0Wb8+gXjuR4F5J6YsaXnFhBoAGEVvUhb60jISgCQnoh/OLBgvIrL8v7DdFkEYM5dtNg97tvz5zJqzdfIBmJlPl5sP+DJP5xtW7xffnzeh7H+Z+3+RpkyWT1YxuURJYVtx6T0fCTocouQV85VkHRIGegEuEv/YKpkA/JceVmL8kv6t5/9pu62tfiPWcFQVEa0DZ9WcLJEPwMx8uvfnjT9IgZyj94t/ldeA/S9tMaGa9SNdmsIxbvVscVJ1GScoMt4UPwhAsmMZ0aXzQBsvdGRBjQz0FUpEJRAJQOq4KAnBdz+sfiPJ3bOYn8fsykyVWMfiN3BOzckS+QDMzKe7OW/88aqQzsfE5kH1fvGjeQ0wADodmVGwOeiMsUqHrGOnS4UFy9P/wAEojkEnI+IqOIJQNLgpCXhcmLAtD/D+kgQE235L93tj+YBqgTX9BiCeW/NedT4AmQ+YkU/3sbzxBymQuZhm8g1T+QbV+wWFdjKO/Te2mEFNlCb6gPF708VJ1TXHgKd91GnZpDfi1k/gM2vqU3DUnCuBmNQe3P9vw6pe229KOvB0K1k+ZS+rnrfM2AlA3JMZtah/EZKZT3drxuDz1O/yxAwu9JgJxr3lQfR+8aa8Buy/wdWQZAVl+ZzCrG3q9c/YrkmHy3IRYryAAqAkEBIlopJxNNUbER+fA/H+/+AAdP9PmS9dazicJybm7mlB8nR2dI1HvgVkOlZGPt2nM29GCamcGZjAwlQ+vvrV+8X/zGsAAUiLVPp/wd+zaTMFWw+/kAA0GQQnpCw5mDsAMIrcRB5mC/+MAffTwgfwKY2KfmCZ6ZIkUShrxXxBX4yYaV8Hzmcn13jUA8CMfDqWYeQcSkhVOl8U6uxH7xekrsg49h8oiCENgC5TUG5vKxxT8f2aRtOtcAKQ1s8soPuOVUIwpchNlEEIOyNSIrrvv3hwnckWIZPZsnbcDyzTpvg3lU8mpZQqozyfK74aj3wAKh1LgrsD5tMxiz/nkGD1sHq/YNFOxkEAcuW7oqmXlisuQOT7VV2jwi/kTgj1RkoZhBje8Z83SCAEEJZW0C3gff8tADCt4VASaWIBK0HI9q8BF5yUAMzIp8tNx5Jg9bB6v/jdDPSRns0BWIZeUitIo9IhHmhXTvzCPQddccnZ76U1V/IvC4SBCFyg26DFNg7c++Mhhb6qiCikT7WVUmr6lYn2nRKyrdZ51GMBlZIc07GUBdMjny6XCiUmpA6j94vMZbgBMFo552pu27PXAqXTyAUQcitOQjAm9xX0N9pIwIPmSCmH5QuPqER0L4kDYgp9zOUL6fYxkbZcFceyAreAF3GlV+NRDwAz8uksnT3jiILVSmpWNlhMze+k94vMZfgGAPJeHDjpCrgM01Tdry9OzvmYAzAqLVWIwEShwzbRwwSEn+MqP6bQK5tZlWyhjCCCsC19Xv7gOnBRbgp7cu/5AOyVjqVMmA75dJZ9nHF0yohWNlhMxKnS+0XmMtwAmFq4imnYbrEqNJPc+9kfd62RKh0On8qV9hXZ9askEPgAfI56ziocUgVbzGT28lEtRMoKtg7lBHtznfZNA+CQ+XQWM8k4uglWK/NLYKzS+8U9GReXD0g/Tyvh4Ne17Yb4Zbr6g6y7/aNWcoPpjKRTsJIags5IJwkEAv6en05S6GUBfRWsUExZyVZVQCQwrgN7Wfdd41GPBczIp8ODeXfTSbBa6YYxlY8/p3q/udc3C+jTbtvqt2oadnB2m4oNgMn0W0p+hYWHWbwg9yU/0Kb9EIy+5y2hiCit4UgKyTeAkN8Valk4Le/ldlONRz4AWWBRM6fdIPfHstw/G+SE5rMnVQ/kA5AkLHS0ak7V7reXfhgACaBqDtD3e/nmc5k9kA/A80JReq+U38zGVp3ObJo/BvAOD3dtwiWar9zEHsgHIGlFubqSx7+Jja36anLLcDvvgwA+NDpDfILv+qlzuXwAXuSjrkKemlO2e3U1uWUYnL8dwB/5e2apca9LNv+vsQfyAUheX4VguB+mzIsaG9ntqxhF4Xbe3QD+n7/uHLAW9wQ1tblMRQ/UA0CaHC7plXEh+q4T0OWcfhleYTSHBK0EH/mi+fcRuKQn4I6fWpeoB4AevCz3HOOm9yb3F5mBlZBNclYCj1aRfyfrbgPCTR6AzK+vD4CyglX7jpmN7HY66d1E0ctdIrEEE4wEIMlam+Pk7YF6AMj7EwAVbU82vTerCwhAXopJN9zVI+AYrOeULLZgErY2x8nZA/kAJGWr0naUWdFpy2cT+oCWjpdjLFxE5UzYIBBpEUX5nLnlvAktb76SPVAfAOUHpiAMm96bsVtCAMaKALICMyxDq6cXfycA+b/mOLl6oF4AiqBRIEzBp7/X2Af0+fi1XIioMIlAI+AIPIGPmeROWV3j1Zuvyu2B+gHoFfZiDS2lC0LiY52WUADkQoTTMH1BFSYRdHoRfKSu5v9qrizMHYPT+vx6ARhSuDcAzzmDo5ZGHT1PAKYMwQxME2jiSo/gEwBrrq+u41ZOy++oD4BaCcsXTPiSI3ey8s4KGoG8QwCMFM+0ggQhLR0BF19SXuD/ayakz7uR0/TsMcxg3SjfqWNA0hsrga/ojaq/8WPcC+YIk4Ke4CMSuB2XVht1Oj8zIfXlU8BtU8DhmYRXWdfrdF1fgr3+S8At48CD04DVjXQSDO70PTUnaJ5uOCwsIIFHSSFy1pKPWCDsZxCpw8UVgKSPxLXM937OzxxAljzcPAbcswU4Qh4V3UN8mKoeKm/bu78IfKJQa8VD48CylHQiL3O3/qg5Rf30BKACMtJXjXKQcfBSK8Dfqc3KVCwuN2VFGRnm/yKZtq4Re5ifyQQgM2A+BeB3GHaZBo5MAIue0l7Kt3cC4xhw+5eL7TuCkJk1jBtyerbUfYG5ExjZ/pqrxE5fAOrOq5SmowVIrRp1IyT2R6+fg0bgVYG4CsyZe2UsaiOGKXr4Sfp9k8CxCYAFSKyvXeY1o1BxQux91yMtfsHPutgnnyUuUvhc0ZsgUXib+nVkq6+ZKaABIHsgVZnuwD9sVo66rrR4ImdhLGSQ8zPL/JgBQxeU1ouWkO9PTgDzbgmXxrzMkatl3keivfG5x4r4IRcz5BfkO5vEZ0kgpIfBZ8yKjlL17syy0tMNcOn9dl4Fy6dLFabj1Mpvow9Ify+I4Nlo9Xt+ZqU9VdJpqZh4QDDyxUyYOYJwHDg+DhgI/WUVZl7aSEt93+GO9Ia2iuZKOfA7lhp9JpvAVy61w2mOwO5hmCgMHC1H9O24gu6UD9jP+ZmbtLRaSsei9SL4XDPbAEh/kGQ/pSUcc0lbApFWb67lQUhpVnLBsoKqqZclFMmUtrxPcwxl3X7vOCAtYLSCcugFQmqhdssH7HU+RznjiOlYXA8wqkOfkItTAom+oKygca4ES8jY+N3z7fSG4hfUtp3ihUHruVSsFy1iRvNP+1N7A5BdJACmVpAgZPhGOyCigEjlPLudn7kvFtOxuB4g6OjD8UWLRkCZFRwrLCEXJQQhp2K+37lQeBCRX1A7KPQto1prFEmSYn2mB9EAsO+kYfk8KQhZF8yjVz5gp/MztyOUjiW9bCUhEBhKRCCgSis45uQ/PhX/xfFWMgOnWu2gxB0TF/o0kEZ/kCDM1Ts+3RHYnwVUL6XhDFrAswfIB6w6P1MrTulY0sum1VICglKwCEACqvQFCUK3gHcsFQCM/ILayqP1k9JshVqrncMalOYYvgcGAyCvIwuod8YBJQmZpmGJeyRwkGw4n8jJOJQNw3idLFhMRNB0SgASTJyKoy/4ieXCeFfJBUeV2SoAclFyR0bbm1OHTUiN0/DTAwD7zQeM52dqj8VsGEkVE2jKetG7AEhQ0frJAv6RC0trC1skl+IWlNinGLbSaZg7Mc0xfA8MbgF1LQV1z08A2G8+oM7PVF9Ms2GUE0gQyp+Lwu2yagLgR9ZaYpkSypQ6a6Q2DCqzpkvietXIFdoZfuieGmcOD0DeP0HEbBhNwYPmA/L8zJQsATAKnguEqS+XTqkE4YfWWwCUFZTksYAYwZfIBeN9Tw0cjOwu8gDIZqsoSSvhEeQDiiGYFoyWiSDRypWgi69UP5sc5fIcquSCNeXqe2X9ZAHfM7Khe2pcOB+AT41+aO5iRD3QAHBEHd9ctuiBBoANEkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cvAFgg4GR9kADwJF2f3PxBoANBkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cfOxqYJ2au9RdPtdp/khoEOlglDYT39V1PzQFXLsMXAlgt9PCxJKPbufyf8/KHIPfBPAZABf79Xc5XQ0ZQ1Q7360NbxoHrlsDvs5ZRsgo0une06by6X1mZvtP99PNAp4F4LsBXA5gjw8EGTeqaGF4QhzQF80CX7cAvGIdeDYAfhdZ2sTKUcVrpE7nd31N5gj8e2dIo2osk7NZpMdK0Z19tv+bJ4F9K8D1ACj8yfNSikHeg+5Z969m57Y/8/ZP+dPLKZhP/rcA+AYAF7g1oRUhEMUzFMt6eSJfX78b2DkPfM0i8GIAX+uWlAMppreUUErn8p2gzTl+2flg/sDbTkvIOik+CP20//mzwAXzwDcCuNTPJeFXpEpM6QEjIHm/zTF8D7T5gATYNQCe69aAloRTGulfBESBSYNyxR5g/Bhw7hKwZwl4vk9LnM5JmsBzUyDGAX3B8G23Mz/g9BuUa/0IiutfMkj7zwKmngAuXSvOpUvAWYBtF4BTnspIj/O8zPaf7qdvWITw6eZA0JLQEhKEGgxZhUj/dz3NzSKwbR44exnYvVKcy+mM5Km0JhxInUtrGkmzCPicg3W5LMGkQiZZTm9xS9Z3+4m2o8C5c4X15pTKW2Lb+fCx7WLtjYxzqiql29Icw/dA5SqYf6RTTilg+lYCIXmICKQ4IK9wxfSJY8AZK8CuFWDnanEua9ZTAMsaCog3Dt92O/MvnRGBtGwkqKRmMEkqCaa+2k+0LQDTh4rP88UHj74kF1WaATo9QHQ7mmP4HugYhtEKj4PB6ZQ+FS0hQahpldPya1kXTOqNY8DscgG+HavAttUCvBxInitrkgL4lcO33c7spBdM3kAuSnq2nx9gQfAh4JyVwvrxwel2z3p4aMlzH6DM2z/lT+8aB+Q/OT4EEqckWQSBkGD6EQKQnDCLwBSnYgcf32fXioGUFawC4esyu7CXXnDP9tOCsyD4KLB1rmgvX7zfbu2WG/Jtme0/3U/vKxBNAMoi0KcjkATCN3HOEr3UAjDrwOP71rXixYEkeKMFlSX8ocwR6KUXTJ7AaNE2tF8WfA4Ye7Kw1mwvX/yZn+eKnvcrfzC6IK/ObP/pfnpfAGQnySoISBqUXyAASS1AK0JfagWYcRDOrAF66TxZQU7jBOEbM0egH71gcgXSFZAV54NQtj9YcNIpbONCyh8Ygi8CVospApDuB63g92W2/3Q/vW8AsqM4gLIKBBIH8bcJwMCNMX68BTqBb8s6sGWtsIA6jwDk662ZI9CvXjA5A6NVa2t/IAicnC/aGV+8T74IQPm/AmGuBc+8/VP+9IEAyLslAKMV/LgAyIUInfnjwPQqMOOgI/DstQ5Mr7UAqMF8V2YXDqoXXNl+EQQ6N9v29aKdesUpWJZbAPyPme0/3U8fGIDssDid/pUASCvCaXgJmFguAEfgEXT27gDkuwaUg/nbmSMwjF7whvbLhSDL5TwwvdRqo9oqHzACkCB8U2b7T/fThwIgO01T1IMCoAZxGRhbKoAXQUcQTjkI+a4B5e5FzjGsXvCG9gdqrLGFYrpVG/UuHzBOw2/LaXxzbh43DKeoJwlAHqLndSs4udoCoIBHQE45EPk3DuitmYOQoxdctp8+rFwIWsGFYiFFoLGNchcEQC6e+OJC5J2Z7T/dTx/aApYdJ37AyJK/DIwvFxYvWr0IwEn/H1Opco5sveDUhSAAF4HJpQJkWixp6k2n4IYfMGf0amDHev2I8+l4/UbvNw8Eozw72wJePOJ8und7EkKj9ztKGA1/7WwATo44n45pWI3e7/AAGPWZ2QBkYHCU+XTMfGGQmYIxjd7vqOE0+PXzATjifDrKtTZ6v4MP/MlyRj4AR5xPF+VaqZLJF1UzKdPV6P2eLDDr3I58AI44n07ZMARbo/d78gMubWE+AEecT8e9YOn2Uheu0fs9tUCYD8AR59MpG6bR+z21gKfW1gNAz4geRT5dTEZo9H5PPRDmAzBmRM8BJzqfLiYjSKKr0fs9dYBYDwBHmE9XtRfMsIz04aQZ1+j9npygrA+Akqs8wfl0BCCTWRq935MTYL1aVQ8Ao1zlAnAi8+kEQGZTNXq/vYb75Pt/fQAcUT5dBGCj93vyAaxXi+oDoFLyT3A+3Rcavd9eY3xS/z8fgCQX/LPR3SOzkon55jg1eyAfgD8M4NcAPD6aDmBtB1e4NMDNcer1QD4AbwbwxwDe4UvRE9wHZG1gNSXDLlwLNcep1QP5APxzzwj9IIAPnXhT5ORc5EYCA9HNcWr1QD4AmRH6FQBMTSZZH98ZmD5Bh5g1FopiNns1x6nTA/kAvAfAEwDudnI+EvQxPfkEzYfaCXRSBluQMB7YHKdGD+QDsBNBH/9+AkAobqTADGK7Inw1x8nfA/kA7EXQt8kgrGAGMfBxZ5Cv5ji5eyAfgL0I+r68uR0QmUFoBQU8vfNvzXHy9kA9AORoMw7CdGQCjoUZDwL4kv/+8OZ1gJhBIjGDgMh3vTavBc035/RAPgD7JegjODfhiMwgoqeJwNPPTaB6Ezq/hq+sB4AcXeXEP+ZhGVo9vRimIQD5v5oPAZCupgDI9wg8/qz/1Xz55usyeyAfgMMQ9GU2Op4eAchpOIJQQEz/VuPlm6/K7IH6AMjgGzdl6QtyX5jWjpQFevF3lq3xf6yhrOlIAUgQCojR8gmE+l9Nl2++JrMH6gEgR5UA5KYsc+AZmCbQCDi+IvgEQMob1XBEAHIajgBMLV+0kCdws6aGu3zqfkV9AGTwjftg3JRVVRAtHQEXX/wbAcoXP5d5CID8GoJKvqDAloKOoIz/y7x8c3pmD4zhaqwjRzCYyQg5gr2ZgsFTLweWr8XQgsXjbwLWrnNtMlKgNoLBmZAa7PTCAuYIBlMvlWQswwr2UlUw45jdDSx8HbD+Ctd+HVCwePKbgJV9aASDM8Yg59TWFDysYPBtmYK91IbNOHaPA/M7gUXKXA4hWDz79cA8+W0aweCMURj+1HYfcBjBYO54MMY3tGDv8I3nmWSHOzYOLJ0LLPGXAQWLz3oB8MQUsEa16kYwOG8whjh74yJkUMFgbsNlCfYO0epwissVY34bsHw2sEIRkAEEi/dcU0SP5qhF1ggG5w3GEGdXr4L5134Fg4kAjuDQgr1DtDqcUmZETwArZwAru4BVqsv0KVh8/o3F4v0QXZBGMDhvMIY4u3MYhv95Zh+Cu1xBcxuOU/HfeDIq5cv7FuwdotXhlCBXjOXZAnyrO4BV6in0IVh8wStLuWCsUAyvEQzOG5ABz+4eB+R/ewnu/kOP/3G/l4kJTERlljQtIot2e53/IwO2OPl4FLtcnCqAp9cahT56CBZf+LpSLhhz1N5qBIPzBmTAs/sLRHcTDKbiNHdBGGymOC/3hglEvgjAnoK9A7Y4+XgiV4zVWYDAs/etxaubYPFFP1QkLtCIP8neaASD8wZkwLP7AyC/tJNg8L/xLNBu+YBdBXsHbHEFAINcMVamgdWZAoRrfPdXm8KitLdmgYveWAq+2y7iMqfuRjA4b1AGOLt/APJLqwSD3+y5T1yI0AoSbAxMMzGV1o8/My2ro2DvAK2t+GgiV4zj4+3AIwDXtwBrVJeuECze+9aW4Dut4PxkIhYsdetGMDhvoDqcPRgA+SWp4O4veQ5Uv/mAGwR78+6rQq4Yq9PAOi2fA4/vBkKudKVU7VZw77uKvWFuZbtcMNb5v0YwOG9g+jx7cADyi6Pg7gccgIxlcA5TKhaD01yYKBmVFpBZMfx/m2Bvny3t8LGqoqTliZbVI+gMgHwnMAnCIFi897cLAAZ6QyzFzzSCwXkD1OPs4QDIL5XgLmk5JHk/SD5gKdibd38VcsVYGmuBTaAzEHLHgyCcaokB7/1IkUET5IKxwF5pBIPzBqbPs4cHIC/AaeqvPL9pmHxAE+zts6VdLCD/lcgVY3UyWD0Bj1ZwqgCggXA7sPfWAoAJvaEtZBrB4Lyx6efsPADyCtmCvf00s/NnOsgVY3m8BTRZPZuGBUACdArY+5lWDqGmYbIrLHEx0ggG5w1OH2fnA7CPizQfaXqgUw80AGywMdIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0BxoAjrT7m4s3AGwwMNIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0B8ZYNMbkX+ZekpuIiOQrPar+xs889HJg6jZg5jAwvVZ8B+ll9PlO5/Fc/o+ECjnHfi8zYfkvM5ulmp4qJXVqx5deD4zfAkw/CGxdAZgoHfuh131QkaI5hu8Bs4Ds8B0AWLnIRGCBsFfn87JffDMwdjOw5R5g8giwZa34jnQQUwDo99wBfJ4TM7COiNdlaj2rA/jeV/vfDeATAP4UGH8I2Lrc6gc+SHqY4oMZ74VSKM0xfA+UUzB/oBUUCKMl6zSQ/PsXqZD5KQC/A0w/DEwcAcYXgYnVwppwADuBkefnCim90FmBWXwnK87Uen53BI8sbuwqaz9p5UgnQhBS+ZN1zE8Ak0utviCwq8DI8/nx5hi+Bzb4gJzKZE1SEFZZgS9/2pWR/gTAJ4HJQ8DEMWB8ARhfBsaWCwDquwQKvvNgHXvOcYVbPFJPkw+dDxC/W1Y4tWDpw/Rlgo4lo1T4/KxTihDNpJwj3/UiMLXemprjffC7eWpzDN8DlYsQDiKtVxzEqoHkyX9HRizW+nIgaQnvAiaeBCbmC0s4tgSMu2rMePAR9X252jXklaTFU108K0MHav/nvJ6ZxVVk9OI7GR2IZoGQNc/HgbHgIwqILIVujuF7oOMqWFawCoRxkfEIB5CWgkREBCNf9wMTc8A4QciBWyoGz16rwNgaML5eWKpctYZL3N+TWLX0gvtuP0HHk2n16JDyxXmVhfU0qywbJbr5GSuXKxA/sV5Y9UYWdnjwyS3qKKgarWA69Wg6fjQOIK0HadnIjPVFB+AiME4AuiUkCFnESyCSkmAuU7Cjm15wX+2X2ifBRn9A8mKcW2UFjULVQcgVDl80u40SYh763FfvquhLCxitoBYUsoJfjXKttByMq9CKcHn4sPuCbgXNJwyWkECcz5Q376UX3LNncZyQAAADEklEQVT9fFgIJs6lBBwtn3Tt6FpIz4RWnuQxPh2XIGzm4CwQ9hWIFgBTK0gQHiIAJddKq0ELQh+KL1qUR4MvSEsoENIKrgALHNiMox+94K7tl9qnnMio8MSf6SNwGpYVjCDk/Ju7isq496fCqX0BkDeqlWwKwic1gAQSpzGREnFgREz01eALLvvq2Kfi45m6cf3qBXdsfxRbJMho8dimqOhEK8cXQRr9QVpvPoDNMXQP9A3ACELFxPh+jACkP0fLIKFCCRRqKuPUdqjlC9o07JZwKVNHeBC94DQcZO0XAAkmgotAk9QYrR9f/BvByYfMSATDVMzwTXMM3QMDAVAgVHCZ7/MaQK4QZUHiNCbBQlqUw74YCb7gcmYkelC9YFlwvVv7RRAorTuBkECU9asCID9/x9B935zYzyKkqpfiNHxcA0gLQgvBAaPVkCqm3h2AtC5m/RyEqzw/4xhGL3hD++MmslgqCbgUfLKAcRrmTlBzDN0DA1tAXUlWcDm1IOIIJAjlT/Fd05lbFQFwjdtgGcewesFt7Rc/Gx8iWjUCjGCT1YvWT1MwgUqrf3NG45tTbcu0aximWx9xENcEQHGbcYAEwtSXSqY0gnCdgeuMI0cvuGx/FUGgFhwEYrR80QckWN+X0fjm1DwAWv8RgJFilJZBznz0pQg+AZAAlVWh1GvGka0XzB0cCQi30aSGVa9AF62fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC",WX="uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}",qX="varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}",Ia={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},ax=class extends Vo{constructor({preset:n=Ia.MEDIUM,edgeDetectionMode:t=nf.COLOR,predicationMode:e=JY.DISABLED}={}){super("SMAAEffect",WX,{vertexShader:qX,blendFunction:Ct.NORMAL,attributes:Fo.CONVOLUTION|Fo.DEPTH,uniforms:new Map([["weightMap",new ue(null)]])});let r,i;arguments.length>1&&(r=arguments[0],i=arguments[1],arguments.length>2&&(n=arguments[2]),arguments.length>3&&(t=arguments[3])),this.renderTargetEdges=new dt(1,1,{minFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new xE(!0,!1,!1),this.clearPass.overrideClearColor=new We(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new Bn(new $Y),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=e,this.weightsPass=new Bn(new lX);let s=new mp;s.onLoad=()=>{let o=new Jt(r);o.name="SMAA.Search",o.magFilter=Vt,o.minFilter=Vt,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!0,this.weightsMaterial.searchTexture=o;let a=new Jt(i);a.name="SMAA.Area",a.magFilter=tt,a.minFilter=tt,a.generateMipmaps=!1,a.needsUpdate=!0,a.flipY=!1,this.weightsMaterial.areaTexture=a,this.dispatchEvent({type:"load"})},s.itemStart("search"),s.itemStart("area"),r!==void 0&&i!==void 0?(s.itemEnd("search"),s.itemEnd("area")):typeof Image<"u"&&(r=new Image,i=new Image,r.addEventListener("load",()=>s.itemEnd("search")),i.addEventListener("load",()=>s.itemEnd("area")),r.src=qR,i.src=YR),this.applyPreset(n)}get edgesTexture(){return this.renderTargetEdges.texture}getEdgesTexture(){return this.edgesTexture}get weightsTexture(){return this.renderTargetWeights.texture}getWeightsTexture(){return this.weightsTexture}get edgeDetectionMaterial(){return this.edgeDetectionPass.fullscreenMaterial}get colorEdgesMaterial(){return this.edgeDetectionMaterial}getEdgeDetectionMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.fullscreenMaterial}getWeightsMaterial(){return this.weightsMaterial}setEdgeDetectionThreshold(n){this.edgeDetectionMaterial.edgeDetectionThreshold=n}setOrthogonalSearchSteps(n){this.weightsMaterial.orthogonalSearchSteps=n}applyPreset(n){let t=this.edgeDetectionMaterial,e=this.weightsMaterial;switch(n){case Ia.LOW:t.edgeDetectionThreshold=.15,e.orthogonalSearchSteps=4,e.diagonalDetection=!1,e.cornerDetection=!1;break;case Ia.MEDIUM:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=8,e.diagonalDetection=!1,e.cornerDetection=!1;break;case Ia.HIGH:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=16,e.diagonalSearchSteps=8,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break;case Ia.ULTRA:t.edgeDetectionThreshold=.05,e.orthogonalSearchSteps=32,e.diagonalSearchSteps=16,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break}}setDepthTexture(n,t=Ii){this.edgeDetectionMaterial.depthBuffer=n,this.edgeDetectionMaterial.depthPacking=t}update(n,t,e){this.clearPass.render(n,this.renderTargetEdges),this.edgeDetectionPass.render(n,t,this.renderTargetEdges),this.weightsPass.render(n,this.renderTargetEdges,this.renderTargetWeights)}setSize(n,t){this.edgeDetectionMaterial.setSize(n,t),this.weightsMaterial.setSize(n,t),this.renderTargetEdges.setSize(n,t),this.renderTargetWeights.setSize(n,t)}dispose(){let{searchTexture:n,areaTexture:t}=this.weightsMaterial;n!==null&&t!==null&&(n.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return qR}static get areaImageDataURL(){return YR}};var YX=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb;
#if VIGNETTE_TECHNIQUE == 0
float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
#else
vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
#endif
outputColor=vec4(color,inputColor.a);}`,sx={DEFAULT:0,ESKIL:1},a3=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,technique:t=sx.DEFAULT,eskil:e=!1,offset:r=.5,darkness:i=.5}={}){super("VignetteEffect",YX,{blendFunction:n,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new ue(r)],["darkness",new ue(i)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(n){this.technique!==n&&(this.defines.set("VIGNETTE_TECHNIQUE",n.toFixed(0)),this.setChanged())}get eskil(){return this.technique===sx.ESKIL}set eskil(n){this.technique=n?sx.ESKIL:sx.DEFAULT}getTechnique(){return this.technique}setTechnique(n){this.technique=n}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}get darkness(){return this.uniforms.get("darkness").value}set darkness(n){this.uniforms.get("darkness").value=n}getDarkness(){return this.darkness}setDarkness(n){this.darkness=n}},m2e=[new Float32Array(3),new Float32Array(3)],g2e=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],y2e=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var v2e=[new Float32Array(2),new Float32Array(2)];var x2e=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),b2e=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],S2e=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],w2e=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var A2e=new Map([[on(0,0,0,0),new Float32Array([0,0,0,0])],[on(0,0,0,1),new Float32Array([0,0,0,1])],[on(0,0,1,0),new Float32Array([0,0,1,0])],[on(0,0,1,1),new Float32Array([0,0,1,1])],[on(0,1,0,0),new Float32Array([0,1,0,0])],[on(0,1,0,1),new Float32Array([0,1,0,1])],[on(0,1,1,0),new Float32Array([0,1,1,0])],[on(0,1,1,1),new Float32Array([0,1,1,1])],[on(1,0,0,0),new Float32Array([1,0,0,0])],[on(1,0,0,1),new Float32Array([1,0,0,1])],[on(1,0,1,0),new Float32Array([1,0,1,0])],[on(1,0,1,1),new Float32Array([1,0,1,1])],[on(1,1,0,0),new Float32Array([1,1,0,0])],[on(1,1,0,1),new Float32Array([1,1,0,1])],[on(1,1,1,0),new Float32Array([1,1,1,0])],[on(1,1,1,1),new Float32Array([1,1,1,1])]]);function gE(n,t,e){return n+(t-n)*e}function on(n,t,e,r){let i=gE(n,t,.75),s=gE(e,r,1-.25);return gE(i,s,1-.125)}var ri=class{constructor(t,e){this.enabled=!1;this.effect=new t(e),Object.defineProperty(this,"opacity",{enumerable:!0,set(r){this.effect.blendMode.opacity.value=r},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(r){this.effect.blendMode.setBlendFunction(Number(r))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=Ct.NORMAL}};var sf=class extends ri{constructor(){super($R),this.blendFunction=Ct.SCREEN}set intensity(t){this.effect.intensity=t}get intensity(){return this.effect.intensity}set luminanceThreshold(t){this.effect.luminanceMaterial.threshold=t}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(t){this.effect.luminanceMaterial.smoothing=t}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(t){this.effect.blurPass.scale=t}get blurScale(){return this.effect.blurPass.scale}set kernelSize(t){this.effect.blurPass.kernelSize=t}get kernelSize(){return this.effect.blurPass.kernelSize}};var of=class extends ri{constructor(){super(e3)}set contrast(t){this.effect.uniforms.get("contrast").value=t}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(t){this.effect.uniforms.get("brightness").value=t}get brightness(){return this.effect.uniforms.get("brightness").value}};var af=class extends ri{constructor(){super(r3),this.effect.offset=new U(.01,.01)}set offset(t){this.effect.offset.set(t[0]/1e3,t[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var lf=class extends ri{constructor(){super(t3)}};var cf=class extends ri{constructor(){super(n3);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var uf=class extends ri{constructor(){super(s3),this.blendFunction=Ct.OVERLAY}};var hf=class extends ri{constructor(){super(a3)}get eskil(){return this.effect.eskil}set eskil(t){this.effect.eskil=t}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(t){this.effect.uniforms.get("darkness").value=t}get offset(){return this.effect.uniforms.get("offset").value}set offset(t){this.effect.uniforms.get("offset").value=t}};var df=class extends ri{constructor(e){super(i3)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e/2e3}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=this.isPerspectiveCamera?e/2e3:(e+992)/2e3}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}setCamera(e){let r=!1;(e.isPerspectiveCamera&&this.isPerspectiveCamera===!1||!e.isPerspectiveCamera&&this.isPerspectiveCamera===!0)&&(r=!0),e.isPerspectiveCamera?(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e.perspCamera),this.isPerspectiveCamera=!0):(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e),this.isPerspectiveCamera=!1),r&&this.effect.setChanged()}};var ff=class extends ri{constructor(){super(o3)}get granularity(){return this.effect.getGranularity()}set granularity(t){this.effect.setGranularity(t)}};var l3=`#define GLSLIFY 1
varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`;var c3=`#define GLSLIFY 1
#include <common>
varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;
#define USE_YCOCG
#define USE_CATMULL_ROM
const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){
#ifdef USE_YCOCG
vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);
#else
return texture(tex,uv);
#endif
}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){
#ifdef CHOOSE_LONGEST_MOTION_VECTOR
float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;
#else
float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;
#endif
}vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);
#ifdef USE_CATMULL_ROM
vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);
#else
vec4 previousColor=sample_color(historyBuffer,previousPixelPos);
#endif
#ifdef USE_YCOCG
previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);
#endif
vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);
#ifdef USE_YCOCG
vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;
#endif
vec4 previousColorClipped=clamp(previousColor,cmin,cmax);
#ifdef LUMINANCE_DIFFERENCES
#ifdef USE_YCOCG
float lum0=currentColor.r;float lum1=previousColorClipped.r;
#else
float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);
#endif
float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));
#else
const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);
#endif
#ifdef USE_YCOCG
gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);
#else
gl_FragColor=result;
#endif
}`;var u3=`#define GLSLIFY 1
varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`;var h3=`#define GLSLIFY 1
layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`;var pf=class extends st{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new ue(null)},blending:Zt,depthWrite:!1,depthTest:!1,vertexShader:u3,fragmentShader:h3})}set inputBuffer(t){this.uniforms.inputBuffer.value=t}},lx=class extends pi{constructor(){super("TAAResolvePass");this.MRTCompatible=!0;this.needsSwap=!1,this.passThroughMaterial=new pf,this.resolutionVector=new U,this.resolveMaterial=new st({name:"TAAResolveMaterial",uniforms:{inputBuffer:new ue(null),historyBuffer:new ue(null),velocityBuffer:new ue(null),depthBuffer:new ue(null),resolution:new ue(new U)},blending:Zt,depthWrite:!1,depthTest:!1,vertexShader:l3,fragmentShader:c3}),this.historyRenderTarget=new dt(1024,1024,{minFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new dt(1024,1024,{minFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,r){this.historyRenderTarget.setSize(e,r),this.resultRenderTarget.setSize(e,r)}render(e,r){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=r.texture[0],this.resolveMaterial.uniforms.velocityBuffer.value=r.texture[1],this.resolveMaterial.uniforms.depthBuffer.value=r.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(r.width,r.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let i=this.renderToScreen?null:r;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(i),e.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}};var cx=class extends pi{constructor(e,r,i){super("TransmissionPass",void 0,r);this.MRTCompatible=!0;this.depthPass=new bE(e,r,{renderTarget:i.transmissionDepthTarget}),this.passThroughMaterial=new pf,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new pf,this.depthPass=new bE(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,r,i){let s=this.camera.layers.mask,o=e;o.setRenderTarget(o.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=r.texture[0],o.clear(),o.render(this.scene,this.camera),this.camera.layers.disable(3),this.depthPass.render(e,r,i),o.shadowMap.needsUpdate=!1,o.shadowMap.autoUpdate=!1;let a=this.renderToScreen?null:r;this.camera.layers.set(3),e.setRenderTarget(a),e.render(this.splineScene,this.camera),this.camera.layers.mask=s}};var d3=new bi,$X=new st({transparent:!0,vertexShader:`
void main() {
gl_Position = vec4(0.0);
}
`,fragmentShader:`
layout(location = 1) out vec4 gVelocity;
void main() {
gl_FragColor = vec4(0.0);
gVelocity = vec4(0.0);
}
`}),Yc=class extends pi{constructor(e,r,i){super("OpaquePass",r??d3,i);this.MRTCompatible=!0;this.hasTransmissionPass=!1;this.clear=!0;this.clearColorOnly=!1;this.clearDepth=!1;this.needsSwap=!1,this.originalMaterials=new Map,this.MRTCompatible=e}setCamera(e){this.camera=e}setScene(e){this.scene=e??d3}getScene(){return this.scene}render(e,r){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.clear(),this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof dr&&(this.originalMaterials.set(s.id,s.material),s.material=$X)}),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let i=this.renderToScreen?null:r;e.setRenderTarget(i),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};var ux=class{constructor(t,{depthBuffer:e=!0,stencilBuffer:r=!1,multisampling:i=0,frameBufferType:s=0}={}){this.renderer=t;this.helperStartIndex=0;this.copyPass=new Cm;this.depthTexture=null;this.timer=new JR;this._width=1;this._height=1;this.passes=[];this.helperPasses=[];this.autoRenderToScreen=!0;this.inputBuffer=this.createBuffer(e,r,s,i,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(e,r,s,i,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.texture[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(e,r,s,i,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.texture[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(t)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(t){let e=this.inputBuffer,r=this.multisampling;r>0&&t>0?(this.inputBuffer.samples=t,this.outputBuffer.samples=t,this.inputBuffer.dispose(),this.outputBuffer.dispose()):r!==t&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,t,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(t){if(this.renderer=t,t!==null){let e=t.getSize(new U),r=t.getContext().getContextAttributes()?.alpha??!1,i=this.inputBuffer.texture[0].type;i===Cr&&t.outputEncoding===at&&(this.inputBuffer.texture[0].encoding=at,this.outputBuffer.texture[0].encoding=at,this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("doing some kinda dispose??")),t.autoClear=!1,this.setSize(e.width,e.height,!1);for(let s of this.passes)s.initialize(t,r,i)}}replaceRenderer(t,e=!0){let r=this.renderer,i=r.domElement.parentNode;return this.setRenderer(t),e&&i!==null&&(i.removeChild(r.domElement),i.appendChild(t.domElement)),r}createDepthTexture(){let t=this.depthTexture=new ns(this._width,this._height);return this.inputBuffer.depthTexture=t,this.inputBuffer.stencilBuffer?(t.format=Qa,t.type=qa):t.type=Ds,t}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let t of this.passes)t.setDepthTexture(null)}}createBuffer(t,e,r,i,s,o){let a=this.renderer,l=a===null?new U:a.getDrawingBufferSize(new U),c={minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt,stencilBuffer:e,depthBuffer:t},u;return i>0?(u=new dt(l.width,l.height,c),u.samples=i):(s?(u=new $g(l.width,l.height,2,c),u.texture[1].type=jn):u=new dt(l.width,l.height,c),u.depthTexture=new ns(2048,2048),u.depthTexture.type=yr),r===Cr&&a!==null&&a.outputEncoding===at&&(Array.isArray(u.texture)?u.texture.forEach(h=>h.encoding=at):u.texture.encoding=at),Array.isArray(u.texture)?u.texture.forEach((h,d)=>{h.name=`EffectComposer.Buffer ${s} ${d}`,h.generateMipmaps=!1}):(u.texture.name=`EffectComposer.Buffer ${s}`,u.texture.generateMipmaps=!1),u.name=o,u}addPass(t,e){let r=this.passes,i=this.renderer,s=i.getDrawingBufferSize(new U),o=i.getContext().getContextAttributes()?.alpha??!1,a;if(t.MRTCompatible&&(a=this.inputBuffer.texture[0].type),t.MRTCompatible||(a=this.inputBuffer.texture.type),t.setRenderer(i),t.setSize(s.width,s.height),t.initialize(i,o,a),this.autoRenderToScreen&&(r.length>0&&(r[r.length-1].renderToScreen=!1),t.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?r.splice(e,0,t):r.push(t),this.autoRenderToScreen&&(r[r.length-1].renderToScreen=!0),t.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let l=this.createDepthTexture();for(t of r)t.setDepthTexture(l)}else t.setDepthTexture(this.depthTexture)}setHelperStartIndex(t){this.helperStartIndex=t}removePass(t){let e=this.passes,r=e.indexOf(t);if(r!==-1&&e.splice(r,1).length>0){if(this.depthTexture!==null){let o=(l,c)=>l||c.needsDepthTexture;e.reduce(o,!1)||t.getDepthTexture()===this.depthTexture&&t.setDepthTexture(null)}this.autoRenderToScreen&&r===e.length&&(t.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let t=this.passes;t.length>0&&(this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!1),this.passes=[])}render(t){let e=this.renderer,r=this.copyPass,i=this.inputBuffer,s=this.outputBuffer,o=this.inputBufferSingle,a=this.outputBufferSingle,l=!1,c,u,h,d;t===void 0&&(t=this.timer.update().getDelta());for(let f of this.passes)f.enabled&&(f.MRTCompatible?f.render(e,i,s,t,l):f.render(e,o,a,t,l),f.needsSwap&&(l&&(r.renderToScreen=f.renderToScreen,c=e.getContext(),u=e.state.buffers.stencil,u.setFunc(c.NOTEQUAL,1,4294967295),r.render(e,i,s,t,l),u.setFunc(c.EQUAL,1,4294967295)),h=i,d=o,i=s,o=a,s=h,a=d),f instanceof ZR?l=!0:f instanceof KR&&(l=!1))}setSize(t,e,r){let i=this.renderer;if(this._width=t,this._height=e,t===void 0||e===void 0){let o=i.getSize(new U);t=o.width,e=o.height}i.setSize(t,e,r);let s=i.getDrawingBufferSize(new U);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height),this.inputBufferSingle.setSize(s.width,s.height),this.outputBufferSingle.setSize(s.width,s.height);for(let o of this.passes)o.setSize(s.width,s.height)}reset(){let t=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(t)}dispose(){for(let t of this.passes)t.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.inputBufferSingle!==null&&this.inputBufferSingle.dispose(),this.outputBufferSingle!==null&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}};var eQ=new st({name:"CombineMaterial",uniforms:{inputBufferA:new ue(null),inputBufferB:new ue(null)},blending:Zt,depthWrite:!1,depthTest:!1,vertexShader:`
varying vec2 vUv;
void main() {
gl_Position = vec4(position.xy, 1.0, 1.0);
vUv = position.xy * 0.5 + 0.5;
}
`,fragmentShader:`
varying vec2 vUv;
uniform sampler2D inputBufferA;
uniform sampler2D inputBufferB;
// TODO: Why do we need these when postpro of framemode is enabled???
layout(location = 1) out vec4 gVelocity;
void main() {
vec4 resA = texture2D(inputBufferA, vUv);
vec4 resB = texture2D(inputBufferB, vUv);
float a = resA.a + resB.a * ( 1.0 - resA.a );
vec4 res;
res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));
res.a = resA.a + resB.a * (1.0 - resA.a);
gl_FragColor = res;
gVelocity = vec4(0.0);
}
`}),hx=class extends pi{constructor(e){super("HelperPass",void 0,e);this.MRTCompatible=!1;this.fullscreenMaterial=eQ,this.helperPass=new Yc(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new Yc(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let r=new ax({preset:Ia.LOW,edgeDetectionMode:nf.COLOR});this.effectPass=new qc(this.camera,r),this.rt=new dt(10,10,{minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt,depthBuffer:!0})}setSize(e,r){this.rt.setSize(e,r),this.effectPass.setSize(e,r)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,r,i){super.initialize(e,r,i),this.effectPass.initialize(e,r,i)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(e,r,i){this.rt.depthTexture=r.depthTexture;let s=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.rt,i),this.fullscreenMaterial.uniforms.inputBufferA.value=i.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=r.texture,e.setClearAlpha(s),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}};var f3=`#define GLSLIFY 1
#include <skinning_pars_vertex>
out vec3 n;void main(){
#include <beginnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <skinning_vertex>
vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`;var p3=`#define GLSLIFY 1
in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`;var m3=`#define GLSLIFY 1
out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`;var g3=`#define GLSLIFY 1
in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/norm;return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(int(mod(gl_FragCoord.x,128.0)),int(mod(gl_FragCoord.y,128.0)));float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=texelFetch(texture_blue_noise_in_disk,ivec2(index,0),0).rg;vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}
#define USE_GBUFFER_NORMALS
void main(){vec3 view_space_p=get_view_position(v_uv);
#ifdef USE_GBUFFER_NORMALS
vec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;
#else
vec3 view_space_n=-rebuild_normal(v_uv,view_space_p);
#endif
float radius_ss=radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`;var y3=`#define GLSLIFY 1
out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`;var v3=`#define GLSLIFY 1
in vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){
#ifdef DEBUG
float d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0);
#else
vec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao;
#endif
}`;var mf=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]];var aQ=new st({vertexShader:f3,fragmentShader:p3}),gf=new st({vertexShader:y3,fragmentShader:v3,uniforms:{texture_ao_lrez:new ue(null),texture_depth_lrez:new ue(null),texture_depth_hrez:new ue(null),near:new ue(null),far:new ue(null)}}),dx=class extends pi{constructor(e,r){super("AmbientOcclusionPass",void 0,r);this.fogEnabled=!1;this.fogNear=1;this.fogFar=1e3;this.frameIndex=0;this._runHalfRes=!0;this._width=1;this._height=1;let i=1024,s=1024;this.gBuffer=new dt(i,s,{type:po?jn:yr,depthTexture:new ns(i,s),minFilter:tt,magFilter:tt}),this.depthBufferHighRes=new dt(i,s,{depthTexture:new ns(i,s)}),this.aoBuffer=new dt(i,s,{minFilter:tt,magFilter:tt}),this.splineScene=e,this.splineCamera=r;let o=new Float32Array(mf.length*2);for(let l=0;l<mf.length;l++){let c=l*2;o[c+0]=mf[l][0],o[c+1]=mf[l][1]}this.blueNoiseInDiskTexture=new di(o,mf.length,1,Xu,yr),this.blueNoiseInDiskTexture.wrapS=Is,this.blueNoiseInDiskTexture.wrapT=Is,this.blueNoiseInDiskTexture.needsUpdate=!0,this.hbaoMaterial=new st({vertexShader:m3,fragmentShader:g3,uniforms:{near:new ue(null),far:new ue(null),fov:new ue(null),proj_info:new ue(new Ke),is_ortho:new ue(!1),resolution:new ue(new U),radius_of_influence:new ue(8),radius_in_screen_space:new ue(1),exponent:new ue(1),ao_color:new ue(new E),bias:new ue(.5),texture_depth:new ue(null),texture_normals:new ue(null),texture_blue_noise:new ue(null),texture_blue_noise_in_disk:new ue(this.blueNoiseInDiskTexture),frame_index:new ue(0),fog_enabled:new ue(!1),fog_near:new ue(1),fog_far:new ue(1e3)}}),this.radius=128,this.aoColor={r:0,g:0,b:0},this.bias=.5,this.hbaoMaterial.uniforms.texture_depth.value=this.gBuffer.depthTexture,this.hbaoMaterial.uniforms.texture_normals.value=this.gBuffer.texture,this.needsSwap=!0,this.aaBuffer=new dt(i,s,{minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt,depthBuffer:!1,type:yr});let a=new ax({preset:Ia.ULTRA,edgeDetectionMode:nf.COLOR});this.effectPass=new qc(this.camera,a)}initialize(e,r,i){super.initialize(e,r,i),this.effectPass.initialize(e,r,i)}setBlueNoiseTexture(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}setSize(e,r){this._width=e,this._height=r,this.depthBufferHighRes.setSize(e,r);let i=this._runHalfRes?.5:1,s=e*i,o=r*i;this.gBuffer.setSize(s,o),this.aoBuffer.setSize(s,o),this.hbaoMaterial.uniforms.resolution.value.set(s,o),this.aaBuffer.setSize(s,o),this.effectPass.setSize(s,o)}get runHalfRes(){return this._runHalfRes}set runHalfRes(e){this._runHalfRes=e,this.setSize(this._width,this._height)}setCamera(e){this.splineCamera=e}setScene(e){this.splineScene=e}setDepthTexture(e){this.depthBufferHighRes.depthTexture=e,gf.uniforms.texture_depth_hrez.value=e,gf.needsUpdate=!0}render(e,r,i){this.splineScene.overrideMaterial=aQ;let s=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),e.setRenderTarget(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=s,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;let o=this.splineCamera.perspCamera.projectionMatrix.elements,a=2/o[0],l=2/o[5],c=-(1-o[8])/o[0],u=-(1+o[9])/o[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,l,c,u);let d=this.splineCamera.perspCamera.fov*(Math.PI/180),p=this.hbaoMaterial.uniforms.resolution.value.y/(Math.tan(d*.5)*2),m=this.hbaoMaterial.uniforms.radius_of_influence.value*.5*p;this.hbaoMaterial.uniforms.radius_in_screen_space.value=m,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;let o=this.splineCamera.orthoCamera.projectionMatrix.elements,a=2/o[0],l=2/o[5],c=-(1+o[12])/o[0],u=-(1-o[13])/o[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,l,c,u);let d=.5*(this.hbaoMaterial.uniforms.resolution.value.y/l),f=this.hbaoMaterial.uniforms.radius_of_influence.value*d;this.hbaoMaterial.uniforms.radius_in_screen_space.value=f,this.hbaoMaterial.uniforms.is_ortho.value=!0}this.runHalfRes?(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=gf,gf.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,gf.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,gf.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(e.aoRenderTarget),e.clear(),e.render(this.scene,this.camera)):(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),e.clear(),e.render(this.scene,this.camera),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.aaBuffer,e.aoRenderTarget))}dispose(){this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose()}};var lQ=`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,cQ=`
uniform sampler2D tInput;
uniform sampler2D tMap;
uniform vec2 resolution;
varying vec2 vUv;
uniform vec2 uResolution;
uniform vec2 uCoords;
// Draws a rectangle at center <st> with size <size>
float rectangle(vec2 st, vec2 size) {
size = vec2(0.5) - size * 0.5;
vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));
uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));
return uv.x * uv.y;
}
uniform vec2 uSize;
uniform float uScale;
uniform float uDPR;
uniform float uCurrent;
uniform vec3 uSceneColor;
void main() {
vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
screenUv *= 1.0 / uDPR;
vec2 center = vec2(0.5, -0.5);
vec2 outsideUv = screenUv;
outsideUv += center;
outsideUv -= uCoords.xy / uResolution.xy;
outsideUv = (outsideUv - 0.5) + 0.5;
outsideUv -= center;
vec2 s = (uSize / uResolution) * uScale;
float isOutside = 1.0 - rectangle(outsideUv, s);
vec2 mid = vec2(0.5);
vec2 insideUv = (screenUv - mid + s * mid) / s;
vec4 background = texture2D(tInput, screenUv);
vec4 image = texture2D(tMap, insideUv);
gl_FragColor = mix(image, background, isOutside);
}
`,fx=class extends Bn{constructor(){super(new st({vertexShader:lQ,fragmentShader:cQ,uniforms:{tInput:new ue(null),tMap:new ue(null),uResolution:new ue(new U),uSize:new ue(new U),uCoords:new ue(new U),uScale:new ue(1),uSceneColor:new ue(new We(16711680)),uDPR:new ue(1),uCurrent:new ue(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(t){this.uniforms.tMap.value=t}};var uQ=`
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,hQ=`
uniform sampler2D toScene;
uniform sampler2D fromScene;
uniform vec2 resolution;
uniform vec2 uResolution;
uniform float uDPR;
uniform float mixRatio;
uniform sampler2D tMixTexture;
uniform int useTexture;
uniform float threshold;
void main() {
vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
screenUv *= 1.0 / uDPR;
vec4 texel1 = texture2D( fromScene, screenUv );
vec4 texel2 = texture2D( toScene, screenUv );
if (useTexture==1) {
vec4 transitionTexel = texture2D( tMixTexture, screenUv );
float r = mixRatio * (1.0 + threshold * 2.0) - threshold;
float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);
gl_FragColor = mix( texel1, texel2, mixf );
} else {
gl_FragColor = mix( texel1, texel2, mixRatio );
}
}
`,dQ=[],px=class extends Bn{constructor(){super(new st({vertexShader:uQ,fragmentShader:hQ,uniforms:{toScene:new ue(null),fromScene:new ue(null),uResolution:new ue(new U),uDPR:new ue(1),mixRatio:new ue(0),threshold:new ue(.1),useTexture:new ue(0),tMixTexture:{value:dQ[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(t){this.uniforms.fromScene.value=t}};var fQ=`
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,pQ=`
uniform sampler2D inputBuffer;
uniform sampler2D blurredInputBuffer;
uniform sampler2D overlay;
uniform float blurIntensity;
uniform vec2 uResolution;
uniform float uDPR;
void main() {
vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
screenUv *= 1.0 / uDPR;
vec4 texel1 = texture2D( overlay, screenUv );
vec4 texel2 = texture2D( inputBuffer, screenUv );
vec4 texel3 = texture2D( blurredInputBuffer, screenUv );
float blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity;
gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a );
}
`,mx=class extends Bn{constructor(){super(new st({vertexShader:fQ,fragmentShader:pQ,uniforms:{inputBuffer:new ue(null),blurredInputBuffer:new ue(null),overlay:new ue(null),uResolution:new ue(new U),uDPR:new ue(1),blurIntensity:new ue(0)}}));this._blurEnabled=!1;this.blurTarget=new dt(1,1,{minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt}),this.blurPass=new ox({width:window.innerWidth,height:window.innerHeight,kernelSize:Pm.HUGE,resolutionScale:.25}),this.blurPass.renderToScreen=!1,this.uniforms.blurredInputBuffer.value=this.blurTarget.texture}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.overlay.value}set texture(e){this.uniforms.overlay.value=e}setResolution(e,r,i=1){this.uniforms.uResolution.value.set(e,r),this.uniforms.uDPR.value=i,this.blurPass.setSize(e,r),this.blurTarget.setSize(e,r),this.blurPass.setSize(e,r)}get uiCanvas(){return this._uiCanvas}set uiCanvas(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);let i=e.frame;if(i){let s=i.data.backgroundBlur,o=s.radius;this._blurEnabled=s.enabled,this.uniforms.blurIntensity.value=this._blurEnabled?1:0,this.blurPass.scale=o/3}}render(e,r,i,s,o){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,r,this.blurTarget,s,o)),super.render(e,r,i,s,o)}};function b3(n,t){return t&&t.enabled&&n.push(t.effect),n}var mQ=n=>Object.values(Ct).includes(n)?n:Ct.NORMAL,_m=class extends hr{constructor(e,r){super();this._needsDOFResize=r;this.postprocessingState=Vh.defaultData;this._scene=new bi;this._camera=new xr;this.effects=new Map;this.blueNoiseTexture=new di;this._renderToScreen=!0;this._isUIOverlayEnabled=!1;this.clock=new py,this.renderer=e,this.debug=!1,this.effects.set("bloom",new sf),this.effects.set("chromaticAberration",new af),this.effects.set("vignette",new hf),this.effects.set("noise",new uf),this.effects.set("colorAverage",new lf),this.effects.set("hueSaturation",new cf),this.effects.set("brightnessContrast",new of),this.effects.set("depthOfField",new df),this.effects.set("pixelation",new ff),this.effectComposer=new ux(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Yc(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new cx(this.scene,this.camera,this.renderer),this.aoPass=new dx(this.scene,this.camera),this.taaPass=new lx,this.taaPass.renderToScreen=!1,this.helperPass=new hx(this.camera),this.helperPass.renderToScreen=!1,this.stylesOverlayPass=new fx,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new mx,this.uiOverlayPass.enabled=!1,this.sceneTransitionPass=new px,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}get overlayTexture(){return this.stylesOverlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){let r=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),r&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),this.effects.get("depthOfField").setCamera(e)}updateRenderToScreen(){let e=!1;for(let r=this.effectComposer.passes.length-1;r>=0;r--){let i=this.effectComposer.passes[r];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new di(e,128,128),this.blueNoiseTexture.wrapS=Is,this.blueNoiseTexture.wrapT=Is,this.blueNoiseTexture.minFilter=Vt,this.blueNoiseTexture.magFilter=Vt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,r,i,s,o,a,l,c){this.aoPass.enabled=e,this.aoPass.radius=r,this.aoPass.bias=i,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!c&&(this.aoPass.runHalfRes=!c)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(b3,[]);e.length>0&&(this.uvEffectPass=new qc(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let r=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(b3,[]);if(r.length>0&&(this.effectPass=new qc(this.camera,...r),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&this.effects.get("depthOfField")?.enabled&&window!==void 0)){let i=this.renderer.viewportWidth,s=this.renderer.viewportHeight;this.renderer.setSize(i-1,s-1),this.renderer.setSize(i,s)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new U;this.renderer.getDrawingBufferSize(e),this._rt=new dt(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Is,wrapT:Is}),this._rt.samples=0,this._savePass=new Cm(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new Cm(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let r=this.effectComposer;!r||(e===!0?r.removePass(this._savePass):r.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:r,...i}=e,s=!1;r!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[c,u]of Object.entries(a))c==="blendFunction"?l.blendFunction=mQ(u):l[c]=u}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,r,i,s){e instanceof Ke?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,r,i,s),this.effectComposer.outputBuffer.scissor.set(e,r,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,r,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,r,i,s){e instanceof Ke?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,r,i,s),this.effectComposer.outputBuffer.viewport.set(e,r,i,s))}resize(e,r,i){if(this.effectComposer.setSize(e,r,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,r*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var gQ=n=>`
// PCSS implementation based on:
// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
// NOTE: This number affects how big the shadow blur can
// possibly get. Bigger number == bigger blur, but less precise results
const float gPenumbraFilterSize = 80.0;
const int gPenumbraSamples = ${n};
const int gShadowSamples = ${n};
const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
/*
#if NUM_RECT_AREA_LIGHTS > 0
// TODO (abelnation): create uniforms for area light shadows
#endif
*/
float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)
{
float penumbra = 1.0;
float blockerDepthAvg = 0.0;
float blockerCount = 0.0;
#pragma unroll_loop_start
for(int i = 0; i < gPenumbraSamples; i ++)
{
vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;
float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );
if(depth < compare + 0.0001)
{
blockerDepthAvg += depth;
blockerCount++;
}
}
#pragma unroll_loop_end
if (blockerCount > 0.0)
{
blockerDepthAvg /= blockerCount;
// Compute penumbra
penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);
penumbra *= penumbra;
penumbra *= 200.0 * penumbraSize[min(index, ${5} - 1)]; // Magic number that affects how quickly the penumbra grows
return clamp(penumbra, 0.00, 1.0);
}
return 0.0;
}
float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)
{
float shadow = 0.0f;
// NOTE: When using TAA, we should use screen space interleaved gradient noise
vec2 halton = haltonSequence[frameIndex];
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
float temporalAngle = temporalOffset * PI2;
float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);
float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);
if (penumbra == -1.0) {
return 1.0;
}
#pragma unroll_loop_start
for (int i = 0; i < gShadowSamples; i++)
{
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
// Overall blurring offset
vec2 offset = vogelSample * (shadowRadius * 2.);
// Penumbra offset
offset += vogelSample * (penumbra * texelScalar);
shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );
}
#pragma unroll_loop_end
return shadow * gShadowSamplesRpc;
}
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
float hard_shadow = step( compare , distribution.x ); // Hard Shadow
if (hard_shadow != 1.0 ) {
float distance = compare - distribution.x ;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
// if ( something && something ) breaks ATI OpenGL shader compiler
// if ( all( something, something ) ) using this instead
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
bool inFrustum = all( inFrustumVec );
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
bool frustumTest = all( frustumTestVec );
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else // no percentage-closer filtering:
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return shadow;
}
// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
// vector suitable for 2D texture mapping. This code uses the following layout for the
// 2D texture:
//
// xzXZ
// y Y
//
// Y - Positive y direction
// y - Negative y direction
// X - Positive x direction
// x - Negative x direction
// Z - Positive z direction
// z - Negative z direction
//
// Source and test bed:
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
vec2 cubeToUV( vec3 v, float texelSizeY ) {
// Number of texels to avoid at the edge of each square
vec3 absV = abs( v );
// Intersect unit cube
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
// Apply scale to avoid seams
// two texels less per square (one texel will do for NEAREST)
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
// Unwrap
// space: -1 ... 1 range for each square
//
// #X## dim := ( 4 , 2 )
// # # center := ( 1 , 1 )
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
// Transform to UV space
// scale := 0.5 / dim
// translate := ( center + 0.5 ) / dim
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
// for point lights, the uniform @vShadowCoord is re-purposed to hold
// the vector from the light to the world-space position of the fragment.
vec3 lightToPosition = shadowCoord.xyz;
// dp = normalized distance from light to fragment position
float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
compare += shadowBias;
// bd3D = base direction 3D
vec3 bd3D = normalize( lightToPosition );
vec2 halton = haltonSequence[frameIndex];
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
float temporalAngle = temporalOffset * PI2;
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )
for (int i = 0; i < gShadowSamples; i++) {
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
// Overall blurring offset
vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
// NOTE: Removed for now
// Penumbra offset
//offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);
shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
}
return shadow * gShadowSamplesRpc;
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
for (int i = 0; i < 16; i++) {
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
// Overall blurring offset
vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
}
return shadow * (1.0 / 16.0);
#else // no percentage-closer filtering
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );
#endif
}
#endif
`,yQ=xt.lights_fragment_begin,vQ=xt.shadowmask_pars_fragment,S3=null,xQ=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},w3=(n="medium")=>{if(S3===n)return!1;S3=n;let t=xQ(n);xt.shadowmap_pars_fragment=gQ(t);let e=yQ.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),xt.lights_fragment_begin=e;let r=vQ.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),xt.shadowmask_pars_fragment=r,!0};var bQ=`
attribute vec3 randomColor;
varying vec3 vNormal;
flat out vec3 vColor;
#include <skinning_pars_vertex>
void main()
{
#include <beginnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
vec3 transformed = vec3(position);
#include <skinning_vertex>
vNormal = normal;
vColor = randomColor;
gl_Position = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
}
`,SQ=`
uniform float depthContrast;
varying vec3 vNormal;
flat in vec3 vColor;
void main()
{
vec3 normal = (normalize(vNormal)).rgb;
float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
gl_FragColor = vec4(resultColor, vColor.r);
gl_FragColor = vec4(resultColor, vColor.r);
}
`,gx=new st({vertexShader:bQ,fragmentShader:SQ,uniforms:{depthContrast:{value:1}}});var A3=new Jt,wQ=new U,yx=class extends hw{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new U;this.dummyCamera=new xr;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,r=!0,i=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),r&&(o|=s.DEPTH_BUFFER_BIT),i&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.pipeline=new _m(this,e?.needsDOFResize??!1),this.autoClear=!1;let r=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=by,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine");let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,r(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new dt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt,depthBuffer:!1}))}_resizeTransmission(e,r){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),r*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,r*this._pixelRatio/1)}get hdTransmission(){return Ze.transmissionLod.value===1}set hdTransmission(e){Ze.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new dt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:cc,magFilter:tt,wrapS:Yt,wrapT:Yt,depthBuffer:!1}),this.transmissionDepthTarget=new dt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Vt,magFilter:Vt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new dt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Vt,magFilter:Vt,type:yr,depthTexture:new ns(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,r,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof xr?gx.uniforms.depthContrast.value=(i.far-i.near)/1e4:gx.uniforms.depthContrast.value=1,r.overrideMaterial=gx,this.render(r,i),this.setClearColor(r.bgColor,r.bgColor.a),this.setRenderTarget(null),r.overrideMaterial=e.wireframeState?vx:null,i.layers.enable(0),i.layers.enable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,r,i=1){this.dummyCamera.updateCameraState(r.dataPatched),this.dummyCamera.matrix.copy(r.matrixWorld);let s=r.height,o=r.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamera.setViewplaneSize(o,s);for(let l=0;l<i;l++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,r,{sceneHelpers:i=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof Gl?e.activePage:e,c=l.visible;l.visible=!0;let u=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(r)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((p,m)=>{Ze.penumbraSize.value[m]=p}),Ze.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ze.resolution.value.set(this.resolution.x,this.resolution.y):Ze.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(Ze.normalRenderTarget.value=a,Ze.normalRenderTargetDepth.value=A3):u.needsNormal()&&(this.createNormalRenderTarget(),Ze.normalRenderTarget.value=this.normalRenderTarget.texture,Ze.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(u,l,r));let h=l.data.ao,d=h.occlusion;if(d&&(this.createAORenderTarget(),Ze.aoRenderTarget.value=this.aoRenderTarget.texture),Ze.aoEnabled.value=d,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,h.aoFullRes&&!po),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&l.uiCanvas?.enabled&&l.uiCanvas.texture&&l.uiCanvas.texture.image.width>0){let p=this.getSize(wQ),m=this.getPixelRatio();(l.uiCanvas.width!==this.viewportWidth||l.uiCanvas.height!==this.viewportHeight||l.uiCanvas.dpr!==m)&&l.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},m),l.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=l.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(p.x,p.y,m),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();let f=!1;if(o!==void 0)Ze.transmissionRenderTarget.value=o,Ze.transmissionRenderTargetDepth.value=A3,this.pipeline.setTransmissionPassEnabled(!1);else{let p=u.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),Ze.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ze.aspectRatio.value=kI(this.viewportWidth,this.viewportHeight),Ze.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}r.layers.enable(3),r.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=r,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!i&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=u.wireframeState?vx:null,this.pipeline.render(),Ze.frameIndex.value=(Ze.frameIndex.value+1)%16,r instanceof xr&&r.copyHistory(),l.visible=c}renderFromSceneForSceneTransitionPass(e,r,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,r),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var yf=class extends Bo(vy){constructor(e,r=15,i=10066329){super(e,r,i);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){No(this.object,yf.geometryHelper,e,r)}};var vf=class extends Bo(yy){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){No(this.object,vf.geometryHelper,e,r)}};var xx=class extends Bo(gy){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){No(this.object,xx.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=xx._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Dm=xx;Dm._vector=new E;function AQ(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}var xf=class extends rf(fy,yf){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new nl(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof nl&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&AQ(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var E3=new E,M3=new E,T3=new Qe,bf=class extends rf(hy,Dm){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=we.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new nl(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof nl&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),M3.setFromMatrixPosition(this.matrixWorld),T3.setFromRotationMatrix(this.matrixWorld),E3.copy(this.up).applyQuaternion(T3).negate().multiplyScalar(this.distance),this.target.position.copy(M3).add(E3),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function EQ(n){let t=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,r=(n[1][0]+n[0][1])/2,i=(n[1][0]-n[0][1])/2,s=Math.sqrt(t*t+i*i),o=Math.sqrt(e*e+r*r),a=s+o,l=s-o,c=Math.atan2(r,e),u=Math.atan2(i,t),h=(u-c)/2,d=(u+c)/2,f=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],p=[[a,0],[0,l]],m=[[Math.cos(h),Math.sin(h)],[-Math.sin(h),Math.cos(h)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,p,m]}function bx(n,t){return[[n[0][0]*t[0][0]+n[0][1]*t[1][0],n[0][0]*t[0][1]+n[0][1]*t[1][1]],[n[1][0]*t[0][0]+n[1][1]*t[1][0],n[1][0]*t[0][1]+n[1][1]*t[1][1]]]}function C3(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function P3(n){let[t,e,r]=EQ(n),i=bx(t,C3(r)),s=bx(bx(r,e),C3(r)),o=Math.atan2(i[1][0],i[0][0]),a=[s[0][0],s[1][1]],l=[s[0][1]/s[1][1],s[1][0]/s[0][0]];return{rotation:o,scale:a,shear:l}}function _3({rotation:n,scale:t,shear:e}){let r=Math.cos(n),i=Math.sin(n),s=[[r,-i],[i,r]],o=[[t[0],e[0]*t[1]],[e[1]*t[0],t[1]]],a=bx(s,o);return[a[0][0],a[1][0],a[0][1],a[1][1]]}var St;(w=>{function n(){return[1,0,0,0,1,0,0,0,1]}w.identity=n;function t(A,M=w.identity()){for(let b=0,T=A.length;b<T;b++)M[b]=A[b];return M}w.copy=t;function e(A,M,b,T,C,P){return w.setAbcdef(w.identity(),A,M,b,T,C,P)}w.create=e;function r(A,M,b,T,C,P,D){return A[0]=M,A[1]=T,A[2]=P,A[3]=b,A[4]=C,A[5]=D,A}w.setAbcdef=r;function i(A,M){let[b,T,C,P,D,_]=o(A),[O,L,j,V,H,W]=o(M),q=O*b+L*C,K=O*T+L*P,G=j*b+V*C,Z=j*T+V*P,te=H*b+W*C+D,$=H*T+W*P+_;return w.create(q,K,G,Z,te,$)}w.append=i;function s(A,M){let[b,T,C,P,D,_]=o(A),[O,L,j,V,H,W]=o(M),q=b,K=T,G=C,Z=P;(O!==1||L!==0||j!==0||V!==1)&&(q=b*O+T*j,K=b*L+T*V,G=C*O+P*j,Z=C*L+P*V);let te=D*O+_*j+H,$=D*L+_*V+W;return w.create(q,K,G,Z,te,$)}w.prepend=s;function o(A){return[A[0],A[3],A[1],A[4],A[2],A[5]]}w.getAbcdef=o;function a(A){let[M,b,T,C,P,D]=w.getAbcdef(A),_=M*C-b*T,O=C/_,L=-b/_,j=-T/_,V=M/_,H=(T*D-C*P)/_,W=-(M*D-b*P)/_;return w.create(O,L,j,V,H,W)}w.invert=a;function l([A,M],b){let[T,C,P,D,_,O]=w.getAbcdef(b);return[T*A+P*M+_,C*A+D*M+O]}w.apply=l;function c(A,M){let[b,T,C,P,D,_]=w.getAbcdef(M),O=1/(b*P+C*-T),[L,j]=A;return[P*O*L+-C*O*j+(_*C-D*P)*O,b*O*j+-T*O*L+(-_*b+D*T)*O]}w.applyInverse=c;function u(A,M,b=M){let[T,C,P,D,_,O]=w.getAbcdef(A);return w.setAbcdef(A,T*M,C*b,P*M,D*b,_*M,O*b),A}w.scale=u;function h(A,M){let b=Math.cos(M),T=Math.sin(M),[C,P,D,_,O,L]=w.getAbcdef(A);return w.setAbcdef(A,C*b-P*T,C*T+P*b,D*b-_*T,D*T+_*b,O*b-L*T,O*T+L*b),A}w.rotate=h;function d(A,M,b){let[T,C]=b,P=w.translate(A,-T,-C);return P=w.rotate(P,M),P=w.translate(P,T,C),P}w.rotateAround=d;function f(A,M,b){let[T,C,P,D,_,O]=w.getAbcdef(A);return w.setAbcdef(A,T,C,P,D,_+M,O+b),A}w.translate=f;function p(A,M,b){let[T,C,P,D]=w.getAbcdef(A);return w.setAbcdef(A,T,C,P,D,M,b),A}w.setTranslate=p;function m(A,M,b){let[T,C,P,D]=w.getAbcdef(A);return w.setAbcdef(A,T,C,P,D,M,b),A}w.setPosition=m;function g(A){let[M,b,T,C]=w.getAbcdef(A),P=Math.sqrt(M*M+b*b),D=Math.sqrt(T*T+C*C);return[P,D]}w.getScale=g;function y(A){let[,,,,M,b]=w.getAbcdef(A);return[M,b]}w.getPosition=y;function v(A,M){return w.decompose(A,M).rotation}w.getRotation=v;function x(A,M){let[b,T,C,P,D,_]=w.getAbcdef(A),{rotation:O,scale:L,shear:j}=P3([[b,C],[T,P]]);return{position:[D+(M[0]*b+M[1]*C)-M[0],_+(M[0]*T+M[1]*P)-M[1]],scale:L,rotation:O,shear:j,pivot:M}}w.decompose=x;function S(A,M,b,T,C=[0,0]){let[P,D]=A,[_,O]=T,[L,j,V,H]=_3({rotation:b,scale:M,shear:C}),W=P-(_*L+O*V)+_,q=D-(_*j+O*H)+O;return w.create(L,j,V,H,W,q)}w.compose=S})(St||(St={}));var MQ=Math.PI/180,RRe=180/Math.PI;function D3(n,t,e,r,i,s){let o=n-e,a=t-r;return o*o/(i*i)+a*a/(s*s)<=1}function O3(n){return n*MQ}function wE(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(i){i(e)}),(r=n.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var er=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=St.identity();this.worldMatrix=St.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new jl;this._recursiveBBox=new jl;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=wE();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=St.append(e.worldMatrix,r)),St.applyInverse(t,r)}intersects(t,e,r,i=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),i)}intersectsInLocalSpace(t,e,r=!1){let{min:i,max:s}=r?this.recursiveBBox:this.singleBBox;return t>=i[0]&&t<=s[0]&&e>=i[1]&&e<=s[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=St.compose(this.position,this.scale,O3(this.rotation),wa.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let i=this.parent;e&&i!==null&&i!==void 0&&i.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=St.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=St.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return wa.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let i=t,s=Lt(t.path,["states","*"]);if(s!==null){if(t.type===0){let[o]=s;if(this?.stateSelection===o){let a={...t.props};if(delete a.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=Or.zoom(l,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(a[u]=c[u])}}i={...t,props:a,path:t.path.slice(2)}}}}else if(t.type===0){let o=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(o!==void 0){if(t.props.name!==void 0&&o.name){let{name:l,...c}=o;o=c}let a=Or.removeOverridden(t.path,t.props,o);i={...t,props:a}}}this.updateByPatchedOpBase(i,Sa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let i of this.data.states)Sa.toOps(this.data,i.data).forEach(o=>{let a=Dh.replaceProps(o,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,e)});if(t!==null){let i=this.data.states.data(t);i&&(this.dataPatched=Sa.patch(this.data,i),Sa.toOps(this.data,i).forEach(o=>{this.updateByPatchedOp(o,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new er(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof er&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var Xi=class extends er{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.context=i;this.children=[]}add(e){e.parent&&e.parent instanceof Xi&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let i of this.children)i instanceof Xi?i.traverse(e):r=e(i)}intersectsChildrenHelper(e,r,i,s,o){for(let a of this.children)if(a.intersects(e,r,i,!1)&&(o.push(a),s)||a instanceof Xi&&a.intersectsChildrenHelper(e,r,i,s,o))return!0;return!1}intersectsChildren(e,r,i,s=!1,o=[],a=!1){return this.intersectsChildrenHelper(e,r,i,s,o),o}intersectsChildrenHelperReverse(e,r,i,s,o){for(let a of this.children)if(a instanceof Xi&&a.intersectsChildrenHelperReverse(e,r,i,s,o)||a.intersects(e,r,i,!1)&&(o.push(a),s))return!0;return!1}intersectsChildrenReverse(e,r,i,s=!1,o=[],a=!1){return this.intersectsChildrenHelperReverse(e,r,i,s,o),o}updateWorldMatrix(e,r,i){if(super.updateWorldMatrix(e,r,i),i&&this.children)for(let s of this.children)s.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(i=>{i.uuid===e&&(r=i)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new Xi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}},Fn=class extends Xi{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.updateState(r,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new Fn(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};function TQ(n,t){let[[e,r],[i,s]]=n,[[o,a],[l,c]]=t,u=(e-i)*(a-c)-(r-s)*(o-l);if(u===0)return!1;let h=((e-o)*(a-c)-(r-a)*(o-l))/u,d=-((e-i)*(r-a)-(r-s)*(e-o))/u;return h>=0&&h<=1&&d>=0&&d<=1}var R3=[[-1,1],[-1,-1],[1,-1],[1,1]],I3=(n,t,e)=>{let r=n.getCenter(),i=n.getHalfSize(),s=St.append(t,n.worldMatrix);i[0]===0&&i[1]===0?e.push(St.apply(r,s)):R3.forEach(o=>{let a=[o[0]*i[0]+r[0],o[1]*i[1]+r[1]];e.push(St.apply(a,s))})},jl=class{constructor(){this.matrix=St.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),St.copy(t.worldMatrix,this.matrix);let r=St.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let i=[];r===!0&&t instanceof Xi?t.traverse(s=>{s.visible&&I3(s,e,i)}):I3(t,e,i),this.setFromPoints(i)}setFromSize(t,e,r){this.makeEmpty(),St.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[St.apply([0,0],r),St.apply([0,e],r),St.apply([t,e],r),St.apply([t,0],r)].forEach(s=>this.expandByPoint(s))}getCenter(){let[t,e]=this.min,[r,i]=this.getHalfSize();return St.apply([t+r,e+i],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[i,s,o,a]=St.getAbcdef(this.matrix),l=St.create(i,s,o,a,r[0],r[1]);this.vertices=R3.map(([c,u])=>St.apply([c*t,u*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=St.append(e.worldMatrix,r)),St.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:i}=this;return t>=r[0]&&t<=i[0]&&e>=r[1]&&e<=i[1]}containsPoint(t){let[e,r]=t,[i,s]=this.min,[o,a]=this.max;return e>=i&&e<=o&&r>=s&&r<=a}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let i=this.edges[e];for(let s=0,o=t.edges.length;s<o;s++){let a=t.edges[s];if(TQ(i,a))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let i=t.vertices[e];if(this.containsPoint(i))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],St.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new jl;return t.copy(this),t}};var B3,N3=new Promise(n=>{B3=n}),L3=!1;var Sx;function F3(){if(L3)return;if(Sx)return Sx;async function n(){let e=await import("./ui.js");B3(e.default??e),L3=!0}return Sx=n(),Sx}function EE(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var pt,AE;async function CQ(n){let t=await N3;pt||(AE||(AE=t({locateFile:()=>n})),pt=await AE)}var V3=St.identity(),Om=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=bt.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=bt.transparent;this._fonts=new Map;this._isSizeDirty=!1;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=V3,this._currentTransform=new Float32Array(V3)}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await CQ(this.wasmURL),this._surface=pt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new pt.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(pt.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(pt.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=pt.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(wx(t),pt.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(wx(t),pt.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(pt.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new pt.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,i,s=0,o=0,a=0,l=0){let c=pt.XYWHRect(t,e,r,i);if(s===0&&o===0&&l===0&&a===0)this.ctx?.clipRect(c,pt.ClipOp.Intersect,!0);else{let u=pt.RRectXY(c,s,s);u[4]=u[5]=s,u[6]=u[7]=o,u[8]=u[9]=a,u[10]=u[11]=l,this.ctx?.clipRRect(u,pt.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=St.invert(this.currentTransform);this.ctx.concat(t);let e=St.translate(St.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let i,s=!1;if(r&&this._hasDropShadow()){let o=t.copy();o.setColor(wx(this._dropShadowColor));let a;this._dropShadowBlur>0&&(a=pt.MaskFilter.MakeBlur(pt.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),o.setMaskFilter(a)),this.ctx.save(),this.ctx.clipPath(this._currentPath,pt.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(o),this.ctx.restore(),o.delete(),a?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,pt.ClipOp.Intersect,!0);let o=pt.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,pt.TileMode.Clamp,null),a=t.copy();a.setImageFilter(o),a.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(a,l,null,pt.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),a.delete(),o.delete(),s=!0}if(this._layerBlur>0){let o=t.copy();i=pt.MaskFilter.MakeBlur(pt.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),o.setMaskFilter(i),e(o),o.delete(),i.delete(),s=!0}if(s||e(t),r&&this._hasInnerShadow()){let o=new pt.Paint;o.setAntiAlias(!0),o.setStyle(pt.PaintStyle.Fill),o.setColor(wx(this._innerShadowColor));let a;this._innerShadowBlur>0&&(a=pt.MaskFilter.MakeBlur(pt.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),o.setMaskFilter(a));let l=this._currentPath.computeTightBounds(),[c,u,h,d]=l,f=h-c,p=d-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,pt.ClipOp.Intersect,!0),this.ctx.saveLayer(o,l,null,pt.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(pt.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+p+Math.abs(this._innerShadowOffsetY*2)),o),o.setBlendMode(pt.BlendMode.Clear),this.ctx.drawPath(this._currentPath,o),this.ctx.restore(),this.ctx.restore(),o.delete(),a?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,i=this._currentPath;this._applyEffectsToPaint(t,s=>{let o=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(i,this._strokeMode==="outside"?pt.ClipOp.Difference:pt.ClipOp.Intersect,!0),o=!0),r.drawPath(i,s),o&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(pt.Path.MakeFromSVGString(t))}ellipse(t,e,r,i,s,o,a,l){if(!z3([t,e,r,i])||!this._currentPath)return;if(r<0||i<0)throw Error("radii cannot be negative");let c=pt.XYWHRect(t-r,e-i,r*2,i*2);this._currentPath?.addOval(c)}rect(t,e,r,i,s=0,o=0,a=0,l=0){let c=pt.XYWHRect(t,e,r,i);if(!!z3(c))if(s===0&&o===0&&l===0&&a===0)this._currentPath?.addRect(c);else{let u=pt.RRectXY(c,s,s);u[4]=u[5]=s,u[6]=u[7]=o,u[8]=u[9]=a,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(t){switch(t){case 2:return pt.TextAlign.Right;case 3:return pt.TextAlign.Center;case 4:return pt.TextAlign.Justify;case 1:default:return pt.TextAlign.Left}}drawTextInner(t,e,r,[i,s,o,a],l,c,u=!0){let h=0,{ctx:d}=this;if(!d)return h;let f=c.copy(),p=c.copy();return p.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,p),e.addText(t);let g=e.build();g.layout(o);let y=s;l===2?y+=(a-g.getHeight())/2:l===3&&(y+=a-g.getHeight()),d.drawParagraph(g,i,y),h=g.getHeight(),e.reset(),g.delete()},u),f.delete(),p.delete(),h}drawText(t,e){let r=0,i=this._fonts.get(e.font),{ctx:s,_paintFill:o,_paintStroke:a}=this;if(i&&s){let l=new pt.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new pt.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=pt.XYWHRect(e.x,e.y,e.width,e.height),h=pt.ParagraphBuilder.Make(c,i);o&&(r=this.drawTextInner(t,h,l,u,e.verticalAlign,o,!0)),a&&(r=this.drawTextInner(t,h,l,u,e.verticalAlign,a,!1)),h.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,i,s,o){this._currentPath?.cubicTo(t,e,r,i,s,o)}quadraticCurveTo(t,e,r,i){this._currentPath?.quadTo(t,e,r,i)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),i=St.invert(r);if(i&&this.ctx.concat(i),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let s=St.getScale(this.camera.worldMatrix);this.ctx?.scale(1/s[0],1/s[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=pt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function z3(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function wx({r:n,g:t,b:e,a:r}){return pt.Color4f(n,t,e,r)}var Im=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=bt.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var Rm=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var Ax=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=bt.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var Ex=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=bt.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var br=class extends er{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Ax(e+"-fill",r.fill,i),this.stroke=new Ex(e+"-stroke",r.stroke,i),this.dropShadow=new Im(e+"-dropShadow",r.dropShadow,i),this.innerShadow=new Im(e+"-innerShadow",r.innerShadow,i),this.backgroundBlur=new Rm(e+"-backgroundBlur",r.backgroundBlur,i),this.layerBlur=new Rm(e+"-layerBlur",r.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:bt.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:bt.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=bt.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=bt.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Lt(e.path,["fill"])?this.fill.update(e.props):Lt(e.path,["stroke"])?this.stroke.update(e.props):Lt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Lt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Lt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Lt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new br(this.uuid,this.data,e);return r.parent=void 0,r}};var Hl=class extends br{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return D3(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Hl(this.uuid,this.data,e);return r.parent=void 0,r}};var As=class extends br{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new As(this.uuid,this.data,e);return r.parent=void 0,r}};var Wl=class extends br{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:bt.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:bt.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,i=this.data.text.textValue.toString(),s=r===2?i.toUpperCase():r===3?i.toLowerCase():i,{height:o}=e.drawText(s,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=o}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Wl(this.uuid,this.data,e);return r.parent=void 0,r}};var Sf=class extends br{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(s=>Mx.extremas(s)),r=[1/0,1/0],i=[-1/0,-1/0];for(let s=0,o=e.length;s<o;s++){let a=e[s];a[0][0]<r[0]&&(r[0]=a[0][0]),a[0][1]<r[1]&&(r[1]=a[0][1]),a[1][0]>i[0]&&(i[0]=a[1][0]),a[1][1]>i[1]&&(i[1]=a[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,s=this.data.points.length;i<s;i++){let o=this.data.points[i].data,a=this.data.points[i-1].data,l={start:a.position,cp1:a.controlNext.position,cp2:o.controlPrevious.position,end:o.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,r]=this.extremasBBox.min,[i,s]=this.getHalfSize();return[e+i,r+s]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let s=0,o=this.data.points.length;s<o;s++){let a=this.data.points[s].data;if(s===0){let[l,c]=a.position;e.moveTo(l,c)}else{let l=this.data.points[s-1].data,[c,u]=l.controlNext.position,[h,d]=a.controlPrevious.position,[f,p]=a.position,m={start:l.position,cp1:l.controlNext.position,cp2:a.controlPrevious.position,end:a.position};Mx.derive(m),e.bezierCurveTo(c,u,h,d,f,p)}}let r=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[s,o]=i.controlNext.position,[a,l]=r.controlPrevious.position,[c,u]=r.position;e.bezierCurveTo(s,o,a,l,c,u)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Sf(this.uuid,this.data,e);return r.parent=void 0,r}},Mx;(s=>{function n(o){let a=o.start,l=o.cp1,c=o.cp2,u=o.end,h=[3*(l[0]-a[0]),3*(l[1]-a[1])],d=[3*(c[0]-l[0]),3*(c[1]-l[1])],f=[3*(u[0]-c[0]),3*(u[1]-c[1])],p={start:h,cp:d,end:f};return o.derivative=p,p.derivative=ME.derive(p),p}s.derive=n;function t(o,a,l,c=!1){let u=o-2*a+l;if(u!==0){let h=-Math.sqrt(Math.abs(a*a-o*l)),d=-o+a,f=-(h+d)/u,p=-(-h+d)/u;return[f,p]}else if(a!==l&&u===0)return[(2*a-l)/(2*(a-l))];return[]}function e(o){let a=o.derivative??s.derive(o),l=a.start,c=a.cp,u=a.end;return[t(l[0],c[0],u[0]),t(l[1],c[1],u[1])]}s.droot=e;function r(o){let[a,l]=s.droot(o),c=[o.start[0],o.end[0]],u=[o.start[1],o.end[1]];for(let h of a)c.push(s.compute(o,Math.min(1,Math.max(0,h)))[0]);for(let h of l)u.push(s.compute(o,Math.min(1,Math.max(0,h)))[1]);return c.sort((h,d)=>h-d),u.sort((h,d)=>h-d),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}s.extremas=r;function i(o,a){if(a===0)return[...o.start];if(a===1)return[...o.end];let l=1-a,c=l*l,u=a*a,h=c*l,d=c*a*3,f=l*u*3,p=a*u;return[h*o.start[0]+d*o.cp1[0]+f*o.cp2[0]+p*o.end[0],h*o.start[1]+d*o.cp1[1]+f*o.cp2[1]+p*o.end[1]]}s.compute=i})(Mx||(Mx={}));var ME;(r=>{function n(i){let s=i.start,o=i.cp,a=i.end,l=[2*(o[0]-s[0]),2*(o[1]-s[1])],c=[2*(a[0]-o[0]),2*(a[1]-o[1])],u={start:l,end:c};return u.derivative=TE.derive(u),i.derivative=u,u}r.derive=n;function t(i){let s=i.derivative??r.derive(i),o=s.start,a=s.end;return[o[0]!==a[0]?o[0]/(o[0]-a[0]):0,o[1]!==a[1]?o[1]/(o[1]-a[1]):0]}r.droot=t;function e(i,s){if(s===0)return[...i.start];if(s===1)return[...i.end];let o=1-s,a=o*o,l=s*s,c=a,u=o*s*2,h=l;return[c*i.start[0]+u*i.cp[0]+h*i.end[0],c*i.start[1]+u*i.cp[1]+h*i.end[1]]}r.compute=e})(ME||(ME={}));var TE;(e=>{function n(r){let i=r.start,s=r.end,o=[s[0]-i[0],s[1]-i[1]];return r.derivative=o,r.derivative}e.derive=n;function t(r,i){if(i===0)return[...r.start];if(i===1)return[...r.end];let s=r.start,o=r.end;return[s[0]+(o[0]-s[0])*i,s[1]+(o[1]-s[1])*i]}e.compute=t})(TE||(TE={}));var Qi=class extends Xi{constructor(e,r,i){super(e,r,i);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new As(e+"-background",Xh.defaultData,i),this.background.parent=this,this.updateState(r,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,i){super.updateWorldMatrix(e,r,i),this.background?.updateWorldMatrix(e,r,i)}draw(e){if(!this.visible)return;e.save();let r=this.width,i=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Lt(e.path,["fill"])?this.fill.update(e.props):Lt(e.path,["stroke"])?this.stroke.update(e.props):Lt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Lt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Lt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Lt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Qi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};var j3=Ko(CE(),1),Ra=class extends br{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),r.setAttribute("d",this.path),e.appendChild(r),this._pathBBox=r.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new Ra(this.uuid,this.data,e);return r.parent=void 0,r}};function H3(n,t=1,e=1){if(t<=0||e<=0)return n;let i=(0,j3.parseSVG)(n).map(s=>{let o={...s};return"x"in o&&(o.x=o.x*t),"y"in o&&(o.y=o.y*e),"x1"in o&&(o.x1=o.x1*t),"x2"in o&&(o.x2=o.x2*t),"y1"in o&&(o.y1=o.y1*e),"y2"in o&&(o.y2=o.y2*e),"rx"in o&&(o.rx=o.rx*t),"ry"in o&&(o.ry=o.ry*e),o});return W3(i)}function W3(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let i=[];t.forEach(o=>{if(o in r){let a=r[o]*1;i.length&&a>=0&&i.push(","),i.push(a)}});let s=(e===r.code?i[0]<0?"":",":r.code)+i.join("");return e=r.code,s}).join("")}function q3(n,t,e){switch(t.type){case"ellipse2d":return new Hl(n,t,e);case"rectangle2d":return new As(n,t,e);case"text2d":return new Wl(n,t,e);case"vector2d":return new Sf(n,t,e);case"path2d":return new Ra(n,t,e);case"frame2d":return new Qi(n,t,e);case"group2d":default:return new Fn(n,t,e)}}var PE=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Fn(PE.GROUP_ID,{...Gp.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,i,s,o){let a=q3(t,e,o);a&&(i.add(a),i.children.splice(s,0,i.children.pop()),a.updateWorldMatrix(),r.length>0&&(a instanceof Fn||a instanceof Qi)&&this.createChildrenObjects(r,a,o))}createChildrenObjects(t,e,r){let i=0;for(let s of t)this.createObject(s.id,s.data,s.children,e,i,r),i+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,i){let s=this.find(t);if(s)try{s.updateByOp(e,r,{shared:i})}catch(o){console.error(o)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof Xi&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof Xi){let i=r.parent;r.resetBBoxNeedsUpdate(),i?.remove(r),i?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let i=r.parent,s=t.parent===null?this:this.find(t.parent);if(s===void 0&&!1&&console.error("unexpected",s,t),s instanceof Xi||s===this){s.add(r);let o=t.localIndex;s.children.splice(o,0,s.children.pop()),r.updateWorldMatrix(!0,!1,!0),i?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,i=!1,s=[]){return this.group.intersectsChildren(t,e,r,i,s,!0)}intersectsChildrenReverse(t,e,r,i=!1,s=[]){return this.group.intersectsChildrenReverse(t,e,r,i,s,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],i=e;for(;i!==this.group;){let s=i;i=i.parent;let o=i.children.indexOf(s);r.splice(0,0,o)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let i=this.getWithSortKey(r.id);i!==void 0&&e.push(i)}return e.sort((r,i)=>Jy(r.sortKey,i.sortKey)),e.map(r=>r.entity)}},Kc=PE;Kc.GROUP_ID="scene2d";function _E({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:i,objectInitialWidth:s,objectInitialHeight:o,objectInitialPosition:a}){let{horizontalConstraint:l,verticalConstraint:c}=n,u=t-r,h=e-i,d=s,f=o,p=a[0],m=a[1];if(l!==0){if(l===1)p+=u;else if(l===3)p+=u/2;else if(l===2)d=Math.max(1,d+u);else if(l===4){let g=t/r;d*=g,p*=g}}if(c!==0){if(c===1)m+=h;else if(c===3)m+=h/2;else if(c===2)f=Math.max(1,f+h);else if(c===4){let g=e/i;f*=g,m*=g}}return{width:d,height:f,position:[p,m]}}var OQ=Ko(CE(),1);var cBe={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};var IQ=`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,RQ=`
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = texel;
}`,LQ=new Ka(-1,1,1,-1,0,1),IE=class extends _e{constructor(){super(),this.setAttribute("position",new Te([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Te([0,2,0,0,2,0],2))}},BQ=new IE,RE=class{constructor(t){this._mesh=new Xt(BQ,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,LQ)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}},Y3=new st({defines:{},uniforms:{tDiffuse:new ue(null)},vertexShader:IQ,fragmentShader:RQ}),NQ=new RE(Y3),DE=null,OE=null,FQ=()=>(DE===null&&(DE=document.createElement("canvas")),DE),VQ=n=>(OE===null&&(OE=new Om(n)),OE),zQ=St.identity(),wf=class{constructor(t,e,r,i){this.uuid=t;this.width=e;this.height=r;this.context=i;this.enabled=!0;this.isScreenSpace=!1;this.dpr=window.devicePixelRatio;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this._innerApplySize=()=>{let t=this.width,e=this.height,r=this.dpr;this.renderer.dpr=this.isScreenSpace?r:Math.floor(2048/Math.max(t,e)),this.renderer.setSize(t,e)};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new Kc(we.generateUUID(),Yv.defaultData,{dpr:window.devicePixelRatio,shared:i.shared}),this.canvas=FQ(),this.renderer=VQ(this.canvas),this.promise=this.init(),this.renderTarget=new dt(1,1,{type:jn,stencilBuffer:!1,depthBuffer:!1}),i.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=i.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new sy(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof Om&&(this.renderer.wasmURL=L0.skiaWasmUrl),await this.renderer.init()}render(t){if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),Y3.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),NQ.render(t),t.setRenderTarget(e),this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,r,i){this.scene2d.updateEntityByOp(t,e,r,i),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=zQ,this.isScreenSpace&&(this.frameOverride.fill.color=bt.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},X3({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let r=t?.width??this.width,i=t?.height??this.height;this.dpr=e,this.width=r,this.height=i,this._innerApplySize();let s=1,o=512,a=512;(r*e<o||i*e<a)&&(s=Math.max(o/(r*e),a/(i*e))),this.renderTarget.setSize(r*e*s,i*e*s),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Qi)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function X3({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s}){if(n instanceof Qi&&t instanceof Qi||n instanceof Fn&&t instanceof Fn)for(let o=0,a=n.children.length;o<a;o++){let l=n.children[o],c=t.children[o];l&&c&&l.uuid===c.uuid&&kQ({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s})}}function UQ(n){if(LE(n))return[n.width,n.height];if(n instanceof Ra){let[t,e]=n.getHalfSize();return[t*2,e*2]}else if(n instanceof Fn){let[t,e]=n.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function kQ({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s}){let[o,a]=UQ(t),{width:l,height:c,position:u}=_E({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s,objectInitialWidth:o,objectInitialHeight:a,objectInitialPosition:t.position});if(n.position=u,n.data={...n.data,position:u},n.states)for(let h in n.states)GQ({stateId:h,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s});if(LE(n)||n instanceof Fn)LE(n)&&(n.width=l,n.height=c,n.data={...n.data,width:l,height:c}),X3({objectOverride:n,objectRoot:t,newParentWidth:l,newParentHeight:c,initialParentWidth:o,initialParentHeight:a});else if(n instanceof Ra){let h=t,d=o!==0?l/o:1,f=a!==0?c/a:1;n.path=H3(h.path,d,f),n.data={...n.data,path:n.path}}}function GQ({stateId:n,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:i,initialParentWidth:s,initialParentHeight:o}){let a=t.states?.[n],l=e.states?.[n];if(a&&l){let{width:c,height:u,position:h}=_E({constraints:t.data,newParentWidth:r,newParentHeight:i,initialParentWidth:s,initialParentHeight:o,objectInitialWidth:wa.isResizeable(l)?l.width:0,objectInitialHeight:wa.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[n],{position:h}),wa.isResizeable(a)&&Object.assign(t.states[n],{width:c,height:u})}}function LE(n){return n instanceof As||n instanceof Qi||n instanceof Hl||n instanceof Wl}var lr=class extends hd(bi){constructor(e,r,i){super();this.data=r;this.bgColor=new mr(1,1,1,1);this.fog=null;this.backupFog=new Du(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new We;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new xr(hs,{..._c.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new uy(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new Kc((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:i.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new wf(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=Yi(e.color,r)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(r=>{r instanceof Ln&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof ys)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&w3(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Yi(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=Yi(e.aoColor,r))}updateByOp(e,r,i,s){let o=this.data.uiFrame;super.updateByOp(e,r,i,s);let a=r;Lt(e.path,["fog"])?this.updateFog(a.fog,i.shared):Lt(e.path,["ao"])?this.updateAo(a.ao,i.shared):Lt(e.path,["ambient"])?this.updateAmbientLight(a.ambient,i.shared):Lt(e.path,["shadow"])?this.updateShadow(a.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||o!==a.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(Yi(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof xf&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof bf&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=i.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],i=s=>{for(let o of s.children){let a=o.cloner;yt.is(o)&&(o.visible||a?.object.data.visible)&&((sn(o)||Mm(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Lm(o,e,r,!0)),i(o))}};return i(this),r}updateEntity2DByOp(e,r,i,s){this.uiCanvas?.updateEntity2DByOp(e,r,i,s)}};var Cx=class extends rf(dy,vf){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new E(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new E(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new Gt(o,a),c=new sl(l,new We(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof sl){let r=this.shadow.camera,i=new E(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new E(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(i,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Px=class extends ar{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?lm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var ql=class extends ar{constructor(e,r,i){super(e,r,i);this._shapeId=null;this._context=i}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let r;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),r=o.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=wd;break;case"Ellipse":s=xd;break;case"Polygon":s=S0;break;case"Star":s=w0;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=s.create({parameters:e}).userData.shape}let i=this.geometry;r&&i.inputs&&(i.inputs.shapeData=r,i.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let i=this.geometry.getAttribute("position");i!==void 0?lm(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,r):super.updateEntityBoxSize(e,r)}};var Js=class extends bs(En,Ss){constructor(e,r,i){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,i)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let i=Gh.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(i){let s,o;for(let a of Ao.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=i.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=go.apply(i.data[a],e[a]));return this.overrideData=o,s}else return{...Mi.defaultData,...e,...Kn(Mi.defaultData,Ao.rootOverrideProps)}}updateByOp(e,r,i,s){let o;if(this.isInstanceRoot&&!s){if(r=this.transformAssignData(r,i),e.type===0&&e.path.length===0&&this.component)for(let a of Ao.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Ao.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:r[a]}})}}super.updateByOp(o??e,r,i,s)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let i=e.scene.find(r.component)??null,s=!1;if(i!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(yt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),_x(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(i){let o={};K3(e,[this.uuid],r.overrides,this,i,i,0,s,o);for(let a of this.children)if(yt.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof ar&&u.bones&&u.boneInverses){let h=c.dataPatched;if(h.bones&&h.boneInverses){let d=h.bones.map(m=>e.scene.find(o[m])),f=h.boneInverses.map(m=>new ce().fromArray(m)),p=new Za(d,f);c.bind(p,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function _x(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)yt.is(e)&&_x(e)}}function Q3(n,t,e,r){return n.component===t&&Ec(n.identity,r)?n.overrideData===e?2:1:0}function K3(n,t,e,r,i,s,o,a,l){if(o>50)return!1;if(r.component!==i){if(r.component){let u=r.component.instances.indexOf(r);u>=0&&r.component.instances.splice(u,1)}i.instances.find(u=>u===r)||i.instances.push(r),r.component=i}i instanceof Js&&i.isInstanceRoot&&i.expandInstanceChildren(n);let c=0;for(let u of i.children)if(yt.is(u)){let h=[...t,...typeof u.identity=="string"?[u.identity]:u.identity],d=Uh.resolve(e,h,1);if(d!=null&&!(d instanceof pr)){if(!1)debugger;Object.setPrototypeOf(d,pr.prototype),console.error("wrong prototype")}let f=null,p;if(!a){let m=r.children[c];if(f=yt.is(m)?m:null,f!==null){let g=Q3(f,u,d,h);p=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(h)??null,f!==null)){let g=Q3(f,u,d,h);if(p=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),r.children.splice(c,0,f),f.parent===r?(y<=c&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?go.apply(u.data,d):u.data;Vs.is(m.type)&&(m={...m,type:"Empty"}),f=Gs.createEntity(h,m,n),f.overrideData=d,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(c,0,f),f.updateState(f.data,n),p&&f.changeSelectedState(p,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}c+=1,K3(n,t,e,f,u,s,o+1,a,l)}if(!a){let u=c;for(;;){let h=r.children[c];if(yt.is(h))n.pendingDeletes.add(h);else break;c+=1}r.children.splice(u,c-u)}return!0}var Dx=class extends bs(cp,Ss){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Sr=class extends ar{constructor(e,r,i){super(e,r,i);this.onBeforeRender=e=>{this.uiCanvas.render(e)};this.uiCanvas=new wf(e+"-canvas",r.geometry.width,r.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,r){let i=e?.width??this.dataPatched.geometry.width,s=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:s}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Ma(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let i=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,i,s){this.uiCanvas.updateEntity2DByOp(e,r,i,s),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(s):Lt(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:s}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r)}};var Ox=class{constructor(t,e,r){this.variables=[],this.currentTextureIndex=0;let i=yr,s=new bi,o=new Wn;o.position.z=1;let a={passThruTexture:{value:null}},l=h(f(),a),c=new Xt(new hn(2,2),l);s.add(c),this.setDataType=function(p){return i=p,this},this.addVariable=function(p,m,g){let y=this.createShaderMaterial(m),v={name:p,initialValueTexture:g,material:y,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:Vt,magFilter:Vt};return this.variables.push(v),v},this.setVariableDependencies=function(p,m){p.dependencies=m},this.init=function(){if(r.capabilities.isWebGL2===!1&&r.extensions.has("OES_texture_float")===!1)return"No OES_texture_float support for float textures.";if(r.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let p=0;p<this.variables.length;p++){let m=this.variables[p];m.renderTargets[0]=this.createRenderTarget(t,e,m.wrapS,m.wrapT,m.minFilter,m.magFilter),m.renderTargets[1]=this.createRenderTarget(t,e,m.wrapS,m.wrapT,m.minFilter,m.magFilter),this.renderTexture(m.initialValueTexture,m.renderTargets[0]),this.renderTexture(m.initialValueTexture,m.renderTargets[1]);let g=m.material,y=g.uniforms;if(m.dependencies!==null)for(let v=0;v<m.dependencies.length;v++){let x=m.dependencies[v];if(x.name!==m.name){let S=!1;for(let w=0;w<this.variables.length;w++)if(x.name===this.variables[w].name){S=!0;break}if(!S)return"Variable dependency not found. Variable="+m.name+", dependency="+x.name}y[x.name]={value:null},g.fragmentShader=`
uniform sampler2D `+x.name+`;
`+g.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){let p=this.currentTextureIndex,m=this.currentTextureIndex===0?1:0;for(let g=0,y=this.variables.length;g<y;g++){let v=this.variables[g];if(v.dependencies!==null){let x=v.material.uniforms;for(let S=0,w=v.dependencies.length;S<w;S++){let A=v.dependencies[S];x[A.name].value=A.renderTargets[p].texture}}this.doRenderTarget(v.material,v.renderTargets[m])}this.currentTextureIndex=m},this.getCurrentRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex===0?1:0]},this.dispose=function(){c.geometry.dispose(),c.material.dispose();let p=this.variables;for(let m=0;m<p.length;m++){let g=p[m];g.initialValueTexture&&g.initialValueTexture.dispose();let y=g.renderTargets;for(let v=0;v<y.length;v++)y[v].dispose()}};function u(p){p.defines.resolution="vec2( "+t.toFixed(1)+", "+e.toFixed(1)+" )"}this.addResolutionDefine=u;function h(p,m){m=m||{};let g=new st({uniforms:m,vertexShader:d(),fragmentShader:p});return u(g),g}this.createShaderMaterial=h,this.createRenderTarget=function(p,m,g,y,v,x){return p=p||t,m=m||e,g=g||Yt,y=y||Yt,v=v||Vt,x=x||Vt,new dt(p,m,{wrapS:g,wrapT:y,minFilter:v,magFilter:x,format:jr,type:i,depthBuffer:!1})},this.createTexture=function(){let p=new Float32Array(t*e*4),m=new di(p,t,e,jr,yr);return m.needsUpdate=!0,m},this.renderTexture=function(p,m){a.passThruTexture.value=p,this.doRenderTarget(l,m),a.passThruTexture.value=null},this.doRenderTarget=function(p,m){let g=r.getRenderTarget(),y=r.xr.enabled,v=r.shadowMap.autoUpdate,x=r.outputEncoding,S=r.toneMapping;r.xr.enabled=!1,r.shadowMap.autoUpdate=!1,r.outputEncoding=un,r.toneMapping=Os,c.material=p,r.setRenderTarget(m),r.render(s,o),c.material=l,r.xr.enabled=y,r.shadowMap.autoUpdate=v,r.outputEncoding=x,r.toneMapping=S,r.setRenderTarget(g)};function d(){return`void main() {
gl_Position = vec4( position, 1.0 );
}
`}function f(){return`uniform sampler2D passThruTexture;
void main() {
vec2 uv = gl_FragCoord.xy / resolution.xy;
gl_FragColor = texture2D( passThruTexture, uv );
}
`}}};var Ki=new Mr,Ix=new E,Rx=class{constructor(t){let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(t){return this.weightAttribute=t?this.geometry.getAttribute(t):null,this}build(){let t=this.positionAttribute,e=this.weightAttribute,r=new Float32Array(t.count/3);for(let s=0;s<t.count;s+=3){let o=1;e&&(o=e.getX(s)+e.getX(s+1)+e.getX(s+2)),Ki.a.fromBufferAttribute(t,s),Ki.b.fromBufferAttribute(t,s+1),Ki.c.fromBufferAttribute(t,s+2),o*=Ki.getArea(),r[s/3]=o}this.distribution=new Float32Array(t.count/3);let i=0;for(let s=0;s<r.length;s++)i+=r[s],this.distribution[s]=i;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e,r){let i=this.distribution[this.distribution.length-1],s=this.binarySearch(this.randomFunction()*i);return this.sampleFace(s,t,e,r)}binarySearch(t){let e=this.distribution,r=0,i=e.length-1,s=-1;for(;r<=i;){let o=Math.ceil((r+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:r=o+1}return s}sampleFace(t,e,r,i){let s=this.randomFunction(),o=this.randomFunction();return s+o>1&&(s=1-s,o=1-o),Ki.a.fromBufferAttribute(this.positionAttribute,t*3),Ki.b.fromBufferAttribute(this.positionAttribute,t*3+1),Ki.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Ki.a,s).addScaledVector(Ki.b,o).addScaledVector(Ki.c,1-(s+o)),r!==void 0&&Ki.getNormal(r),i!==void 0&&this.colorAttribute!==void 0&&(Ki.a.fromBufferAttribute(this.colorAttribute,t*3),Ki.b.fromBufferAttribute(this.colorAttribute,t*3+1),Ki.c.fromBufferAttribute(this.colorAttribute,t*3+2),Ix.set(0,0,0).addScaledVector(Ki.a,s).addScaledVector(Ki.b,o).addScaledVector(Ki.c,1-(s+o)),i.r=Ix.x,i.g=Ix.y,i.b=Ix.z),this}};function Z3(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let i=e*n+r;t[i*2+0]=e/(n-1),t[i*2+1]=r/(n-1)}return t}function J3(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function $3(n,t){let e=new Xt(n.geometry,n.material),r=[],i=[],s=new E,o=new E;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let a=new Rx(e).build();for(let u=0;u<t;u++)a.sample(s,o),r.push(s.x,s.y,s.z),i.push(o.x,o.y,o.z);let l=new Float32Array(r),c=new Float32Array(i);return{positions:l,normals:c}}function BE(n,t){let e=n,r=new Float32Array(4*t*t);for(let s=0;s<t*t;s++)r[4*s]=e[3*s],r[4*s+1]=e[3*s+1],r[4*s+2]=e[3*s+2],r[4*s+3]=0;let i=new di(r,t,t,jr,yr);return i.needsUpdate=!0,i}function eL({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new di(t,n,n,jr,yr);return e.needsUpdate=!0,e}function tL(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new di(t,n,n,jr,yr);return e.needsUpdate=!0,e}var rL=`
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
uniform sampler2D uOriginalPosition;
uniform float uTime;
uniform float uSpeed; // update speed of the particles
uniform vec3 uWorldOffset;
uniform vec4 uWorldQuaternion;
uniform float uMaxLifeTime;
uniform vec3 uEmitterSize;
uniform float uFPSRatio; // 1 for 60 FPS
float random (vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898,78.233)))*
43758.5453123);
}
vec3 applyQuaternionToVector( vec4 q, vec3 v ){
return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
}
vec3 applyForce(vec3 force, float mass) {
vec3 acceleration = force / mass;
return acceleration;
}
void main() {
vec2 vUv = gl_FragCoord.xy / resolution.xy;
vec3 position = texture2D( uCurrentPosition, vUv ).xyz;
float currentLife = texture2D( uCurrentPosition, vUv ).w; // from 1 to 0
float isSpawning = texture2D( uCurrentEmissionRate, vUv ).r; // 1. = spawning, 0. = not spawning
float isActive = texture2D( uCurrentEmissionRate, vUv ).g; // 1. = active, 0. = not active
float timeStart = texture2D( uCurrentEmissionRate, vUv ).b; // timeStart in seconds when the particle was emitted
vec3 originalPosition = ((texture2D( uOriginalPosition, vUv ).xyz) * uEmitterSize);
vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;
float collisionFlag = texture2D( uCurrentVelocity, vUv ).w; // 1. = collided, 0. = not collided
float lifeTime = uMaxLifeTime;
// Calculate the position adjustment based on collision
// if (collisionFlag > .5) {
float isColliding = step(0.5, collisionFlag); // 1.0 if collisionFlag > 0.5, otherwise 0.0
float bounceOffset = 3.0 * isColliding; // Becomes 3.0 if colliding, 0.0 otherwise
vec3 collisionAdjustedVelocity = velocity * (1.0 + bounceOffset);
// Update position based on collision or normal movement
vec3 fpsVelocity = velocity * min(uFPSRatio, 5.0);
position += mix(fpsVelocity, collisionAdjustedVelocity, isColliding);
// EMISSION RATE - BIRTH
// if (isSpawning == 1.0) {
// Better Approach to avoid If statement
vec3 newPosition = applyQuaternionToVector(uWorldQuaternion, originalPosition) + uWorldOffset;
originalPosition = mix(originalPosition, newPosition, isSpawning);
position = mix(position, originalPosition, isSpawning);;
timeStart = mix(timeStart, uTime, isSpawning);
// Calculate timeLeft for life normalization
float timeLeft = max(lifeTime - (uTime - timeStart), 0.0);
float life_Normalize = timeLeft / lifeTime;
// Use isActive to blend between the calculated color and black
vec4 activeColor = vec4(position, life_Normalize);
// if (isActive == 1.0) {
gl_FragColor = mix(vec4(0.0), activeColor, isActive);
}
`;var iL=`
vec3 mod289(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
vec3 fade(vec3 t) {
return t*t*t*(t*(t*6.0-15.0)+10.0);
}
float snoise(vec3 v)
{
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857; // 1.0/7.0
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
vec3 snoiseVec3( vec3 x ){
float s = snoise(vec3( x ));
float s1 = snoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 ));
float s2 = snoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 ));
vec3 c = vec3( s , s1 , s2 );
return c;
}
vec3 curlNoise( vec3 p, float seed){
p += seed;
const float e = .1;
vec3 dx = vec3( e , 0.0 , 0.0 );
vec3 dy = vec3( 0.0 , e , 0.0 );
vec3 dz = vec3( 0.0 , 0.0 , e );
vec3 p_x0 = snoiseVec3( p - dx );
vec3 p_x1 = snoiseVec3( p + dx );
vec3 p_y0 = snoiseVec3( p - dy );
vec3 p_y1 = snoiseVec3( p + dy );
vec3 p_z0 = snoiseVec3( p - dz );
vec3 p_z1 = snoiseVec3( p + dz );
float x = p_y1.z - p_y0.z - p_z1.y + p_z0.y;
float y = p_z1.x - p_z0.x - p_x1.z + p_x0.z;
float z = p_x1.y - p_x0.y - p_y1.x + p_y0.x;
const float divisor = 1.0 / ( 2.0 * e );
return normalize( vec3( x , y , z ) * divisor );
}
// Classic Perlin noise
float cnoise(vec3 P)
{
vec3 Pi0 = floor(P); // Integer part for indexing
vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
Pi0 = mod289(Pi0);
Pi1 = mod289(Pi1);
vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;
vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);
vec4 gx0 = ixy0 * (1.0 / 7.0);
vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
gx0 = fract(gx0);
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
vec4 sz0 = step(gz0, vec4(0.0));
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
gy0 -= sz0 * (step(0.0, gy0) - 0.5);
vec4 gx1 = ixy1 * (1.0 / 7.0);
vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
gx1 = fract(gx1);
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
vec4 sz1 = step(gz1, vec4(0.0));
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
gy1 -= sz1 * (step(0.0, gy1) - 0.5);
vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
float n111 = dot(g111, Pf1);
vec3 fade_xyz = fade(Pf0);
vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}
vec3 fbm_vec3(vec3 p, float frequency, float offset)
{
return vec3(
cnoise((p+vec3(offset))*frequency),
cnoise((p+vec3(offset+20.0))*frequency),
cnoise((p+vec3(offset-30.0))*frequency)
);
}
`;var nL=`
#ifdef USE_COLLIDER
float restitution = max(uBounce * 2., .01); // Energy Loss
// SPHERE COLLIDER
// **************************************************************
#ifdef USE_SPHERE_COLLIDER
// Convert collider size to radii (assuming uColliderSize is the diameter in each axis)
vec3 radii = uColliderSize;
// Adjust position relative to collider
vec3 relPos = position - uColliderPos;
// Apply rotation of the collider to the relative position
relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
// Scale relative position by radii (for ellipsoid collision detection)
vec3 scaledPos = relPos / radii;
// Calculate ellipsoidal distance
float dist = length(scaledPos); // Distance in terms of ellipsoid
// Check for collision
if (dist <= 1. + particleSize / length(radii) && collisionFlag == 0.0) {
// Compute the normal at the collision point, accounting for particle size
vec3 adjustedPos = scaledPos * (1.0 + particleSize / length(radii));
// Compute the normal at the collision point
vec3 normal = ellipsoidNormal(adjustedPos, radii);
// Rotate the normal back to world space
normal = applyQuaternionToVector(uColliderQuaternion, normal);
// Reflect the velocity vector off the normal
velocity = reflect(velocity, normal) * restitution;
collisionFlag = 1.0;
} else {
collisionFlag = 0.0;
}
#endif
// BOX COLLIDER or PLANE COLLIDER
// **************************************************************
#ifdef USE_BOX_COLLIDER
// Box dimensions and repulsion variables
vec3 boxHalfSize = uColliderSize / 2.0;
// Convert world position to box's local space
vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
// Collision detection
vec3 localDistance = abs(localPos) - boxHalfSize;
float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
// Collision Detected
if (distToSurface <= particleSize * 0.5 && collisionFlag == 0.0) {
// Find the nearest face normal for bounce direction
vec3 normal;
if (localDistance.x > localDistance.y && localDistance.x > localDistance.z) {
normal = vec3(sign(localPos.x), 0.0, 0.0);
} else if (localDistance.y > localDistance.z) {
normal = vec3(0.0, sign(localPos.y), 0.0);
} else {
normal = vec3(0.0, 0.0, sign(localPos.z));
}
// Rotate normal back to world space
normal = applyQuaternionToVector(uColliderQuaternion, normal);
// Reflect velocity and apply repulsion force
velocity = reflect(velocity, normal) * restitution;
collisionFlag = 1.0;
} else {
collisionFlag = 0.0;
}
#endif
#endif
// END COLLIDER
`;var sL=`
#ifdef USE_ATTRACTOR
#ifdef USE_SPHERE_COLLIDER
// Convert collider size to radii (assuming uColliderSize is the diameter in each axis)
vec3 radii = uColliderSize;
// Adjust position relative to collider
vec3 relPos = position - uColliderPos;
// Apply rotation of the collider to the relative position
relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
// Scale relative position by radii (for ellipsoid collision detection)
vec3 scaledPos = relPos / radii;
// Calculate ellipsoidal distance
float distToSurface = length(scaledPos); // Distance in terms of ellipsoid
float insideCheck = 1.0;
#endif
#ifdef USE_BOX_COLLIDER
// Box dimensions
vec3 boxHalfSize = uColliderSize / 2.0;
// Convert world position to box's local space
vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
vec3 localDistance = abs(localPos) - boxHalfSize;
float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
float insideCheck = particleSize;
#endif
// Apply vortex force inside the Helper
#ifdef USE_FORCE_LOCAL_SPACE
if (distToSurface <= insideCheck ) {
// Define parameters for the attractor field
#ifdef USE_SPHERE_COLLIDER
float attractorStrength = (1.0 - distToSurface ) * uForceIntensity; // Adjust as needed
#endif
#ifdef USE_BOX_COLLIDER
float attractorStrength = max((1.0 - insideCheck / distToSurface), 0.) * uForceIntensity; // Adjust as needed
#endif
float attractorDamping = uForceDamping; // Adjust as needed (higher values will attenuate velocity more)
// Use the same radii calculation code as for the collider
vec3 attractorRadii = uColliderSize;
// Adjust position relative to attractor center
vec3 relPos = position - uColliderPos;
// Apply rotation of the collider to the relative position
relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
// Scale relative position by radii (for ellipsoid attraction)
vec3 scaledPos = relPos / attractorRadii;
// Calculate ellipsoidal distance as attractor radius
float attractorRadius = length(scaledPos);
// Calculate the distance from the attractor center
vec3 relativePosition = position - uColliderPos;
// Calculate the force vector towards the attractor center
vec3 attractorForce = normalize(relativePosition) * attractorStrength;
// Apply the attractor force to the particle
velocity -= attractorForce;
// Attenuate the particle's velocity
velocity *= attractorDamping;
}
#else
// Calculate the distance from the attractor center
vec3 relativePosition = position - uColliderPos;
// Calculate the force vector towards the attractor center
vec3 attractorForce = normalize(relativePosition) * uForceIntensity;
// Apply the attractor force to the particle
velocity -= attractorForce;
// Attenuate the particle's velocity
velocity *= uForceDamping;
#endif
#endif
`;var oL=`
#ifdef USE_VORTEX
// Box dimensions
vec3 boxHalfSize = uColliderSize / 2.0;
// Convert world position to box's local space
vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
vec3 localDistance = abs(localPos) - boxHalfSize;
float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
// Apply vortex force inside the box
if (distToSurface <= particleSize) {
float vortexStrength = uForceIntensity;
vec3 localTopCenter = vec3(0.0, 0., 0.0);
// Transform the local top center to the world space
vec3 vortexCenter = uColliderPos + applyQuaternionToVector(uColliderQuaternion, localTopCenter);
// Calculate the vector from particle to vortex center
vec3 vortexVector = vortexCenter - position;
// Calculate the rotation axis from the inverse of the collider's quaternion and the fixed up vector
// Note: important to add a tiny z component to the up vector to avoid instability
vec3 upVector = vec3(0.0, 1.0, 0.01);
vec3 rotationAxis = cross(upVector, applyQuaternionToVector(uColliderQuaternion, vortexVector));
rotationAxis = normalize(rotationAxis);
// Add rotational component to velocity
float rotationSpeed = length(vortexVector * vortexStrength * 3.0) ;
vec3 rotationVelocity = rotationAxis * rotationSpeed;
// velocity += rotationVelocity * 0.005 ;
velocity = rotationVelocity * 0.005 ;
// Calculate vortex force
// vec3 vortexForce = normalize(vortexVector) * uSpeed * .1 ;
// Apply the vortex force to the particle
vec3 originDirection = applyQuaternionToVector(uWorldQuaternion, directions);
velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
}
#endif
`;var aL=`
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
uniform sampler2D uOriginalPosition;
uniform sampler2D uDirections;
uniform vec3 uDirectionsAxis;
uniform vec4 uWorldQuaternion;
uniform vec3 uGravity;
uniform float uNoiseStrength; // Variation of the noise
uniform float uNoiseScale; // Scale of the noise
uniform float uNoiseSeed; // Seed of the noise
uniform float particleSize;
uniform float uSpeed; // update speed of the particles
uniform float uRandomMassFactor;
// COLLIDER
uniform vec3 uColliderPos; // Collider Position
uniform vec3 uColliderSize; // Collider Dimension
uniform vec4 uColliderQuaternion; // Collider Rotation
uniform vec4 uColliderQuaternionInvert; // Collider Rotation
uniform float uBounce; // Bounce factor
uniform float uForceDamping;
uniform float uForceIntensity;
`+iL+`
float rand(vec2 co){
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
}
vec3 applyQuaternionToVector( vec4 q, vec3 v ){
return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
}
vec3 applyForce(vec3 force, float mass) {
vec3 acceleration = force / mass;
return acceleration;
}
vec4 conjugate(vec4 q) {
return vec4(q.w, -q.x, -q.y, -q.z);
}
// Function to compute the normal of the ellipsoid at a given point
vec3 ellipsoidNormal(vec3 p, vec3 radii) {
return normalize(p / (radii * radii));
}
float friction = .3;
void main() {
vec2 vUv = gl_FragCoord.xy / resolution.xy;
vec3 position = texture2D( uCurrentPosition, vUv ).xyz;
vec3 originalPosition = texture2D( uOriginalPosition, vUv ).xyz;
float timeLeft = texture2D( uCurrentPosition, vUv ).w;
vec3 directions = texture2D( uDirections, vUv ).xyz;
vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;
float mass = rand(originalPosition.xy) * 0.5 + 0.5;
float isSpawning = texture2D( uCurrentEmissionRate, vUv ).x; // 1. = spawning, 0. = not spawning
float isActive = texture2D( uCurrentEmissionRate, vUv ).y; // 1. = active, 0. = not active
float collisionFlag =texture2D( uCurrentVelocity, vUv ).w; // Indicate collision
// Randomness Mass
mass = (1.0 - (uRandomMassFactor * mass));
if (isActive == 1.0) {
// **************************************************************
// FORCES NOISES
// **************************************************************
#ifdef USE_CURL_NOISE
if (uNoiseScale > 0.0 ) {
velocity = curlNoise(position * uNoiseScale * .002, uNoiseSeed) * ( uNoiseStrength + 1.0) * .05 * uSpeed;
}
// Variation of the noise Over Time
if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {
velocity += curlNoise( position, uNoiseSeed) * uNoiseStrength * 0.05 * uSpeed;
}
#endif
// **************************************************************
#ifdef USE_SIMPLEX_NOISE
if (uNoiseScale > 0.0 ) {
velocity = vec3(snoise(position * uNoiseScale * .001) * ( uNoiseStrength + 1.0) * .1);
velocity *= uSpeed;
}
// Variation of the noise Over Time
if (uNoiseStrength > 0.0 && uNoiseScale == 0.0) {
velocity += vec3(snoise(position * uNoiseStrength * .001) * .05 * uSpeed);
}
#endif
// **************************************************************
#ifdef USE_FBM_NOISE
if (uNoiseScale > 0.0 ) {
velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), uNoiseSeed);
velocity *= uSpeed;
}
// Variation of the noise Over Time
if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {
velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed;
}
#endif
// COLLIDER
${nL}
// ATTRACTION
${sL}
// VORTEX
${oL}
}
// End isActive
// SPAWN BIRTH
// **************************************************************
// if (isSpawning == 1.)
#ifdef USE_NORMALS
velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, directions) * uSpeed, isSpawning);
#else
velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, uDirectionsAxis) * uSpeed, isSpawning);
#endif
// if (collisionFlag == 0.0)
velocity += applyForce(uGravity, mass * .5) * (1.0 - collisionFlag);
gl_FragColor = vec4(velocity, collisionFlag);
}
`;var NE=`
// Linear Fade In
float linearFadeIn(float t) {
return t;
}
// linear fade out
float linearFadeOut(float t) {
return 1.0 - t;
}
float linearInOut(float t) {
return t < 0.5 ? t : (1.0 - t);
}
// lerp
float lerp(float a, float b, float t) {
return a + (b - a) * t;
}
// Ease In Out Quart
float exponentialInOut(float t) {
return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) :
t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) :
1.0;
}
// constant
float constant(float t) {
return 1.0;
}
`;var lL=`
float rand(vec3 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
vec3 applyQuaternionToVector( vec4 q, vec3 v ){
return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
}
vec3 applyForce(vec3 force, float mass) {
vec3 acceleration = force / mass;
return acceleration;
}
`;var cL=`
vec3 rgb2xyz (in vec3 rgb) {
float r = rgb.r;
float g = rgb.g;
float b = rgb.b;
r = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
g = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
b = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
float x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
float y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
float z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
vec3 xyz = vec3(
(r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0,
(r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0,
(r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0
);
return(xyz);
}
vec3 xyz2lab (in vec3 xyz) {
float x = xyz.x / 95.047;
float y = xyz.y / 100.0;
float z = xyz.z / 108.883;
x = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0);
y = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0);
z = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0);
vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z));
return(lab);
}
vec3 rgb2lab(in vec3 rgb) {
vec3 xyz = rgb2xyz(rgb);
vec3 lab = xyz2lab(xyz);
return(lab);
}
vec3 xyz2rgb (in vec3 xyz) {
float x = xyz.x / 100.0;
float y = xyz.y / 100.0;
float z = xyz.z / 100.0;
float r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
float g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
float b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
r = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92;
g = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92;
b = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92;
r = min(max(0.0, r), 1.0);
g = min(max(0.0, g), 1.0);
b = min(max(0.0, b), 1.0);
return(vec3(r, g, b));
}
vec3 lab2xyz (in vec3 lab) {
float l = lab.x;
float a = lab.y;
float b = lab.z;
float y = (l + 16.0) / 116.0;
float x = a / 500.0 + y;
float z = y - b / 200.0;
float y2 = pow(y, 3.0);
float x2 = pow(x, 3.0);
float z2 = pow(z, 3.0);
y = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787;
x = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787;
z = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787;
x *= 95.047;
y *= 100.0;
z *= 108.883;
return(vec3(x, y, z));
}
vec3 lab2rgb (in vec3 lab) {
vec3 xyz = lab2xyz(lab);
vec3 rgb = xyz2rgb(xyz);
return(rgb);
}
`;var uL=`
uniform sampler2D uPosition;
uniform float uSize;
uniform float uSizeEnd;
uniform vec3 uWorldOffset;
uniform vec4 uWorldQuaternion;
// Billboard Behavior - Currently at Zero, but we can change that
uniform float uRotation;
uniform float uRotationEnd;
uniform vec2 center;
// Randomness
uniform float uRandScaleFactor;
uniform float uRandRotationFactor;
attribute vec2 ref;
varying float v_LifeLeft; // normalized lifetime 1 to 0
varying vec2 vUv;
varying vec2 vRef;
${lL}
${NE}
`,hL=({easeSize:n="linearFadeOut"})=>`
vUv = uv;
vRef = ref;
// Normalized LifeTime 1 to 0
float lifeLeft = texture2D(uPosition, ref).w;
v_LifeLeft = lifeLeft;
// Position From DataTexture Simulation
vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset;
// Apply World Quaternion
pos = applyQuaternionToVector(uWorldQuaternion, pos);
#ifdef USE_SIZE_END
// Scaled Over Time
float t = 1. - lifeLeft;
float currentSize = mix(uSize, uSizeEnd, t); // Linearly interpolate between uSize and uSizeEnd
vec3 scaledPosition = position * vec3(currentSize);
#else
// Change Size Behavior over LifeTime
float easeSize = ${n}(1. - lifeLeft);
// Scaled Over Time
vec3 scaledPosition = position * vec3(uSize * easeSize);
#endif
// Billboard Behavior
vec2 scale;
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
// Randomness
float randRef = rand(ref);
scale *= (1.0 - (uRandScaleFactor * randRef));
// Rotation
float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef);
float originalRotation = (1.0 - uRotation) * 2.0 * PI;
float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI;
// OverTime
float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft);
vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y;
rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y;
mat4 instanceMatrix = mat4(
vec4(1.0, 0.0, 0.0, 0.0),
vec4(0.0, 1.0, 0.0, 0.0),
vec4(0.0, 0.0, 1.0, 0.0),
vec4(pos.x, pos.y, pos.z, 1.0)
);
mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
`,dL=`
uniform vec4 uColor; // start color
uniform vec4 uColor2; // end color
uniform sampler2D uTexture; // texture
varying float v_LifeLeft; // normalized lifetime 1 to 0
varying vec2 vUv;
varying vec2 vRef;
float random(vec2 co) {
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
`+NE+`
${cL}
`,fL=({easeOpacity:n="linearFadeOut"})=>`
// if Particle is dead, hide it
if (v_LifeLeft <= 0.005 ) {
discard;
}
#ifdef USE_RANDOM_COLORING
float randVal = random(vRef); // Generate a random value based on the reference
vec4 color = mix(uColor, uColor2, randVal); // Interpolate between the two colors
#else
vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft);
#endif
// Opacity over Life Time
float finalAlpha = ${n}(1. - v_LifeLeft);
vec4 textureColor = texture2D(uTexture, vUv).rgba;
finalColor = textureColor.rgb * color.rgb;
finalAlpha = color.a * textureColor.a * finalAlpha;
gl_FragColor = vec4(finalColor, finalAlpha);
`;var Lx=class extends st{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],nr.startContext(nr.globalContext),this.lightLayer=new xn(0,"",{...zr.defaultData("light","phong"),visible:!1},new Ca,{},r.shared),nr.endContext(nr.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Id;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(NI),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(FI),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(uL),e.addFragmentParsCode(dL),e.addVertexFinalCode(hL({easeSize:this.easeSize})),e.addFragmentFinalCode(fL({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var Af=class{constructor(t,e,r,i){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=J3(e);let s=1;this.targetMesh=i?.type==="Mesh"&&i?i:this.getMesh(r,s);let{positions:o,dataTexture:a,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,s));this.positionsTexture=a,this.positionsAttribute=o,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:i}=$3(e,t*t),s=BE(r,t),o=BE(i,t);return{dataTexture:s,positions:r,dataTextureNormals:o}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new Ls(e*.5,32,32);break}case"TorusEmitterShape":{r=new Fu(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new $a(e,e,15);break}case"BoxEmitterShape":{r=new hi(e,e,e);break}case"PlaneEmitterShape":{r=new hn(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new Ls(e,32,32);break}default:{r=new Ls(e,32,32);break}}return new Xt(r,new Hn({color:16711680}))}applyToShader(t,e){this.size=new E().fromArray(e.size),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Yl(n){let t={...n},e=Lh.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},i={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:i}}var pL=`
// uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
// uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
uniform sampler2D uIndex; // Texture with corresponding index
uniform float uLastIndexEmitted; // Last emitted index
uniform float uParticlesToEmit; // Number of particles to emit on that frame
uniform float uTime;
void main() {
vec2 vUv = gl_FragCoord.xy / resolution.xy;
float particleIndex = texture(uIndex, vUv).x;
float timeLeft = texture2D( uCurrentPosition, vUv ).w;
float isActive = texture2D( uCurrentEmissionRate, vUv ).g; // 1. = active, 0. = not active
float timeStart = texture2D( uCurrentEmissionRate, vUv ).b;
// ********** Detect Colision to Create a flag and use it in position **********
// We are doing this here, so
// ********** Emit Particles **********
// X = isSpawning 0.0 or 1.0
// Y = isActive 0.0 or 1.0
// Check if the vertex index is between the first value and the last value
// if (particleIndex >= uLastIndexEmitted && particleIndex < uLastIndexEmitted + uParticlesToEmit) {
// // Emit a particle by writing 1 to the red channel of the color output
// // r: 1. == emit the particle
// // g: 1. == particle is now active
// timeStart = uTime;
// gl_FragColor = vec4(1.0, 1.0, timeStart, 1.0);
// } else {
// // The Particle is either already emitted or not in the range of the particles to emit
// // Do not emit a particle by writing 0 to the red channel of the color output
// gl_FragColor = vec4(0.0, isActive, timeStart, 1.0);
// }
// Determine if the particle is within the emission range
float emitLowerBound = step(uLastIndexEmitted, particleIndex);
float emitUpperBound = step(particleIndex, uLastIndexEmitted + uParticlesToEmit - 1.0);
float emitParticle = emitLowerBound * emitUpperBound; // 1.0 if in range, 0.0 otherwise
// Set timeStart and color
timeStart = mix(timeStart, uTime, emitParticle);
gl_FragColor = vec4(emitParticle, mix(isActive, 1.0, emitParticle), timeStart, 1.0);
}
`;var FE=10,Bx=class extends Et{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new cy;this.currentWorldPosition=new E;this.systemQuaternion=new Qe;this.worldGravity=new E(0,0,0);this.directionAxis=new E(0,0,0);this.colliderV3=new E(0,0,0);this.colliderQuaternion=new Qe(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let i=r.data;this.material=new Lx(i.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:i.renderMaterial.color},uColor2:{value:i.renderMaterial.color2},uPosition:{value:new E(0,0,0)},uEmissionData:{value:new E(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new E(0,0,0)},uWorldQuaternion:{value:new Ke(0,0,0,1)},uRandScaleFactor:{value:i.randomScale??0},uRandRotationFactor:{value:i.randomRotation??0},uRotation:{value:i.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:i.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,i.renderMaterial.texture),this.init(i)}setTexture(e,r){let i=r.data;if(typeof r=="string"){let s=this.shared.image(r),o=new Jt(s.img);o.needsUpdate=!0,e.uTexture.value=o;return}if(typeof i!="string"){let s=new Image;s.onload=()=>{let l=new Jt(s);l.needsUpdate=!0,e.uTexture.value=l};let o=new Blob([i],{type:"image/*"}),a=URL.createObjectURL(o);s.src=a}}updateGeometryAttributes(e,r){let i=Z3(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new ho(i,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let i=1e3/r,s=this.targetFPS/i,o=this.previousRatio+(s-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=o,this.previousRatio=o;let a=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=a,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],r=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&r&&this.init(Yl({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=e.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let i=(s,o)=>{let a=[...this.system.data.shape.size];a[s]=o,this.updateParticleState({shape:{...this.system.data.shape,size:a}})};r[2]==="shape_size_0"&&i(0,e),r[2]==="shape_size_1"&&i(1,e),r[2]==="shape_size_2"&&i(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/FE),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Yl(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/FE),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,i=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],s={...Yl(this.system.data).shape,size:i};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,s)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*we.DEG2RAD,Number(e[1])*we.DEG2RAD,Number(e[2])*we.DEG2RAD],i=new rr(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:i,colliderEntityId:s,shape:o,emitTimeDuration:a,emitTimeCycle:l,life:c,directionMode:u,noiseType:h}=e;return r!==void 0||i!==void 0||(s||s===null)||l!==void 0||o!==void 0||c!==void 0||a!==void 0||u!==void 0||h!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let i=new Ox(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),s=this.updateSimulationDefinition(e),o=i.addVariable("uCurrentPosition",s+rL,this.emitterShape.positionsTexture),a=i.addVariable("uCurrentVelocity",s+aL,this.emitterShape.directionsTexture),l=i.addVariable("uCurrentEmissionRate",pL,tL(this.emitterShape.textureSize));i.setVariableDependencies(o,[o,a,l]),i.setVariableDependencies(a,[o,a,l]),i.setVariableDependencies(l,[o,a,l]);let c=eL({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new E(0,0,0)},uWorldQuaternion:{value:new Ke(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new E(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};o.material.uniforms=u;let h=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(h),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let d=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ke(0,0,0,1)},uColliderPos:{value:new E(0,0,0)},uColliderSize:{value:new E(0,0,0)},uForceIntensity:{value:d?d.forceIntensity:0},uForceDamping:{value:d?d.forceDambing:0},uColliderQuaternion:{value:new Ke(0,0,0,1)},uColliderQuaternionInvert:{value:new Ke(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/FE}};a.material.uniforms=f;let p={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=p;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],g={...Yl(this.system.data).shape,size:m};this.emitterShape.applyToShader(o.material.uniforms,g),i.init(),this.gpuCompute=i,this.positionSimRT=o,this.velocitySimRT=a,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),i=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),s=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,i,s]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let i=this.system.getColliderData(e.colliderEntityId);switch(i?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let s=i?.colliderType;s==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),s==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),i?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[i,s]of Object.entries(this.simFeaturesDefinition))s&&(r+=`#define ${i}
`);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let i=new E(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let s=null;return this.system.context.scene.traverseEntity(o=>{o.uuid===e.fromMeshId&&(s=o)}),s?new Af(i,r,e.type,s):new Af(i,r,"SphereEmitterShape")}else return new Af(i,r,e.type)}createPrimaryEmitter(e){let r,i=e*e;return r=new iy(new hn(1,1,1),this.material,i),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:i=0}){return Math.ceil(e*(r+i))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let i=e-this.lastEmitTime,s=1/r;if(i>=s){let o=Math.max(1,Math.floor(i/s));return this.lastEmitTime=e,this.emittedParticlesAmount+o>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=o,o}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Yl(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var Xl=class extends dr{constructor(e,r,i){super(e,r);this.type="ParticleSystem";this.geometry=new _e;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=i,this.data={...r,...Yl(r)},this.geometry.setAttribute("position",new Te([],3)),this.material=new Hn({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Bx(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let s=this.actualTime/1e3;this.emitter.update(s,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(i=>i.identity===e);return r?r.data:null}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Lt(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...Ir.drop(e,1).props}}),Lt(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...Ir.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function jQ(){try{let n=window.location.href;if(n.includes("reducesubdiv=")){let t=n.indexOf("reducesubdiv=")+13;return parseInt(n.slice(t,t+1))}}catch{}}var VE=jQ();function HQ(n,t,e){VE!==void 0&&(t?.geometry?.subdivisions??0)>VE&&(console.log("reducing subdivisions",t.name,t.geometry.subdivisions),t.geometry.subdivisions=VE);let r;return t.geometry.type==="TextGeometry"?new Jd(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new Qs(n,t,e):t.geometry.type==="PathGeometry"?r=new ql(n,t,e):t.geometry.type==="VectorGeometry"?r=new Px(n,t,e):t.geometry.type==="BooleanGeometry"?r=new Ln(n,t,e):t.geometry.type==="UIGeometry"?r=new Sr(n,t,e):r=new ar(n,t,e),r)}function Nx(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?HQ(n,t,e):t.type==="Empty"?new ws(n,t):t.type==="Particle"?new Xl(n,t,e):t.type==="ParticleCollider"?new zl(n,t,e):t.type==="Splat"?new ws(n,t):t.type==="Bone"?new Dx(n,t):t.type==="Page"?new lr(n,t,e):t.type==="PointLight"?new Cx(n,t,e):t.type==="SpotLight"?new bf(n,t,e):t.type==="DirectionalLight"?new xf(n,t,e):t.type==="Component"||t.type==="Instance"?new Js(n,t,e):Vs.is(t.type)?new xr(n,t):(console.error(t),new ws(n,t))}Gs.createEntity=Nx;function WQ(n,t,e){let r=Nx(n.identity,t,e),i=n.children,s=n.attachedPaths,o=n.parent,a=n.component,l=n.instances,c=n.overrideData,u=n.uuid,h=n.stateSelection;n.dispose();for(let d of Object.keys(n))delete n[d];Object.setPrototypeOf(n,Object.getPrototypeOf(r));for(let d of Object.keys(r))n[d]=r[d];n.children=[...n.children,...i],n.attachedPaths=s,n.parent=o,n.component=a,n.instances=l,n.uuid=u,n.overrideData=c,n.updateState(n.data,e),h&&n.changeSelectedState(h,e),n.resetBBoxNeedsUpdate()}Gs.changeEntityProptotype=WQ;Gs.Cloner=Ui;function gL(n,t,e,r){n.updateByOp(t,e,r,!1)}function yL(n,t){let e=!1,r=t.getLayersOfType("transmission"),i=t.getLayersOfType("outline");return i.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,Kd(n),Qd(n)),r.length===0&&i.length===0&&n.layers.set(0),n instanceof ys&&n.needsAO&&n.layers.enable(5),e}function vL(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(s=>s.data.visible),i=t.getLayersOfType("outline").filter(s=>s.data.visible);return r.length>0&&(n.layers.set(3),i.length>0&&n.layers.enable(8),e=!0),r.length===0&&i.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function xL(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof ys)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)yL(e,e.material[r])&&(t=!0);else yL(e,e.material)&&(t=!0)}),t}function bL(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof ys)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)vL(e,e.material[r])&&(t=!0);else vL(e,e.material)&&(t=!0)}),t}var qQ=new Wu,YQ=new ce,XQ=new Rs;function Lm(n,t,e,r=!1){let i=n.cloner;if(i)for(let s of i.children){let o=YQ.copy(s.matrixWorld).invert(),a=XQ.copy(t.ray).applyMatrix4(o),l=n.matrixWorld;a.applyMatrix4(l);let c=qQ;c.set(a.origin,a.direction),c.near=t.near,c.far=t.far;let u=c.intersectObject(n,!1);u.length>0&&e.push({...u[0],object:r?s:n})}}var Fx=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,i)=>{let s=[i,r],o=r;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var SL="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var zo=class{};tc(zo,"DepthMapRange",1<<16),tc(zo,"MemoryPageSize",65536),tc(zo,"BytesPerFloat",4),tc(zo,"BytesPerInt",4);function QQ(n){let t,e,r,i,s,o,a,l,c,u,h,d,f,p,m,g;function y(P){let D=new Float64Array(u,o,16);for(let O=0;O<16;O++)D[O]=P[O];let _;if(r>1){t.exports.sortIndexes(i,s,c,o,a,l,d.DepthMapRange,r);let O=new Uint32Array(r);_=O.buffer,O.set(new Uint32Array(u,l,r))}else if(r===1){let O=new Uint32Array(r);O[0]=new Uint32Array(u,i,e)[0],_=O.buffer}else _=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:_},[_])}function v(P,D,_){let O=new Float32Array(u,s,e*3);r=0;let L=new Uint32Array(u,i,e);for(let j=0;j<_.length-1;j++){let V=D[j],H=P[j].elements,W=V.filter(K=>K.enabled&&K.mode==="Include").map(K=>K.type==="Box"?A(K):T(K)),q=V.filter(K=>K.enabled&&K.mode==="Exclude").map(K=>K.type==="Box"?A(K):T(K));for(let K=_[j];K<_[j+1];K++){let G=f[K*3],Z=f[K*3+1],te=f[K*3+2];if((W.length===0||S(G,Z,te,W))&&(q.length===0||!S(G,Z,te,q))){let $=1/(H[3]*G+H[7]*Z+H[11]*te+H[15]);O[r*3]=(H[0]*G+H[4]*Z+H[8]*te+H[12])*$,O[r*3+1]=(H[1]*G+H[5]*Z+H[9]*te+H[13])*$,O[r*3+2]=(H[2]*G+H[6]*Z+H[10]*te+H[14])*$,L[r]=K,r++}}}}function x(P,D){let _=[],O=D.filter(V=>V.enabled&&V.mode==="Include").map(V=>V.type==="Box"?A(V):T(V)),L=D.filter(V=>V.enabled&&V.mode==="Exclude").map(V=>V.type==="Box"?A(V):T(V)),j=P.length;for(let V=0;V<j;V+=3){let H=P[V],W=P[V+1],q=P[V+2];(O.length===0||S(H,W,q,O))&&(L.length===0||!S(H,W,q,L))||_.push(V/3)}return _}function S(P,D,_,O,L){return O[L==="Intersect"?"every":"some"](j=>{let V=w(P,D,_,j.invRotationMatrix,j.cropCenter);return Array.isArray(j)?b(V.x,V.y,V.z,j):C(V.x,V.y,V.z,j)})}function w(P,D,_,O,L){let j=P-L[0],V=D-L[1],H=_-L[2],W=1/(O[3]*j+O[7]*V+O[11]*H+O[15]);return{x:(O[0]*j+O[4]*V+O[8]*H+O[12])*W+L[0],y:(O[1]*j+O[5]*V+O[9]*H+O[13])*W+L[1],z:(O[2]*j+O[6]*V+O[10]*H+O[14])*W+L[2]}}function A(P){let D=P.cropSize[0]/2,_=P.cropSize[1]/2,O=P.cropSize[2]/2,L=[P.cropCenter[0]-D,P.cropCenter[1]-_,P.cropCenter[2]-O,P.cropCenter[0]+D,P.cropCenter[1]+_,P.cropCenter[2]+O],j=M(P.cropRotation);return Object.assign(L,{invRotationMatrix:j,cropCenter:P.cropCenter})}function M(P){let D=[],_=P[0]*Math.PI/180,O=P[1]*Math.PI/180,L=P[2]*Math.PI/180,j=Math.cos(_),V=Math.sin(_),H=Math.cos(O),W=Math.sin(O),q=Math.cos(L),K=Math.sin(L),G=j*q,Z=j*K,te=V*q,$=V*K;return D[0]=H*q,D[1]=-H*K,D[2]=W,D[4]=Z+te*W,D[5]=G-$*W,D[6]=-V*H,D[8]=$-G*W,D[9]=te+Z*W,D[10]=j*H,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function b(P,D,_,O){return P>=O[0]&&P<=O[3]&&D>=O[1]&&D<=O[4]&&_>=O[2]&&_<=O[5]}function T(P){let D=2/P.cropSize[0],_=2/P.cropSize[1],O=2/P.cropSize[2],L=M(P.cropRotation);return{invRadiusX:D,invRadiusY:_,invRadiusZ:O,cropCenter:P.cropCenter,invRotationMatrix:L}}function C(P,D,_,O){let L=(P-O.cropCenter[0])*O.invRadiusX,j=(D-O.cropCenter[1])*O.invRadiusY,V=(_-O.cropCenter[2])*O.invRadiusZ;return L*L+j*j+V*V<=1}n.onmessage=P=>{if(P.data.getCroppedIndexes){let D=new Uint32Array(x(new Float32Array(P.data.positions),P.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:D},[D])}else if(P.data.positions)h=P.data.positions,f=new Float32Array(h),m=P.data.meshMatrixWorlds,g=P.data.cropsArray,p=P.data.meshIndexIntervals,v(m,g,p),n.postMessage({sortSetupComplete:!0});else if(P.data.sort||P.data.newMatrixWorlds||P.data.newCropsArray)(P.data.newMatrixWorlds||P.data.newCropsArray)&&(g=P.data.newCropsArray||g,m=P.data.newMatrixWorlds||m,v(m,g,p)),y(P.data.sort.view,P.data.sort.cameraPosition);else if(P.data.init){d=P.data.init.Constants,e=P.data.init.splatCount;let D=d.BytesPerInt,_=d.BytesPerFloat*3,O=new Uint8Array(P.data.init.sorterWasmBytes),L=D+_,j=e*L,V=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,H=d.MemoryPageSize*32,W=j+V+H,q=Math.floor(W/d.MemoryPageSize)+1,K={module:{},env:{memory:new WebAssembly.Memory({initial:q*2,maximum:q*3,shared:!0})}};WebAssembly.compile(O).then(G=>WebAssembly.instantiate(G,K)).then(G=>{t=G,i=0,s=e*D,o=s+e*_,c=o+16*d.BytesPerFloat*2,a=c+e*d.BytesPerInt,l=a+d.DepthMapRange*d.BytesPerInt,u=K.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function wL(n){let t=new Worker(URL.createObjectURL(new Blob(["(",QQ.toString(),")(self)"],{type:"application/javascript"}))),e=atob(SL),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:zo.BytesPerFloat,BytesPerInt:zo.BytesPerInt,DepthMapRange:zo.DepthMapRange,MemoryPageSize:zo.MemoryPageSize}}}),t}var Vx=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),AL=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var zx=new U;function Ux(n){let t=!1;return n.scene.objects.traverse((e,r)=>{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var Ql=class extends Xt{constructor(e,r,i,s,o=!1,a=1,l,c){super(i,s);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=i,this.material=s,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=o,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,i=!1,s=1,o,a){let l=Ql.buildGeomtery(r),c=Ql.buildMaterial(o);return new Ql(e,r,l,c,i,s,o,a)}static buildMaterial(e){let r=`
precision highp float;
#include <common>
attribute uint splatIndex;
uniform highp sampler2D covariancesTexture;
uniform highp usampler2D centersColorsTexture;
uniform vec2 focal;
uniform vec2 viewport;
uniform vec2 basisViewport;
uniform vec2 covariancesTextureSize;
uniform vec2 centersColorsTextureSize;
uniform highp sampler2D meshMatrixWorldsTexture;
uniform uint meshIndexIntervals[257];
uniform float orthoZoom;
varying vec4 vColor;
varying vec2 vUv;
varying vec2 vPosition;
const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000));
const uvec4 shift4 = uvec4(0, 8, 16, 24);
vec4 uintToRGBAVec (uint u) {
uvec4 urgba = mask4 & u;
urgba = urgba >> shift4;
vec4 rgba = vec4(urgba) * encodeNorm4;
return rgba;
}
vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) {
vec2 samplerUV = vec2(0.0, 0.0);
float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x;
samplerUV.y = float(floor(d)) / dimensions.y;
samplerUV.x = fract(d);
return samplerUV;
}
void main () {
uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize));
vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba));
vColor = uintToRGBAVec(sampledCenterColor.r);
vPosition = position.xy * 2.0;
uint meshIndex;
for (int i = 1; i < 257; i++) {
if (splatIndex < meshIndexIntervals[i]) {
meshIndex = uint(i - 1);
break;
}
}
float strideMulmeshIndex = float(4u*meshIndex);
float meshMatrixWorldsTextureLength = float(256*4);
mat4 modelMat = mat4(
texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)),
texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)),
texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)),
texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0))
);
mat4 modelViewMat = viewMatrix * modelMat;
vec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0);
vec4 clipCenter = projectionMatrix * viewCenter;
vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg;
vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg;
vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg;
vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r);
vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg);
// Compute the 2D covariance matrix from the upper-right portion of the 3D covariance matrix
mat3 Vrk = mat3(
cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z,
cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y,
cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z
);
float s = 1.0 / (viewCenter.z * viewCenter.z);
mat3 W = transpose(mat3(modelViewMat));
mat3 T = orthoZoom > 0.0 ? W : W * mat3(
focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s,
0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s,
0., 0., 0.
);
mat3 cov2Dm = transpose(T) * Vrk * T;
cov2Dm[0][0] += 0.3;
cov2Dm[1][1] += 0.3;
// We are interested in the upper-left 2x2 portion of the projected 3D covariance matrix because
// we only care about the X and Y values. We want the X-diagonal, cov2Dm[0][0],
// the Y-diagonal, cov2Dm[1][1], and the correlation between the two cov2Dm[0][1]. We don't
// need cov2Dm[1][0] because it is a symetric matrix.
vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]);
vec3 ndcCenter = clipCenter.xyz / clipCenter.w;
// We now need to solve for the eigen-values and eigen vectors of the 2D covariance matrix
// so that we can determine the 2D basis for the splat. This is done using the method described
// here: https://people.math.harvard.edu/~knill/teaching/math21b2004/exhibits/2dmatrices/index.html
//
// This is a different approach than in the original work at INRIA. In that work they compute the
// max extents of the 2D covariance matrix in screen space to form an axis aligned bounding rectangle
// which forms the geometry that is actually rasterized. They then use the inverse 2D covariance
// matrix (called 'conic') to determine fragment opacity.
float a = cov2Dv.x;
float d = cov2Dv.z;
float b = cov2Dv.y;
float D = a * d - b * b;
float trace = a + d;
float traceOver2 = 0.5 * trace;
float term2 = sqrt(trace * trace / 4.0 - D);
float eigenValue1 = traceOver2 + term2;
float eigenValue2 = max(traceOver2 - term2, 0.00); // prevent negative eigen value
const float maxSplatSize = 1024.0;
vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a));
// since the eigen vectors are orthogonal, we derive the second one from the first
vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);
vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize);
vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize);
vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport;
if (orthoZoom > 0.0) {
ndcOffset *= orthoZoom;
}
gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0);
}`,i=`
precision highp float;
#include <common>
uniform vec3 debugColor;
varying vec4 vColor;
varying vec2 vUv;
varying vec2 vPosition;
layout(location = 1) out vec4 gVelocity;
void main () {
// compute the negative squared distance from the center of the splat to the
// current fragment in the splat's local space.
float A = -dot(vPosition, vPosition);
if (A < -4.0) discard;
vec3 color = vColor.rgb;
A = exp(A) * vColor.a;
gl_FragColor = vec4(color.rgb, A);
gVelocity = vec4(0.0); // so it is ignored by TAA
}`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new U},viewport:{type:"v2",value:new U},basisViewport:{type:"v2",value:new U},debugColor:{type:"v3",value:new We},covariancesTextureSize:{type:"v2",value:new U(1024,1024)},centersColorsTextureSize:{type:"v2",value:new U(1024,1024)},orthoZoom:{type:"f",value:-1}};return new st({uniforms:s,vertexShader:r,fragmentShader:i,transparent:!0,alphaTest:1,blending:Wa,depthTest:!0,depthWrite:!1,side:ji})}static buildGeomtery(e){let r=new _e;r.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),s=new Xe(i,3);r.setAttribute("position",s),s.setXYZ(0,-1,-1,0),s.setXYZ(1,-1,1,0),s.setXYZ(2,1,1,0),s.setXYZ(3,1,-1,0),s.needsUpdate=!0;let o=new yp().copy(r),a=new Uint32Array(e),l=new ho(a,1,!1);return l.setUsage(PC),o.setAttribute("splatIndex",l),o.instanceCount=e,o}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(s=>s.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,i=0;for(let s of this.splatBuffers){let o=s.nsplats;this.colors.subarray(e,e+o*4).set(s.colorsA),e+=o*4,this.centers.subarray(r,r+o*3).set(s.decoded.xyz.denormDequant().data),r+=o*3,this.covariances.subarray(i,i+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),i+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let i=this.splatCount,s=new U(4096,1024);for(;s.x*s.y*2<i*6;)s.y*=2;let o=new U(4096,1024);for(;o.x*o.y*4<i*4;)o.y*=2;let a,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(s.x*s.y*2);for(let p=0;p<this.covariances.length;p++)l[p]=jC.toHalfFloat(this.covariances[p]);a=new di(l,s.x,s.y,Xu,jn)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new di(l,s.x,s.y,Xu,yr);a.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=a,this.material.uniforms.covariancesTextureSize.value.copy(s);let c=new Uint32Array(o.x*o.y*4);for(let p=0;p<i;p++){let m=p*4,g=p*3,y=p*4;c[y]=AL(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[y+1]=Vx(this.centers[g]),c[y+2]=Vx(this.centers[g+1]),c[y+3]=Vx(this.centers[g+2])}let u=new di(c,o.x,o.y,nw,Ds);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(o);let h=256*4,d=new Float32Array(256*16);for(let p=0;p<this.meshMatrixWorlds.length;p++)d.set(this.meshMatrixWorlds[p].elements,p*16);let f=new di(d,h,1,jr,yr);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:a,size:s},centerColors:{data:c,texture:u,size:o},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,i,s){this.splatCount>0&&(zx.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(zx),this.material.uniforms.basisViewport.value.set(2/zx.x,2/zx.y),this.material.uniforms.focal.value.set(r,i),this.material.uniforms.orthoZoom.value=s,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var ML,zE=new Promise(n=>{ML=n}),EL=!1;var kx;function UE(){if(EL)return;if(kx)return kx;async function n(){let e=await import("./gaussian-splat-compression.js");ML(e),EL=!0}return kx=n(),kx}var TL;zE.then(n=>TL=n);var Bm=class{constructor(t={}){tc(this,"updateView",function(){let t=new ce,e=[],r=new E(0,0,-1),i=new E(0,0,-1),s=new E,o=new E;return function(a=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!a){i.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(i.dot(r)<=.95&&(d=!0),o.copy(l.position).sub(s).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,s.copy(l.position),r.copy(i),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let h={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=h:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(h))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new ce().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new U;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new E().fromArray(t.position)),t.orientation&&(t.orientation=new Qe().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(o=>{o.data.type==="Splat"&&e.push(o)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(o=>o.matrixWorld),this.meshMatrixWorldsOld=e.map(o=>o.matrixWorld.clone()),this.cropsArray=e.map(o=>o.data.crops.map(a=>a.data));let r=e.map(o=>new TL.GSplineBuffer(new Uint8Array(o.data.buffer).buffer)),i=0,s=[0];for(let o of r)i+=o.getSplatCount(),s.push(i);return this.setupSplatMesh(r,i,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(i),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((i,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=i.data):Object.entries(i.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,c)=>l!==this.cropsArray[r][s][o][c])?(t=!0,this.cropsArray[r][s][o]=a):a!==this.cropsArray[r][s]?.[o]&&(t=!0,this.cropsArray[r][s][o]=a)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new E,i=new Qe,s=!1,o=1,a,l){this.splatMesh=Ql.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(i),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,h)=>this.update(c,h)}setupSortWorker(t){this.sortWorker=wL(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var vx=new Hn;vx.wireframe=!0;var CL=new E,Gl=class extends bi{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Fx;this.invisibleObjects=new ws("jflkdsafjasdifjaslk",{...zv.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new lr("fdasfa",{...pa.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=bL(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=xL(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),i=this.entityIdentityToEntity[r];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof lr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let i=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:r,sortKey:i}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push(s)}return r.sort((i,s)=>Jy(i.sortKey,s.sortKey)),r.map(i=>i.entity)}nonExistOrDescendantOf(e,r){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===r)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===hs)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof lr&&r.uiScene){let i=r.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof lr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(i=>{r===void 0&&i instanceof Sr&&(r=i.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof lr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,i,e.localIndex,r);s.updateVisible(this),s.resetBBoxNeedsUpdate(),sn(s)&&Sn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Sn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(i)&&(i.freeBooleanPointer(),s instanceof Ln&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof ql&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),sn(i)&&(i.invalidateUpstreamBooleanData(),Sn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Ln&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof lr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,i,s){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:a}=r.props;r={...r,props:a},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let o=this.find(e);if(o)try{gL(o,r,i,{scene:this,shared:s}),o instanceof ar&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,r,i,s,o,a=[]){e.updateEntityByOp(r,i,s,o),this.traverseEntity(l=>{(l instanceof Sr||l instanceof lr)&&(a.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,i,s,o)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let i=Object.entries(r.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{s instanceof xr&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){yt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{yt.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,i,s,o,a,l){if(e){let c=s.find(e);c&&c!==s&&o.forInstancesRec(u=>{u.data=fl(u.data,h=>{let d=h.events.data(l.id),f=u.goUp(a);if(f){let p=[...Zy(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Or.zoom(d,r);y[i]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,i,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",i,s,o,a):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",i,s,o,a):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],i,s,o,a),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],i,s,o,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Js&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,i)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=fl(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Hh.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,i,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,i,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,i,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,i,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,i,s)})}),!0})}expandInstances(e,r,i){let s=new Set;this.traverseEntity(o=>{if(o instanceof Js&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),i&&o.traverseEntity(a=>{i.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),_x(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Js&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let i=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[i]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[i]),r.dispose()})}clearScene(){for(let e of this.children)yt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let i=[],s=o=>{for(let a of o.children){let l=a.cloner;if(yt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let c=[];if(e.intersectObject(a,!0,c),c.length){let u=c[0];u.object=a,u.point.applyMatrix4(u.object.matrixWorld);let h=a.matrixWorld.clone().invert();u.point.applyMatrix4(h),i.push(u)}}else(sn(a)||Mm(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),Lm(a,e,i)),s(a)}};return s(this.activePage),i}raycastWithClones(e){let r=[],i=s=>{for(let o of s.children){let a=o.cloner;yt.is(o)&&(o.visible||a?.object.data.visible)&&((sn(o)||Mm(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Lm(o,e,r,!0)),i(o))}};return i(this),r}forEachEntity(e){for(let r of this.children)yt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)yt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)yt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(i=>{if(i instanceof ar&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let s=i.geometry,o=i.data.geometry;s.updateFont(e,r).then(()=>{s.update(o);let a=i.invalidateDownstreamBooleanData();Sn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)ld.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)yt.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,i){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,i),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,i,s,o,a){let l={scene:this,shared:a},c=Nx(e,r,l);return c&&(this.entityByUuid[e]=c,s.add(c),s.children.splice(o,0,s.children.pop()),i.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,c,a)),c.updateState(r,l),c instanceof ar&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let h=u.dataPatched;if(u instanceof ar&&h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new ce().fromArray(m)),p=new Za(d,f);u.bind(p,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],c=this.find(a),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let i=new Gt;return i.setFromPoints(r),i.getCenter(CL),CL}copyMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e)?.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof dr)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)r.material[i]instanceof Rn&&e(r.material[i]);else r.material instanceof Rn&&e(r.material)})}updateViewPlaneSize(e,r,i=!1){this.traverseConcreteEntity(s=>{s instanceof xr&&s.setViewplaneSize(e,r,i)})}initializeSplatViewer(){this.splatViewer=new Bm({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Nm=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},PL=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return KQ(Math.atan2(r,e))},_L=(n,t,e)=>{let r={x:0,y:0};return e=Gx(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Gx=n=>n*(Math.PI/180),KQ=n=>n*(180/Math.PI),DL=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,kE=new Map,GE=n=>{kE.has(n)&&clearTimeout(kE.get(n)),kE.set(n,setTimeout(n,100))},Ef=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let s=0;s<r.length;s+=1)i=r[s],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},jE=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let s=0;s<r.length;s+=1)i=r[s],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var jx=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),HE=()=>{if(typeof window>"u")return;let n=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:n,y:t}},Hx=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},Wx=(n,t,e)=>{let r=IL(n);for(let i in r)if(r.hasOwnProperty(i))if(typeof t=="string")r[i]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";r[i]=s.slice(0,-2)}return r},OL=(n,t)=>{let e=IL(n);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},IL=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},qx=(n,t)=>{for(let e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},RL=(n,t)=>{let e={};for(let r in n)n.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:n.hasOwnProperty(r)&&(e[r]=n[r]);return e},Fm=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},LL=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&(BL="ontouchstart"in window,NL=!!window.PointerEvent,FL=!!window.MSPointerEvent);var BL,NL,FL,Vm={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Mf,zm={};NL?Mf=Vm.pointer:FL?Mf=Vm.MSPointer:BL?(Mf=Vm.touch,zm=Vm.mouse):Mf=Vm.mouse;function Zc(){}Zc.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Zc.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Zc.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)i=r[s],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(o){o.call(e,{type:i,target:e},t)})};Zc.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=RL(t.options,n))};Zc.prototype.bindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Ef(n,Mf[t],e._domHandlers_[t]),zm[t]&&Ef(n,zm[t],e._domHandlers_[t]),e};Zc.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},jE(n,Mf[t],e._domHandlers_[t]),zm[t]&&jE(n,zm[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Tf=Zc;function Pi(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Pi.id,Pi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Pi.prototype=new Tf;Pi.constructor=Pi;Pi.id=0;Pi.prototype.buildEl=function(n){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Pi.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=OL("borderRadius","50%"),e=Wx("transition","opacity",n),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},qx(r.el,e),this.options.shape==="circle"&&qx(r.back,t),qx(r.front,t),this.applyStyles(r),this};Pi.prototype.applyStyles=function(n){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};Pi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Pi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Pi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Pi.prototype.show=function(n){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof n=="function"&&n.call(this)},t.options.fadeTime)),t};Pi.prototype.hide=function(n){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof n=="function"&&n.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(n,r)}return t};Pi.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=Wx("transition",["top","left"],r);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};Pi.prototype.restCallback=function(){var n=this,t={};t.front=Wx("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};Pi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Pi.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,s,o;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?s="left":s="right"),n.lockX||(t>0?o="up":o="down"),n.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var c={};this.direction={x:s,y:o,angle:i},n.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+s,n),c.y||this.trigger("plain:"+o,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var VL=Pi;function ii(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=ii.id,ii.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}ii.prototype=new Tf;ii.constructor=ii;ii.id=0;ii.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};ii.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};ii.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};ii.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},s=e.options,o={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-o.x,y:n.y-o.y};else if(n.top||n.right||n.bottom||n.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=n.top,a.style.right=n.right,a.style.bottom=n.bottom,a.style.left=n.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new VL(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:n,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Hx(c.ui.el,i),Hx(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};ii.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};ii.prototype.bindNipple=function(n){var t=this,e,r=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};ii.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var s=n.force||n.pressure||n.webkitForce||0;s!==i&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),i=s)}.bind(r),100)};ii.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=jx(n),t.updateBox();var i=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(r.touches).findIndex(function(l){return l.identifier===o})<0){var a=[n[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return Fm(n,i),t.manager.bindDocument(),!1};ii.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),s=n.force||n.pressure||n.webkitForce||0,o={x:n.pageX,y:n.pageY},a=t.getOrCreate(i,o);a.identifier!==i&&t.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),s>0&&t.pressureFn(n,u,u.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(a))>=0&&t.idles.splice(r,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var c=Nm(o,a.position);if(c<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(n);return}}return a};ii.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};ii.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),s=t.manager.scroll;if(!DL(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=r;var a=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=Nm(l,i.position),u=PL(l,i.position),h=Gx(u),d=c/a,f={distance:c,position:l},p,m;if(i.options.shape==="circle"?(p=Math.min(c,a),m=_L(i.position,p,u)):(m=LL(l,i.position,a),p=Nm(m,i.position)),e.follow){if(c>a){let x=l.x-m.x,S=l.y-m.y;i.position.x+=x,i.position.y+=S,i.el.style.top=i.position.y-(t.box.top+s.y)+"px",i.el.style.left=i.position.x-(t.box.left+s.x)+"px",c=Nm(l,i.position)}}else l=m,c=p;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y},e.dataOnly||Hx(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:d,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:h,degree:u},vector:{x:g/a,y:-y/a},raw:f,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Gx(180-u),degree:180-u},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};ii.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),s=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};ii.prototype.onDestroyed=function(n,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};ii.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)n.pressureIntervals.hasOwnProperty(t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off()};var zL=ii;function ki(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=HE(),t.config(n),t.prepareCollections();var e=function(){var i;t.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+i.left,y:t.scroll.y+i.top}})})};if(typeof window>"u")return t.collections;Ef(window,"resize",function(){GE(e)});var r=function(){t.scroll=HE()};return Ef(window,"scroll",function(){GE(r)}),t.collections}ki.prototype=new Tf;ki.constructor=ki;ki.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};ki.prototype.create=function(n){return this.createCollection(n)};ki.prototype.createCollection=function(n){var t=this,e=new zL(t,n);return t.bindCollection(e),t.collections.push(e),e};ki.prototype.bindCollection=function(n){var t=this,e,r=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};ki.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};ki.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};ki.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};ki.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};ki.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};ki.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};ki.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};ki.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=jx(t);var s=function(a,l,c){c.ids.indexOf(l)>=0&&(c[i](a),a._found_=!0)},o=function(a){r=e.getIdentifier(a),Fm(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return Fm(t,o),!1};ki.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.off()};ki.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var UL=ki;var kL=new UL,GL={create:function(n){return kL.create(n)},factory:kL};var jL=new Map,Um=new Map,Uo=class{constructor(t,e,r,i){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let c=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new Da({src:c,volume:o,delay:a,loop:l}),Um.has(r.uuid)?Um.get(r.uuid).push(this):Um.set(r.uuid,[this]),jL.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Cf=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=jL.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Um.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...Um.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},km=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new Uo(t,e,r,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Cf(e);else throw new Error("Missing property")}dispatchBasic(){if(Pt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Uo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Pt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Uo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(Pt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Uo&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Gm=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.delay=0;this.emission=t.emission,t.delay!==void 0&&(this.delay=t.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},t);return}this.particleSystem.start()}stop(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},t);return}this.particleSystem.stop()}freeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},t);return}this.particleSystem.froze()}unFreeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},t);return}this.particleSystem.unFroze()}reset(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},t);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(Pt(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchConditional(){if(Pt(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchGameControl(t){if(Pt(this.shared,this.condition)===!1||!this.particleSystem)return!1;t==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};var ZQ="text/plain",JQ="us-ascii",HL=(n,t)=>t.some(e=>e instanceof RegExp?e.test(n):e===n),$Q=(n,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(n);if(!e)throw new Error(`Invalid URL: ${n}`);let{type:r,data:i,hash:s}=e.groups,o=r.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),u=[...o.map(h=>{let[d,f=""]=h.split("=").map(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===JQ)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&u.push("base64"),(u.length>0||l&&l!==ZQ)&&u.unshift(l),`data:${u.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function WE(n,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},n=n.trim(),/^data:/i.test(n))return $Q(n,t);if(/^view-source:/i.test(n))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=n.startsWith("//");!e&&/^\.*\//.test(n)||(n=n.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(n);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let u=o.exec(i.pathname);if(!u)break;let h=u[0],d=u.index,f=i.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let c=i.pathname.slice(a,i.pathname.length);l+=c.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];HL(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...i.searchParams.keys()])HL(o,t.removeQueryParameters)&&i.searchParams.delete(o);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=n;return n=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(n=n.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(n=n.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(n=n.replace(/^http:\/\//,"//")),t.stripProtocol&&(n=n.replace(/^(?:https?:)?\/\//,"")),n}var Xx=class{constructor({url:t,context:e},r,i,s){this.controlsManager=r;this.shared=i;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:WE(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Pt(this.shared,this.condition)===!1)return!1;po?window.location.assign(this.url):(this.context==="tab"||Iw&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp($e[0]),E2())}};var jm=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,i=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)i?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(i||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(Pt(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Pt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var Hm=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.shared=r;this.eventManager=i;this.condition=s;this.shared=r}dispatch(){if(Pt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Pf(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};var KL={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},QE={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},eK=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Kx={CSS:{},springs:{}};function $s(n,t,e){return Math.min(Math.max(n,t),e)}function Wm(n,t){return n.indexOf(t)>-1}function qE(n,t){return n.apply(null,t)}var ht={arr:function(n){return Array.isArray(n)},obj:function(n){return Wm(Object.prototype.toString.call(n),"Object")},pth:function(n){return ht.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return!("isNode"in n)&&(n.nodeType||ht.svg(n))},str:function(n){return typeof n=="string"},fnc:function(n){return typeof n=="function"},und:function(n){return typeof n>"u"},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return ht.hex(n)||ht.rgb(n)||ht.hsl(n)},key:function(n){return!KL.hasOwnProperty(n)&&!QE.hasOwnProperty(n)&&n!=="targets"&&n!=="keyframes"}};function ZL(n){var t=/\(([^)]+)\)/.exec(n);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function JL(n,t){var e=ZL(n),r=$s(ht.und(e[0])?1:e[0],.1,100),i=$s(ht.und(e[1])?100:e[1],.1,100),s=$s(ht.und(e[2])?10:e[2],.1,100),o=$s(ht.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/r),l=s/(2*Math.sqrt(i*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,h=l<1?(l*a+-o)/c:-o+a;function d(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(u*Math.cos(c*m)+h*Math.sin(c*m)):m=(u+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=Kx.springs[n];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,d(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return Kx.springs[n]=v,v}return t?d:f}function tK(n){return n===void 0&&(n=10),function(t){return Math.ceil($s(t,1e-6,1)*n)*(1/n)}}var rK=function(){var n=11,t=1/(n-1);function e(u,h){return 1-3*h+3*u}function r(u,h){return 3*h-6*u}function i(u){return 3*u}function s(u,h,d){return((e(h,d)*u+r(h,d))*u+i(h))*u}function o(u,h,d){return 3*e(h,d)*u*u+2*r(h,d)*u+i(h)}function a(u,h,d,f,p){var m,g,y=0;do g=h+(d-h)/2,m=s(g,f,p)-u,m>0?d=g:h=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(u,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var g=s(h,d,f)-u;h-=g/m}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var p=new Float32Array(n);if(u!==h||d!==f)for(var m=0;m<n;++m)p[m]=s(m*t,u,d);function g(y){for(var v=0,x=1,S=n-1;x!==S&&p[x]<=y;++x)v+=t;--x;var w=(y-p[x])/(p[x+1]-p[x]),A=v+w*t,M=o(A,u,d);return M>=.001?l(y,A,u,d):M===0?A:a(y,v,v+t,u,d)}return function(y){return u===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return c}(),$L=function(){var n={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var i,s=4;r<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-r,2)}},Elastic:function(r,i){r===void 0&&(r=1),i===void 0&&(i=.5);var s=$s(r,1,10),o=$s(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,i){t[r]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(r){var i=t[r];n["easeIn"+r]=i,n["easeOut"+r]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},n["easeInOut"+r]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),n}();function KE(n,t){if(ht.fnc(n))return n;var e=n.split("(")[0],r=$L[e],i=ZL(n);switch(e){case"spring":return JL(n,t);case"cubicBezier":return qE(rK,i);case"steps":return qE(tK,i);default:return qE(r,i)}}function eB(n){try{var t=document.querySelectorAll(n);return t}catch{return}}function Zx(n,t){for(var e=n.length,r=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in n){var o=n[s];t.call(r,o,s,n)&&i.push(o)}return i}function Jx(n){return n.reduce(function(t,e){return t.concat(ht.arr(e)?Jx(e):e)},[])}function WL(n){return ht.arr(n)?n:(ht.str(n)&&(n=eB(n)||n),n instanceof NodeList||n instanceof HTMLCollection?[].slice.call(n):[n])}function ZE(n,t){return n.some(function(e){return e===t})}function JE(n){var t={};for(var e in n)t[e]=n[e];return t}function YE(n,t){var e=JE(n);for(var r in n)e[r]=t.hasOwnProperty(r)?t[r]:n[r];return e}function $x(n,t){var e=JE(n);for(var r in t)e[r]=ht.und(n[r])?t[r]:n[r];return e}function iK(n){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n);return t?"rgba("+t[1]+",1)":n}function nK(n){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=n.replace(t,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),i=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+i+","+s+","+o+",1)"}function sK(n){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(n)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(n),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,c;if(r==0)a=l=c=i;else{var u=i<.5?i*(1+r):i+r-i*r,h=2*i-u;a=o(h,u,e+1/3),l=o(h,u,e),c=o(h,u,e-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function oK(n){if(ht.rgb(n))return iK(n);if(ht.hex(n))return nK(n);if(ht.hsl(n))return sK(n)}function La(n){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(t)return t[1]}function aK(n){if(Wm(n,"translate")||n==="perspective")return"px";if(Wm(n,"rotate")||Wm(n,"skew"))return"deg"}function XE(n,t){return ht.fnc(n)?n(t.target,t.id,t.total):n}function ko(n,t){return n.getAttribute(t)}function $E(n,t,e){var r=La(t);if(ZE([e,"deg","rad","turn"],r))return t;var i=Kx.CSS[t+e];if(!ht.und(i))return i;var s=100,o=document.createElement(n.tagName),a=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(t);return Kx.CSS[t+e]=c,c}function tB(n,t,e){if(t in n.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=n.style[t]||getComputedStyle(n).getPropertyValue(r)||"0";return e?$E(n,i,e):i}}function eM(n,t){if(ht.dom(n)&&!ht.inp(n)&&(ko(n,t)||ht.svg(n)&&n[t]))return"attribute";if(ht.dom(n)&&ZE(eK,t))return"transform";if(ht.dom(n)&&t!=="transform"&&tB(n,t))return"css";if(n[t]!=null)return"object"}function rB(n){if(!!ht.dom(n)){for(var t=n.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,i;i=e.exec(t);)r.set(i[1],i[2]);return r}}function lK(n,t,e,r){var i=Wm(t,"scale")?1:0+aK(t),s=rB(n).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?$E(n,s,r):s}function tM(n,t,e,r){switch(eM(n,t)){case"transform":return lK(n,t,r,e);case"css":return tB(n,t,e);case"attribute":return ko(n,t);default:return n[t]||0}}function rM(n,t){var e=/^(\*=|\+=|-=)/.exec(n);if(!e)return n;var r=La(n)||0,i=parseFloat(t),s=parseFloat(n.replace(e[0],""));switch(e[0][0]){case"+":return i+s+r;case"-":return i-s+r;case"*":return i*s+r}}function iB(n,t){if(ht.col(n))return oK(n);if(/\s/g.test(n))return n;var e=La(n),r=e?n.substr(0,n.length-e.length):n;return t?r+t:r}function iM(n,t){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))}function cK(n){return Math.PI*2*ko(n,"r")}function uK(n){return ko(n,"width")*2+ko(n,"height")*2}function hK(n){return iM({x:ko(n,"x1"),y:ko(n,"y1")},{x:ko(n,"x2"),y:ko(n,"y2")})}function nB(n){for(var t=n.points,e=0,r,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=iM(r,s)),r=s}return e}function dK(n){var t=n.points;return nB(n)+iM(t.getItem(t.numberOfItems-1),t.getItem(0))}function sB(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return cK(n);case"rect":return uK(n);case"line":return hK(n);case"polyline":return nB(n);case"polygon":return dK(n)}}function fK(n){var t=sB(n);return n.setAttribute("stroke-dasharray",t),t}function pK(n){for(var t=n.parentNode;ht.svg(t)&&ht.svg(t.parentNode);)t=t.parentNode;return t}function oB(n,t){var e=t||{},r=e.el||pK(n),i=r.getBoundingClientRect(),s=ko(r,"viewBox"),o=i.width,a=i.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function mK(n,t){var e=ht.str(n)?eB(n)[0]:n,r=t||100;return function(i){return{property:i,el:e,svg:oB(e),totalLength:sB(e)*(r/100)}}}function gK(n,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return n.el.getPointAtLength(l)}var r=oB(n.el,n.svg),i=e(),s=e(-1),o=e(1);switch(n.property){case"x":return(i.x-r.x)*r.w;case"y":return(i.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function qL(n,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=iB(ht.pth(n)?n.totalLength:n,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:ht.str(n)||t?r.split(e):[]}}function aB(n){var t=n?Jx(ht.arr(n)?n.map(WL):WL(n)):[];return Zx(t,function(e,r,i){return i.indexOf(e)===r})}function lB(n){var t=aB(n);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:rB(e)}}})}function yK(n,t){var e=JE(t);if(/^spring/.test(e.easing)&&(e.duration=JL(e.easing)),ht.arr(n)){var r=n.length,i=r===2&&!ht.obj(n[0]);i?n={value:n}:ht.fnc(t.duration)||(e.duration=t.duration/r)}var s=ht.arr(n)?n:[n];return s.map(function(o,a){var l=ht.obj(o)&&!ht.pth(o)?o:{value:o};return ht.und(l.delay)&&(l.delay=a?0:t.delay),ht.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return $x(o,e)})}function vK(n){for(var t=Zx(Jx(n.map(function(s){return Object.keys(s)})),function(s){return ht.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=n.map(function(a){var l={};for(var c in a)ht.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i<t.length;i++)r(i);return e}function xK(n,t){var e=[],r=t.keyframes;r&&(t=$x(vK(r),t));for(var i in t)ht.key(i)&&e.push({name:i,tweens:yK(t[i],n)});return e}function bK(n,t){var e={};for(var r in n){var i=XE(n[r],t);ht.arr(i)&&(i=i.map(function(s){return XE(s,t)}),i.length===1&&(i=i[0])),e[r]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function SK(n,t){var e;return n.tweens.map(function(r){var i=bK(r,t),s=i.value,o=ht.arr(s)?s[1]:s,a=La(o),l=tM(t.target,n.name,a,t),c=e?e.to.original:l,u=ht.arr(s)?s[0]:c,h=La(u)||La(l),d=a||h;return ht.und(o)&&(o=c),i.from=qL(u,d),i.to=qL(rM(o,u),d),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=KE(i.easing,i.duration),i.isPath=ht.pth(s),i.isColor=ht.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var cB={css:function(n,t,e){return n.style[t]=e},attribute:function(n,t,e){return n.setAttribute(t,e)},object:function(n,t,e){return n[t]=e},transform:function(n,t,e,r,i){if(r.list.set(t,e),t===r.last||i){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),n.style.transform=s}}};function uB(n,t){var e=lB(n);e.forEach(function(r){for(var i in t){var s=XE(t[i],r),o=r.target,a=La(s),l=tM(o,i,a,r),c=a||La(l),u=rM(iB(s,c),l),h=eM(o,i);cB[h](o,i,u,r.transforms,!0)}})}function wK(n,t){var e=eM(n.target,t.name);if(e){var r=SK(t,n),i=r[r.length-1];return{type:e,property:t.name,animatable:n,tweens:r,duration:i.end,delay:r[0].delay,endDelay:i.endDelay}}}function AK(n,t){return Zx(Jx(n.map(function(e){return t.map(function(r){return wK(e,r)})})),function(e){return!ht.und(e)})}function hB(n,t){var e=n.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,n.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,i}var YL=0;function EK(n){var t=YE(KL,n),e=YE(QE,n),r=xK(e,n),i=lB(n.targets),s=AK(i,r),o=hB(s,e),a=YL;return YL++,$x(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Es=[],XL=[],Qx,MK=function(){function n(){Qx=requestAnimationFrame(t)}function t(e){var r=Es.length;if(r){for(var i=0;i<r;){var s=Es[i];s.paused?(Es.splice(i,1),r-=1):(s.tick(e),i++)}n()}else Qx=cancelAnimationFrame(Qx)}return n}();function TK(n){document.hidden?(Es.forEach(function(t){return t.pause(n.timeStamp)}),XL=Es.slice(0),ni.running=Es=[]):XL.forEach(function(t){return t.play(n.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",TK);function ni(n){n===void 0&&(n={});var t=0,e=0,r=0,i,s,o=0,a=null;function l(M){var b=window.Promise&&new Promise(function(T){return a=T});return M.finished=b,b}var c=EK(n),u=l(c);function h(){var M=c.direction;M!=="alternate"&&(c.direction=M!=="normal"?"normal":"reverse"),c.reversed=!c.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=c.reversed)})}function d(){c.direction="normal",c.reversed=!1,s.forEach(function(M){return M.reversed=!1})}function f(M){return c.reversed?c.duration-M:M}function p(){t=0,e=f(c.currentTime)*(1/ni.speed)}function m(M,b,T=!1){b&&(c.reversed?b.seek(b.duration*b.loop-(M-b.timelineOffset-b.pingPongDelayCorrection),T):b.seek(M-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection,T))}function g(M,b=!1){if(c.reversed)for(var C=o;C--;)m(M,s[C],b);else for(var T=0;T<o;T++)m(M,s[T],b)}function y(M){var b=0,T=c.animations,C=T.length;for(c.direction!=="alternate"&&c.parent?.direction==="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1&&(c.parent?.reversed&&c.direction==="alternate"?M=c.duration-c.delay+c.endDelay-M:M=c.duration+c.delay-c.endDelay-M):w(!1,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)&&(c.parent?.reversed&&c.direction==="alternate"?M=c.duration-c.delay+c.endDelay-M:M=c.duration+c.delay-c.endDelay-M);b<C;){var P=T[b],D=P.animatable,_=P.tweens,O=_.length-1,L=_[O];O&&(L=Zx(_,function(J){return M<J.end})[0]||L);let re;c.parent?.reversed&&c.direction==="alternate"?re=$s(M-L.start-L.endDelay,0,L.duration)/L.duration:re=$s(M-L.start-L.delay,0,L.duration)/L.duration;for(var j=isNaN(re)?1:L.easing(re),V=L.to.strings,H=L.round,W=[],q=L.to.numbers.length,K=void 0,G=0;G<q;G++){var Z=void 0;let J,Ae;c.direction!=="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1?(J=L.to.numbers[G],Ae=L.from.numbers[G]||0):(Ae=L.to.numbers[G],J=L.from.numbers[G]||0):w(!0,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)?(J=L.to.numbers[G],Ae=L.from.numbers[G]||0):(Ae=L.to.numbers[G],J=L.from.numbers[G]||0),L.isPath?Z=gK(L.value,j*Ae):Z=J+j*(Ae-J),H&&(L.isColor&&G>2||(Z=Math.round(Z*H)/H)),W.push(Z)}var te=V.length;if(!te)K=W[0];else{K=V[0];for(var $=0;$<te;$++){var Y=V[$],oe=V[$+1],ie=W[$];isNaN(ie)||(oe?K+=ie+oe:K+=ie+" ")}}cB[P.type](D.target,P.property,K,D.transforms),P.currentValue=K,b++}}function v(M){c[M]&&!c.passThrough&&c[M](c)}function x(){c.remaining&&c.remaining!==!0&&c.remaining--}let S={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(M,b,T,C,P){return S[M<<4|b<<3|T<<2|C<<1|P]}function A(M,b=!1){var T=c.duration;let C=c.delay,P=T-c.endDelay;c.parent?.reversed&&c.direction==="alternate"&&(C=c.endDelay,P=T-c.delay);var D=f(M);if(c.progress=$s(D/T*100,0,100),b||(c.reversePlayback=D<c.currentTime),o&&g(D,b),!c.began&&c.currentTime>=0&&(c.began=!0,v("begin")),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,v("loopBegin")),(c.reversed||D>=0)&&D<=C&&c.currentTime!==0&&(y(0),v("change")),(D>=P&&c.currentTime!==T+c.pingPongDelayCorrection||!T)&&(y(T),v("change")),D>C&&D<P?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,v("changeBegin")),y(D),v("change")):c.changeBegan?(c.changeCompleted=!0,c.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):c.began&&D>P&&v("changeComplete"),c.currentTime=$s(D,0,T+c.pingPongDelayCorrection),c.began&&v("update"),M>=T)if(x(),!c.remaining)c.paused=!0,c.completed||(c.completed=!0,v("loopComplete"),v("complete"),!c.passThrough&&"Promise"in window&&(a(),u=l(c)));else{o?t+=c.duration/ni.speed:t+=c.duration;for(let _ of s)_.setStartTime(0),_.remaining=_.loop;v("loopComplete"),c.loopBegan=!1,c.direction==="alternate"?h():o&&d()}}return c.reset=function(){var M=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversePlayback=!1,c.reversed=M==="reverse",c.remaining=c.loop,s=c.children,o=s.length;for(var b=o;b--;)c.children[b].reset();y(c.reversed?c.duration:0)},c.setStartTime=function(M){t=M},c.set=function(M,b){return uB(M,b),c},c.tick=function(M){r=M,t||(t=r),A((r+(e-t))*ni.speed)},c.seek=function(M,b=!1){A(M-t,b)},c.pause=function(M){c.paused=!0,o&&(i=M??performance.now())},c.play=function(M){!c.paused||(c.completed&&c.reset(),c.paused=!1,Es.push(c),o&&i!==void 0&&(t+=(M??performance.now())-i),Qx||MK())},c.reverse=function(){h(),c.completed=!c.reversed,p()},c.restart=function(){c.reset(),c.play()},c.reset(),c.autoplay&&c.play(),c}function QL(n,t){for(var e=t.length;e--;)ZE(n,t[e].animatable.target)&&t.splice(e,1)}function CK(n){for(var t=aB(n),e=Es.length;e--;){var r=Es[e],i=r.animations,s=r.children;QL(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;QL(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&r.pause()}}function PK(n,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?KE(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",c=o==="last",u=ht.arr(n),h=parseFloat(u?n[0]:n),d=u?parseFloat(n[1]):0,f=La(u?n[1]:n)||0,p=t.start||0+(u?h:0),m=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!m.length){for(var S=0;S<x;S++){if(!i)m.push(Math.abs(o-S));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),M=S%i[0],b=Math.floor(S/i[0]),T=w-M,C=A-b,P=Math.sqrt(T*T+C*C);s==="x"&&(P=-T),s==="y"&&(P=-C),m.push(P)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(_){return r(_/g)*g})),e==="reverse"&&(m=m.map(function(_){return s?_<0?_*-1:-_:Math.abs(g-_)}))}var D=u?(d-h)/g:h;return p+D*(Math.round(m[v]*100)/100)+f}}function _K(n){n===void 0&&(n={});var t=ni(n);return t.duration=0,t.add=function(e,r){var i=Es.indexOf(t),s=t.children;i>-1&&Es.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=$x(e,YE(QE,n));l.targets=l.targets||n.targets;var c=t.duration;l.autoplay=!1,l.timelineOffset=ht.und(r)?c:rM(r,c),o(t);var u=ni(l);o(u),s.push(u),u.parent=t;var h=hB(s,n);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}ni.version="3.2.0";ni.speed=1;ni.running=Es;ni.remove=CK;ni.get=tM;ni.set=uB;ni.convertPx=$E;ni.path=mK;ni.setDashoffset=fK;ni.stagger=PK;ni.timeline=_K;ni.easing=KE;ni.penner=$L;ni.random=function(n,t){return Math.floor(Math.random()*(t-n+1))+n};var eb=ni;var dB=new E,fB=new E,pB=new Qe;function gB(n,t,e,r){if(r===0)return e.copy(n);if(r===1)return e.copy(t);let i=n.w*t.w+n.x*t.x+n.y*t.y+n.z*t.z;if(i>=1)return e.copy(n);let s=1-i*i;if(s<=Number.EPSILON){let u=1-r;return e.w=u*n.w+r*t.w,e.x=u*n.x+r*t.x,e.y=u*n.y+r*t.y,e.z=u*n.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-r)*a)/o,c=Math.sin(r*a)/o;return e.w=n.w*l+t.w*c,e.x=n.x*l+t.x*c,e.y=n.y*l+t.y*c,e.z=n.z*l+t.z*c,e}function Xr(n,t,e,r,i,s){let o=e[n]!==void 0?e[n]:void 0,a=r[n];if(a==null)return;let l=o!=null?typeof o=="string"?Number(i.getVariable(o)??0):o:t[n],c=typeof a=="string"?Number(i.getVariable(a)??0):a;if(l!==c)return{update:u=>{let h=we.lerp(l,c,u);s?t[n]=Math.trunc(h):t[n]=h},start:()=>{t[n]=l},end:()=>{t[n]=c}}}function Ym(n,t,e,r,i,s){let o=e[n]?e[n]:void 0,a=r[n];if(!a)return;let l=t[n],c=[...o??l].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h),u=[...a].map(h=>typeof h=="string"?Number(i.getVariable(h)??0):h);if(!(c.length!==u.length||Ec(c,u)))return{update:h=>{c.forEach((d,f)=>{let p=we.lerp(d,u[f],h);t[n][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[n],c)},end:()=>{Object.assign(t[n],u)}}}function qm(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function nM(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?qm(new E,s,i):a.clone(),c=qm(new E,o,i);if(!l.equals(c))return{update:u=>{a.lerpVectors(l,c,u)},start:()=>{a.copy(l)},end:()=>{a.copy(c)}}}function mB(n,t,e){return t.forEach((r,i)=>{n.setComponent(i,typeof r=="string"?Number(e.getVariable(r)??0):r)}),n}function _f(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=!(a instanceof U),c=a instanceof U?a:new U().fromArray(a),u=s?mB(new U,s,i):c.clone(),h=mB(new U,o,i);if(!u.equals(h))return{update:d=>{c.lerpVectors(u,h,d),l&&(t[n]=c.toArray())},start:()=>{c.copy(u),l&&(t[n]=c.toArray())},end:()=>{c.copy(h),l&&(t[n]=c.toArray())}}}function yB(n,t,e,r){let i=e[n]?e[n]:void 0,s=r[n];if(!s)return;let o=t[n],a=i?new ce().fromArray(i):o.clone(),l=new E,c=new Qe,u=new E;a.decompose(l,c,u);let h=new ce().fromArray(s),d=new E,f=new Qe,p=new E;if(h.decompose(d,f,p),!a.equals(h))return{update:m=>{pB.slerpQuaternions(c,f,m),dB.lerpVectors(l,d,m),fB.lerpVectors(u,p,m),o.compose(dB,pB,fB)},start:()=>{o.compose(l,c,u)},end:()=>{o.compose(d,f,p)}}}function vB(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=s?typeof s=="string"?i.getColor(s).clone():new We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new We().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return t[n]=u,{update:h=>{u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function Xm(n,t,e,r,i){let s=e[n]?e[n]:void 0,o=r[n];if(!o)return;let a=t[n],l=new mr(a.r,a.g,a.b,a.a),c=s?typeof s=="string"?i.getColor(s).clone():new mr(s.r,s.g,s.b,s.a):l.clone(),u=typeof o=="string"?i.getColor(o).clone():new mr(o.r,o.g,o.b,o.a);if(!c.equals(u))return{update:h=>{l.lerpColors(c,u,h);let d=we.lerp(c.a,u.a,h);l.a=d,t[n]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(u)}}}function Go(n,t,e,r,i){if(typeof t[n]=="number")return Xr(n,t,e??{},r,i);if(Array.isArray(t[n]))return Ym(n,t,e??{},r,i)}function xB(n,t,e,r){let i=[],s=n.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,o=n.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(o!==void 0){let a=s??n.zoom,l=o;a!==l&&i.push({update:c=>{n.zoom=we.lerp(a,l,c),n.updateProjectionMatrix()},start:()=>{n.zoom=a,n.updateProjectionMatrix()},end:()=>{n.zoom=l,n.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let a=Xr("targetOffset",n,t,e,r);a&&i.push(a)}return i}function DK(n,t,e,r){if(e.scaleBaked===void 0)return;let i=(t.scaleBaked??n.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a);if(So.isEqual(i,s))return;let o=[];return o.push({update:a=>{n.updateGeometryInteractions({scaleBaked:[we.lerp(i[0],s[0],a),we.lerp(i[1],s[1],a),we.lerp(i[2],s[2],a)]},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()},start:()=>{n.updateGeometryInteractions({scaleBaked:i},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()},end:()=>{n.updateGeometryInteractions({scaleBaked:s},r),n.invalidateDownstreamBooleanData(),n.refreshAttachedClonersInteractions()}}),o}function OK(n,t,e,r){if(!e.extrusion)return;let i=n.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return u1.forEach(l=>{let c=Go(l,i,s,o,r);c&&a.push(c)}),a}function bB(n,t,e,r){let i=[];if(!("geometry"in e))return i;let s=n.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(n instanceof Qs){let l=DK(n,o,a,r);l&&i.push(...l)}else{let l={};if(Object.assign(l,Kn(s,h1)),h1.forEach(c=>{let u=Go(c,l,o,a,r);u&&i.push(u)}),n instanceof ql){Object.assign(l,{extrusion:{...s.extrusion}});let c=OK(l,o,a,r);c&&i.push(...c)}i.length&&i.push({update:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()},start:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()},end:c=>{n.updateGeometryInteractions(l,r),n.updateGeometryGroupsIfNeeded(),n.refreshAttachedClonersInteractions()}})}return i}function SB(n,t,e,r){let i=[];if(e.intensity!==void 0){let s=Xr("intensity",n,t,e,r);s&&i.push(s)}if(e.color!==void 0){let s=vB("color",n,t,e,r);s&&i.push(s)}return i}function AB(n,t,e,r){let i=[];if(Array.isArray(n.material)){if(!("materials"in e&&e.materials))return i;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;n.material.forEach((a,l)=>{if(!o[l])return;let c=s[l]??{},u=o[l];typeof c=="string"||typeof u=="string"||i.push(...wB(a,c,u,r))})}else{if(!("material"in e&&e.material))return i;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return i;i.push(...wB(n.material,s,o,r))}return i}function wB(n,t,e,r){let i=[],s=Gc(e,r)||!!t.layers&&Gc(t,r);i.push(UK(n,s));for(let o of n.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||o.type!=="light"&&(!(o.visible??!0)||!(l.visible??!0)))continue;let c=o.getNames().filter(u=>!Iv.some(h=>u.includes(h)));for(let u of c)try{let h=o.getValue(u),d;if(u==="colors")d=VK(o,a,l,u);else if(Array.isArray(h))u==="steps"&&(d=FK(o,a,l,u));else if(typeof h=="number")d=IK(o,a,l,u,r);else{if(typeof h=="boolean")continue;h instanceof U?d=RK(o,a,l,u):h instanceof E?d=LK(o,a,l,u,r):h instanceof mr?d=NK(o,a,l,u,r):h instanceof We?d=BK(o,a,l,u,r):"isTexture"in h&&(d=zK(o,a,l,u))}d&&(Array.isArray(d)?i.push(...d):i.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${u}`,h)}}return i}function IK(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:n.getValue(r),o=e[r],a=typeof s=="string"?Number(i.getVariable(s)??0):s,l=typeof o=="string"?Number(i.getVariable(o)??0):o;if(a!==l)return{update:c=>{n.setValue(r,we.lerp(a,l,c))},start:()=>{n.setValue(r,a)},end:()=>{n.setValue(r,l)}}}function RK(n,t,e,r){if(!n.hasValue(r)||!(r in e))return;let i=n.getValue(r),s=t?new U().fromArray(t[r]):i.clone(),o=new U().fromArray(e[r]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function LK(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=n.getValue(r),o=t?t[r]:void 0,a=e[r],l=o?qm(new E,o,i):s.clone(),c=qm(new E,a,i);if(!l.equals(c))return{update:u=>{s.lerpVectors(l,c,u)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function BK(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=n.getValue(r),l=s?typeof s=="string"?i.getColor(s).clone():new We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new We().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return{update:h=>{n.getValue(r)!==u&&n.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function NK(n,t,e,r,i){if(!n.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=n.getValue(r),l=s?typeof s=="string"?i.getColor(s).clone():new We().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?i.getColor(o).clone():new mr(o.r,o.g,o.b,o.a);if(l.equals(c))return;let u=a.clone();return{update:h=>{n.getValue(r)!==u&&n.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function FK(n,t,e,r="steps"){if(!n.hasValue(r)||!(r in e))return;let i=[],s=n.getValue(r),o=t?t[r]:s,a=e[r];return Ec(o,a)||i.push({update:l=>{let c=[...s];for(let u=0;u<s.length;++u){let h=o[u],d=a[u];c[u]=we.lerp(h,d,l)}n.setValue(r,c)},start:()=>{n.setValue(r,o)},end:()=>{n.setValue(r,a)}}),i.length?i:void 0}function VK(n,t,e,r="colors"){if(!n.hasValue(r)||!(r in e))return;let i=[],s=n.getValue(r),o=t?t[r]:s.map(l=>l.toArray()),a=e[r];for(let l=0;l<s.length;++l){let c=[...o[l]],u=[...a[l]];zp.isEqual(c,u)||i.push({update:h=>{s[l].fromArray(zp.lerp(c,u,h))},start:()=>{s[l].fromArray(c)},end:()=>{s[l].fromArray(u)}})}return i.length?i:void 0}function zK(n,t,e,r="texture"){if(!n.hasValue(r)||!(r in e))return;let i=n.getNode("rotation"),s=t?.[r]?.rotation??0,o=e[r]?.rotation??0;if(i&&s!==o)return{update:g=>{i.value=we.lerp(s,o,g)*we.DEG2RAD},start:()=>{i.value=s*we.DEG2RAD},end:()=>{i.value=o*we.DEG2RAD}};let a=n.getNode("mat");if(!a)return;let l=t?t[r]:a,c=e[r],u=[...l.repeat],h=[...l.offset],d=[...c.repeat],f=[...c.offset],p=l.rotation??0,m=c.rotation??0;if(!Fs.isEqual(u,d)||!Fs.isEqual(h,f)||p!==m)return{update:g=>{a.repeat=Fs.lerp(u,d,g),a.offset=Fs.lerp(h,f,g),a.rotation=we.lerp(p,m,g),a.updateMatrix()},start:()=>{a.repeat=[...u],a.offset=[...h],a.rotation=p,a.updateMatrix()},end:()=>{a.repeat=[...d],a.offset=[...f],a.rotation=m,a.updateMatrix()}}}function UK(n,t){return{update:()=>{n.transparent=t}}}var sM=new E,EB=new rr;function MB(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f;if(n instanceof er?(o=_f("position",n,t,e,i),o&&s.push(o),l=Xr("rotation",n,t,e,i),l&&s.push(l),c=_f("shear",n,t,e,i),c&&s.push(c)):(f={slide:t.pathSnapping?.slide??n.updatedPathSnapping?.slide??n.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??n.updatedPathSnapping?.offset??n.dataPatched.pathSnapping?.offset??0},h=Xr("slide",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),h&&s.push(h),d=Xr("offset",f,t.pathSnapping??n.updatedPathSnapping??n.dataPatched.pathSnapping,e.pathSnapping??n.dataPatched.pathSnapping,i),d&&s.push(d),!h&&!d&&(o=nM("position",n,t,e,i),o&&s.push(o),a=nM("scale",n,t,e,i),a&&s.push(a),l=kK(n,t,e,r,i),l&&s.push(l),u=yB("hiddenMatrix",n,t,e),u&&s.push(u))),o||a||l||u||h||d){let p=n instanceof er?()=>{n.updateWorldMatrix(!0)}:()=>{n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n.parent?.matrixWorldFusedFalse&&(n.matrixWorld.multiplyMatrices(n.parent.matrixWorldFusedFalse,n.matrix),n.matrixWorldNeedsUpdate=!1),sn(n)&&Sn(n.parent)&&n.invalidateDownstreamBooleanData(!0),n.updatePathSnapping(Object.assign({},t.pathSnapping,f))};s.push({update:p,start:p,end:p})}return s}function kK(n,t,e,r,i){let s=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*we.DEG2RAD):void 0,o=e.rotation?.map(u=>(typeof u=="string"?Number(i.getVariable(u)??0):u)*we.DEG2RAD);if(!o)return;let a=s?new E().fromArray(s):new E().setFromEuler(n.rotation),l=new E().fromArray(o);if(a.equals(l))return;let c=sM.subVectors(l,a);if(r&&c.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Qe().setFromEuler(EB.setFromVector3(a)),h=new Qe().setFromEuler(EB.setFromVector3(l));return{update:d=>{gB(u,h,n.quaternion,d)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}else return{update:u=>{sM.lerpVectors(a,l,u),n.rotation.setFromVector3(sM)},start:()=>{n.rotation.setFromVector3(a)},end:()=>{n.rotation.setFromVector3(l)}}}function TB(n,t,e,r){let i=[];if(!("cloner"in e)||!n.cloner)return i;let s=n.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;t1.forEach(f=>{let p;f==="count"?p=Xr("count",s.parameters,o,a,r,!0):p=Go(f,s.parameters,o??{},a,r),p&&i.push(p)});let l=GK(s,o,a,r);l?.length&&i.push(...l);let c=jK(s,o,a,r);c?.length&&i.push(...c);let u=HK(s,o,a,r);u?.length&&i.push(...u);let h=WK(s,o,a,r);h?.length&&i.push(...h);let d=qK(s,o,a,r);return d?.length&&i.push(...d),i.length&&i.push({update:()=>{s.update()}}),i}function GK(n,t,e,r){if(n.parameters.type!=="radial")return;let i=t.radial,s=e.radial;if(!s)return;let o=n.parameters.radial,a=[];return r1.forEach(l=>{let c=Go(l,o,i??{},s,r);c&&a.push(c)}),a}function jK(n,t,e,r){if(n.parameters.type!=="linear")return;let i=t.linear,s=e.linear;if(!s)return;let o=[],a=n.parameters.linear;return i1.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function HK(n,t,e,r){if(n.parameters.type!=="grid")return;let i=t.grid,s=e.grid;if(!s)return;let o=[],a=n.parameters.grid;return n1.forEach(l=>{let c;l==="count"?c=Ym(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function WK(n,t,e,r){if(n.parameters.type!=="toObject")return;let i=t.toObject,s=e.toObject;if(!s)return;let o=[],a=n.parameters.toObject;return s1.forEach(l=>{let c;l==="count"?c=Xr(l,a,i??{},s,r,!0):c=Go(l,a,i??{},s,r),c&&o.push(c)}),o}function qK(n,t,e,r){if(!n.parameters.randomness)return;let i=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=n.parameters.randomnessObject;return o1.forEach(l=>{let c=Go(l,a,i??{},s,r);c&&o.push(c)}),o}function YK(n,t){return{update:()=>{n instanceof br&&(n.fill.enabled=t)}}}function XK(n,t){return{update:()=>{n instanceof br&&(n.stroke.enabled=t)}}}function QK(n,t){return{update:()=>{n instanceof br&&(n.dropShadow.enabled=t)}}}function KK(n,t){return{update:()=>{n instanceof br&&(n.innerShadow.enabled=t)}}}function ZK(n,t){return{update:()=>{n instanceof br&&(n.backgroundBlur.enabled=t)}}}function JK(n,t){return{update:()=>{n instanceof br&&(n.layerBlur.enabled=t)}}}function CB(n,t,e,r,i){let s=[],o,a,l,c,u,h,d,f,p,m,g,y,v,x,S;if("width"in n&&(o=Xr("width",n,t,e,i),o&&s.push(o)),"height"in n&&(a=Xr("height",n,t,e,i),a&&s.push(a)),n instanceof br||n instanceof Qi){let w={...t.fill},A={...e.fill};w.enabled!==void 0&&w.enabled!==A.enabled&&(s.push(YK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),l=Xm("color",n.fill,w,A,i),l&&s.push(l)}if(n instanceof br){let w={...t.stroke},A={...e.stroke};(w.enabled||A.enabled)&&(s.push(XK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),c=Xm("color",n.stroke,w,A,i),c&&s.push(c),u=Xr("thickness",n.stroke,w,A,i),u&&s.push(u)}if(n instanceof br){let w={...t.dropShadow},A={...e.dropShadow};(w.enabled||A.enabled)&&(s.push(QK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),h=Xm("color",n.dropShadow,w,A,i),h&&s.push(h),d=Xr("blurRadius",n.dropShadow,w,A,i),d&&s.push(d),p=Xr("spread",n.dropShadow,w,A,i),p&&s.push(p),f=_f("offset",n.dropShadow,w,A,i),f&&s.push(f)}if(n instanceof br){let w={...t.innerShadow},A={...e.innerShadow};(w.enabled||A.enabled)&&(s.push(KK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),m=Xm("color",n.innerShadow,w,A,i),m&&s.push(m),g=Xr("blurRadius",n.innerShadow,w,A,i),g&&s.push(g),v=Xr("spread",n.innerShadow,w,A,i),v&&s.push(v),y=_f("offset",n.innerShadow,w,A,i),y&&s.push(y)}if(n instanceof br||n instanceof Qi){let w={...t.backgroundBlur},A={...e.backgroundBlur};(w.enabled||A.enabled)&&(s.push(ZK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),x=Xr("radius",n.backgroundBlur,w,A,i),x&&s.push(x)}if(n instanceof br){let w={...t.layerBlur},A={...e.layerBlur};(w.enabled||A.enabled)&&(s.push(JK(n,!0)),w.enabled||Object.assign(w,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),S=Xr("radius",n.layerBlur,w,A,i),S&&s.push(S)}if(n instanceof Qi||n instanceof As){let w=Ym("cornerRadius",n,t,e,i);w&&s.push(w)}return s}function oM(n,t,e,r,i){let s=[];return n.data.visible&&s.push(...MB(n,t,e,i,r)),n instanceof er?s.push(...CB(n,t,e,i,r)):(n.data.visible&&s.push(...TB(n,t,e,r)),sn(n)?(n instanceof ar&&n.data.visible&&s.push(...bB(n,t,e,r)),n.data.visible&&s.push(...AB(n,t,e,r))):zR(n)?n.data.visible&&s.push(...SB(n,t,e,r)):VR(n)&&s.push(...xB(n,t,e,r))),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var PB=new E;function Pf(n,t,e=!1){let r=[],i=s=>{let o=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let a of o.states){let l={...a.data};s.states||(s.states={}),s.states[a.id]=Sa.patch(o,l)}DB(n.scene,s,null,t,o.events.find(a=>a.data.type==="Follow"||a.data.type==="LookAt")!==void 0),_B(n)};n.scene.traverse2D(i),n.traverseChildren(s=>{if(e&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(PB,!0),s.rigidBody?.setAngvel(PB,!0)),!yt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,s.uuid===hs)return;let l=!1;r.some(c=>n.scene.find(o)?.isDescendantOf(c))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&r.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let c of a.states){let u={...c.data};n.data.globalPhysics.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete u.position,c.data.rotation!==void 0&&delete u.rotation,c.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),s.states||(s.states={}),s.states[c.id]=ma.patch(a,u)}DB(n.scene,s,null,t,a.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),_B(n),s instanceof Sr&&s.frame&&(s.frame.traverse(c=>i(c)),s.uiCanvas?.applySize())}),n.frame&&(n.frame.traverse(s=>i(s)),n.uiCanvas?.applySize())}function _B(n){n.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let i of Object.values(e.data.gameActions))r.push(...i);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let i of r)if(i.data.type==="Create"&&i.data.hideBase==="Yes"){let s=n.scene.find(i.data.object);s&&(s.visible=!1)}}})}function DB(n,t,e,r,i=!1){if(t instanceof ar&&t.removeInteractionGeometry(r),t instanceof er?t.changeSelectedState(e,{shared:r},i):t.changeSelectedState(e,{scene:n,shared:r},i),t instanceof ar&&t.updateGeometryGroupsIfNeeded(),t instanceof xr&&t.updateCameraState(t.dataPatched,{scene:n,shared:r}),!(t instanceof er)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function lM(n){let t;if(n.easing===5){let{control1:e,control2:r}=n;t=`cubicBezier(
${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
)`}else if(n.easing===6){let{mass:e,stiffness:r,damping:i,velocity:s}=n;t=`spring( ${e}, ${r}, ${i}, ${s} )`}else{let e;switch(n.easing){case 0:e=fa.linear;break;case 1:e=fa.ease;break;case 2:e=fa.easeIn;break;case 3:e=fa.easeOut;break;case 4:e=fa.easeInOut;break;default:e=fa.linear}let[r,i,s,o]=e;t=`cubicBezier( ${r}, ${i}, ${s}, ${o} )`}return{duration:Math.max(n.duration,1e-4),easing:t}}function aM(n){let t={delay:0,loop:n.repeat===-1?!0:n.repeat+1};if(n.repeat===0)t.direction="normal",t.rewind=!1;else switch(n.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,n.delayDirection){case"start-once":t.startOnceDelay=n.delay;break;case"start":t.delay=n.delay;break;case"end":t.endDelay=n.delay;break;case"start-end":case void 0:t.delay=n.delay,t.endDelay=n.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,n.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):n.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):n.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var $K={type:"beginState"},eZ={type:"completeState",isfromEntity:!1},rb=class{constructor(t,e,r,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object instanceof er||this.object.traverseEntity(e=>{e!==this.object&&e instanceof xr&&e.dispatchEvent($K)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object instanceof er||this.object.traverseEntity(e=>{e!==this.object&&e instanceof xr&&e.dispatchEvent(eZ)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=oM(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=tb(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=tb(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=tb(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...aM(i),...lM(i),change:this.onChange},this.callback=oM(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Qm=class extends hr{constructor(e,r,i,s,o){super();this.eventType=e;this.data=r;this.page=i;this.shared=s;this.condition=o;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.hasPlayedOnce=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())};if(!r.object)throw new Error("Missing property");let a=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,r.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=r.tweens[0].data.delayDirection==="start-once"?r.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=tb(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"||!$w(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:i=!1}={}){try{let s=aM(this.data.tweens[0].data);i&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=eb.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let c=this.data.tweens[l],u=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof xr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new rb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let c=this.data.tweens[l],u=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof xr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new rb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Pt(this.shared,this.condition)===!1||$w(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=aM(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof er?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(Pt(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Pt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function tb(n,t){let e,r;if(typeof t=="string"?(e=t,r=n.states?.[e]):t===null&&(e=null,r=n.data),!(e===void 0||r===void 0))return{id:e,data:r}}var tZ={type:"beginState"},OB={type:"completeState",isfromEntity:!1},IB={type:"requestRender"},Km=class extends hr{constructor(e,r,i,s){super();this.data=e;this.page=r;this.shared=i;this.condition=s;this.toggleIsForward=!1;this.posStart=new E;this.posEnd=new E;this.qStart=new Qe;this.qEnd=new Qe;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=eb({targets:i,t:1,...lM(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(tZ));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,i.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(IB),i.t===1&&s.dispatchEvent(OB)}})}switchCamera(e){let r=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),r.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Pt(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(Pt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(OB),this.page.activeCamera.dispatchEvent(IB))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Zm=class extends hr{constructor(e,r,i,s,o){super();this.data=e;this.page=r;this.animationControls=i;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let c=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=c?.getClip()?.duration??1;let u=c?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/u*this.duration,this.rightFrameTime=this.data.crop[1]/u*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Pt(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,s])=>{let o=i.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=we.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Pt(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===i&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var Jm=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.eventManager=r;this.shared=i;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Pt(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(r=>r.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Pf(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var $m=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Pt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=A0(this.data.expression,this.shared,Ni.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var eg=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i;this.timeoutId=null}dispatchInner(){if(Pt(this.shared,this.condition)===!1)return!1;let t=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};var ib=class{constructor(t,e,r,i){this.data=t;this.page=e;this.shared=r;this.condition=i}dispatch(){if(Pt(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Y0(e))})}dispose(){}};function Pt(n,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=A0(t.expression,n,"boolean");return t.negate?!e:!!e}function wr(n,t,e,r,i,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?nn[n.type].includes("Audio")&&o.Audio.push(new km(c,u,s,r,l)):u.type==="Video"&&!(s instanceof er)?nn[n.type].includes("Video")&&o.Video.push(new tg(c,u,s,r,l)):u.type==="Particles"?nn[n.type].includes("Particles")&&o.Particles.push(new Gm(u,e,r,l)):u.type==="Link"?nn[n.type].includes("Link")&&o.Link.push(new Xx(u,i.controlsManager,r,l)):u.type==="Create"?nn[n.type].includes("Create")&&o.Create.push(new rg(u,e,i.controlsManager,r,l)):u.type==="Destroy"?nn[n.type].includes("Destroy")&&o.Destroy.push(new jm(u,e,i.controlsManager,r,l)):u.type==="Reset"?nn[n.type].includes("Reset")&&o.Reset.push(new Hm(u,e,r,i,l)):u.type==="Transition"?nn[n.type].includes("Transition")&&o.Transition.push(new Qm(n.type,u,e,r,l)):u.type==="SwitchCamera"?nn[n.type].includes("SwitchCamera")&&o.SwitchCamera.push(new Km(u,e,r,l)):u.type==="SceneTransition"?nn[n.type].includes("SceneTransition")&&o.SceneTransition.push(new Jm(u,e,i,r,l)):u.type==="Animation"?nn[n.type].includes("Animation")&&o.Animation.push(new Zm(u,e,i.animationControls,r,l)):u.type==="SetVariable"?nn[n.type].includes("SetVariable")&&o.SetVariable.push(new $m(u,e,r,l)):u.type==="DynamicVariablePlay"?nn[n.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new eg(u,e,r,l)):u.type==="Conditional"?nn[n.type].includes("Conditional")&&(u.ifActions.forEach(a({expression:u.condition,negate:!1})),u.elseActions.forEach(a({expression:u.condition,negate:!0}))):u.type==="ClearLocalStorage"&&nn[n.type].includes("ClearLocalStorage")&&o.ClearLocalStorage.push(new ib(u,e,r,l))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function cr(n){Object.values(n).forEach(t=>{t.forEach(e=>{(e instanceof km||e instanceof tg||e instanceof Gm||e instanceof Zm||e instanceof Qm||e instanceof rg||e instanceof jm||e instanceof Km||e instanceof Jm||e instanceof Hm||e instanceof $m||e instanceof eg)&&e.dispose()})})}function RB(n,t){let e;if("material"in n){let r=n.material;Array.isArray(r)?e=n.material[0].layers.find(i=>i.uuid===t):e=n.material.layers.find(i=>i.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var LB=new Map,ig=new Map,Ba=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=r,i===void 0)throw new Error("Missing property");let l=RB(r,i);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,po&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),ig.has(r.uuid)?ig.get(r.uuid).push(this):ig.set(r.uuid,[this]),LB.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(i=>{}).catch(i=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Df=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=LB.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=ig.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...ig.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},tg=class{constructor(t,e,r,i,s){this.data=e;this.shared=i;this.condition=s;if(e.interaction==="play")this.interaction=new Ba(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Df(e);else throw new Error("Missing property")}dispatchBasic(){if(Pt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ba?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Pt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Ba?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var BB=(()=>{let n,t,e,r;function i(a){!n&&!NB()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(n=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,c=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,h=c.length,d=0;for(;d<h;){let f=c[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,c.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}n=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){NB()?n&&(cancelAnimationFrame(n),n=void 0,e=void 0):i()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),i})();function NB(){return!!document&&document.hidden}var FB=new Qe,rZ=new E,iZ=new E,rg=class{constructor(t,e,r,i,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=i;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=we.generateUUID();this.dispatch=()=>{if(Pt(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(Pt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Ow(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{this.timeoutIdQueue.shift();let t=new Rr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,i=this.page.scene.find(r);i&&(i.updateMatrixWorldSVD(),t.hiddenMatrix.copy(i.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),BB(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Ui)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof Rr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Ui)return;t instanceof Rr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new E().fromArray(this.data.velocity),i=e.dataPatched;if(!(i.physics.enabled==="visibility"?!i.visible:!i.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(rZ,FB,iZ),r.applyQuaternion(FB),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");BB(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var dM=200,cM=.02,uM=.3,nZ=65,pje=new E,VB=new E,zB=new E,sZ=new E,wn=new E,Vn=new E,Kl=new E,hM=new ce,UB=new ce,oZ=new ce,mje=new ce,eo=new Qe,Na=new Qe,jo=new rr(0,0,0,"YXZ"),aZ=new E(1,0,0),to=new E(0,1,0),lZ=new E(0,0,1),kB=new E(1,1,1),gje=new Dr,cZ=1,uZ=.025,hZ=16e-6,GB=12,dZ=20,Gi=new Si,Ms=new Gt,fZ={type:"requestRender"},pZ={type:"updateMatrix"},jB=Math.PI/6,nb=class extends hr{constructor(e,r,i,s,o,a,l,c,u){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=c;this.sharedAssets=u;this.enableDamping=!0;this.hiddenMatrix0=new ce;this.target0=new E;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=dM;this.euler0=new rr(0,0,0,"YXZ");this.position0Cam=new E;this.quat0Cam=new Qe;this.scale0Cam=new E;this.hiddenMatrix0Cam=new ce;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Si(new E(0,-40,0),new E(0,40,0)),matrix:new ce,position:new E,rotation:new Qe};this.euler=new rr(0,0,0,"YXZ");this.eulerDelta=new E;this.lastPosition=new E;this.lastCameraQuaternion=new Qe;this.lastCameraPosition=new E;this.PI_2=Math.PI/2;this.prevMouse=new U;this.velocityTarget=new E;this.velocity=new E;this.directionXZ=new E;this.rotVelocityStick=new E;this.rotVelocityTarget=new E;this.rotVelocity=new E;this.rotDirection=new E;this.nonColliderRotOffset=new ce;this.nonColliderPosOffset=new ce;this.firstPointerId=-1;this.rot=new E;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.vrEulerYOffset=0;this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new ce;this.objectToTarget=new E;this.objectToTarget0=new E;this.objectToCamXZ=new E;this.objectToCamXZ0=new E;this.targetToCamera=new E;this.targetToCamera0=new E;this.cameraPolarAxis0=new E;this.targetPos=new E;this.targetQuat=new Qe;this.lerpFactorPos=new E().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Qe;this.objXZQuatInv=new Qe;this.objXZRotMat=new ce;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new E;this.pushedVelocity=new E;this.groundYRotation=0;this.objectRealQuat=new Qe;this.colliderWorldQuat=new Qe;this.groundNormal=new E;this.groundTilt=new Qe;this.groundTiltInv=new Qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new E;this.quaternion=new Qe;this.scale=new E;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Ai&&!Rw&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Rw&&S2<15.5&&!Ai?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?nb.isLocked=!0:nb.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let i=2;i<4;i++){let s=e.axes[i];r===0?i===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let g=new E(0,0,-1).applyQuaternion(this.camera.quaternion),y=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let S=new rr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof xr&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*cZ,this.speedOrbit=(i.speedRotate??100)*uZ,this.mouseOrbitSensitivity=(i.speedRotate??100)*hZ,this.keyAssignments=i.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),i.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??wl.defaultData.gravity)*GB,this.usePhysics=this.gloabalPhysics.usePhysics??wl.defaultData.usePhysics,this.jumpPower=i.jumpPower*dZ,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Wh.defaultDataThirdPerson.orientWith,this.slopeThresh=nZ*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*cM/this.pixelsPerMeter,this.stepThresh=i.collider.height*uM/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*cM/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*uM/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*cM/this.pixelsPerMeter,this.stepThresh=i.collider.height*uM/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let f=new E().fromArray(i.collider.position),p=new Qe().setFromEuler(new rr().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,kB),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let m=i.navmesh.destinationHelperRadius*2;if(m>0){let g=new ke;g.push({fi:0,data:{...zr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...zr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let y=new _a({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Xt(u0.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new rr().setFromQuaternion(this.quaternion,"YXZ"),i=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,i,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof xr?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Hh.list.forEach(i=>{this.actions[i]=wr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,r,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),cr(this.actions.idle),cr(this.actions.move),cr(this.actions.run),cr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return wn.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let c=Vn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*GB),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(u){this.onObject=!0,this.groundNormal.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),u.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=u.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(wn,Na,Vn),this.groundVelocity.subVectors(wn,d.prevT),this.object.getWorldPosition(Vn).add(this.collider.position).sub(wn),this.groundYRotation=jo.setFromQuaternion(Na).y-d.prevR.y,Kl.copy(Vn).applyAxisAngle(to,this.groundYRotation),this.groundVelocity.add(Kl.sub(Vn)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let c=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let u=wn.subVectors(this.path[1],this.position),h=Vn.subVectors(this.path[1],this.path[0]);u.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),c.opacity=c.userData.opacity0}else c.opacity-=.05*c.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=sZ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=Vn.copy(l);c.y=0,l.set(0,l.y,c.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let c=wn;this.camera.getWorldDirection(c);let u=Kl.copy(to).multiplyScalar(c.dot(to));c.sub(u);let h=Vn.copy(this.directionXZ);h.x*=-1,this.rot.y=c.angleTo(h)*(c.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(jo.setFromVector3(this.rot),this.moveMode==="walk"&&(jo.x=0),l.applyEuler(jo),a&&(Na.setFromUnitVectors(to,this.groundNormal),l.applyQuaternion(Na)),i){let c=jo.set(0,this.vrEulerYOffset*jB,0);i.applyEuler(c),l.x+=i.x,l.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*s}if(this.usePhysics===!0){let c=Vn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Kl.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),wn.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=yt.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let p;u instanceof Rr&&(p=u);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(sb));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),c.copy(d.normal1).applyQuaternion(u.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let u=c.dot(l);u<0&&l.addScaledVector(c,-u),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(to,this.euler.y-this.euler0.y);let c=Vn.copy(this.objectToCamXZ).normalize(),u=Kl.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(wn.copy(c).multiplyScalar(u.dot(c))).cross(c).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=we.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(jo.copy(r),jo.y=0):(jo.copy(this.euler),jo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(jo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*jB),eo.setFromAxisAngle(aZ,this.rot.x),Na.setFromAxisAngle(to,this.rot.y),Na.multiply(eo),eo.setFromAxisAngle(lZ,this.rot.z),Na.multiply(eo),this.quaternion.copy(Na),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let c=Vn.copy(l).multiplyScalar(s/this.pixelsPerMeter),u=null;this.didHit=!1;let h=new E;for(let d=0;d<5;d++){let f=c.length(),p=Kl.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let S of x)if(S.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,A;if(m.cloner){for(let M of m.cloner.children)if(M.rigidBody===w){A=M;break}}S.dispatch(A),m.dispatchEvent(sb)}}}let g=VB.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),y=zB.copy(p).multiplyScalar(u.toi).dot(g),v=u.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=u.toi*(y-this.offset)/y,h.addScaledVector(p,v)),c.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),S=Kl.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let w=x.add(S);w.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}c.addScaledVector(g,-c.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(c);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(wn.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(eo.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let c=this.onObject?1:5,u=l.multiplyScalar(s/c);for(let h=0;h<c;h++)this.position.add(u),this.collisionAdjustment(s/c)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let c=this.objectToTarget.add(this.position),u=this.targetToCamera.add(c);hM.lookAt(u,c,to).setPosition(u),hM.decompose(this.targetPos,this.targetQuat,wn),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=we.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=we.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(pZ),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(fZ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=eo.setFromAxisAngle(to,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?we.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=we.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=we.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=wn.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let s=Na.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){to.angleTo(e)*180/Math.PI<15||to.angleTo(e)*180/Math.PI>85?eo.identity():eo.setFromUnitVectors(to,e),this.groundTilt.slerp(eo,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=zB.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=hM.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(wn,eo,Vn).compose(wn,eo,kB);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ms.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=UB.copy(a).invert(),c=oZ.copy(UB).multiply(i);Gi.copy(this.collider.segment),Gi.start.applyMatrix4(c),Gi.end.applyMatrix4(c);let u=VB.copy(this.position).applyMatrix4(l);Ms.expandByPoint(Gi.start),Ms.expandByPoint(Gi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Gi.end)},intersectsBounds:h=>h.intersectsBox(Ms),intersectsTriangle:h=>{let d=wn,f=Vn,p=h.closestPointToSegment(Gi,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=Kl.copy(u);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),Gi.start.addScaledVector(g,m),Gi.end.addScaledVector(g,m)}}})}),Ms.makeEmpty(),Gi.copy(this.collider.segment),Gi.start.applyMatrix4(i),Gi.end.applyMatrix4(i),Ms.expandByPoint(Gi.start),Ms.expandByPoint(Gi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Gi.end)},intersectsBounds:o=>o.intersectsBox(Ms),intersectsTriangle:o=>{let a=wn,l=Vn,c=o.closestPointToSegment(Gi,a,l);if(c<this.collider.radius){let u=this.collider.radius-c,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,u),Gi.start.addScaledVector(h,u),Gi.end.addScaledVector(h,u)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},ng=nb;ng.isLocked=!1;var HB=Ko(z1());function ro(n,t){let e=new _e;if(!n.getAttribute("position"))return e.setAttribute("position",new Te([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Nc(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Te(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var mZ=new ce,gZ=new ce,Ho=[[0,0,0],[0,0,0],[0,0,0]];function fM(n){let t=n.elements;Ho[0][0]=t[0],Ho[0][1]=t[4],Ho[0][2]=t[8],Ho[1][0]=t[1],Ho[1][1]=t[5],Ho[1][2]=t[9],Ho[2][0]=t[2],Ho[2][1]=t[6],Ho[2][2]=t[10];let{u:e,v:r}=(0,HB.SVD)(Ho),i=mZ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=gZ.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return i.multiply(s.transpose())}var ob=class extends Wu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(i=>{i.visible&&this.intersectObject(i,e,r)}),r}createRaycastLineHelper(){let t=new ss({color:65280,linewidth:10}),e=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new E().addVectors(e,r.multiplyScalar(i)),o=new _e;return o.setFromPoints([e,s]),new dc(o,t)}};var WB=n=>n instanceof ws||n instanceof Js;function yZ(n,t){return n.distance-t.distance}function qB(n,t,e){if(!(!Po(t)||!t.visible)){sn(t)&&t.raycast(n,e);for(let r of t.children)qB(n,r,e)}}function Of(n,t,e,r=!1){if(!r&&!e.some(s=>If(n,s)!==void 0))return[];let i=[];return t.children.forEach(s=>qB(n,s,i)),i.sort(yZ),i}function sg(n){let t=[];if(n.length){let e=n[0].object;Po(e)&&t.push(e);let r=e.parent;for(;r;)WB(r)&&t.push(r),r=r.parent}return t}function io(n,t,e,r){let i=n.frame;if(i){let s=t[0]*i.width,o=(1-t[1])*i.height;for(let a of e){let l=a===i.uuid?i:i.find(a);if(l?.intersects(s,o))return r(l),!0}}return!1}function If(n,t){if(sn(t)){if(t.visible){let e=[];return t.raycast(n,e),e.length?e[0]:void 0}}else if(WB(t))return YB(n,t)}function YB(n,t){if(!(!Po(t)||!t.visible)){if(sn(t)){let e=[];if(t.raycast(n,e),e.length)return e[0]}for(let e of t.children){let r=YB(n,e);if(r)return r}}}function vZ(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}function xZ(n,t,e){return{x:(n-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var ab=class{constructor(t,e,r,i,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=i;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new ob;this._useWindowEvents=!1;this.pointerWorld={x:0,y:0};this.pointerScreen={x:0,y:0};this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=vZ(e,r,this._domRect),this.pointerScreen=xZ(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var Lr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var pM=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],XB=n=>pM.find(([t,e])=>e===n)?.[0],Wo=n=>pM.find(([t])=>t===n)?.[1],bZ=(n,t)=>{let e=XB(n);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},lb=class extends Lr{constructor(){super(...arguments);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[XB(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(r)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(r=>{if(!!r.data?.events.length){for(let[i,s]of pM)if(r.data.events.some(o=>o.data.type===s&&!o.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(r):this.objectsPerEvents.set(i,[r]);let o={id:r.uuid,name:r.name},a=bZ(s,o),l=this.splineEvents[i];l?l[r.uuid]=a:this.splineEvents[i]={[r.uuid]:a}}}}),this.objectsPerEvents.forEach(r=>{r.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var mM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;if((e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=wr(e,e.actions,i,s,o,r)}disconnect(){cr(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.Transition.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.SwitchCamera.some(i=>i.playing&&i.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()}),this.actions.Animation.forEach(i=>{i.data.runMode==="Toggle"?i.toggle():i.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch())}},cb=class extends Lr{constructor(e,r,i){super(e);this.eventManager=r;this.useForRaycastProperty=i;this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.sceneInterects=null;this.onCanvasRaycast=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=Of(r,i,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Wo(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:r,domElement:i}=this.eventContext,s=(o,a)=>{if(!o.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let c of l){let u=this.eventsPerObjects[c];o.data.events.filter(({data:h})=>h.type===c&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new mM(h,d,o,e,r,this.eventManager);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):u[o.uuid]?u[o.uuid].some(p=>p.id===f.id)||u[o.uuid].push(f):u[o.uuid]=[f]}catch(f){!1&&console.log(f)}}),u[o.uuid]?.length&&this.objectsPerTypes[c].push(o instanceof er&&(c==="MouseDown"||c==="MouseUp"||c==="MousePress")?a:o)}};e.traverseEntity(o=>{(o instanceof Sr||o instanceof lr)&&o.frame?.traverse(a=>{s(a,o)}),s(o)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([o,a])=>{a.forEach(l=>{l.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(r=>{Object.values(r).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:i,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof er));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&io(s,[o.x,o.y],Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}))){if(r||this.useForRaycastProperty){let c;if(this.sceneInterects===null?c=Of(i,s,l,this.useForRaycastProperty):(c=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&c.length&&(this.eventContext.sharedAssets.raycastProperty={x:c[0].point.x,y:c[0].point.y,z:c[0].point.z,objX:c[0].object.matrixWorld.elements[12],objY:c[0].object.matrixWorld.elements[13],objZ:c[0].object.matrixWorld.elements[14]}),r){let u=[c[0]?.uv?.x??0,c[0]?.uv?.y??0];sg(c).forEach(h=>{h instanceof Sr&&io(h,u,Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}r||l.forEach(c=>{let u=If(i,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof Sr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let r="MousePress",i=this.objectsPerTypes[r],s=i.filter(a=>!(a instanceof er)),o=[];if(!!i.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=io(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=Of(l,c,s);o=sg(d),d.forEach(f=>{f.object instanceof Sr&&io(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)})})}else s.forEach(d=>{let f=If(l,d);f&&(o.push(d),d instanceof Sr&&io(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{o.includes(a)||this.handleObjectMouseEventDispatchRelease(a,r)}),o.length&&o.forEach(a=>{this.handleObjectMouseEventDispatch(a,r)}),this._prevObjects=o}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,i=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}};var SZ=new E,wZ=new E;var ub=class{constructor(t,e,r,i,s){this.actionsIn=wr(t,t.inActions,r,i,s,e),this.actionsOut=wr(t,t.outActions,r,i,s,e)}disconnect(){cr(this.actionsIn),cr(this.actionsOut)}};var gM=class extends ub{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=SZ.setFromMatrixPosition(this.objects[0].matrixWorld),r=wZ.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==i){this.stage=i;let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Particles.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch()),s.ClearLocalStorage.forEach(o=>o.dispatch())}};let{distance:l,fromObject:c,toObject:u}=r.condition;this.distance=l;for(let h of[c,u]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},yM=class extends ub{constructor(e,r,i,s,o,a){super(r,i,s,o,a);this.id=e;this.data=r;this.object=i;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Particles.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Link.forEach(i=>i.dispatch()),this.actionsOut.Create.forEach(i=>i.dispatch()),this.actionsOut.Destroy.forEach(i=>i.dispatch()),this.actionsOut.Reset.forEach(i=>i.dispatch()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()),this.actionsOut.Animation.forEach(i=>i.play()),this.actionsIn.SwitchCamera.forEach(i=>i.pause()),this.actionsOut.SwitchCamera.forEach(i=>i.play()),this.actionsOut.SceneTransition.forEach(i=>i.dispatch()),this.actionsOut.SetVariable.forEach(i=>i.checkConditions()),this.actionsOut.SetVariable.forEach(i=>i.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Particles.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Link.forEach(i=>i.dispatch()),this.actionsIn.Create.forEach(i=>i.dispatch()),this.actionsIn.Destroy.forEach(i=>i.dispatch()),this.actionsIn.Reset.forEach(i=>i.dispatch()),this.actionsOut.Transition.forEach(i=>i.pause()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()),this.actionsIn.Animation.forEach(i=>i.play()),this.actionsOut.SwitchCamera.forEach(i=>i.pause()),this.actionsIn.SwitchCamera.forEach(i=>i.play()),this.actionsIn.SceneTransition.forEach(i=>i.dispatch()),this.actionsIn.SetVariable.forEach(i=>i.checkConditions()),this.actionsIn.SetVariable.forEach(i=>i.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actionsOut.ClearLocalStorage.forEach(i=>i.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let c=s.find(l.object)??s.scene.find2D(l.object);if(!c)throw new Error("Missing property");if(this.toObject=c,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){ls(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),ls(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),ls(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},hb=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:r}=this.eventContext;e.traverseEntity(i=>{if(!!i.data?.events.length){for(let{id:s,data:o}of i.data.events)if(!o.disabled&&o.type==="Conditional")try{let a;o.condition.type==="Comparison"||(o.condition.type==="Distance"?a=new gM(s,o,i,e,r,this.eventManager):o.condition.type==="State"&&(a=new yM(s,o,i,e,r,this.eventManager))),a&&(this.eventsPerConditions[o.condition.type].push(a),(a.actionsIn.Video.length||a.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(a){!1&&console.log(a)}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(s=>s.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var og=new E,Zl=new E,$c=new E,QB=new Zr,AZ=.01,tr=new E,_i=new E,KB=new E,eu=new Qe,vM=new rr,EZ=new ce,xM=new vr,Rf=new E,qo=new E,Lf=.2;function bM(n,t){!t||(t[0]<t[1]&&(n.x=Math.min(Math.max(n.x,t[0]),t[1])),t[2]<t[3]&&(n.y=Math.min(Math.max(n.y,t[2]),t[3])),t[4]<t[5]&&(n.z=Math.min(Math.max(n.z,t[4]),t[5])))}var MZ=function(){let n=new ce;return(t,e,r)=>{let i=t.obj;n.copy(i.hiddenMatrix),i.parent!==null&&n.premultiply(i.parent.matrixWorld),n.invert(),i.position.copy(e),t.reference==="global"&&bM(i.position,t.limits),i.position.applyMatrix4(n),t.reference==="parent"?bM(i.position,t.limits):t.reference==="local"&&(eu.copy(t.quat0).invert(),i.position.sub(t.position0),i.position.applyQuaternion(eu),bM(i.position,t.limits),eu.invert(),i.position.applyQuaternion(eu),i.position.add(t.position0)),n.multiply(r??i.matrixWorld).decompose(tr,i.quaternion,_i),i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i instanceof dr&&Sn(i.parent)&&i.invalidateDownstreamBooleanData(!0)}}(),SM=class{constructor(t,e,r,i,s,o,a){this.object=t;this.id=e;this.data=r;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=wr(r,r.dragDropActions.drag,i,s,o,this.object),this.actionsDrop=wr(r,r.dragDropActions.drop,i,s,o,this.object);let l=[];this.data.objects.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(l.push(u),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&l.push(d)}))}),this.data.dropDestinations.forEach(c=>{let u=i.find(c);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),a[u.uuid]&&a[u.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=l.map(c=>(this.data.planeMode==="locked"&&(c.userData.lockedPlane=!0),c.userData.worldPosition0=new E().setFromMatrixPosition(c.matrixWorld),{obj:c,fromPosition:new E().setFromMatrixPosition(c.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(c.position),quat0:new Qe().copy(c.quaternion),snapped:!1,orientationMatrix:new ce,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){cr(this.actionsDrag),cr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},db=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if($e.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:c,pointStart:u}of o.dragItems){if(l===s[0].object||l===s[0].object.object||yt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(tr,eu,_i),vM.setFromQuaternion(eu),h.prevR===void 0?(h.prevR=vM.clone(),h.prevT=tr.clone()):(h.prevR.copy(vM),h.prevT.copy(tr)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if($e.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:i}=this.eventContext,s=i.raycastWithClones(r);if($e.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||yt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ws)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===l.object.uuid||i.scene.find(c).isAncestorOf(l.object.uuid))))[0]),a){let l=KB.copy(a.face.normal).applyMatrix3(xM.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){tr.copy(l).applyMatrix3(xM.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;tr.x>Lf?_i.x=-c.recursiveBBox.min.x:tr.x<-Lf&&(_i.x=-c.recursiveBBox.max.x),tr.y>Lf?_i.y=-c.recursiveBBox.min.y:tr.y<-Lf&&(_i.y=-c.recursiveBBox.max.y),tr.z>Lf?_i.z=-c.recursiveBBox.min.z:tr.z<-Lf&&(_i.z=-c.recursiveBBox.max.z),_i.applyMatrix3(xM.invert())}else _i.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(_i)}this.activeEvent.data.autoOrient&&(tr.set(0,1,0).cross(l),tr.length()<1e-4&&tr.set(-1,0,0).cross(l),_i.crossVectors(KB,tr),o.orientationMatrix.makeBasis(tr,_i,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(i=>{i.stop(),i.object.currentState!==null&&i.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(i=>{i.stop()}),this.activeEvent.actionsDrag.Audio.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(i=>{i.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(i=>i.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(i=>i.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new SM(i,s.id,s.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let r=this.eventContext.domElement;r.addEventListener("pointerdown",this.onPointerDown),r.addEventListener("pointermove",this.onPointerMove),r.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,i,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(Zl),Zl.negate();let l=eu.identity();switch(s==="parent"?EZ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(tr,l,_i):s==="local"&&e.matrixWorld.decompose(tr,l,_i),i){case"x":tr.set(1,0,0).applyQuaternion(l),Rf.copy(Zl).cross(tr),qo.copy(tr).cross(Rf);break;case"y":tr.set(0,1,0).applyQuaternion(l),Rf.copy(Zl).cross(tr),qo.copy(tr).cross(Rf);break;case"z":tr.set(0,0,1).applyQuaternion(l),Rf.copy(Zl).cross(tr),qo.copy(tr).cross(Rf);break;case"xy":qo.set(0,0,1).applyQuaternion(l);break;case"yz":qo.set(1,0,0).applyQuaternion(l);break;case"xz":qo.set(0,1,0).applyQuaternion(l);break;case"adaptive":Zl.angleTo(_i.set(0,1,0))>Math.PI/6?(tr.crossVectors(_i.set(0,1,0),Zl),qo.crossVectors(tr,_i)):qo.set(0,1,0);break;default:qo.copy(Zl);break}$c.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:$c;if(QB.setFromNormalAndCoplanarPoint(qo,c),!!a.ray.intersectPlane(QB,r)&&(i==="x"||i==="y"||i==="z")){let u=_i.subVectors(r,c).dot(tr);r.copy(c).addScaledVector(tr,u)}}updateDragItem(e,r=!1){$c.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?og.subVectors(e.fromPosition,$c).divideScalar(e.currentDampingFactor):e.reset==="original"?(og.subVectors(e.obj.userData.worldPosition0,$c).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):og.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub($c).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?og.length()<AZ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&MZ(e,og.add($c),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Bf=new E,wM=new E,Fa=new E,Va=new E,ZB=new Zr,TZ=.01,CZ={type:"requestRender"},PZ=function(){let n=new E,t=new E;return(e,r,i)=>i>0?(n.subVectors(e,r),n.length()<=i?e:t.copy(r).add(n.normalize().multiplyScalar(i))):r}(),JB=function(){let n=new ce;return(t,e)=>{t.position.copy(e),t.parent!==null&&(n.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(n)),n.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(n),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof dr&&Sn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),AM=class{constructor(t,e,r,i,s,o){this.data=t;this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new E;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Av.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=wr(t,t.actions,i,s,o,r)}},fb=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!($e.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new AM(o.data,o.id,s,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Ai&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events)if(s.target!==void 0){let o=s.target,a=this.onTargetChange(s);this.pairOfEventListeners.push([o,a]),o.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Ai&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1,cr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(c=>{c.dispatchThrottled()})});let{plane:i,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Fa),e.isReset)Va.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Va);else{let{getCamera:l,raycaster:c}=this.eventContext;if(i==="custom"?(l().getWorldDirection(wM),wM.negate(),Bf.copy(wM)):i==="xy"?Bf.set(0,0,1):i==="xz"?Bf.set(0,1,0):i==="yz"&&Bf.set(1,0,0),ZB.setFromNormalAndCoplanarPoint(Bf,Fa),!c.ray.intersectPlane(ZB,Va))return}if(!e.isReset){if(Va.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Va.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(Va.x=Fa.x),e.data.enabledTranslation[1]===!1&&(Va.y=Fa.y),e.data.enabledTranslation[2]===!1&&(Va.z=Fa.z);let a=PZ(Fa,Va,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Bf.subVectors(a,Fa).divideScalar(e.currentDampingFactor);Fa.add(l),r&&JB(e.object,Fa),e.paused=l.length()<TZ}else JB(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(CZ)}};var ag=new E,pb=new E,lg=new ce,Nf=new Qe,Jl=new Qe,cg=new E,ug=new E,tu=new E,za=new E,EM=new Zr,_Z=1e-6,DZ={type:"requestRender"},OZ={type:"changeRotation"},$B=function(){let n=new ce;return function(e,r){e.parent!==null?n.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):n.copy(e.hiddenMatrix),r.premultiply(fM(n).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof dr&&Sn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),MM=class{constructor(t,e,r,i){this.id=e;this.object=r;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Ev.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=i.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},mb=class extends Lr{constructor(){super(...arguments);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!($e.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onScroll=e=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:i})=>{if(!r||!i)return;let s=Wo(r);s&&s==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);o&&(!e.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new MM(o.data,o.id,s,e))}),!this.events.length)return;let{domElement:r,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),Ai&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(r.addEventListener("pointerenter",this.onMouseEnter),r.addEventListener("pointerleave",this.onMouseLeave));for(let s of this.events){if(s.target!==void 0){let l=this.onTargetChange(s),c=s.target;this.pairOfEventListeners.push([c,l]),c.addEventListener("requestRender",l)}let o=this.createUserEventListener(s),a=s.object;this.pairOfUserEventListeners.push([a,o]),a.addEventListener("userEvent",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Ai&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let[i,s]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",s);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:c}=e.data,{getCamera:u,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(cg),!e.isReset)if(e.target)e.target.getWorldPosition(ug);else{if(o==="custom"?(u().getWorldDirection(pb),pb.negate(),EM.setFromNormalAndCoplanarPoint(pb,cg)):(o==="xy"?ag.set(0,0,1):o==="xz"?ag.set(0,1,0):o==="yz"&&ag.set(1,0,0),EM.setFromNormalAndCoplanarPoint(ag,cg)),!h.ray.intersectPlane(EM,ug))return;s>0&&(o==="custom"||o===void 0)&&ug.addScaledVector(pb,s)}if(e.isReset||(f?r==="target"?tu.copy(f.up).applyMatrix4(lg.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(i==="x"?(za.set(0,0,1),l[2]===!1&&za.set(0,1,0)):i==="y"?(za.set(1,0,0),l[0]===!1&&za.set(0,0,1)):(za.set(0,1,0),l[1]===!1&&za.set(1,0,0)),tu.copy(za).applyQuaternion(e.worldQuaternion0).normalize()):tu.set(0,1,0):o==="custom"?tu.set(0,1,0):tu.copy(ag)),e.isReset)Jl.copy(e.worldQuaternion0);else if(cg.distanceTo(ug)>a&&c&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Jl.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;IZ(lg,ug,cg,tu,i,za),Jl.setFromRotationMatrix(lg),Nf.setFromUnitVectors(za.applyQuaternion(Jl),tu),l.some(p=>p===!1)&&r!=="target"&&Jl.premultiply(Nf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Nf.setFromRotationMatrix(fM(d.matrixWorld)),Nf.slerp(Jl,1/e.currentDampingFactor),$B(d,lg.makeRotationFromQuaternion(Nf)),e.paused=8*(1-Nf.dot(Jl))<_Z):($B(d,lg.makeRotationFromQuaternion(Jl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(DZ),d.dispatchEvent(OZ)}},Ts=new E,Di=new E,si=new E;function IZ(n,t,e,r,i,s){let o=n.elements;si.subVectors(t,e),si.lengthSq()===0&&(si.z=1),si.normalize(),Di.crossVectors(r,si),Di.lengthSq()===0&&(Math.abs(r.z)===1?si.x+=1e-4:si.z+=1e-4,si.normalize(),Di.crossVectors(r,si)),Di.normalize(),Ts.crossVectors(si,Di),i==="x"?s.z===1?[Di,Ts,si]=[si,Di,Ts]:(Di.negate(),[Di,si]=[si,Di]):i==="y"?s.x===1?[Di,Ts,si]=[Ts,si,Di]:(Di.negate(),[Ts,si]=[si,Ts]):s.x===1&&(Di.negate(),[Di,Ts]=[Ts,Di]),o[0]=Di.x,o[4]=Ts.x,o[8]=si.x,o[1]=Di.y,o[5]=Ts.y,o[9]=si.y,o[2]=Di.z,o[6]=Ts.z,o[10]=si.z}var TM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=wr(e,e.actions,i,s,o,r)}disconnect(){cr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatchStart()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Create.forEach(t=>t.dispatchStop()),this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch())}},gb=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{$e.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{$e.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Wo(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(i)))}}connect(){let{page:e,sharedAssets:r}=this.eventContext,i=(o,a)=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:l,data:c}of o.data.events)if(!c.disabled&&c.type==="MouseHover")try{let u=new TM(l,c,o,e,r,this.eventManager);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o instanceof er?a:o)}};if(e.traverseEntity(o=>{(o instanceof Sr||o instanceof lr)&&o.frame?.traverse(a=>{i(a,o)}),i(o)}),!this.objects.length)return;let{domElement:s}=this.eventContext;this.domEventsNeeded.clear(),Ai&&(this.domEventsNeeded.add("pointerdown"),s.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),s.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),s.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(o=>{o.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Ai&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(i=>{i.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:i,raycaster:s,page:o,pointerScreen:a}=this.eventContext,l=!1;if(o.uiCanvas&&(l=io(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),i&&!l){let c=Of(s,o,this.objects);r=sg(c),c.forEach(u=>{u.object instanceof Sr&&io(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)})})}else this.objects.forEach(c=>{let u=If(s,c);u&&(r.push(c),c instanceof Sr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{r.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var CM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=wr(e,e.actions,i,s,o,r)}connect(){this.scrollCounter=0}disconnect(){cr(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(r)),this.actions.Animation.forEach(i=>i.seek(e)),this.actions.Create.forEach(i=>i.dispatchThrottled()),this.actions.SetVariable.forEach(i=>i.checkConditions()),this.actions.SetVariable.forEach(i=>i.dispatch()),this.actions.DynamicVariablePlay.forEach(i=>i.dispatch()),this.actions.ClearLocalStorage.forEach(i=>i.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch())}},PM=class{constructor(t,e,r,i,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=wr(e,e.actions,i,s,a,r)}getStickyParentElement(){let t=this.domElement;for(;t;){if(window.getComputedStyle(t).position==="sticky")return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,r=this.domElement.getBoundingClientRect(),i={top:r.top,bottom:r.bottom,left:r.left,right:r.right,width:r.width,height:r.height};if(e){let u=e.getBoundingClientRect(),h=window.getComputedStyle(t),d=parseFloat(h.marginTop)+parseFloat(h.marginBottom),f=parseFloat(h.top),p=parseFloat(h.bottom),m=u.height-d;if(!isNaN(f))r.top===f?(i.top+=u.top-f,i.bottom+=u.top-f):r.top<0&&(i.top-=m-r.height,i.bottom-=m-r.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,y=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);r.bottom===g-p?(i.top+=u.top-r.height+p+y,i.bottom+=u.top-r.height+p+y):r.bottom<g-p&&(i.top-=m-r.height,i.bottom-=m-r.height)}}let s=document.body,o=document.documentElement,a=window.pageYOffset||o.scrollTop||s.scrollTop,l=o.clientTop||s.clientTop||0,c=Math.round(i.top+a-l);if(this.data.startFrom==="enter"){let u=window.innerHeight,h=i.height,d=this.data.enterAnchor,f=d==="top"?u:d==="bottom"?u-h:u-h*.5;this.scrollStart=c-f}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=i,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){cr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,i=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(i)),this.actions.Animation.forEach(s=>s.seek(i)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch())}},yb=class extends Lr{constructor(e,r){super(e);this.managers=r;this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,i])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Wo(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{page:e,sharedAssets:r,domElement:i,isExport:s}=this.eventContext,o=a=>{if(!!a.data?.events.length){for(let{id:l,data:c}of a.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!s){let u=new CM(l,c,a,e,r,this.managers);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(u):this.wheelEventsPerObject.set(a,[u])}else{let u=new PM(l,c,a,e,r,i,this.managers);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(u):this.scrollEventsPerObject.set(a,[u])}}};e.traverseEntity(a=>{(a instanceof Sr||a instanceof lr)&&a.frame?.traverse(l=>{o(l)}),o(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let l=a[0];l&&(this.isInview=l.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,l])=>{l.forEach(c=>c.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var _M=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=wr(e,e.actions,i,s,o,r)}disconnect(){cr(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Uo?e.interaction.audioPlayer.play():e.interaction instanceof Cf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof Ba?e.interaction.play(r==="autoplay"):e.interaction instanceof Df&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Uo?e.interaction.audioPlayer.play():e.interaction instanceof Cf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Ba?e.interaction.play():e.interaction instanceof Df&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},vb=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext,i=r?document:e;i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.actions.Audio.forEach(s=>{s.interaction instanceof Uo&&s.interaction.audioPlayer.play()}),i.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Ba&&s.interaction.play(o==="autoplay")}),i.actions.Particles.forEach(s=>{s.dispatchBasic()})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:i})=>{if(!e||!r)return;let s=Wo(e);s&&s==="Start"&&(r instanceof er||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(i)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext,i=s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new _M(o,a,s,r,e,this.eventManager);(l.actions.Transition.length||l.actions.Animation.length||l.actions.SwitchCamera.length||l.actions.Create.length||l.actions.Destroy.length||l.actions.SceneTransition.length||l.actions.Reset.length||l.actions.SetVariable.length||l.actions.DynamicVariablePlay.length||l.actions.ClearLocalStorage.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Particles.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}};if(r.traverseEntity(s=>{(s instanceof Sr||s instanceof lr)&&s.frame?.traverse(o=>{i(o)}),i(s)}),[...this.eventsAfterPerObject.values()].some(s=>s.length)){if(this.eventManager.activateCount===0){let{domElement:s,isExport:o}=this.eventContext,a=o?document:s;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([l,c])=>{l.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>a.dispatch()),s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,i=r?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var xb=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.initialDisabled=!1;this.actions=wr(e,e.actions,i,s,o,r),this.target=e.target}disconnect(){cr(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Animation.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()))}};var bb=class extends Lr{constructor(e,r,i,s,o){super(e);this.sharedVariables=r;this.eventManager=i;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.isOutOfFocus=!1;this.events=[];this.onFrame=e=>{let r=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let i=new Date,s=[],o=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:u,property:h,prevValue:d}=this.propertiesToWatch[c],f=this.eventContext.scene.find(u),p=Tv.propertyPaths[h];if(p[0]==="width"||p[0]==="height"||p[0]==="depth")f=f.geometry.userData.parameters[p[0]];else for(let m=0;m<p.length;m++)f=f[p[m]];d===null?this.propertiesToWatch[c].prevValue=f instanceof E?f.clone():f:(f instanceof E?!f.equals(d):d!==f)&&(o.push({objId:u,property:h}),f instanceof E?this.propertiesToWatch[c].prevValue.copy(f):this.propertiesToWatch[c].prevValue=f)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:u,prevValue:h}=this.variablesToWatch[c],d=r.getVariable(u);d!==h&&(s.push(u),this.variablesToWatch[c].prevValue=d)}for(let c=0;c<this.dynamicVars.length;c++){let{id:u,expectedTime:h,last:d,data:f,timerSeconds:p,startValue:m}=this.dynamicVars[c],g=1e3;if((f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&f.format==="number3decimal"?g=1:f.dynamicVariableType==="counter"?g=f.updateInterval:f.dynamicVariableType==="random"&&(g=f.isStatic?1/0:f.updateInterval),h===-1){this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g;continue}if(!((r.getDynamicVariablePlayState(u)==="Stopped"||r.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime=e+g,f.dynamicVariableType==="counter"&&r.getVariable(u)!==m&&(r.updateVariable(u,m),this.eventManager.requestRender()),(f.dynamicVariableType==="timer"||f.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==m&&(this.dynamicVars[c].timerSeconds=m,r.updateVariable(u,mn.getFormattedTimerTime(m,f)),this.eventManager.requestRender()),r.getDynamicVariablePlayState(u)==="Restarted"&&r.setDynamicVariablePlayState(u,"Playing"),r.getDynamicVariablePlayState(u)==="Stopped"))){if(r.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-e,0)),this.dynamicVars[c].last=e-(g-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=e+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(e>=h)if(this.dynamicVars[c].last=e,this.dynamicVars[c].expectedTime+=g,f.dynamicVariableType==="random"){let y=f.min+Math.random()*(f.max-f.min),v=f.decimals;y=Math.round(y*Math.pow(10,v))/Math.pow(10,v),r.updateVariable(u,y),s.push(u),this.eventManager.requestRender()}else if(f.dynamicVariableType==="counter"){let y=r.getVariable(u),v=r.getDynamicVariableToggleIsForward(u)??!0,x=r.getVariable(u)+f.increment*(v?1:-1);f.hasEnd&&(x=f.increment>0?we.clamp(x,m,f.endValue):we.clamp(x,f.endValue,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?x===f.endValue&&(x=m):(x===m||x===f.endValue)&&r.setDynamicVariablePlayState(u,"Paused")),x!==y&&(s.push(u),r.updateVariable(u,x),this.eventManager.requestRender())}else if(f.dynamicVariableType==="time"){let y=r.getVariable(u),v=XA(i,f);if(typeof y=="object"&&"textValue"in y&&typeof v=="object"&&"textValue"in v){if(Array.isArray(y.textValue)&&Array.isArray(v.textValue)){if(y.textValue.every((x,S)=>x===v.textValue[S]))continue}else if(y.textValue===v.textValue)continue}else if(y===v)continue;r.updateVariable(u,v),s.push(u),this.eventManager.requestRender()}else{let y=Ni.isTextValue(f.endValue)?eN(f.endValue.textValue):f.endValue,v=r.getDynamicVariableToggleIsForward(u)??!0,x=p+(e-d)/1e3*(f.dynamicVariableType==="timer"?-1:1)*(v?1:-1);x=Math.max(x,0),f.hasEnd&&(x=f.dynamicVariableType==="stopwatch"?we.clamp(x,m,y):we.clamp(x,y,m),x===m&&r.setDynamicVariableToggleIsForward(u,void 0),f.repeat?Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1)&&(x=m):(Math.abs(x-m)<(f.format==="number3decimal"?1e-4:.1)||Math.abs(x-y)<(f.format==="number3decimal"?1e-4:.1))&&r.setDynamicVariablePlayState(u,"Paused")),x!==p&&(s.push(u),this.dynamicVars[c].timerSeconds=x,r.updateVariable(u,mn.getFormattedTimerTime(x,f)),this.eventManager.requestRender())}}}let a=!1;r.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=r.mouseProperty,a=!0);let l=!1;r.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=r.raycastProperty,l=!0),this.events.forEach(c=>{(s.includes(c.data.variableId)||o.find(u=>u.objId===c.data.objectId&&u.property===c.data.property)||c.data.variableId==="mouseProperty"&&a||c.data.variableId==="raycastProperty"&&l)&&(c.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(r=>{r.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new DM(i.id,i.data,r,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(r=>r.data.variableId==="objectProperty"&&r.data.objectId!==null).map(r=>({objectId:r.data.objectId,property:r.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:r,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(o=>o.data.variableId===r)&&this.variablesToWatch.push({id:r,prevValue:e.getVariable(r)});return}let s;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let o;if(Ni.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?o=a[2]+a[1]*60+a[0]*3600:o=a[1]+a[0]*60}else o=i.value;s=o,this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,timerSeconds:o,startValue:s})}else i.dynamicVariableType==="time"&&e.updateVariable(r,XA(new Date,i)),i.dynamicVariableType==="counter"&&(s=Ni.isTextValue(i.value)?eN(i.value.textValue):i.value),this.dynamicVars.push({id:r,last:-1,expectedTime:-1,data:i,startValue:s})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},DM=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.actions=wr(e,e.actions,i,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch())}dispose(){cr(this.actions)}};function eN(n){return n.length===3?n[2]+n[1]*60+n[0]*3600:n[1]+n[0]*60}var rN=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.7.6/build/",RZ=!1?rN:"https://unpkg.com/@splinetool/navmesh-wasm@1.7.6/build/",LZ=`
(async function() {
const [wasmImport, wasmBinary] = await Promise.all([
import('${rN}' + 'navmesh.js'),
fetch('${RZ}' + 'navmesh.wasm').then((res) => res.arrayBuffer()),
]);
const wasmModule = wasmImport.default;
self.module = await wasmModule({ wasmBinary });
postMessage('ready');
})();
`,BZ=`
(async function() {
const [wasmImport, wasmBinary] = await Promise.all([
import(self.location.origin + '/_libraries/navmesh.js'),
fetch(self.location.origin + '/_libraries/navmesh.wasm').then((res) => res.arrayBuffer()),
]);
const wasmModule = wasmImport.default;
self.module = await wasmModule({ wasmBinary });
postMessage('ready');
})();
`,NZ=`
onmessage = function(messageEvent) {
const meshData = messageEvent.data;
const positions = meshData[0];
const offset = meshData[1];
const indices = meshData[2];
const indicesLength = meshData[3];
const parameters = meshData[4];
const module = self.module;
const rc = new module.rcConfig();
rc.cs = parameters.cs;
rc.ch = parameters.ch;
rc.borderSize = parameters.borderSize ? parameters.borderSize : 0;
rc.tileSize = parameters.tileSize ? parameters.tileSize : 0;
rc.walkableSlopeAngle = parameters.walkableSlopeAngle;
rc.walkableHeight = parameters.walkableHeight;
rc.walkableClimb = parameters.walkableClimb;
rc.walkableRadius = parameters.walkableRadius;
rc.maxEdgeLen = parameters.maxEdgeLen;
rc.maxSimplificationError = parameters.maxSimplificationError;
rc.minRegionArea = parameters.minRegionArea;
rc.mergeRegionArea = parameters.mergeRegionArea;
rc.maxVertsPerPoly = parameters.maxVertsPerPoly;
rc.detailSampleDist = parameters.detailSampleDist;
rc.detailSampleMaxError = parameters.detailSampleMaxError;
if (!self.navMesh) {
self.navMesh = new module.NavMesh();
}
self.navMesh.build(positions, offset, indices, indicesLength, rc);
const navmeshData = navMesh.getNavmeshData();
const arrView = new Uint8Array(module.HEAPU8.buffer, navmeshData.dataPointer, navmeshData.size);
const ret = new Uint8Array(navmeshData.size);
ret.set(arrView);
navMesh.freeNavmeshData(navmeshData);
postMessage(ret);
}
`,tN=.001,FZ={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1},iN,It,Zi;D2.then(n=>{iN=n,It=new n.Vec3,Zi=new n.Vec3});var VZ=new E,Sb=class{constructor(t=!1,e=!1){this.usePhysics=t;this.isExport=e;this.onPointerDown=t=>{if($e.length!==1)return;let{raycaster:e,page:r}=this.eventContext;this.eventContext.updateRaycaster(t);let i=r.raycastWithClones(e);if(i.length!==0){if(this.gameControl){let s=VZ.copy(this.gameControl.colliderWorldPosition);s.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(s,i[0].point)}this.eventContext.requestRender()}};this.traverseWithPhysics=(t,e)=>r=>{let i;if(r instanceof Ui)if(r.objectForSample){if(r.objectForSample.dataPatched.physics.fusedBody)return;i=r.object}else return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(r instanceof Rr)i=r.object;else if(i=r,i.dataPatched.cloner?.disabled===!1&&i.dataPatched.cloner?.hideBase&&i.dataPatched.physics?.fusedBody!==!0)return!0;if(e&&!i.userData.navmesh)return;let s=i.dataPatched;if(!s.visible&&s.physics?.enabled!==!0)return!0;r.updateMatrixWorldSVD();let o=hg(s),a=i.userData.hasDestroy,l=i.userData.hasDrag,c=!1,u=!1;for(let h of s.events)h.data.disabled!==!0&&(h.data.type==="GameControl"?c=!0:h.data.type==="Follow"&&(u=!0));if(c||o||u||a||l)return!0;if(this.usePhysics&&s.physics?.rigidBody==="dynamic"){if(this.usePhysics&&s.physics?.fusedBody)return!0}else if("geometry"in r&&r.geometry&&t.push(ro(r.geometry,r.matrixWorld)),this.usePhysics&&s.physics?.fusedBody)return r.traverseObject((h,d)=>{if(d===0)return;let f;if(h instanceof Ui)if(h.objectForSample){if(h.objectForSample.dataPatched.physics.fusedBody)return;f=h.object}else return h.object.dataPatched.physics.fusedBody===!0&&h.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(h instanceof Rr)f=h.object;else if(f=h,h.dataPatched.cloner?.hideBase)return!0;let p=f.dataPatched;if(!p.visible&&p.physics?.enabled!==!0)return!0;"geometry"in h&&h.geometry&&t.push(ro(h.geometry,h.matrixWorld))}),!0};this.traverseNoPhysics=(t,e)=>r=>{let i;if(r instanceof Ui)return;r instanceof Rr?i=r.object:i=r;let s=i.dataPatched;if(s.physics.enabled==="visibility"?!s.visible:!s.physics.enabled)return!0;if(e&&!i.userData.navmesh)return;let o=r.geometry,a=i.userData.hasDestroy===!0,l=i.userData.hasDrag===!0;if(hg(s)||a||l||i.dataPatched.events.some(c=>c.data.disabled!==!0&&c.data.type==="GameControl"))return!0;o&&t.push(ro(o,r.matrixWorld))};this.navmeshWasm=iN,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?LZ:BZ)+NZ])),this._worker=new Worker(this._workerURL)}init(t,e,r){this.gameControl=e,this.eventContext=r,this.setDefaultQueryExtent(new E().setScalar(t.ch*t.walkableRadius*1.2)),this._worker.onmessage=()=>{this.createNavMesh(r.page,t,i=>{this.buildFromNavmeshData(i.data)})},this.eventContext.renderer.domElement.addEventListener("pointerdown",this.onPointerDown)}createNavMesh(t,e,r){e.objects.forEach(c=>{let u=t.scene.find(c);u.traverseEntity(h=>{h.userData.navmesh=!0}),u.cloner?.traverseObject(h=>{h.userData.navmesh=!0})});let i=[],s=(this.usePhysics?this.traverseWithPhysics:this.traverseNoPhysics)(i,e.zones==="custom");if(t.traverseChildren(s),e.objects.forEach(c=>{let u=t.scene.find(c);u.traverseEntity(h=>{h.userData.navmesh=void 0}),u.cloner?.traverseObject(h=>{h.userData.navmesh=void 0})}),i.length===0)return!1;let o=Us(i),{positions:a,triIndices:l}=Nc(o.getAttribute("position"),o.getIndex());return this._worker.postMessage([a,a.length/3,l,l.length,{...FZ,...e}]),this._worker.onmessage=r,!0}createDebugNavGeometry(){let t,e,r=this.navMesh.getDebugNavMesh(),i=r.getTriangleCount(),s=new Uint32Array(i*3),o=new Float32Array(i*3*3);for(t=0;t<i*3;t++)s[t]=t;for(t=0;t<i;t++)for(e=0;e<3;e++){let l=r.getTriangle(t).getPoint(e);o[t*9+e*3+0]=l.x,o[t*9+e*3+1]=l.y,o[t*9+e*3+2]=l.z}let a=new _e;return a.setIndex(new Xe(s,1)),a.setAttribute("position",new Xe(o,3)),a}getClosestPoint(t){return It.x=t.x,It.y=t.y,It.z=t.z,this.navMesh.getClosestPoint(It)}getClosestPointToRef(t,e){It.x=t.x,It.y=t.y,It.z=t.z;let r=this.navMesh.getClosestPoint(It);e.set(r.x,r.y,r.z)}getRandomPointAround(t,e){return It.x=t.x,It.y=t.y,It.z=t.z,this.navMesh.getRandomPointAround(It,e)}getRandomPointAroundToRef(t,e,r){It.x=t.x,It.y=t.y,It.z=t.z;let i=this.navMesh.getRandomPointAround(It,e);r.set(i.x,i.y,i.z)}moveAlong(t,e){return It.x=t.x,It.y=t.y,It.z=t.z,Zi.x=e.x,Zi.y=e.y,Zi.z=e.z,this.navMesh.moveAlong(It,Zi)}moveAlongToRef(t,e,r){return It.x=t.x,It.y=t.y,It.z=t.z,Zi.x=e.x,Zi.y=e.y,Zi.z=e.z,this.navMesh.moveAlong(It,Zi)}computePath(t,e){let r=this.getClosestPoint(e);if(Zi.x=r.x,Zi.y=r.y,Zi.z=r.z,Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)+Math.pow(e.z-r.z,2))>this.getDefaultQueryExtent().y)return[];this.getClosestPoint(t);let s=this.navMesh.computePath(It,Zi),o=s.getPointCount(),a=[];for(let l=0;l<o;l++){let c=s.getPoint(l);a.push(new E(c.x,c.y,c.z))}return a}createCrowd(t,e){return new OM(this,t,e)}setDefaultQueryExtent(t){It.x=t.x,It.y=t.y,It.z=t.z,this.navMesh.setDefaultQueryExtent(It)}getDefaultQueryExtent(){return this.navMesh.getDefaultQueryExtent()}buildFromNavmeshData(t){let e=t.length*t.BYTES_PER_ELEMENT,r=this.navmeshWasm._malloc(e),i=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,r,e);i.set(t);let s=new this.navmeshWasm.NavmeshData;s.dataPointer=i.byteOffset,s.size=t.length,this.navMesh.buildFromNavmeshData(s),this.navmeshWasm._free(i.byteOffset)}getNavmeshData(){let t=this.navMesh.getNavmeshData(),e=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,t.dataPointer,t.size),r=new Uint8Array(t.size);return r.set(e),this.navMesh.freeNavmeshData(t),r}getDefaultQueryExtentToRef(t){let e=this.navMesh.getDefaultQueryExtent();t.set(e.x,e.y,e.z)}dispose(){this.navMesh.destroy(),this._worker.terminate(),URL.revokeObjectURL(this._workerURL),this.eventContext?.renderer.domElement.removeEventListener("pointerdown",this.onPointerDown)}addCylinderObstacle(t,e,r){return It.x=t.x,It.y=t.y,It.z=t.z,this.navMesh.addCylinderObstacle(It,e,r)}addBoxObstacle(t,e,r){return It.x=t.x,It.y=t.y,It.z=t.z,Zi.x=e.x,Zi.y=e.y,Zi.z=e.z,this.navMesh.addBoxObstacle(It,Zi,r)}removeObstacle(t){this.navMesh.removeObstacle(t)}isSupported(){return this.navmeshWasm!==void 0}},OM=class{constructor(t,e,r){this.navmeshWasmWrapper=t;this.transforms=[];this.agents=new Array;this.reachRadii=new Array;this._agentDestinationArmed=new Array;this._agentDestination=new Array;this.crowd=new this.navmeshWasmWrapper.navmeshWasm.Crowd(e,r,this.navmeshWasmWrapper.navMesh.getNavMesh())}onReachTarget(t,e){}addAgent(t,e,r){let i=new this.navmeshWasmWrapper.navmeshWasm.dtCrowdAgentParams;i.radius=e.radius,i.height=e.height,i.maxAcceleration=e.maxAcceleration,i.maxSpeed=e.maxSpeed,i.collisionQueryRange=e.collisionQueryRange,i.pathOptimizationRange=e.pathOptimizationRange,i.separationWeight=e.separationWeight,i.updateFlags=7,i.obstacleAvoidanceType=0,i.queryFilterType=0,i.userData=0;let s=this.crowd.addAgent(new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z),i);return this.transforms.push(r),this.agents.push(s),this.reachRadii.push(e.reachRadius?e.reachRadius:e.radius),this._agentDestinationArmed.push(!1),this._agentDestination.push(new E(0,0,0)),s}getAgentPosition(t){return this.crowd.getAgentPosition(t)}getAgentPositionToRef(t,e){let r=this.crowd.getAgentPosition(t);e.set(r.x,r.y,r.z)}getAgentVelocity(t){return this.crowd.getAgentVelocity(t)}getAgentVelocityToRef(t,e){let r=this.crowd.getAgentVelocity(t);e.set(r.x,r.y,r.z)}getAgentNextTargetPath(t){return this.crowd.getAgentNextTargetPath(t)}getAgentNextTargetPathToRef(t,e){let r=this.crowd.getAgentNextTargetPath(t);e.set(r.x,r.y,r.z)}getAgentState(t){return this.crowd.getAgentState(t)}overOffmeshConnection(t){return this.crowd.overOffmeshConnection(t)}agentGoto(t,e){this.crowd.agentGoto(t,new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z));let r=this.agents.indexOf(t);r>-1&&(this._agentDestinationArmed[r]=!0,this._agentDestination[r].set(e.x,e.y,e.z))}agentTeleport(t,e){this.crowd.agentTeleport(t,new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z))}updateAgentParameters(t,e){let r=this.crowd.getAgentParameters(t);e.radius!==void 0&&(r.radius=e.radius),e.height!==void 0&&(r.height=e.height),e.maxAcceleration!==void 0&&(r.maxAcceleration=e.maxAcceleration),e.maxSpeed!==void 0&&(r.maxSpeed=e.maxSpeed),e.collisionQueryRange!==void 0&&(r.collisionQueryRange=e.collisionQueryRange),e.pathOptimizationRange!==void 0&&(r.pathOptimizationRange=e.pathOptimizationRange),e.separationWeight!==void 0&&(r.separationWeight=e.separationWeight),this.crowd.setAgentParameters(t,r)}removeAgent(t){this.crowd.removeAgent(t);let e=this.agents.indexOf(t);e>-1&&(this.agents.splice(e,1),this.transforms.splice(e,1),this.reachRadii.splice(e,1),this._agentDestinationArmed.splice(e,1),this._agentDestination.splice(e,1))}getAgents(){return this.agents}update(t){if(this.navmeshWasmWrapper.navMesh.update(),t<=tN)return;let e=1/60,r=10;if(e<=tN)this.crowd.update(t);else{let i=Math.floor(t/e);r&&i>r&&(i=r),i<1&&(i=1);let s=t/i;for(let o=0;o<i;o++)this.crowd.update(s)}for(let i=0;i<this.agents.length;i++){let s=this.agents[i],o=this.getAgentPosition(s);if(this.transforms[i].copy(o),this._agentDestinationArmed[i]){let a=o.x-this._agentDestination[i].x,l=o.z-this._agentDestination[i].z,c=this.reachRadii[i],u=this._agentDestination[i].y-this.reachRadii[i],h=this._agentDestination[i].y+this.reachRadii[i],d=a*a+l*l;o.y>u&&o.y<h&&d<c*c&&(this.onReachTarget(s,this._agentDestination[i]),this._agentDestinationArmed[i]=!1)}}}setDefaultQueryExtent(t){let e=new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z);this.crowd.setDefaultQueryExtent(e)}getDefaultQueryExtent(){return this.crowd.getDefaultQueryExtent()}getDefaultQueryExtentToRef(t){let e=this.crowd.getDefaultQueryExtent();t.set(e.x,e.y,e.z)}getCorners(t){let e,r=this.crowd.getCorners(t),i=r.getPointCount(),s=[];for(e=0;e<i;e++){let o=r.getPoint(e);s.push(new E(o.x,o.y,o.z))}return s}dispose(){this.crowd.destroy()}};function IM(n){let t=!1;return n.scene.objects.forEach(e=>{e.data.type==="Page"&&!t&&e.data.publish.gameControlObject&&Al.traverseModuleInstances(n,e.id,(i,s,o)=>{for(let a of o)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}var zZ={type:"change"},nN={type:"changeZoom"},UZ={type:"changePan"},ru={type:"start"},iu={type:"end",changed:!0},kZ={type:"end",changed:!1},RM=new Qe,sN=new U,GZ=2*Math.PI,jZ=1e-8,HZ=.01,LM=new E,wb=new U,BM=new E,Ab=new Qe,oN=new ce;var WZ={type:"requestRender"},Ff=class extends hr{constructor(e,r,i={isPlayMode:!1,isExport:!1}){super();this.object=e;this.domElement=r;this.options=i;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Yn.DOLLY_ROTATE,Yn.PAN];this.offset=new E;this.eye=new E;this.lastPosition=new E;this.lastQuaternion=new Qe;this.current=new U;this.overShoot=new U;this.overRatio=new U;this.spherical=new vp;this.sphericalDelta=new vp;this.panOffset=new E;this.panLeftV=new E;this.panUpV=new E;this.panV=new E;this.rotateStart=new U;this.rotateEnd=new U;this.rotateDelta=new U;this.panStart=new U;this.panEnd=new U;this.panDelta=new U;this.dollyStart=new U;this.dollyEnd=new U;this.dollyDelta=new U;this.rotationRangeFactor=new U;this.panRangeFactor=new U;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.resetHoverEffectOnPointerLeave=!1;this.hasChange=!1;this.useWindowEvents=!1;this.isTouchZoom=!0;this.autoRotateSpeed=2;this.dampingFactor=.125;this.zoomSpeed=2;this.rotateSpeed=1;this.panSpeed=1;this.hoverRotatePanStrength=.1;this.hoverRotateDamping=this.dampingFactor;this.thetaIsFree=!1;this.phiIsFree=!1;this.needsUpdate=!0;this.onCameraChange=e=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=e.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)};this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(BM,Ab,LM),this.offset.copy(BM).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(RM.copy(Ab).invert()),this.panOffset.applyQuaternion(RM),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(Ab),this.panOffset.applyQuaternion(Ab)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),BM.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(oN.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(oN));let e=this.spherical.phi%GZ;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(Et.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),e>0&&e>Math.PI||e<0&&e>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0){let r=this.hoverRotatePanMode===1?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-r,this.sphericalDelta.phi*=1-r}else this.sphericalDelta.set(0,0,0);return this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>HZ||8*(1-this.lastQuaternion.dot(this.object.quaternion))>jZ?(this.dispatchEvent(zZ),this.object.dispatchEvent(WZ),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=e=>{this.enabled!==!1&&(e.pointerType==="touch"||e.pointerType==="pen"&&Ai?this.onPointerDownTouch(e):this.onPointerDownMouse(e),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(ru),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),e.stopPropagation(),e.pointerType==="touch"||e.pointerType==="pen"&&Ai||this.domElement.setPointerCapture(e.pointerId)))};this.onPointerLeave=e=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,LM.subVectors(this.position0,this.target0),this.spherical.setFromVector3(LM),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=e};this.onPointerEnter=e=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?wb.set(e.clientX-this.domElement.clientWidth/2,e.clientY-this.domElement.clientHeight/2):wb.set(e.clientX-this.pointerLeaveEvent.clientX,e.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(wb).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(sN,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(e.clientX,e.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(wb).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(e.clientX,e.clientY)),this.update()};this.onPointerMove=e=>{this.enabled!==!1&&(this.checkRaycastLock()||(e.pointerType==="touch"||e.pointerType==="pen"&&Ai?this.onPointerMoveTouch(e):this.onPointerMoveMouse(e),e.stopPropagation()))};this.onPointerUp=e=>{this.isPointerDown=!1,$e.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),$e.length>1&&e.preventDefault(),this.hasChange?this.dispatchEvent(iu):this.dispatchEvent(kZ),this.state=-1,e&&(e.stopPropagation(),e.pointerType==="touch"||e.pointerType==="pen"&&Ai||this.domElement.releasePointerCapture(e.pointerId))};this.onPointerDownMouse=e=>{let r;switch(this.useKeyEvents?r=this.mouseButtons[e.button]:r=this.mouseButtonsPlay[e.button],r){case 0:if(e.altKey===!0&&!e.shiftKey&&!_p(e)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2;break;case 3:if(_p(e)||e.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}break;case 5:if(_p(e)||e.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;default:this.state=-1}};this.onPointerMoveMouse=e=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(e);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(e);break}this.object.wasMovedByUser=!0};this.onPointerDownTouch=e=>{switch($e.length>1&&e.preventDefault(),this.touches[$e.length-1]){case Yn.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Yn.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Yn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Yn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}};this.onPointerMoveTouch=e=>{switch($e.length>1&&e.preventDefault(),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(e),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(e),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(e),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(e),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0};this.dispatchEndDebounced=Ac(()=>this.dispatchEvent(iu),33);this.onMouseWheel=e=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||this.checkRaycastLock()||(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&e.preventDefault(),this.dispatchEvent(ru),this.handleMouseWheel(e),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0)};this.onGesture=e=>{if(e.preventDefault(),this.enabled!==!1&&!this.checkRaycastLock()&&!po)if(e.type==="gesturechange"){if(this.enableZoom===!1||this.isTouchZoom===!1)return;this.dispatchEvent(ru),e.scale>this.prevScale?this.dollyIn(this.getZoomScale()):e.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=e.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(iu)};this.onContextMenu=e=>{e.preventDefault()};this.onTouchEnd=e=>{e.preventDefault()};this.onKeyDown=e=>{this.enabled!==!1&&(this.key=e.key,e.key===" "&&this.dispatchEvent(ru))};this.onKeyUp=e=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&e.key==="Alt"&&this.onPointerUp($e[0]),e.key===" "&&this.dispatchEvent(iu))};this.onPointerHover=e=>{e.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(e,this.hoverRotatePanStrength):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(e,this.hoverRotatePanStrength))};this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1};this.onCompleteState=e=>{e.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.offset.copy(this.object.position).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(e){e.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(e)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(e){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=e,this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let r=this.useWindowEvents?window:this.domElement;r.addEventListener("pointerleave",this.onPointerLeave),r.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(e,r){this.setEnableDampingSpeed(e.enableDamping),this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableRotate=e.enableRotate,this.rotationLimitsMode=e.rotationLimitsMode,this.thetaIsFree=e.rotationHorizontalOffset.min===e.rotationHorizontalOffset.max&&e.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=e.rotationVerticalOffset.min===e.rotationVerticalOffset.max&&e.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=e.panLimitsMode,this.panSoftLimit=e.panSoftLimit,this.rotationSoftLimit=e.rotationSoftLimit,this.hoverRotatePanMode=e.hoverRotatePanMode,this.hoverRotateDamping=e.hoverRotateDamping??this.dampingFactor,this.useWindowEvents=r==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=e.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=e.zoomLimitsEnabled,this.minZoom=e.zoomLimits.min,this.maxZoom=Math.max(e.zoomLimits.min,e.zoomLimits.max),this.minDistance=1e3/e.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/e.zoomLimits.min),this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed,this.autoRotateClockwise=e.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(RM.copy(this.object.quaternion).invert());this.minV=-e.panVerticalOffset.min+s.y,this.maxV=e.panVerticalOffset.max+s.y,this.minH=-e.panHorizontalOffset.min+s.x,this.maxH=e.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Yo(this.spherical.phi-e.rotationVerticalOffset.min),this.maxPhi=Yo(this.spherical.phi+e.rotationVerticalOffset.max),this.minTheta=Yo(Yo(this.spherical.theta)-e.rotationHorizontalOffset.min),this.maxTheta=Yo(Yo(this.spherical.theta)+e.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,e.orbitTouches===1&&(this.touches[0]=Yn.ROTATE),e.panTouches===1&&(this.touches[0]=Yn.PAN),e.orbitTouches===2&&(this.touches[1]=Yn.DOLLY_ROTATE),e.panTouches===2&&(this.touches[1]=Yn.DOLLY_PAN),e.orbitTouches===3&&(this.touches[2]=Yn.ROTATE),e.panTouches===3&&(this.touches[2]=Yn.PAN),this.isTouchZoom=e.isTouchZoom,this.resetHoverEffectOnPointerLeave=e.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(e,r,i,s,o,a,l,c){this.overShoot.set(0,0);let u,h,d;e instanceof E?(u=e.x,h=e.y,this.current.set(this.target.x,this.target.y),d=!0):(u=e.theta,h=e.phi,this.current.set(Yo(this.spherical.theta),Yo(this.spherical.phi)),d=!1),i===0&&(this.current.x+=u,this.current.y+=h),(r===3||r===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(r===3||r===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y)),d||(this.overShoot.x=Yo(this.overShoot.x),this.overShoot.y=Yo(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(c),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=aN(Math.abs(this.overRatio.x)),this.overRatio.y=aN(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(u*this.overShoot.x<0&&!this.thetaIsFree&&(u*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):i===2&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(u=this.overShoot.x*.05),this.phiIsFree||(h=this.overShoot.y*.05),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(u+=this.overShoot.x,h+=this.overShoot.y),e instanceof E?(e.x=u,e.y=h):(this.thetaIsFree||(e.theta=u),this.phiIsFree||(e.phi=h))}setEnableDampingSpeed(e){this.enableDamping=e,this.rotateSpeed=e===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}panLeft(e,r){this.panLeftV.setFromMatrixColumn(r,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)}panUp(e,r){this.panUpV.setFromMatrixColumn(r,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)}pan(e,r){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*o/i.clientHeight,this.object.matrixWorld),this.panUp(2*r*o/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(r*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(UZ)}dollyOut(e){this.object.isPerspectiveCamera?this.scale/=e:this.object.isOrthographicCamera&&(this.object.zoom*=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(nN)}dollyIn(e){this.object.isPerspectiveCamera?this.scale*=e:this.object.isOrthographicCamera&&(this.object.zoom/=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(nN)}zoomOut(e=this.getZoomScale()){this.dispatchEvent(ru),this.dollyOut(e),this.dispatchEvent(iu)}zoomIn(e=this.getZoomScale()){this.dispatchEvent(ru),this.dollyIn(e),this.dispatchEvent(iu)}setZoom(e){if(this.dispatchEvent(ru),this.object.isPerspectiveCamera){let i=this.initialSphericalRadius/e/this.spherical.radius;this.scale=i}else this.object.isOrthographicCamera&&(this.object.zoom=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(iu)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e,r=1){e.movementX!==void 0?this.rotateDelta.set(e.movementX,e.movementY):(this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*r).rotateAround(sN,-this.object.angleOffsetFromUp);let i=this.domElement,s=this.useWindowEvents?window.innerHeight:i.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e,r=1){e.movementX!==void 0?this.panDelta.set(e.movementX,e.movementY):(this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*r),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(e){if(b2===!1&&_p(e)===!1&&w2(e)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-e.deltaX,-e.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),e.altKey?this.pan(0,this.panDelta.y):e.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1||this.gesture)return;e.deltaY===0?e.deltaX<0?this.dollyIn(this.getZoomScale()):e.deltaX>0&&this.dollyOut(this.getZoomScale()):e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if($e.length===2){let e=.5*($e[0].pageX+$e[1].pageX),r=.5*($e[0].pageY+$e[1].pageY);this.rotateStart.set(e,r)}else this.rotateStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartPan(){if($e.length===2){let e=.5*($e[0].pageX+$e[1].pageX),r=.5*($e[0].pageY+$e[1].pageY);this.panStart.set(e,r)}else this.panStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartDolly(){let e=$e[0].pageX-$e[1].pageX,r=$e[0].pageY-$e[1].pageY,i=Math.sqrt(e*e+r*r);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(e){if($e.length===2){let i=rv(e),s=.5*(e.pageX+i.x),o=.5*(e.pageY+i.y);this.rotateEnd.set(s,o)}else{if(e.pointerId!==$e[0].pointerId)return;this.rotateEnd.set(e.pageX,e.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let r=this.domElement;r&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/r.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/r.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if($e.length===2){let r=rv(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this.panEnd.set(i,s)}else{if(e.pointerId!==$e[0].pointerId)return;this.panEnd.set(e.pageX,e.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){let r=rv(e),i=e.pageX-r.x,s=e.pageY-r.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let e=this.options?.showCameraLock;return e&&e(),!0}}else return!1}};function Yo(n){let t=Math.PI*2;for(;n<=-Math.PI;)n+=t;for(;n>Math.PI;)n-=t;return n}function aN(n){return 1-Math.pow(1-n,4)}var dg=class{constructor(t,e,r,i,s,o){this.id=t;this.data=e;this.object=r;this.page=i;this.currentIntersectedObjects=[];this.actions=wr(e,e.actions,i,s,o,r),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let l=i.scene.find(a);l&&this.triggeringObjects.push(l)}}isValidTriggeringObject(t){return this.target==="all"?!0:this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){cr(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()))}};var Ut;R2.then(n=>Ut=n);var mi=new E,no=new Qe,$l=new E,NM=new rr(0,0,0,"YXZ"),lN=new rr(0,0,0,"XYZ"),so=new E,FM=new E,VM=new E(1,1,1),Vf=new Qe,Eb=new ce,cN=new ce,qZ={type:"updateMatrix"},uN=new Qe,zM=new Dr,sb={type:"beginEvent",eventName:"Collision"},YZ={type:"beginEvent",eventName:"Trigger"};function hN(n){if(Al.physicsEnabled(n.scene.objects))return!0;let t=!1;return n.scene.objects.traverse((e,r)=>{if(r.events){if(Array.isArray(r.events)){for(let i of r.events)if(i.data.disabled!==!0&&i.data.type==="GameControl"&&i.data.collisionEnabled){t=!0;break}}else for(let i of Object.values(r.events))if(i.disabled!==!0&&i.type==="GameControl"&&i.collisionEnabled){t=!0;break}}}),t}var hg=n=>n.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0),Mb=class{constructor(t){this.eventContext=t;this.isEnabled=!1;this.gameControl=null;this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}};this.sensorToTriggerEvent={};this.eventManager=void 0;this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.collisionEvents=[];this.isExport=!1;this.processRigidBody=t=>{if(t.bodyType()!==Ut.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,r,i]=this.rigidBodyToMesh.get(t.handle);if(mi.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),no.copy(t.rotation()),e.matrixWorld.compose(mi,no,r),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(qZ),i){let s=e.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(e.matrixWorld);for(let o of s.children)o.updateMatrixWorld(!0)}for(let o of e.children)o.updateMatrixWorld(!0)}};this.accumulator=0;this.handleCollisionEvents=(t,e,r)=>{if(r===!1)return;let i,s;if(this.sensorToTriggerEvent[t]?(i=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(i=this.sensorToTriggerEvent[e],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),i&&s&&i.isValidTriggeringObject(s)){i.dispatch();return}for(let o=this.sharedGameControlGlobals.createdObjects.length-1;o>=0;o--){let a=this.sharedGameControlGlobals.createdObjects[o];if(a.userData.hasCollisionDestroy&&(a.rigidBody?.collider(0).handle===t||a.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(o,1),a.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(a.rigidBody));break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a===void 0)return;for(let l of a)l.data.target==="character"&&this.dispatchCollisionEvent(l,o,e)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let o=this.sharedGameControlGlobals.colliderToEntity.get(t),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a===void 0)return;for(let l of a)l.data.target==="character"&&this.dispatchCollisionEvent(l,o,t)}else{let o=this.sharedGameControlGlobals.colliderToEntity.get(t),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a!==void 0)for(let u of a)u.data.target==="scene"&&this.dispatchCollisionEvent(u,o,t);let l=this.sharedGameControlGlobals.colliderToEntity.get(e),c=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(c!==void 0)for(let u of c)u.data.target==="scene"&&this.dispatchCollisionEvent(u,l,e)}};this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=dM,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}attachVRControllers(t){t.forEach(e=>{e.addEventListener("connected",r=>{"gamepad"in r.data&&"axes"in r.data.gamepad&&this.sharedGameControlGlobals.gamePads.push(r.data.gamepad)})})}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let r of e.events){if(r.data.disabled===!0)continue;let i=r.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(i)for(let s of i.objects){let o=this.page.scene.find(s);o&&(o.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let r of e.events)if(!(r.data.disabled===!0||r.data.type!=="DragDrop"))for(let i of r.data.objects){let s=this.page.scene.find(i);s&&(s.userData.hasDrag=!0)}})}initBVH(){let t=[];if(this.page.traverseChildren(e=>{let r,i=e instanceof zl,s=e instanceof Xl;if(e instanceof Ui||i||s)return;e instanceof Rr?r=e.object:r=e;let o=r.dataPatched;if(o.physics?.enabled==="visibility"?!o.visible:!o.physics?.enabled)return!0;let a=e.geometry,l=r.userData.hasDestroy===!0,c=r.userData.hasDrag===!0;if(hg(o)||l||c||r.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return e.updateMatrixWorldSVD(),this.addBoundsTree(e),!0;a&&t.push(ro(a,e.matrixWorld))}),t.length>0){let e=Us(t,!1);this.sharedGameControlGlobals.staticMeshBVH=new To(e)}}addRigidBody(t,e,r){let i=[],s="geometry"in t?t.geometry:void 0,o=e.dataPatched;if(s?.getAttribute("position")!==void 0&&i.push(ro(s,t.shearScale)),o.physics.fusedBody){let a=this.gatherChildrenGeom(t,i);t.traverseObject(a),t.children.forEach(c=>c.updateMatrixWorld(!0));let l=t.cloner;l&&l.objectForSample===void 0&&o.physics.rigidBody==="dynamic"&&(l.traverseObject(a),l.children.forEach(c=>c.updateMatrixWorld(!0)))}if(i.length>0){let a,l=!r.fromCreate&&o.physics.rigidBody==="dynamic"||r.fromCreate&&r.dynamic;l?(a=Ut.RigidBodyDesc.dynamic(),a.setLinearDamping(o.physics.damping).setAngularDamping(o.physics.damping).setAdditionalMass(1e-9).setGravityScale(o.physics.gravityScale).enabledRotations(...o.physics.enabledRotation).enabledTranslations(...o.physics.enabledTranslation)):(r.hasTransformAnim||r.hasFollow||r.hasDrag)&&!r.fromCreate?(a=Ut.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):a=Ut.RigidBodyDesc.fixed();let c=Us(i);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(mi,no,$l),t.position0=mi.clone().divideScalar(this.pixelsPerMeter),t.rotation0=no.clone(),mi.divideScalar(this.pixelsPerMeter),a.setTranslation(mi.x,mi.y,mi.z).setRotation(no),s?c?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):c?.scale($l.x/this.pixelsPerMeter,$l.y/this.pixelsPerMeter,$l.z/this.pixelsPerMeter);let u=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a);l&&this.rigidBodyToMesh.set(u.handle,[t,$l.clone(),o.physics.fusedBody]);let h=!(o.geometry===void 0||o.geometry.type==="SubdivGeometry"||o.geometry.type==="NonParametricGeometry"||o.geometry.type==="BooleanGeometry"||o.geometry.type==="VectorGeometry"||o.geometry.type==="StarGeometry"||o.geometry.type==="RectangleGeometry"||o.geometry.type==="EllipseGeometry"||o.geometry.type==="TriangleGeometry"||o.geometry.type==="TorusGeometry"||o.geometry.type==="HelixGeometry");try{this.addCollider(u,o.physics,c,e,h)}catch{try{this.addCollider(u,o.physics,c,e,!1)}catch(f){console.error(f)}}t.rigidBody=u}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(ro(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(r=>r.updateMatrixWorld(!0)),e.length>0){let r=Us(e,!1);t.bvhGeometry=r,r.getAttribute("position").count>0?(t.bvhGeometry.boundsTree=new To(r),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):!1&&console.warn(`ControlsManager.addBoundsTree: object "${t.name}" has empty geometry`)}}addCollider(t,e,r,i,s=!0){if(r?.getAttribute("position").count===0||r?.getIndex()?.count===0)return;let o;r&&(e.colliderType==="trimesh"?o=Ut.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array):o=Ut.ColliderDesc.convexMesh(r.getAttribute("position").array,s?r.getIndex().array:void 0)),o.setFrictionCombineRule(Ut.CoefficientCombineRule.Average).setRestitutionCombineRule(Ut.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,i),this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid]?.some(l=>l.target==="scene")&&a.setActiveEvents(Ut.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){return(r,i)=>{if(i===0)return;let s;if(r instanceof Ui)if(r.objectForSample){if(r.objectForSample.dataPatched.physics.fusedBody)return;s=r.object}else return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(r instanceof Rr)s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let o=s.dataPatched;if(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)return!0;i===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let a=r.geometry;a?.getAttribute("position")!==void 0&&e.push(ro(a,r.matrixWorld))}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,r=!1,i=5,s=8,o=9,a="drag",l=this.page.data.publish.gameControlObject,c=l!==null?this.page.find(l):null,u=null;if(c)for(let f of c.data.events){if(f.data.disabled||f.data.type!=="GameControl")continue;let p=c;for(;this.usePhysics&&(p=p.parent)?.parent!==null;)p.data.physics?.fusedBody;f.data.collisionEnabled&&(this.needsCollisionDetection=!0),u===null&&(u=f.data)}if(this.page.traverseEntity(f=>{for(let p of f.dataPatched.events)if(p.data.disabled===!1&&p.data.type==="Trigger")return this.needsCollisionDetection=!0,!0}),c&&u&&(c.data.visible===!0||c.data.physics.enabled===!0)){r=r||u.camera===e.uuid||c.uuid===e.uuid;let f=new ng(c,this.renderer.domElement,u,this.eventContext.page.data.globalPhysics,this,c.uuid!==e.uuid&&u.camera===e.uuid,e,this.page,this.sharedAssets);this.gameControl=f,i=u.joystickPosLoc,s=u.joystickRotLoc,o=u.jumpTouchButtonLoc,a=u.rotByTouch,Ai&&u.touchControl&&(this.joystickToGameControls[i]="pos",u.moveMode==="walk"&&(this.joystickToGameControls[o]="jmp"),a==="joystick"&&(this.joystickToGameControls[s]="rot"))}if(this.gameControl&&this.gameControl.data.navmesh.enabled){let f=this.gameControl.data;if(!this.navigationMeshWrapper){this.navigationMeshWrapper=new Sb(this.usePhysics,this.isExport);let p;f.collider.type==="sphere"?p=f.collider.radius*2:p=f.collider.height,p=Math.floor(p/f.navmesh.ch-1),this.navigationMeshWrapper.init({...f.navmesh,walkableHeight:p},this.gameControl,this.eventContext)}}if(r===!1){let{enableRotate:f,enablePan:p,enableZoom:m,autoRotate:g,hoverRotatePanMode:y}=this.eventManager.publish.orbitControls;(f||p||m||g||y!==0)&&(this.orbitControls=new Ff(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let h=this.renderer.domElement.width/this.renderer.getPixelRatio(),d=this.renderer.domElement.height/this.renderer.getPixelRatio();this.joystickToGameControls.forEach((f,p)=>{let m=document.body.appendChild(document.createElement("div")),[g,y,v]=this.eventManager.eventContext.publish.joystickSizeAndXYOffset[p],x=(h-5*g)/4+g,S={},w=f==="jmp",A=w?0:g;p<10?(p<5?S.top=A/2:S.bottom=A/2,S.left=A/2+p%5*x):p===10?(S.left=A/2,S.top=d/2):(S.right=A/2,S.top=d/2),S.top?S.top-=y[1]:S.bottom+=y[1],S.left?S.left+=y[0]:S.right-=y[0];for(let T in S)S[T]+="px";if(w){let T=m.appendChild(document.createElement("div"));Object.assign(T.style,S,{position:"absolute",width:g+"px",height:g+"px",backgroundColor:`rgba(255,255,255,${v==="show"?.4:0})`,zIndex:"9999",borderRadius:g+"px",border:v==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let C=g/16*16*.4;v==="show"&&(T.innerHTML=`
<svg width="${C}" height="${g*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`),T.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),T.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[p]=[void 0,m];return}let M={zone:m,mode:"static",position:S,size:g};v==="hide"&&(M.restOpacity=0);let b=GL.create(M);b.on("move",(T,C)=>{let P=this.gameControl;f==="pos"?C.force<.2?P.moveForce=0:(P.movementState.movePosZ=Math.sin(-C.angle.radian),P.movementState.movePosX=Math.cos(-C.angle.radian),C.force>1.2?P.movementState.run=1:P.movementState.run=0,C.force<.3?P.moveForce=(C.force-.2)/.1:P.moveForce=1):f==="rot"&&(C.force<.2?P.rotForce=0:(P.movementState.rotPosX=C.vector.y,P.movementState.rotPosY=-C.vector.x,C.force<.3?P.rotForce=(C.force-.2)/.1:P.rotForce=1)),this.requestRender()}),b.on("end",(T,C)=>{let P=this.gameControl;f==="pos"?(P.movementState.movePosZ=0,P.movementState.movePosX=0,P.moveForce=1):f==="rot"&&(P.movementState.rotPosX=0,P.movementState.rotPosY=0,P.rotForce=1)}),this.joysticks[p]=[b,m]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Ut.World(new Ut.Vector3(0,this.gravity,0)),this.events=new Ut.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Ui)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof Rr)l=a.object;else{if(a instanceof Xl||a instanceof zl)return;if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0}let c=l.dataPatched,u;for(let y of c.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(u=y.data);if(!c.physics||(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=hg(c),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,m=!1;for(let y of c.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let v=new xb(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.initialDisabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){m=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(u!==void 0){let y=Ut.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(mi,no,$l),a.position0=mi.clone().divideScalar(this.pixelsPerMeter),a.rotation0=no.clone(),mi.divideScalar(this.pixelsPerMeter),y.setTranslation(mi.x,mi.y,mi.z).setRotation(no);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;u.collider.type==="sphere"?x=Ut.ColliderDesc.ball(u.collider.radius/this.pixelsPerMeter):u.collider.type==="capsule"?x=Ut.ColliderDesc.capsule((u.collider.height/2-u.collider.radius)/this.pixelsPerMeter,u.collider.radius/this.pixelsPerMeter):x=Ut.ColliderDesc.cuboid(u.collider.width/this.pixelsPerMeter/2,u.collider.height/this.pixelsPerMeter/2,u.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(Ut.CoefficientCombineRule.Average).setRestitutionCombineRule(Ut.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(c.physics.restitution);let S=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(S.handle,l),mi.fromArray(u.collider.position).multiply($l.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),S.setTranslationWrtParent(mi);let w=new Qe().setFromEuler(new rr().setFromVector3(new E().fromArray(u.collider.rotation)));S.setRotationWrtParent(w),S.setActiveEvents(Ut.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else c.physics.rigidBody==="dynamic"||h||m||f||p||d?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,c.physics.fusedBody)):(g&&t.push(ro(g,a.matrixWorld)),c.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof Ui)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(y instanceof Xl||y instanceof zl)return;if(y instanceof Rr)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0}let S=x.dataPatched;if(S.physics.enabled==="visibility"?!S.visible:!S.physics.enabled)return!0;let w=y.geometry;w?.getAttribute("position")!==void 0&&t.push(ro(w,y.matrixWorld))}),this.generateSensorColliderDescs(l,c.physics.fusedBody,e));if(c.physics?.fusedBody===!0||u)return!0}),t.length===0)return;let r=Us(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let i=Ut.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(i),o=Ut.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(Ut.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Ut.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let c=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[c.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let r=new dg(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),i=new ce().compose(so.fromArray(e.data.position),Vf.setFromEuler(lN.fromArray(e.data.rotation)),VM);if(e.data.triggerZone==="box"){let s=new Gt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,i,t,r])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,i,t,r])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,r){if(!this.isEnabled)return!0;let i=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(i=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,i=!1):this.initializationCounter===2&&this.gameControl&&(i=!this.gameControl.update(t,e,r)&&i),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)i=this.stepPhysics()&&i;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,c=6;for(;this.accumulator>=s&&l<c&&(i=this.stepPhysics()&&i,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return i}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(mi,no,$l),NM.setFromQuaternion(no);let r=e;r.prevR===void 0?(r.prevR=NM.clone(),r.prevT=mi.clone()):(r.prevR.copy(NM),r.prevT.copy(mi)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(mi.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(no))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,r){let i=(this.sharedGameControlGlobals.rapierWorld?.getCollider(r))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===i){s=o;break}}t.dispatch(s),e.dispatchEvent(sb)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let i=cN.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new dg(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),c;if(a.data.triggerZone==="box"?c=Ut.ColliderDesc.cuboid(...a.data.size.map(u=>u/(2*this.pixelsPerMeter))):c=Ut.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),c.setDensity(0).setSensor(!0).setActiveEvents(Ut.ActiveEvents.COLLISION_EVENTS),so.fromArray(a.data.position),Vf.setFromEuler(lN.fromArray(a.data.rotation)),Eb.compose(so,Vf,VM).premultiply(s.matrixWorld),r?(Eb.decompose(so,Vf,FM),c.setActiveCollisionTypes(Ut.ActiveCollisionTypes.KINEMATIC_FIXED|Ut.ActiveCollisionTypes.DYNAMIC_FIXED)):(Eb.premultiply(i).decompose(so,Vf,FM),t.rigidBody.bodyType()===Ut.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Ut.RigidBodyType.Fixed?c.setActiveCollisionTypes(Ut.ActiveCollisionTypes.KINEMATIC_FIXED|Ut.ActiveCollisionTypes.DYNAMIC_FIXED):c.setActiveCollisionTypes(Ut.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Ut.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),so.divideScalar(this.pixelsPerMeter),c.setTranslation(so.x,so.y,so.z),c.setRotation(Vf),r)r.push([c,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(c,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[r,i,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(yt.is(l)?l:l.object)===!1)continue;let c=cN.copy(s.matrixWorld).decompose(so,uN,FM).compose(so,uN,VM).multiply(i),u=Eb.copy(l.matrixWorld).invert().multiply(c);r instanceof Gt?t=l.bvhGeometry.boundsTree.intersectsBox(r,u):(zM.radius=r,zM.center.setFromMatrixPosition(u),t=l.bvhGeometry.boundsTree.intersectsSphere(zM)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(YZ)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function dN(n){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,i=this.time+n,s=this._loopCount,o=r===xp;if(n===0)return s===-1?i:o&&(s&1)===1?t-(i-e):i;if(r===sw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:n<0?-1:1})}}else{if(s===-1&&(n>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<e){let a=Math.floor((i-e)/(t-e));i-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(i=n>0?t:e,this.repetitions===1&&(i=t)),this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:n>0?1:-1});else{if(l===1){let c=n<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-(i-e)}return i}var fN=!1,Tb=class{constructor(t,e,r,i){this.scene=t;this.requestRender=e;this.updateDisplayProgress=r;this.animationInspectorState=i;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,r)=>{let i=e[0]+"/";if(Array.isArray(t.identity)?i+=t.identity[0]:i+=t.uuid,this.clipIdToAction[i])return;let s=Gu.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);fN===!1&&(Object.getPrototypeOf(o)._updateTime=dN,fN=!0),o.clampWhenFinished=!0,this.clipIdToAction[i]=o})};this.mixer=new my(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let r=this.scene.find(e);if(!r)return;let i=r.animations.find(o=>o.uuid===t);if(!i)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(i),delete this.clipIdToAction[t],r.animations=r.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=ow}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,r=this.clipIdToAction[e];if(!!r)return t&&(t.repeat>=0&&(r.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(r.loop=xp)),r.play(),r.paused=!1,this.requestRender(),r}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let r=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),r&&(this.clipIdToAction[e].paused=!0)}};var UM=new WeakMap,Cb=class extends rl{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,i){let s=new ju(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(i)},r,i)}decodeDracoFile(t,e,r,i){let s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!r};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let r=JSON.stringify(e);if(UM.has(t)){let l=UM.get(t);if(l.key===r)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,u)=>{i._callbacks[s]={resolve:c,reject:u},i.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),UM.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new _e;t.index&&e.setIndex(new Xe(t.index.array,1));for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r],s=i.name,o=i.array,a=i.itemSize;e.setAttribute(s,new Xe(o,a))}return e}_loadLibrary(t,e){let r=new ju(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((i,s)=>{r.load(t,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{let i=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let s=XZ.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function XZ(){let n,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":n=a.decoderConfig,t=new Promise(function(u){n.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(n)});break;case"decode":let l=a.buffer,c=a.taskConfig;t.then(u=>{let h=u.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,c),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in u){let y=self[h[g]],v,x;if(c.useUniqueIDs)x=u[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(i(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=r(o,a,d)),o.destroy(d),m}function r(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,u,h){let d=h.num_components(),p=l.num_points()*d,m=p*u.BYTES_PER_ELEMENT,g=s(o,u),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new u(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:c,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var ec;function pN(){return ec||(ec=new Cb,ec.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ec.decoderPending}async function QZ(n){if(ec){let t={attributeIDs:ec.defaultAttributeIDs,attributeTypes:ec.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ec.decodeGeometry(new Int8Array(n).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,i])=>({name:r,itemSize:i.itemSize,array:i.array}))}}return null}async function mN(n,t){let[e,r]=zw(Sv.deserialize(new Uint8Array(n)));return Gv(e),t&&t(e),r.result().data}function gN(n){let t=[];return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function yN(n){for(let t of n){let e=await QZ(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let i={};e.attributes.forEach(({name:s,array:o,itemSize:a})=>{i[s]={array:o,itemSize:a,type:"Float32Array",normalized:!1}}),r.attributes=i,r.draco=void 0}}}var kM=class{constructor(t,e,r,i,s,o,a,l){this.eventId=t;this.id=e;this.data=r;this.dataEvent=i;this.object=s;this.stage=!1;this.actions=wr(i,r.actions,o,a,l,s)}disconnect(){cr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},Pb=class extends Lr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(i=>{let s=Mv.deviceToSize(i.data.size),o=i.dataEvent.orientation==="horizontal"?e:r,a;switch(i.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}i.stage!==a&&(i.stage=a,i.stage?i.dispatchIn():i.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:i,height:s}=r.contentRect;this.resize(i,s)}})}connect(){let{page:e,sharedAssets:r,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let s=o=>{if(!(!o.visible||!o.data?.events.length))for(let{data:a,id:l}of o.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:c,id:u})=>{try{let h=new kM(l,u,c,a,o,e,r,this.eventManager);this.breakpoints.push(h)}catch(h){!1&&console.log(h)}})};e.traverseEntity(o=>{(o instanceof Sr||o instanceof lr)&&o.frame?.traverse(a=>{s(a)}),s(o)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var _b=class{constructor(t,e,r,i,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=i;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{let e=window.parent!==window,r=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(t.touches.length>1||this.preventTouchScroll||e===!1&&r===!1)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:i}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:i-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=i.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new lb(this.eventContext),["VariableChange"]:new bb(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new hb(this.eventContext,this),["Start"]:new vb(this.eventContext,this),Basic:new cb(this.eventContext,this,this.needsRaycast),["MouseHover"]:new gb(this.eventContext,this),["Scroll"]:new yb(this.eventContext,this),["Follow"]:new fb(this.eventContext,this),["DragDrop"]:new db(this.eventContext,this),["LookAt"]:new mb(this.eventContext),["Resize"]:new Pb(this.eventContext,this)};let{page:t,domElement:e}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let i of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in i&&Array.isArray(i.id)&&(i.id[0]==="mouse"&&(this.needsMouse=!0),i.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length)for(let i of r.data.events)if(i.data.type==="VariableChange"&&(i.data.variableId==="mouseProperty"&&(this.needsMouse=!0),i.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),i.data.type==="Conditional")for(let s of["inActions","outActions"])i.data[s].forEach(e);else if(i.data.type==="DragDrop")for(let s of["drag","drop"])i.data.dragDropActions[s].forEach(e);else if(i.data.type==="GameControl")for(let s of["idle","move","jump","run"])i.data.gameActions[s].forEach(e);else if(i.data.type==="Resize")for(let s of i.data.breakpoints)s.data.actions.forEach(e);else i.data.type==="LookAt"||i.data.actions.forEach(e)})}};var Db=class{constructor(t,e,r,i,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new U().copy(r),this._editorSize=new U().copy(i),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,i=this._fov;if(t&&e>r){let s=KZ(e,1080,2160,1,15)/100;i*=e/r,i*=1-s}this._camera.aspect=this._aspect,this._camera.fov=i,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function KZ(n,t,e,r,i){return(n-t)/(e-t)*(i-r)+r}var Ob=class{get sharedAssets(){return this.shared}constructor(t,e={},r=!0){this.shared=new Hc(t.shared,e,!0,r),this.scene=new Gl(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof lr&&!t.uiScene&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof ar&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Ib=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function ZZ(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}function fg(n){return n instanceof Qs?"SubdivObject":n.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function JZ(n,t){let e={};return n.traverseEntity(r=>{if(!r.visible||!(r instanceof dr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let i=r.parent;for(;i;){if(i instanceof dr&&r.states&&Object.keys(r.states).length)return;i=i.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!ei.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!ei.isMergable(c.material))return;s=ei.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][fg(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][fg(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][fg(r)].push(c)}),e}function $Z(n){let t=0;return Object.values(n).forEach(e=>{Object.values(e).forEach(r=>{let i=r.length;i>t&&(t=i)})}),t}function vN(n,t){let e=JZ(t,n),r=$Z(e),i=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),c=0,u=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,c=0,p.forEach(g=>{g instanceof dr&&(o[a++]=g.geometry.clone(),l[c++]=g)}),c<2)continue;for(let g=0;g<c;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&ZZ(o[g]);let m=Us(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Xt(m,l[0].material);break}default:{g=new Xt(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof dr&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][fg(x)]&&e[x.material.uuid][fg(x)].length>1||(u[h++]=x));for(let x=0;x<h;x++)t.attach(u[x])};for(let v=0;v<c;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var SN=Ko(bN(),1);var tJ=new U;function rJ(n){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";n.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):n.endsWith(".splinecode")||console.warn(t)}var GM=class{constructor(t,{renderOnDemand:e,renderMode:r="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._variablesCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(e=>{e.type==="ParticleSystem"&&(e.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=tJ.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}};this._debouncedResize=Ac(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Ib({x:10,y:10})),C2(t)}async load(t,e,r){rJ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let i=await mN(t);this._data=i;let s=gN(i);i.version&&(0,SN.default)(i.version,"1.7.6")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([s.length&&pN(),dE(i)&&PI(),SR(i)&&SI(),Al.physicsEnabled(i.scene.objects)&&L2(),nE(i)&&mR(),Ux(i)&&UE(),dR(i)&&uR(),EE(i)&&F3(),IM(i)&&O2()].filter(Boolean)),s.length&&await yN(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new Ob(i);if(o.resetPersonalCameraFromDocumentData(),this._scene=o.scene,this._sharedAssetsManager=o.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let c=performance.now();vN(i,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}dE(i)&&this._scene.traverse(c=>{Sn(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Ui&&c.pendingMediaLoad&&c.update()})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop())});let a=Object.keys(i.shared.fonts).map(c=>this._sharedAssetsManager.getFont(c).loadingPromise);if(Promise.all(a).then(()=>{o.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),nE(i)&&hN(i)&&await Promise.all(a),EE(i)){let c=[];this._scene.traverseEntity(u=>{(u instanceof Sr||u instanceof lr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),Pf(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new yx({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),Ux(i)&&this._scene.initializeSplatViewer(),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData);let l=Object.values(i.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(l.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=l.size[0],this._viewportHeight=l.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Db(this._renderer,this._camera,new U(this._viewportWidth,this._viewportHeight),new U(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(l.allowResponsive??!1)&&l.preset==="fullscreen"),e){let c=new ab(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new Mb(c),this._animationControls=new Tb(this._scene,this._requestRenderAutoMode),this._eventManager=new _b(i.scene.publish,this._controls,this._animationControls,c,i.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,i]of e)this.setVariable(r,i)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let i=e;typeof r.data.value=="number"?i=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?i=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(i=e.toString());let s=typeof i=="string"?{textValue:i}:i;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&Ni.isTextValue(t)?Ni.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==hs&&!this._scene.isInvisibleObjects(e)&&!(e instanceof lr)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ff&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:i,a:s}={r:0,g:0,b:0,a:1},o=new mr(e,r,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Ew.unsubscribe(t)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),this.dt=0,P2(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof lr&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof lr||t instanceof Gl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},i=Ew(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,i),i}setUIWasmUrl(t){L0.skiaWasmUrl=t}};