var uN=Object.create;var mg=Object.defineProperty;var hN=Object.getOwnPropertyDescriptor;var dN=Object.getOwnPropertyNames;var fN=Object.getPrototypeOf,pN=Object.prototype.hasOwnProperty;var mN=(n,t,e)=>t in n?mg(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),gN=(n,t)=>{for(var e in t)mg(n,e,{get:t[e],enumerable:!0})},yN=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dN(t))!pN.call(n,i)&&i!==e&&mg(n,i,{get:()=>t[i],enumerable:!(r=hN(t,i))||r.enumerable});return n};var Ko=(n,t,e)=>(e=n!=null?uN(fN(n)):{},yN(t||!n||!n.__esModule?mg(e,"default",{value:n,enumerable:!0}):e,n));var ec=(n,t,e)=>(mN(n,typeof t!="symbol"?t+"":t,e),e);var sO=Qo((R1,nO)=>{(function(n,t){typeof R1=="object"?nO.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(R1,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>>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 B1=Qo((l0,cO)=>{(function(n,t){typeof l0=="object"&&typeof cO<"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{(function(n,t){typeof $1=="object"&&typeof eA<"u"?eA.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})($1,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=0)break;s[r]=u,r=c}s[r]=l};function t(e,r){return er?1:0}return n})});var VO=Qo((Ime,tA)=>{"use strict";var p0=NO();p0.default&&(p0=p0.default);tA.exports=FO;tA.exports.default=FO;function FO(n,t,e){t=t||1;for(var r,i,s,o,a=0;as)&&(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,L9),m=r;my.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 _l(S.x-d,S.y-d,d,n)),p.push(new _l(S.x+d,S.y-d,d,n)),p.push(new _l(S.x-d,S.y+d,d,n)),p.push(new _l(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 L9(n,t){return t.max-n.max}function _l(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=B9(n,t,r),this.max=this.d+this.h*Math.SQRT2}function B9(n,t,e){for(var r=!1,i=1/0,s=0;st!=h[1]>t&&n<(h[0]-u[0])*(t-u[1])/(h[1]-u[1])+u[0]&&(r=!r),i=Math.min(i,F9(n,t,u,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function N9(n){for(var t=0,e=0,r=0,i=n[0],s=0,o=i.length,a=o-1;s1?(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 FI=Qo((z0,NI)=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});z0.default=N7;function N7(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)}NI.exports=z0.default});var zI=Qo((U0,VI)=>{"use strict";Object.defineProperty(U0,"__esModule",{value:!0});U0.default=F7;function F7(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()}VI.exports=U0.default});var _3=Qo((X3e,P3)=>{"use strict";function gQ(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Yc(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,Yc)}gQ(Yc,Error);Yc.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var u="",h;for(h=0;h0){for(h=1,d=1;hae&&(ae=F,ge=[]),ge.push(I))}function ye(I,R){return new Yc(I,null,null,R)}function Me(I,R,X){return new Yc(Yc.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=Pt(),R!==e){for(X=[],z=F,ee=[],Pe=At();Pe!==e;)ee.push(Pe),Pe=At();for(ee!==e?(Pe=Pt(),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=Pt(),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 Pt(){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=Ob(),I===e&&(I=Ib(),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,iu;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=Nt(),z!==e?(ee=F,Pe=gt(),Pe===e&&(Pe=null),Pe!==e?(iu=Jn(),iu!==e?(Pe=[Pe,iu],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=Jn(),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 Jn(){var I,R,X,z,ee,Pe;if(I=F,R=Nt(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Nt(),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=Nt(),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=Vf(),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 Vf(){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 Ob(){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=Vf(),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 Ib(){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=Rb(),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 Rb(){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=Nt(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Nt(),z!==e?(ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Nt(),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=Nt(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Nt(),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=Nt(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(z=Nt(),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=Nt(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Nt(),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=Nt(),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=Bt(),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 Bt(){var I,R,X,z,ee,Pe;if(I=F,R=_t(),R!==e){for(X=[],z=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=_t(),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=_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,iu,Lb,fg,Bb,pg,Nb;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?(iu=gt(),iu!==e?(Lb=oo(),Lb!==e?(fg=gt(),fg===e&&(fg=null),fg!==e?(Bb=oo(),Bb!==e?(pg=gt(),pg===e&&(pg=null),pg!==e?(Nb=Nt(),Nb!==e?(N=I,R=W(R,z,Pe,Lb,Bb,Nb),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 Nt(){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=eu(),R===e&&(R=Vn()),R!==e&&(N=I,R=K(R)),I=R,I}function $i(){var I,R,X,z;return I=F,R=F,X=tu(),X===e&&(X=null),X!==e?(z=eu(),z!==e?(X=[X,z],R=X):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=tu(),X===e&&(X=null),X!==e?(z=Vn(),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=It(),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=It(),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 It(){var I;return n.charCodeAt(F)===44?(I=oe,F++):(I=e,me===0&&Q(ie)),I}function eu(){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=Vn(),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=Vn(),X===e&&(X=null),X!==e?(n.charCodeAt(F)===46?(z=J,F++):(z=e,me===0&&Q(we)),z!==e?(ee=Vn(),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=Vn(),X!==e?(n.charCodeAt(F)===46?(z=J,F++):(z=e,me===0&&Q(we)),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=tu(),z===e&&(z=null),z!==e?(ee=Vn(),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 tu(){var I;return Oe.test(n.charAt(F))?(I=n.charAt(F),F++):(I=e,me===0&&Q(Te)),I}function Vn(){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{var Mx=_3().parse;Mx.parseSVG=Mx;Mx.makeAbsolute=vQ;D3.exports=Mx;function vQ(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 aN=Qo((E6e,oN)=>{oN.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 oa="149";var Wn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},vN=0,LM=1,xN=2;var by=1,bN=2,Xf=3,kn=0,ui=1,ji=2;var Kt=0,Wa=1,BM=2,NM=3,FM=4,SN=5,vu=100,wN=101,AN=102,VM=103,zM=104,EN=200,MN=201,TN=202,CN=203,dC=204,fC=205,PN=206,_N=207,DN=208,ON=209,IN=210,RN=0,LN=1,BN=2,bS=3,NN=4,FN=5,VN=6,zN=7,pC=0,UN=1,kN=2,Ds=0,GN=1,jN=2,HN=3,WN=4,qN=5,mC=300,Ya=301,Xa=302,SS=303,wS=304,Hu=306,Os=1e3,Yt=1001,AS=1002,Ft=1003,UM=1004;var Fb=1005;var tt=1006,YN=1007;var lc=1008;var Cr=1009,XN=1010,QN=1011,gC=1012,KN=1013,_s=1014,yr=1015,Is=1016,ZN=1017,JN=1018,qa=1020,$N=1021,jr=1023,eF=1024,tF=1025,oc=1026,Qa=1027,rF=1028,iF=1029,Wu=1030,nF=1031,rw=1033,Vb=33776,zb=33777,Ub=33778,kb=33779,kM=35840,GM=35841,jM=35842,HM=35843,sF=36196,WM=37492,qM=37496,YM=37808,XM=37809,QM=37810,KM=37811,ZM=37812,JM=37813,$M=37814,eT=37815,tT=37816,rT=37817,iT=37818,nT=37819,sT=37820,oT=37821,Gb=36492,oF=36283,aT=36284,lT=36285,cT=36286,iw=2200,nw=2201,yp=2202,Wg=2300,qg=2301,jb=2302,xu=2400,bu=2401,Yg=2402,sw=2500,aF=2501;var cn=3e3,ot=3001,Ii=3200,ow=3201,lF=0,cF=1;var lo="srgb",tp="srgb-linear";var Hb=7680;var uF=519,ES=35044,yC=35048;var uT="300 es",MS=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>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 aw(n,t){return(n%t+t)%t}function hF(n,t,e,r,i){return r+(n-t)*(i-r)/(e-t)}function dF(n,t,e){return n!==t?(e-n)/(t-n):0}function Zf(n,t,e){return(1-e)*n+e*t}function fF(n,t,e,r){return Zf(n,t,1-Math.exp(-e*r))}function pF(n,t=1){return t-Math.abs(aw(n,t*2)-t)}function mF(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function gF(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function yF(n,t){return n+Math.floor(Math.random()*(t-n+1))}function vF(n,t){return n+Math.random()*(t-n)}function xF(n){return n*(.5-Math.random())}function bF(n){n!==void 0&&(hT=n);let t=hT+=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 SF(n){return n*Kf}function wF(n){return n*rp}function TS(n){return(n&n-1)===0&&n!==0}function vC(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 AF(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 Ee=Object.freeze({__proto__:null,DEG2RAD:Kf,RAD2DEG:rp,ceilPowerOfTwo:vC,clamp:ci,damp:fF,degToRad:SF,denormalize:na,euclideanModulo:aw,floorPowerOfTwo:Xg,generateUUID:rs,inverseLerp:dF,isPowerOfTwo:TS,lerp:Zf,mapLinear:hF,normalize:gr,pingpong:pF,radToDeg:wF,randFloat:vF,randFloatSpread:xF,randInt:yF,seededRandom:bF,setQuaternionFromProperEuler:AF,smootherstep:gF,smoothstep:mF}),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(Wb.makeScale(t,e)),this}rotate(t){return this.premultiply(Wb.makeRotation(-t)),this}translate(t,e){return this.premultiply(Wb.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)}},Wb=new vr;function xC(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}var EF={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function gg(n,t){return new EF[n](t)}function ip(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function ac(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 qb={[lo]:{[tp]:ac},[tp]:{[lo]:Hg}},on={legacyMode:!0,get workingColorSpace(){return tp},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(qb[t]&&qb[t][e]!==void 0){let r=qb[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)}},bC={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},Ts={h:0,s:0,l:0},yg={h:0,s:0,l:0};function Yb(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,on.toWorkingColorSpace(this,e),this}setRGB(t,e,r,i=on.workingColorSpace){return this.r=t,this.g=e,this.b=r,on.toWorkingColorSpace(this,i),this}setHSL(t,e,r,i=on.workingColorSpace){if(t=aw(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=Yb(o,s,t+1/3),this.g=Yb(o,s,t),this.b=Yb(o,s,t-1/3)}return on.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,on.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,on.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,on.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,on.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=lo){let r=bC[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=ac(t.r),this.g=ac(t.g),this.b=ac(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 on.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=on.workingColorSpace){on.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"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{nu===void 0&&(nu=ip("canvas")),nu.width=t.width,nu.height=t.height;let r=nu.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=nu}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=ip("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;o0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==mC)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Os:t.x=t.x-Math.floor(t.x);break;case Yt:t.x=t.x<0?0:1;break;case AS: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 Os:t.y=t.y-Math.floor(t.y);break;case Yt:t.y=t.y<0?0:1;break;case AS: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)}};Zt.DEFAULT_IMAGE=null;Zt.DEFAULT_MAPPING=mC;Zt.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 Zt(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 Zt{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=Ft,this.minFilter=Ft,this.wrapR=Yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Jg=class extends Zt{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=Ft,this.minFilter=Ft,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=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 rMath.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(dT.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(dT.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 Qb.copy(this).projectOnVector(t),this.sub(Qb)}reflect(t){return this.sub(Qb.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}},Qb=new E,dT=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;ls&&(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;ls&&(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;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,tc),tc.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(zf),xg.subVectors(this.max,zf),su.subVectors(t.a,zf),ou.subVectors(t.b,zf),au.subVectors(t.c,zf),Ua.subVectors(ou,su),ka.subVectors(au,ou),rc.subVectors(su,au);let e=[0,-Ua.z,Ua.y,0,-ka.z,ka.y,0,-rc.z,rc.y,Ua.z,0,-Ua.x,ka.z,0,-ka.x,rc.z,0,-rc.x,-Ua.y,Ua.x,0,-ka.y,ka.x,0,-rc.y,rc.x,0];return!Zb(e,su,ou,au,xg)||(e=[1,0,0,0,1,0,0,0,1],!Zb(e,su,ou,au,xg))?!1:(bg.crossVectors(Ua,ka),e=[bg.x,bg.y,bg.z],Zb(e,su,ou,au,xg))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return tc.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=this.getSize(tc).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],tc=new E,Kb=new Gt,su=new E,ou=new E,au=new E,Ua=new E,ka=new E,rc=new E,zf=new E,xg=new E,bg=new E,ic=new E;function Zb(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){ic.fromArray(n,s);let a=i.x*Math.abs(ic.x)+i.y*Math.abs(ic.y)+i.z*Math.abs(ic.z),l=t.dot(ic),c=e.dot(ic),u=r.dot(ic);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var TF=new Gt,Uf=new E,Jb=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):TF.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;sthis.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;Uf.subVectors(t,this.center);let e=Uf.lengthSq();if(e>this.radius*this.radius){let r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Uf,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):(Jb.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Uf.copy(t.center).add(Jb)),this.expandByPoint(Uf.copy(t.center).sub(Jb))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Jo=new E,$b=new E,Sg=new E,Ga=new E,eS=new E,wg=new E,tS=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){$b.copy(t).add(e).multiplyScalar(.5),Sg.copy(e).sub(t).normalize(),Ga.copy(this.origin).sub($b);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($b),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=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=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,Jo)!==null}intersectTriangle(t,e,r,i,s){eS.subVectors(e,t),wg.subVectors(r,t),tS.crossVectors(eS,wg);let o=this.direction.dot(tS),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(eS.cross(Ga));if(c<0||l+c>o)return null;let u=-a*Ga.dot(tS);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/lu.setFromMatrixColumn(t,0).length(),s=1/lu.setFromMatrixColumn(t,1).length(),o=1/lu.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(CF,t,PF)}lookAt(t,e,r){let i=this.elements;return zn.subVectors(t,e),zn.lengthSq()===0&&(zn.z=1),zn.normalize(),ja.crossVectors(r,zn),ja.lengthSq()===0&&(Math.abs(r.z)===1?zn.x+=1e-4:zn.z+=1e-4,zn.normalize(),ja.crossVectors(r,zn)),ja.normalize(),Ag.crossVectors(zn,ja),i[0]=ja.x,i[4]=Ag.x,i[8]=zn.x,i[1]=ja.y,i[5]=Ag.y,i[9]=zn.y,i[2]=ja.z,i[6]=Ag.z,i[10]=zn.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=lu.set(i[0],i[1],i[2]).length(),o=lu.set(i[4],i[5],i[6]).length(),a=lu.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],Cs.copy(this);let c=1/s,u=1/o,h=1/a;return Cs.elements[0]*=c,Cs.elements[1]*=c,Cs.elements[2]*=c,Cs.elements[4]*=u,Cs.elements[5]*=u,Cs.elements[6]*=u,Cs.elements[8]*=h,Cs.elements[9]*=h,Cs.elements[10]*=h,e.setFromRotationMatrix(Cs),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}},lu=new E,Cs=new ce,CF=new E(0,0,0),PF=new E(1,1,1),ja=new E,Ag=new E,zn=new E,fT=new ce,pT=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 fT.makeRotationFromQuaternion(t),this.setFromRotationMatrix(fT,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return pT.setFromEuler(this),this.setFromQuaternion(pT,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 np=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let r=0;r0&&(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(kf,t,DF),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(kf,OF,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;r0&&(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;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(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;r0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Ps.subVectors(i,e),ea.subVectors(r,e),rS.subVectors(t,e);let o=Ps.dot(Ps),a=Ps.dot(ea),l=Ps.dot(rS),c=ea.dot(ea),u=ea.dot(rS),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 Ps.subVectors(r,e),ea.subVectors(t,e),Ps.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 Ps.subVectors(this.c,this.b),ea.subVectors(this.a,this.b),Ps.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;uu.subVectors(i,r),hu.subVectors(s,r),iS.subVectors(t,r);let l=uu.dot(iS),c=hu.dot(iS);if(l<=0&&c<=0)return e.copy(r);nS.subVectors(t,i);let u=uu.dot(nS),h=hu.dot(nS);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(uu,o);sS.subVectors(t,s);let f=uu.dot(sS),p=hu.dot(sS);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(hu,a);let g=u*p-f*h;if(g<=0&&h-u>=0&&f-p>=0)return bT.subVectors(s,i),a=(h-u)/(h-u+(f-p)),e.copy(i).addScaledVector(bT,a);let y=1/(g+m+d);return o=m*y,a=d*y,e.copy(r).addScaledVector(uu,o).addScaledVector(hu,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},RF=0,cc=class extends hr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:RF++}),this.uuid=rs(),this.name="",this.type="Material",this.blending=Wa,this.side=kn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=dC,this.blendDst=fC,this.blendEquation=vu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=bS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=uF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hb,this.stencilZFail=Hb,this.stencilZPass=Hb,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!==kn&&(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++}},Gn=class extends cc{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=pC,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=ES,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;i0&&(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;h0&&(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;d0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;se.far?null:{distance:c,point:Dg.clone(),object:n}}function Og(n,t,e,r,i,s,o,a,l){n.getVertexPosition(o,jf),n.getVertexPosition(a,Hf),n.getVertexPosition(l,Wf);let c=BF(n,t,e,r,jf,Hf,Wf,cS);if(c){i&&(Cg.fromBufferAttribute(i,o),Pg.fromBufferAttribute(i,a),_g.fromBufferAttribute(i,l),c.uv=Mr.getUV(cS,jf,Hf,Wf,Cg,Pg,_g,new U)),s&&(Cg.fromBufferAttribute(s,o),Pg.fromBufferAttribute(s,a),_g.fromBufferAttribute(s,l),c.uv2=Mr.getUV(cS,jf,Hf,Wf,Cg,Pg,_g,new U));let u={a:o,b:a,c:l,normal:new E,materialIndex:0};Mr.getNormal(jf,Hf,Wf,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 Ce(c,3)),this.setAttribute("normal",new Ce(u,3)),this.setAttribute("uv",new Ce(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;q0?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;q0&&(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}},jn=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 jn{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=rp*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Kf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return rp*2*Math.atan(Math.tan(Kf*.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(Kf*.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}},pu=-90,mu=1,CS=class extends Et{constructor(t,e,r){super(),this.type="CubeCamera",this.renderTarget=r;let i=new Kr(pu,mu,t,e);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i);let s=new Kr(pu,mu,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let o=new Kr(pu,mu,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new Kr(pu,mu,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new Kr(pu,mu,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let c=new Kr(pu,mu,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=Ds,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}},Mu=class extends Zt{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}},PS=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 Mu(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 #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},i=new hi(5,5,5),s=new at({name:"CubemapFromEquirect",uniforms:Eu(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ui,blending:Kt});s.uniforms.tEquirect.value=e;let o=new tr(i,s),a=e.minFilter;return e.minFilter===lc&&(e.minFilter=tt),new CS(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)}},uS=new E,zF=new E,UF=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=uS.subVectors(r,e).cross(zF.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(uS),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||UF.getNormalMatrix(t),i=this.coplanarPoint(uS).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)}},gu=new Dr,Ig=new E,sp=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(),gu.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(gu)}intersectsSprite(t){return gu.center.set(0,0,0),gu.radius=.7071067811865476,gu.applyMatrix4(t.matrixWorld),this.intersectsSphere(gu)}intersectsSphere(t){let e=this.planes,r=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(r)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 wC(){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 kF(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 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`,ZF=`#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`,JF=`#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`,$F=`#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`,eV=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,tV=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,rV=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,iV=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,nV=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,sV=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,oV=`#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`,aV=`#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 ); }`,lV=`#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`,cV=`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`,uV=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,hV=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,dV=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,fV=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,pV="gl_FragColor = linearToOutputTexel( gl_FragColor );",mV=`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 ); }`,gV=`#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`,yV=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,vV=`#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`,xV=`#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`,bV=`#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`,SV=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,wV=`#ifdef USE_FOG varying float vFogDepth; #endif`,AV=`#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`,EV=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,MV=`#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 }`,TV=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,CV=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,PV=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,_V=`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`,DV=`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`,OV=`#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`,IV=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,RV=`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`,LV=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,BV=`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`,NV=`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`,FV=`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 ); }`,VV=` 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`,zV=`#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`,UV=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,kV=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,GV=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,jV=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,HV=`#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`,WV=`#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`,qV=`#ifdef USE_MAP uniform sampler2D map; #endif`,YV=`#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`,XV=`#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`,QV=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,KV=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,ZV=`#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`,JV=`#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`,$V=`#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`,ez=`#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`,tz=`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;`,rz=`#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`,iz=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,nz=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,sz=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,oz=`#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`,az=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,lz=`#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`,cz=`#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`,uz=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,hz=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dz=`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 ); }`,fz=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,pz=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,mz=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,gz=`#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`,yz=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,vz=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,xz=`#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`,bz=`#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`,Sz=`#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`,wz=`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; }`,Az=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,Ez=`#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`,Mz=`#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`,Tz=`#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`,Cz=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,Pz=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,_z=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,Dz=`#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; }`,Oz=`#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`,Iz=`#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`,Rz=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,Lz=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,Bz=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,Nz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,Fz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,Vz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,zz=`#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`,Uz=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,kz=`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 #include }`,Gz=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,jz=`#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 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 #include }`,Hz=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,Wz=`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 #include }`,qz=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,Yz=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include 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 }`,Xz=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,Qz=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,Kz=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,Zz=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,Jz=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,$z=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,eU=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,tU=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,rU=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,iU=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,nU=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,sU=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include 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 #include #include #include #include #include }`,oU=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,aU=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,lU=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,cU=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,uU=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,hU=`#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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include 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 #include #include #include #include #include }`,dU=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,fU=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,pU=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,mU=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,gU=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,yU=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,vU=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,xU=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,xt={alphamap_fragment:GF,alphamap_pars_fragment:jF,alphatest_fragment:HF,alphatest_pars_fragment:WF,aomap_fragment:qF,aomap_pars_fragment:YF,begin_vertex:XF,beginnormal_vertex:QF,bsdfs:KF,iridescence_fragment:ZF,bumpmap_pars_fragment:JF,clipping_planes_fragment:$F,clipping_planes_pars_fragment:eV,clipping_planes_pars_vertex:tV,clipping_planes_vertex:rV,color_fragment:iV,color_pars_fragment:nV,color_pars_vertex:sV,color_vertex:oV,common:aV,cube_uv_reflection_fragment:lV,defaultnormal_vertex:cV,displacementmap_pars_vertex:uV,displacementmap_vertex:hV,emissivemap_fragment:dV,emissivemap_pars_fragment:fV,encodings_fragment:pV,encodings_pars_fragment:mV,envmap_fragment:gV,envmap_common_pars_fragment:yV,envmap_pars_fragment:vV,envmap_pars_vertex:xV,envmap_physical_pars_fragment:OV,envmap_vertex:bV,fog_vertex:SV,fog_pars_vertex:wV,fog_fragment:AV,fog_pars_fragment:EV,gradientmap_pars_fragment:MV,lightmap_fragment:TV,lightmap_pars_fragment:CV,lights_lambert_fragment:PV,lights_lambert_pars_fragment:_V,lights_pars_begin:DV,lights_toon_fragment:IV,lights_toon_pars_fragment:RV,lights_phong_fragment:LV,lights_phong_pars_fragment:BV,lights_physical_fragment:NV,lights_physical_pars_fragment:FV,lights_fragment_begin:VV,lights_fragment_maps:zV,lights_fragment_end:UV,logdepthbuf_fragment:kV,logdepthbuf_pars_fragment:GV,logdepthbuf_pars_vertex:jV,logdepthbuf_vertex:HV,map_fragment:WV,map_pars_fragment:qV,map_particle_fragment:YV,map_particle_pars_fragment:XV,metalnessmap_fragment:QV,metalnessmap_pars_fragment:KV,morphcolor_vertex:ZV,morphnormal_vertex:JV,morphtarget_pars_vertex:$V,morphtarget_vertex:ez,normal_fragment_begin:tz,normal_fragment_maps:rz,normal_pars_fragment:iz,normal_pars_vertex:nz,normal_vertex:sz,normalmap_pars_fragment:oz,clearcoat_normal_fragment_begin:az,clearcoat_normal_fragment_maps:lz,clearcoat_pars_fragment:cz,iridescence_pars_fragment:uz,output_fragment:hz,packing:dz,premultiplied_alpha_fragment:fz,project_vertex:pz,dithering_fragment:mz,dithering_pars_fragment:gz,roughnessmap_fragment:yz,roughnessmap_pars_fragment:vz,shadowmap_pars_fragment:xz,shadowmap_pars_vertex:bz,shadowmap_vertex:Sz,shadowmask_pars_fragment:wz,skinbase_vertex:Az,skinning_pars_vertex:Ez,skinning_vertex:Mz,skinnormal_vertex:Tz,specularmap_fragment:Cz,specularmap_pars_fragment:Pz,tonemapping_fragment:_z,tonemapping_pars_fragment:Dz,transmission_fragment:Oz,transmission_pars_fragment:Iz,uv_pars_fragment:Rz,uv_pars_vertex:Lz,uv_vertex:Bz,uv2_pars_fragment:Nz,uv2_pars_vertex:Fz,uv2_vertex:Vz,worldpos_vertex:zz,background_vert:Uz,background_frag:kz,backgroundCube_vert:Gz,backgroundCube_frag:jz,cube_vert:Hz,cube_frag:Wz,depth_vert:qz,depth_frag:Yz,distanceRGBA_vert:Xz,distanceRGBA_frag:Qz,equirect_vert:Kz,equirect_frag:Zz,linedashed_vert:Jz,linedashed_frag:$z,meshbasic_vert:eU,meshbasic_frag:tU,meshlambert_vert:rU,meshlambert_frag:iU,meshmatcap_vert:nU,meshmatcap_frag:sU,meshnormal_vert:oU,meshnormal_frag:aU,meshphong_vert:lU,meshphong_frag:cU,meshphysical_vert:uU,meshphysical_frag:hU,meshtoon_vert:dU,meshtoon_frag:fU,points_vert:pU,points_frag:mU,shadow_vert:gU,shadow_frag:yU,sprite_vert:vU,sprite_frag:xU},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:ln([De.common,De.specularmap,De.envmap,De.aomap,De.lightmap,De.fog]),vertexShader:xt.meshbasic_vert,fragmentShader:xt.meshbasic_frag},lambert:{uniforms:ln([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:ln([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:ln([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:ln([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:ln([De.common,De.bumpmap,De.normalmap,De.displacementmap,De.fog,{matcap:{value:null}}]),vertexShader:xt.meshmatcap_vert,fragmentShader:xt.meshmatcap_frag},points:{uniforms:ln([De.points,De.fog]),vertexShader:xt.points_vert,fragmentShader:xt.points_frag},dashed:{uniforms:ln([De.common,De.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xt.linedashed_vert,fragmentShader:xt.linedashed_frag},depth:{uniforms:ln([De.common,De.displacementmap]),vertexShader:xt.depth_vert,fragmentShader:xt.depth_frag},normal:{uniforms:ln([De.common,De.bumpmap,De.normalmap,De.displacementmap,{opacity:{value:1}}]),vertexShader:xt.meshnormal_vert,fragmentShader:xt.meshnormal_frag},sprite:{uniforms:ln([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:ln([De.common,De.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xt.distanceRGBA_vert,fragmentShader:xt.distanceRGBA_frag},shadow:{uniforms:ln([De.lights,De.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:xt.shadow_vert,fragmentShader:xt.shadow_frag}};co.physical={uniforms:ln([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 bU(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===Hu)?(u===void 0&&(u=new tr(new hi(1,1,1),new at({name:"BackgroundCubeMaterial",uniforms:Eu(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!==ot,(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 tr(new un(2,2),new at({name:"BackgroundMaterial",uniforms:Eu(co.background.uniforms),vertexShader:co.background.vertexShader,fragmentShader:co.background.fragmentShader,side:kn,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!==ot,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,SC(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 SU(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=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=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,we=J.stride,xe=Z.offset;if(J.isInstancedInterleavedBuffer){for(let de=0;de0&&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 EU(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.length0){let c=new PS(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 Tu=class extends jn{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}},Su=4,wT=[.125,.215,.35,.446,.526,.582],sc=20,hS=new Tu,AT=new We,dS=null,nc=(1+Math.sqrt(5))/2,yu=1/nc,ET=[new E(1,1,1),new E(-1,1,1),new E(1,1,-1),new E(-1,1,-1),new E(0,nc,yu),new E(0,nc,-yu),new E(yu,0,nc),new E(-yu,0,nc),new E(nc,yu,0),new E(-nc,yu,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){dS=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=CT(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TT(),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;t2?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=CT()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=TT());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new tr(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,hS)}_applyPMREM(t){let e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let i=1;isc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${sc}`);let y=[],v=0;for(let M=0;Mx-Su?i-x+Su:0),A=4*(this._cubeSize-S);Lg(e,w,A,3*S,2*S),l.setRenderTarget(e),l.render(h,hS)}};function TU(n){let t=[],e=[],r=[],i=n,s=n-Su+1+wT.length;for(let o=0;on-Su?l=wT[o-n+Su-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;A2?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>Su&&i--}return{lodPlanes:t,sizeLods:e,sigmas:r}}function MT(n,t,e){let r=new dt(n,t,e);return r.texture.mapping=Hu,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 CU(n,t,e){let r=new Float32Array(sc),i=new E(0,1,0);return new at({name:"SphericalGaussianBlur",defines:{n:sc,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:lw(),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 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:Kt,depthTest:!1,depthWrite:!1})}function TT(){return new at({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:lw(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:Kt,depthTest:!1,depthWrite:!1})}function CT(){return new at({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:lw(),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:Kt,depthTest:!1,depthWrite:!1})}function lw(){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 PU(n){let t=new WeakMap,e=null;function r(a){if(a&&a.isTexture){let l=a.mapping,c=l===SS||l===wS,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;ut.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;j0)return n;let i=t*e,s=PT[i];if(s===void 0&&(s=new Float32Array(i),PT[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":" "} ${a}: ${e[o]}`)}return r.join(` `)}function Tk(n){switch(n){case cn:return["Linear","( value )"];case ot:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function BT(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+` `+Mk(n.getShaderSource(t),o)}else return i}function Ck(n,t){let e=Tk(t);return"vec4 "+n+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function Pk(n,t){let e;switch(t){case GN:e="Linear";break;case jN:e="Reinhard";break;case HN:e="OptimizedCineon";break;case WN:e="ACESFilmic";break;case qN:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+n+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function _k(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(Qf).join(` `)}function Dk(n){let t=[];for(let e in n){let r=n[e];r!==!1&&t.push("#define "+e+" "+r)}return t.join(` `)}function Ok(n,t){let e={},r=n.getProgramParameter(t,35721);for(let i=0;i/gm;function IS(n){return n.replace(Ik,Rk)}function Rk(n,t){let e=xt[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return IS(e)}var Lk=/#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 VT(n){return n.replace(Lk,Bk)}function Bk(n,t,e,r){let i="";for(let s=parseInt(t);s0&&(g+=` `),y=[f,p].filter(Qf).join(` `),y.length>0&&(y+=` `)):(g=[zT(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(Qf).join(` `),y=[f,zT(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!==Ds?"#define TONE_MAPPING":"",e.toneMapping!==Ds?xt.tonemapping_pars_fragment:"",e.toneMapping!==Ds?Pk("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",xt.encodings_pars_fragment,Ck("linearToOutputTexel",e.outputEncoding),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` `].filter(Qf).join(` `)),o=IS(o),o=NT(o,e),o=FT(o,e),a=IS(a),a=NT(a,e),a=FT(a,e),o=VT(o),a=VT(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===uT?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===uT?"":"#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=LT(i,35633,x),A=LT(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=BT(i,w,"vertex"),L=BT(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 Au(i,m)),M};let b;return this.getAttributes=function(){return b===void 0&&(b=Ok(i,m)),b},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=e.shaderName,this.id=Ek++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=A,this}var Gk=0,RS=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 LS(t),e.set(t,r)),r}},LS=class{constructor(t){this.id=Gk++,this.code=t,this.usedTimes=0}};function jk(n,t,e,r,i,s,o){let a=new np,l=new RS,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===Hu?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 we=co[H];G=we.vertexShader,Z=we.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:cn,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===cF,tangentSpaceNormalMap:b.normalMapType===lF,decodeVideoTexture:!!b.map&&b.map.isVideoTexture===!0&&b.map.encoding===ot,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:Ds,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;P0?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||Wk),r.length>1&&r.sort(d||UT),i.length>1&&i.sort(d||UT)}function u(){for(let h=t,d=n.length;h=s.length?(o=new kT,s.push(o)):o=s[i],o}function e(){n=new WeakMap}return{get:t,dispose:e}}function Yk(){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 Xk(){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 Qk=0;function Kk(n,t){return(t.castShadow?2:0)-(n.castShadow?2:0)+(t.map?1:0)-(n.map?1:0)}function Zk(n,t){let e=new Yk,r=Xk(),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(Kk);let T=h!==!0?Math.PI:1;for(let P=0,D=u.length;P0&&(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=Qk++)}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=a.length?(l=new GT(n,t),a.push(l)):l=a[o],l}function i(){e=new WeakMap}return{get:r,dispose:i}}var op=class extends cc{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}},BS=class extends cc{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}},$k=`void main() { gl_Position = vec4( position, 1.0 ); }`,eG=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include 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 tG(n,t,e){let r=new sp,i=new U,s=new U,o=new Ke,a=new op({depthPacking:ow}),l=new BS,c={},u=e.maxTextureSize,h={[kn]:ui,[ui]:kn,[ji]:ji},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new U},radius:{value:4}},vertexShader:$k,fragmentShader:eG}),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 tr(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(Kt),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,D=S.length;Pu||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!==Xf?{minFilter:Ft,magFilter:Ft}:{};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;V0||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===Xf?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===Xf)&&(!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=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 Pt=0;Pt"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):ip("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 TS(N.width)&&TS(N.height)}function w(N){return a?!1:N.wrapS!==Yt||N.wrapT!==Yt||N.minFilter!==Ft&&N.minFilter!==tt}function A(N,B){return N.generateMipmaps&&B&&N.minFilter!==Ft&&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===ot&&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!==Ft&&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===Ft||N===UM||N===Fb?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=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={[Os]:10497,[Yt]:33071,[AS]:33648},$={[Ft]:9728,[UM]:9984,[Fb]:9986,[tt]:9729,[YN]:9985,[lc]: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!==Ft&&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===Ft||B.minFilter!==Fb&&B.minFilter!==lc||B.type===yr&&t.has("OES_texture_float_linear")===!1||a===!1&&B.type===Is&&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,Lt=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===_s?Je=33190:B.type===qa?Je=35056:Je=33189:B.type===yr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),B.format===oc&&Je===6402&&B.type!==gC&&B.type!==_s&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),B.type=_s,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(Lt.length>0&&rt){ur&&Ar&&e.texStorage2D(3553,Q,Je,Lt[0].width,Lt[0].height);for(let ye=0,Me=Lt.length;ye>=1,Me>>=1}}else if(Lt.length>0&&rt){ur&&Ar&&e.texStorage2D(3553,Q,Je,Lt[0].width,Lt[0].height);for(let ye=0,Me=Lt.length;ye0&&Ar++,e.texStorage2D(34067,Ar,nt,pe[0].width,pe[0].height));for(let ye=0;ye<6;ye++)if(Re){Lt?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=34069&&me<=34074)&&n.framebufferTexture2D(36160,ge,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function we(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===_s&&(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;me0&&Ie(N)===!1){let Re=Le?B:[B];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe0&&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;rt0&&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===MS||ae!==cn&&(ae===ot?a===!1?t.has("EXT_sRGB")===!0&&ge===jr?(N.format=MS,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=Te,this.updateRenderTargetMipmap=Ue,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Ie}function nG(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===Cr)return 5121;if(s===ZN)return 32819;if(s===JN)return 32820;if(s===XN)return 5120;if(s===QN)return 5122;if(s===gC)return 5123;if(s===KN)return 5124;if(s===_s)return 5125;if(s===yr)return 5126;if(s===Is)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===$N)return 6406;if(s===jr)return 6408;if(s===eF)return 6409;if(s===tF)return 6410;if(s===oc)return 6402;if(s===Qa)return 34041;if(s===MS)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===rF)return 6403;if(s===iF)return 36244;if(s===Wu)return 33319;if(s===nF)return 33320;if(s===rw)return 36249;if(s===Vb||s===zb||s===Ub||s===kb)if(o===ot)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Vb)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===zb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ub)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===kb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Vb)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===zb)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ub)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===kb)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===kM||s===GM||s===jM||s===HM)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===kM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===GM)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===jM)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===HM)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===sF)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===WM||s===qM)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===WM)return o===ot?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===qM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===YM||s===XM||s===QM||s===KM||s===ZM||s===JM||s===$M||s===eT||s===tT||s===rT||s===iT||s===nT||s===sT||s===oT)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===YM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===XM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===QM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===KM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===ZM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===JM)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===$M)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===eT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===tT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===rT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===iT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===nT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===sT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===oT)return o===ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Gb)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Gb)return o===ot?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===oF||s===aT||s===lT||s===cT)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Gb)return a.COMPRESSED_RED_RGTC1_EXT;if(s===aT)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===lT)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===cT)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 NS=class extends Kr{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ts=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},sG={type:"move"},Jf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ts,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 ts,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 ts,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(sG)))}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 ts;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},is=class extends Zt{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:oc,u!==oc&&u!==Qa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===oc&&(r=_s),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:Ft,this.minFilter=l!==void 0?l:Ft,this.flipY=!1,this.generateMipmaps=!1}},FS=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 NS;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 Jf,v[G]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(G){let Z=v[G];return Z===void 0&&(Z=new Jf,v[G]=Z),Z.getGripSpace()},this.getHand=function(G){let Z=v[G];return Z===void 0&&(Z=new Jf,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=0&&(x[$]=null,v[$].disconnect(te))}for(let Z=0;Z=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],we=(Y[9]-1)/Y[5],xe=(Y[8]-1)/Y[0],de=(oe[8]+1)/oe[0],Oe=ie*xe,Te=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=Te+($-ze),N=J*re/Ie*Ve,B=we*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;YY&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}p=null}let K=new wC;K.setAnimationLoop(q),this.setAnimationLoop=function(G){W=G},this.dispose=function(){}}};function oG(n,t){function e(m,g){g.color.getRGB(m.fogColor.value,SC(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 aG(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;v0){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 lG(){let n=ip("canvas");return n.style.display="block",n}function cw(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:lG(),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=cn,this.physicallyCorrectLights=!1,this.toneMapping=Ds,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 sp,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;ve0?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!==we.render.frame&&(k.skeleton.update(),k.skeleton.frame=we.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,Bt=Tt.length;kt0&&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")?Is:Cr,minFilter:lc,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=Ds,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;be0&&de.useMultisampledRTT(k)===!1?be=xe.get(k).__webglMultisampledFramebuffer:be=Bt,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,Bt=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 _t=Bt===Is&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Bt!==Cr&&Re.convert(Bt)!==Y.getParameter(35738)&&!(Bt===yr&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!_t){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(Bt),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),Bt;if(se.isData3DTexture)de.setTexture3D(se,0),Bt=32879;else if(se.isDataArrayTexture)de.setTexture2DArray(se,0),Bt=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 _t=Y.getParameter(3314),Nt=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(Bt,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(Bt,be,le.x,le.y,le.z,ct,mt,wt,Tt,gt.data)):Y.texSubImage3D(Bt,be,le.x,le.y,le.z,ct,mt,wt,Tt,kt,gt),Y.pixelStorei(3314,_t),Y.pixelStorei(32878,Nt),Y.pixelStorei(3316,Ji),Y.pixelStorei(3315,$i),Y.pixelStorei(32877,oo),be===0&&se.generateMipmaps&&Y.generateMipmap(Bt),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 VS=class extends cw{};VS.prototype.isWebGL1Renderer=!0;var Cu=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 Cu(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=ES,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=rs()}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;il)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);bt.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;xl)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);At.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=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var sy=class extends Zt{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}},ss=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}},dc=class extends ss{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)i;)s-=i;s0?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+2i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return r.set(ZT(a,l.x,c.x,u.x,h.x),ZT(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){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;r1&&!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;e0){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}},_u=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;v0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Ce(h,3)),this.setAttribute("normal",new Ce(d,3)),this.setAttribute("uv",new Ce(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.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;T80*e){a=c=n[0],l=u=n[1];for(let p=e;pc&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return up(s,o,e,a,l,f,0),o}};function CC(n,t,e,r,i){let s,o;if(i===BG(n,t,e,r)>0)for(s=t;s=t;s-=r)o=JT(s,n[s],n[s+1],o);return o&&wy(o,o.next)&&(dp(o),o=o.next),o}function gc(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(dp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function up(n,t,e,r,i,s,o){if(!n)return;!o&&s&&_G(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?SG(n,r,i,s):bG(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),dp(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=wG(gc(n),t,e),up(n,t,e,r,i,s,2)):o===2&&AG(n,t,e,r,i,s):up(gc(n),t,e,r,i,s,1);break}}}function bG(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=is?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&&wu(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 SG(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=al?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=GS(f,p,t,e,r),v=GS(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&&wu(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&&wu(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&&wu(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&&wu(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 wG(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!wy(i,s)&&PC(i,r,r.next,s)&&hp(i,s)&&hp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),dp(r),dp(r.next),r=n=s),r=r.next}while(r!==n);return gc(r)}function AG(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&IG(o,a)){let l=_C(o,a);o=gc(o,o.next),l=gc(l,l.next),up(o,t,e,r,i,s,0),up(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function EG(n,t,e,r){let i=[],s,o,a,l,c;for(s=0,o=t.length;s=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.x&&e.x>=l&&s!==e.x&&wu(oi.x||e.x===i.x&&PG(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function PG(n,t){return Fr(n.prev,n,t.prev)<0&&Fr(t.next,n,n.next)<0}function _G(n,t,e,r){let i=n;do i.z===0&&(i.z=GS(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,DG(i)}function DG(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;t0||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 GS(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 OG(n){let t=n,e=n;do(t.x=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function IG(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!RG(n,t)&&(hp(n,t)&&hp(t,n)&&LG(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 PC(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 RG(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&&PC(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function hp(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 LG(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 _C(n,t){let e=new jS(n.i,n.x,n.y),r=new jS(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 JT(n,t,e,r){let i=new jS(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 dp(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 jS(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 BG(n,t,e,r){let i=0;for(let s=t,o=e-r;s2&&n[t-1].equals(n[0])&&n.pop()}function eC(n,t){for(let e=0;e0)&&f.push(x,S,A),(y!==r-1||l=s)){let a=e[1];t=s)break t}o=r,r=0;break r}break e}for(;r>>1;te;)--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&&DC(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()===jb,s=t.length-1,o=1;for(let a=1;a0){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}};os.prototype.TimeBufferType=Float32Array;os.prototype.ValueBufferType=Float32Array;os.prototype.DefaultInterpolation=qg;var $a=class extends os{};$a.prototype.ValueTypeName="bool";$a.prototype.ValueBufferType=Array;$a.prototype.DefaultInterpolation=Wg;$a.prototype.InterpolantFactoryMethodLinear=void 0;$a.prototype.InterpolantFactoryMethodSmooth=void 0;var ay=class extends os{};ay.prototype.ValueTypeName="color";var Fu=class extends os{};Fu.prototype.ValueTypeName="number";var qS=class extends Nu{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}},yc=class extends os{InterpolantFactoryMethodLinear(t){return new qS(this.times,this.values,this.getValueSize(),t)}};yc.prototype.ValueTypeName="quaternion";yc.prototype.DefaultInterpolation=qg;yc.prototype.InterpolantFactoryMethodSmooth=void 0;var el=class extends os{};el.prototype.ValueTypeName="string";el.prototype.ValueBufferType=Array;el.prototype.DefaultInterpolation=Wg;el.prototype.InterpolantFactoryMethodLinear=void 0;el.prototype.InterpolantFactoryMethodSmooth=void 0;var Vu=class extends os{};Vu.prototype.ValueTypeName="vector";var zu=class{constructor(t,e=-1,r,i=sw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=rs(),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(VG(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(os.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(t,e,r,i){let s=e.length,o=[];for(let a=0;a1){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=[];OC(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{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{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{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{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var XS=class extends tl{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=ip("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 tl{constructor(t){super(t)}load(t,e,r,i){let s=new Zt,o=new XS(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}},rl=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 rl{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}},vS=new ce,rC=new E,iC=new E,pp=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 sp,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;rC.setFromMatrixPosition(t.matrixWorld),e.position.copy(rC),iC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(iC),e.updateMatrixWorld(),vS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(vS)}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}},QS=class extends pp{constructor(){super(new Kr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=rp*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 rl{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 QS}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}},nC=new ce,Yf=new E,xS=new E,KS=class extends pp{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()),Yf.setFromMatrixPosition(t.matrixWorld),r.position.copy(Yf),xS.copy(r.position),xS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(xS),r.updateMatrixWorld(),i.makeTranslation(-Yf.x,-Yf.y,-Yf.z),nC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nC)}},dy=class extends rl{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 KS}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}},ZS=class extends pp{constructor(){super(new Tu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},fy=class extends rl{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 ZS}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var mp=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}},ku=class extends tl{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new Uu(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 mp: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 uc(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"u"?Date:performance).now()}var JS=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=.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}}},hw="\\[\\]\\.:\\/",UG=new RegExp("["+hw+"]","g"),dw="[^"+hw+"]",kG="[^"+hw.replace("\\.","")+"]",GG=/((?:WC+[\/:])*)/.source.replace("WC",dw),jG=/(WCOD+)?/.source.replace("WCOD",kG),HG=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dw),WG=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dw),qG=new RegExp("^"+GG+jG+HG+WG+"$"),YG=["material","materials","bones","map"],$S=class{constructor(t,e,r){let i=r||Qt.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()}},Qt=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Qt.parseTrackName(e),this.node=Qt.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 Qt.Composite(t,e,r):new Qt(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(UG,"")}static parseTrackName(t){let e=qG.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);YG.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;o0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case aF:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case sw: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===yp;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===iw){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=bu,i.endingEnd=bu):(t?i.endingStart=this.zeroSlopeAtStart?bu:xu:i.endingStart=Yg,e?i.endingEnd=this.zeroSlopeAtEnd?bu:xu: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}},XG=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 JS(Qt.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=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;ethis.max.x||t.ythis.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.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return aC.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)}},lC=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){lC.subVectors(t,this.start),kg.subVectors(this.end,this.start);let r=kg.dot(kg),s=kg.dot(lC)/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)}},cC=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>-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 KG(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 ZG(n){let t=n>>10;return ia.uint32View[0]=ia.mantissaTable[ia.offsetTable[t]+(n&1023)]+ia.exponentTable[t],ia.floatView[0]}var IC=Object.freeze({__proto__:null,fromHalfFloat:ZG,toHalfFloat:KG});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 Yu=".",vp=Symbol("target"),fw=Symbol("unsubscribe");function xp(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function RC(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var qn=Array.isArray;function vc(n){return typeof n=="symbol"}var JG={after:(n,t)=>qn(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>qn(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=Yu),vc(t)?n+t.toString():n+t):n,initial:n=>{if(qn(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(Yu);return t===-1?"":n.slice(0,t)},last:n=>{if(qn(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(Yu);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(qn(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(Yu);if(r===-1)t(n);else for(;e{n&&(n=n[e])}),n}},hn=JG;function pw(n){return typeof n=="object"&&typeof n.next=="function"}function mw(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[vp].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&&vc(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var bp=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,hn.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 Xu(n){return toString.call(n)==="[object Object]"}function Qu(){return!0}function sl(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 $G=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),gw={push:Qu,pop:Qu,shift:Qu,unshift:Qu,copyWithin:sl,reverse:sl,sort:sl,splice:sl,flat:sl,fill:sl},LC=new Set([...Ey,...$G,...Object.keys(gw)]);function Ku(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var yw=["keys","values","entries"],vw=new Set(["has","toString"]),xw={add:Ku,clear:Ku,delete:Ku,forEach:Ku},BC=new Set([...vw,...Object.keys(xw),...yw]);function Zu(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 e4=new Set([...vw,"get"]),bw={set:Zu,clear:Zu,delete:Zu,forEach:Zu},NC=new Set([...e4,...Object.keys(bw),...yw]);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(Xu(t))e={...t};else if(qn(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?(qn(i)?this._onIsChanged=gw[e]:i instanceof Set?this._onIsChanged=xw[e]:i instanceof Map&&(this._onIsChanged=bw[e]),i):r}update(t,e,r){let i=hn.after(t,this._path);if(e!=="length"){let s=this.clone;hn.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],hn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Ju=class extends Ri{static isHandledMethod(t){return LC.has(t)}};var Sp=class extends Ri{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var $u=class extends Ri{static isHandledMethod(t){return BC.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 eh=class extends Ri{static isHandledMethod(t){return NC.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 wp=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 Ap=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 Xu(t)||qn(t)||xp(t)}static isHandledMethod(t,e){return Xu(t)?Ri.isHandledMethod(e):qn(t)?Ju.isHandledMethod(e):t instanceof Set?$u.isHandledMethod(e):t instanceof Map?eh.isHandledMethod(e):xp(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Ri;qn(t)?i=Ju:t instanceof Date?i=Sp:t instanceof Set?i=$u:t instanceof Map?i=eh:t instanceof WeakSet?i=wp:t instanceof WeakMap&&(i=Ap),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 t4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Sw=(n,t,e={})=>{e={...t4,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new bp(i),c=typeof e.onValidate=="function",u=new Ns(c),h=(v,x,S,w,A)=>!c||u.isCloning||e.onValidate(hn.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(hn.concat(v,x),S,w,A)},p=v=>v&&(v[r]||v),m=(v,x,S,w)=>RC(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,hn.concat(w,S),g,r)),g={get(v,x,S){if(vc(x)){if(x===r||x===vp)return v;if(x===fw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=xp(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=hn.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=hn.concat(A,S[0])),b=l.getProxy(b,A,g)),T){let P={name:v.name,args:S,result:b},D=u.isCloning?hn.initial(A):A,_=u.isCloning?hn.last(A):"";h(hn.get(n,D),_,w,C,P)?f(D,_,w,C,P):u.undo(w)}return(x instanceof Map||x instanceof Set)&&pw(b)?mw(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};Sw.target=n=>n&&n[vp]||n;Sw.unsubscribe=n=>n[fw]||n;var ww=Sw;var r4=typeof global=="object"&&global&&global.Object===Object&&global,My=r4;var i4=typeof self=="object"&&self&&self.Object===Object&&self,n4=My||i4||Function("return this")(),Hr=n4;var s4=Hr.Symbol,Li=s4;var FC=Object.prototype,o4=FC.hasOwnProperty,a4=FC.toString,Ep=Li?Li.toStringTag:void 0;function l4(n){var t=o4.call(n,Ep),e=n[Ep];try{n[Ep]=void 0;var r=!0}catch{}var i=a4.call(n);return r&&(t?n[Ep]=e:delete n[Ep]),i}var VC=l4;var c4=Object.prototype,u4=c4.toString;function h4(n){return u4.call(n)}var zC=h4;var d4="[object Null]",f4="[object Undefined]",UC=Li?Li.toStringTag:void 0;function p4(n){return n==null?n===void 0?f4:d4:UC&&UC in Object(n)?VC(n):zC(n)}var Yn=p4;function m4(n){return n!=null&&typeof n=="object"}var Hi=m4;var g4="[object Symbol]";function y4(n){return typeof n=="symbol"||Hi(n)&&Yn(n)==g4}var ol=y4;function v4(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e0){if(++t>=rj)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var iP=sj;function oj(n){return function(){return n}}var nP=oj;var aj=function(){try{var n=En(Object,"defineProperty");return n({},"",{}),n}catch{}}(),th=aj;var lj=th?function(n,t){return th(n,"toString",{configurable:!0,enumerable:!1,value:nP(t),writable:!0})}:XC,sP=lj;var cj=iP(sP),oP=cj;function uj(n,t){for(var e=-1,r=n==null?0:n.length;++e-1&&n%1==0&&n-1&&n%1==0&&n<=Sj}var sh=wj;function Aj(n){return n!=null&&sh(n.length)&&!Cy(n)}var Oy=Aj;var Ej=Object.prototype;function Mj(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Ej;return n===e}var oh=Mj;function Tj(n,t){for(var e=-1,r=Array(n);++e-1}var IP=qH;function YH(n,t){var e=this.__data__,r=al(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var RP=YH;function hh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t0&&e(a)?t>1?qP(a,t-1,e,r,i):fh(i,a):r||(i[i.length]=a)}return i}var YP=qP;function m5(n){var t=n==null?0:n.length;return t?YP(n,1):[]}var XP=m5;function g5(n){return oP(cP(n,void 0,XP),n+"")}var Ny=g5;var y5=Ly(Object.getPrototypeOf,Object),ph=y5;var v5="[object Object]",x5=Function.prototype,b5=Object.prototype,QP=x5.toString,S5=b5.hasOwnProperty,w5=QP.call(Object);function A5(n){if(!Hi(n)||Yn(n)!=v5)return!1;var t=ph(n);if(t===null)return!0;var e=S5.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&QP.call(e)==w5}var KP=A5;function E5(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);++ra))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&b6?new z_:void 0;for(s.set(n,t),s.set(t,n);++h=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 wc=J6;function $6(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var r2=$6;function e8(n,t){return t.length<2?n:By(n,ZP(t,0,-1))}var i2=e8;function t8(n,t){return J_(n,t)}var Cp=t8;function r8(n,t){return t=ls(t,n),n=i2(n,t),n==null||delete n[hl(r2(t))]}var n2=r8;function i8(n){return KP(n)?void 0:n}var s2=i8;var n8=1,s8=2,o8=4,a8=Ny(function(n,t){var e={};if(n==null)return e;var r=!1;t=Ty(t,function(s){return s=ls(s,n),r||(r=s.length>1),s}),fo(n,Uy(n),e),r&&(e=Wy(e,n8|s8|o8,s2));for(var i=t.length;i--;)n2(e,t[i]);return e}),bh=a8;function l8(n,t,e,r){if(!fi(n))return n;t=ls(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++itypeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),m8=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),g8=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Sh&&"ontouchend"in document,y8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,v8=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,x8=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},b8=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},S8=()=>{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"},w8=p8(),Vae=w8?S8():void 0,Sh=m8(),po=g8(),c2=y8(),Ai=v8(),Dw=x8(),u2=Number(b8());function Zy(n){return Array.isArray(n)?n:[n]}function Jy(n,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}function Pp(n){return Sh?n.metaKey:n.ctrlKey}function h2(n){return n.wheelDeltaY===0||n.deltaY===0?Sh&&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={},_p={},$y={};function d2(n){$e.includes(n)||$e.push(n)}function wh(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 f2(){$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 p2(n){_p[n.key]=!0,$y[n.key]=$y[n.key]===void 0?1:$y[n.key]+1}function m2(n){if(Sh&&_p.Meta)for(let t in _p)_p[t]=!1;else _p[n.key]=!1;$y={}}function g2(n){n.addEventListener("pointerdown",d2,!0),n.addEventListener("pointerdown",tv,!0),n.addEventListener("pointermove",tv,!0),n.addEventListener("pointerup",wh,!0),n.addEventListener("pointercancel",wh,!0),n.addEventListener("pointerleave",wh,!0),window.addEventListener("keydown",p2,!0),window.addEventListener("keyup",m2,!0)}function y2(n){n.removeEventListener("pointerdown",d2,!0),n.removeEventListener("pointerdown",tv,!0),n.removeEventListener("pointermove",tv,!0),n.removeEventListener("pointerup",wh,!0),n.removeEventListener("pointercancel",wh,!0),n.removeEventListener("pointerleave",wh,!0),window.removeEventListener("keydown",p2,!0),window.removeEventListener("keyup",m2,!0)}var v2,x2=new Promise(n=>{v2=n});var iv;function b2(){if(iv)return iv;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.3.1/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});v2(l)}return iv=n(),iv}var S2,w2=new Promise(n=>{S2=n});var nv;function A2(){if(nv)return nv;async function n(){let e=await import("./physics.js");await e.init(),S2(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 Dp(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"&&Dp(r)}return Object.freeze(n)}function E2(n,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Ah=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;su.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 Ah("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(s0?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)=>E2(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 Mh;(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})(Mh||(Mh={}));var ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ke.prototype)}deepFreeze(){let e=0;for(;ec.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 M2()||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 Th(n){return n&&typeof n=="object"&&n instanceof pr}var pr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,s={};for(;i0;){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 Op(i,s)??i}r.apply=n;function t(i,s){return Iw(i,s)}r.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o{let s=i.id,o=Op(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=Ow(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 A8(n,t){if(t===void 0)return;let e=!1,r=n.map(i=>{let s=i.id,o=Op(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 Op(n,t){if(!Th(t))return t;if(n instanceof fr){let e=Ow(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ke)return A8(n,t);if(Array.isArray(n)){let e=!1,r=n.map((i,s)=>{let o=Op(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 Iw(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[i,s]of Object.entries(n)){let o=Op(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 Iw(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!Th(t))return t;if(!Th(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=Iw(n===void 0?void 0:n[i],t===void 0?void 0:t[i]);r[i]=s}return r}function P2(n,t){let e={cur:[],result:[],len:0};return n=Ip(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 E8(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function _2(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=Ip(s.data,t,ov(e,o));av(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=_2(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 M8(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=Ip(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 Ip(n,t,e){if(n instanceof fr){let r=_2(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof ke)return M8(n,t,e);if(Array.isArray(n)){let r=!1,i=n.map((s,o)=>{let a=Ip(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"&&!Eh(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=Ip(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&&E8(e),r}else return}}var Ch;(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})(Ch||(Ch={}));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=Mh.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;uc.props[u]!==void 0):!1}a.subsumed=o})(Ir||(Ir={}));var Rp;(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]=P2(h,{[p.id]:m});h=v;for(let S=0;SM.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 Ah)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Rp||(Rp={}));var D2=Symbol(),T8=Symbol(),cv=Symbol(),Ac=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]}}}},Lw=class extends Ac{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,Mh.runOp(this._current,t),t.path)}},Bw=class extends Ac{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))}},O2={get(n,t){if(t===cv)return()=>{n._parent=null};if(t===D2)return n._current;if(t===T8)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]}}},C8={...O2,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}},P8={...O2,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}},Ph=class extends Ac{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{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r0){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 Ac{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){Rw(this.ts,e,t),Rw(this.actual,r,t),Rw(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 Ph(n,t,e):e instanceof ke?new _h(n,t,e):e instanceof it?new Proxy(new Bw(n,t,e),P8):e!==null&&typeof e=="object"?Eh(e)?e:new Proxy(new Lw(n,t,e),C8):e}function Nw(n){let t=new lv(n);return[uv(t,"",n),t]}function dl(n,t){let[e,r]=Nw(n);return t(e),r.result()}function Vr(n){return n instanceof Ph||n instanceof _h?n._current:n!==null&&typeof n=="object"?n[D2]:n}var Or;(i=>{function n(s,o){if(o.length===s.length)for(var a=0;a{delete c[u]}),c}else return o}i.removeOverridden=t;function e(s,o){if((s instanceof fr||s instanceof Ph)&&typeof o=="string")return s.data(o);if((s instanceof ke||s instanceof _h)&&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(fv(),this?this.unpack(t,e):vo.prototype.unpack.call(R2,t,e)));pl=e>-1?e:t.length,ne=0,Uw=0,yo=0,fl=null,zw=U2,Qn=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(Mn=this,this.structures)return Xt=this.structures,dv();(!Xt||Xt.length>0)&&(Xt=[])}else Mn=R2,(!Xt||Xt.length>0)&&(Xt=[]);return dv()}unpackMultiple(t,e){let r,i=0;try{Dh=!0;let s=t.length,o=this?this.unpack(t,s):gv.unpack(t,s);if(e){for(e(o);ne=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(!Mn.trusted&&!Dh){let t=Xt.sharedLength||0;tpl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Dh)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Xt.restoreStructures&&L2(),fv(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function L2(){for(let n in Xt.restoreStructures)Xt[n]=Xt.restoreStructures[n];Xt.restoreStructures=null}function qr(){let n=qe[ne++];if(n<160)if(n<128){if(n<64)return n;{let t=Xt[n&63]||Mn.getStructures&&k2()[n&63];return t?(t.read||(t.read=jw(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,Mn.mapsAsObjects){let t={};for(let e=0;e=ne)return fl.slice(ne-cs,(ne+=t)-cs);if(yo==0&&pl<140){let e=t<16?Hw(t):G2(t);if(e!=null)return e}return kw(t)}else{let t;switch(n){case 192:return null;case 193:return Qn?(t=qr(),t>0?Qn[1].slice(Qn.position1,Qn.position1+=t):Qn[0].slice(Qn.position0,Qn.position0-=t)):Gw;case 194:return!1;case 195:return!0;case 196:return Fw(qe[ne++]);case 197:return t=ir.getUint16(ne),ne+=2,Fw(t);case 198:return t=ir.getUint32(ne),ne+=4,Fw(t);case 199:return Ec(qe[ne++]);case 200:return t=ir.getUint16(ne),ne+=2,Ec(t);case 201:return t=ir.getUint32(ne),ne+=4,Ec(t);case 202:if(t=ir.getFloat32(ne),Mn.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 Mn.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 Mn.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 z2(qe[ne++]&63);{let e=fn[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++,z2(qe[ne++]&63,qe[ne++])):Ec(2);case 214:return Ec(4);case 215:return Ec(8);case 216:return Ec(16);case 217:return t=qe[ne++],yo>=ne?fl.slice(ne-cs,(ne+=t)-cs):D8(t);case 218:return t=ir.getUint16(ne),ne+=2,yo>=ne?fl.slice(ne-cs,(ne+=t)-cs):O8(t);case 219:return t=ir.getUint32(ne),ne+=4,yo>=ne?fl.slice(ne-cs,(ne+=t)-cs):I8(t);case 220:return t=ir.getUint16(ne),ne+=2,N2(t);case 221:return t=ir.getUint32(ne),ne+=4,N2(t);case 222:return t=ir.getUint16(ne),ne+=2,F2(t);case 223:return t=ir.getUint32(ne),ne+=4,F2(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 _8=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function jw(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(s=>_8.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(qr);return n.highByte===0&&(n.read=B2(t,n.read)),i()}let r={};for(let i=0,s=n.length;ifunction(){let e=qe[ne++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Xt[r]||k2()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=jw(i,n)),i.read()};function k2(){let n=W2(()=>(qe=null,Mn.getStructures()));return Xt=Mn._mergeStructures(n,Xt)}var kw=pv,D8=pv,O8=pv,I8=pv;function pv(n){let t;if(n<16&&(t=Hw(n)))return t;if(n>64&&Vw)return Vw.decode(qe.subarray(ne,ne+=n));let e=ne+n,r=[];for(t="";ne65535&&(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 N2(n){let t=new Array(n);for(let e=0;e0){ne=t;return}e[r]=i}return Bi.apply(String,e)}function Hw(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 Fw(n){return Mn.copyBuffers?Uint8Array.prototype.slice.call(qe,ne,ne+=n):qe.subarray(ne,ne+=n)}function Ec(n){let t=qe[ne++];if(fn[t])return fn[t](qe.subarray(ne,ne+=n));throw new Error("Unknown extension type "+t)}var V2=new Array(4096);function j2(){let n=qe[ne++];if(n>=160&&n<192){if(n=n-160,yo>=ne)return fl.slice(ne-cs,(ne+=n)-cs);if(!(yo==0&&pl<180))return kw(n)}else return ne--,qr();let t=(n<<5^(n>1?ir.getUint16(ne):n>0?qe[ne]:0))&4095,e=V2[t],r=ne,i=ne+n-3,s,o=0;if(e&&e.bytes==n){for(;r{var e=qr();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Xt[n];return i&&i.isShared&&((Xt.restoreStructures||(Xt.restoreStructures=[]))[n]=i),Xt[n]=e,e.read=jw(e,r),e.read()},H2=typeof self=="object"?self:global;fn[0]=()=>{};fn[0].noBuffer=!0;fn[101]=()=>{let n=qr();return(H2[n[0]]||Error)(n[1])};fn[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)};fn[112]=n=>{let t=ir.getUint32(ne-4),e=da.get(t);return e.used=!0,e.target};fn[115]=()=>new Set(qr());var Ww=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");fn[116]=n=>{let t=n[0],e=Ww[t];if(!e)throw new Error("Could not find typed array for code "+t);return new H2[e](Uint8Array.prototype.slice.call(n,1).buffer)};fn[120]=()=>{let n=qr();return new RegExp(n[0],n[1])};fn[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=ne;ne+=t-4,Qn=[qr(),qr()],Qn.position0=0,Qn.position1=0;let r=ne;ne=e;try{return qr()}finally{ne=r}};fn[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 W2(n){let t=pl,e=ne,r=Uw,i=cs,s=yo,o=fl,a=zw,l=da,c=Qn,u=new Uint8Array(qe.slice(0,pl)),h=Xt,d=Xt.slice(0,Xt.length),f=Mn,p=Dh,m=n();return pl=t,ne=e,Uw=r,cs=i,yo=s,fl=o,zw=a,da=l,Qn=c,qe=u,Dh=p,Xt=h,Xt.splice(0,Xt.length,...d),Mn=f,ir=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),m}function fv(){qe=null,da=null,Xt=null}function q2(n){n.unpack?fn[n.type]=n.unpack:fn[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}),R8=gv.unpack,L8=gv.unpackMultiple,B8=gv.unpack,yv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},N8=new Float32Array(1),Qle=new Uint8Array(N8.buffer,0,4);var vv;try{vv=new TextEncoder}catch{}var xv,Yw,bv=typeof Buffer<"u",qw=bv?Buffer.allocUnsafeSlow:Uint8Array,K2=bv?Buffer:Uint8Array,Y2=bv?4294967296:2144337920,Se,Jr,ue=0,xo,bo=null,F8=/[\u0080-\uFFFF]/,Fp=Symbol("record-id"),Mc=class extends vo{constructor(t){super(t),this.offset=0;let e,r,i,s,o,a,l=0,c=K2.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),ue=0),xo=Se.length-10,xo-ue<2048?(Se=new qw(Se.length),Jr=new DataView(Se.buffer,0,Se.length),xo=Se.length-10,ue=0):ue=ue+7&2147483640,r=ue,a=u.structuredClone?new Map:null,u.bundleStrings?(bo=["",""],Se[ue++]=214,Se[ue++]=98,bo.position=ue-r,ue+=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;Pxo&&M(ue),u.offset=ue;let C=z8(Se.subarray(r,ue),a.idsToInsert);return a=null,C}return T&J2?(Se.start=r,Se.end=ue,Se):Se.subarray(r,ue)}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;CC&&(i=i.slice(0,C));let P=Se.subarray(r,ue);return u.saveStructures(i,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(b)):(l=C,P)}}T&q8&&(ue=r)}};let w=b=>{ue>xo&&(Se=M(ue));var T=typeof b,C;if(T==="string"){let P=b.length;if(bo&&P>=8&&P<4096){let O=F8.test(b);bo[O?0:1]+=b,Se[ue++]=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(ue+_>xo&&(Se=M(ue+_)),P<64||!c){let O,L,j,V=ue+D;for(O=0;O>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-ue-D}else C=c(b,ue+D,_);C<32?Se[ue++]=160|C:C<256?(D<2&&Se.copyWithin(ue+2,ue+1,ue+1+C),Se[ue++]=217,Se[ue++]=C):C<65536?(D<3&&Se.copyWithin(ue+3,ue+2,ue+2+C),Se[ue++]=218,Se[ue++]=C>>8,Se[ue++]=C&255):(D<5&&Se.copyWithin(ue+5,ue+3,ue+3+C),Se[ue++]=219,Jr.setUint32(ue,C),ue+=4),ue+=C}else if(T==="number")if(b>>>0===b)b<64?Se[ue++]=b:b<256?(Se[ue++]=204,Se[ue++]=b):b<65536?(Se[ue++]=205,Se[ue++]=b>>8,Se[ue++]=b&255):(Se[ue++]=206,Jr.setUint32(ue,b),ue+=4);else if(b>>0===b)b>=-32?Se[ue++]=256+b:b>=-128?(Se[ue++]=208,Se[ue++]=b+256):b>=-32768?(Se[ue++]=209,Jr.setInt16(ue,b),ue+=2):(Se[ue++]=210,Jr.setInt32(ue,b),ue+=4);else{let P;if((P=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){Se[ue++]=202,Jr.setFloat32(ue,b);let D;if(P<4||(D=b*mv[(Se[ue]&127)<<1|Se[ue+1]>>7])>>0===D){ue+=4;return}else ue--}Se[ue++]=203,Jr.setFloat64(ue,b),ue+=8}else if(T==="object")if(!b)Se[ue++]=192;else{if(a){let D=a.get(b);if(D){if(!D.id){let _=a.idsToInsert||(a.idsToInsert=[]);D.id=_.push(D)}Se[ue++]=214,Se[ue++]=112,Jr.setUint32(ue,D.id),ue+=4;return}else a.set(b,{offset:ue-r})}let P=b.constructor;if(P===Object)A(b,!0);else if(P===Array){C=b.length,C<16?Se[ue++]=144|C:C<65536?(Se[ue++]=220,Se[ue++]=C>>8,Se[ue++]=C&255):(Se[ue++]=221,Jr.setUint32(ue,C),ue+=4);for(let D=0;D>8,Se[ue++]=C&255):(Se[ue++]=223,Jr.setUint32(ue,C),ue+=4);for(let[D,_]of b)w(D),w(_)}else{for(let D=0,_=xv.length;D<_;D++){let O=Yw[D];if(b instanceof O){let L=xv[D];if(L.write){L.type&&(Se[ue++]=212,Se[ue++]=L.type,Se[ue++]=0),w(L.write.call(this,b));return}let j=Se,V=Jr,H=ue;Se=null;let W;try{W=L.pack.call(this,b,q=>(Se=j,j=null,ue+=q,ue>xo&&M(ue),{target:Se,targetView:Jr,position:ue-q}),w)}finally{j&&(Se=j,Jr=V,ue=H,xo=Se.length-10)}W&&(W.length+ue>xo&&M(W.length+ue),ue=V8(W,Se,ue,L.type));return}}A(b,!b.hasOwnProperty)}}else if(T==="boolean")Se[ue++]=b?195:194;else if(T==="bigint"){if(b=-(BigInt(1)<0)Se[ue++]=207,Jr.setBigUint64(ue,b);else if(this.largeBigIntToFloat)Se[ue++]=203,Jr.setFloat64(ue,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");ue+=8}else if(T==="undefined")this.encodeUndefinedAsNil?Se[ue++]=192:(Se[ue++]=212,Se[ue++]=0,Se[ue++]=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[ue++]=128|C:C<65536?(Se[ue++]=222,Se[ue++]=C>>8,Se[ue++]=C&255):(Se[ue++]=223,Jr.setUint32(ue,C),ue+=4);let P;for(let D=0;D{Se[ue++]=222;let C=ue-r;ue+=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=96&&m?(Se[ue++]=((_-=96)&31)+96,Se[ue++]=_>>5):Se[ue++]=_;else{_=o.nextId,_||(_=64),_=y&&(_=g),o.nextId=_+1);let O=T.highByte=_>=96&&m?_-96>>5:-1;P[Fp]=_,o[_-64]=T,_=0?(Se[ue++]=(_&31)+96,Se[ue++]=O):Se[ue++]=_):(O>=0?(Se[ue++]=213,Se[ue++]=114,Se[ue++]=(_&31)+96,Se[ue++]=O):(Se[ue++]=212,Se[ue++]=114,Se[ue++]=_),D&&(x+=S*D),v.length>=p&&(v.shift()[Fp]=0),v.push(P),w(T))}for(let O=0,L=T.length;O{let T;if(b>16777216){if(b-r>Y2)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(Y2,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)),ue-=r,r=0,xo=C.length-10,Se=C}}useBuffer(t){Se=t,Jr=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),ue=0}};Yw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Np];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?X2(n,16,t):Q2(bv?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==K2&&this.structuredClone?X2(n,Ww.indexOf(e.name),t):Q2(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function X2(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 Q2(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 V8(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 z8(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 ml(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)");Yw.unshift(n.Class),xv.unshift(n)}q2(n)}var Z2=new Mc({useRecords:!1}),U8=Z2.pack,k8=Z2.pack;var{NEVER:G8,ALWAYS:j8,DECIMAL_ROUND:H8,DECIMAL_FIT:W8}=yv,J2=512,q8=1024;var $2=new Mc({structuredClone:!0});ml({Class:it.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,it.prototype),n}});ml({Class:ke.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ke.prototype),n}});ml({Class:fr.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,fr.prototype),n}});ml({Class:Lp.prototype.constructor,type:4,write(n){return n.id},read(n){return new Lp(n)}});ml({Class:Bp.prototype.constructor,type:5,write(n){return n.data},read(n){return new Bp(n)}});ml({Class:pr.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,pr.prototype),n}});function Y8(n){var t=0;if(n.length===0)return t;for(let e=0;e{function n(i){return $2.pack(i)}r.serialize=n;function t(i){return $2.unpack(i)}r.deserialize=t;function e(i){return Y8(n(Xw(i))).toString()}r.checksum=e})(Sv||(Sv={}));var eD;(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})(eD||(eD={}));function uD(n){return n==="MouseDown"||n==="MouseUp"||n==="KeyDown"||n==="KeyUp"||n==="Collision"||n==="Trigger"}var pn={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional"],["MouseHover"]:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],["Start"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Conditional"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MousePress"]:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["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"],["GameControl"]:["Transition","Animation","Audio","Particles","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Trigger"]:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Resize"]:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},tD;(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})(tD||(tD={}));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 Qw;(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})(Qw||(Qw={}));var rD;(t=>{function n(e){return e.find(r=>r==="ifActions"||r==="elseActions")!=null}t.isConditionalSubActions=n})(rD||(rD={}));var iD;(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:Qw.distanceDefaultData(r)}}e.defaultData=t})(iD||(iD={}));var nD;(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}})(nD||(nD={}));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 sD;(e=>{function n(r){return r.type==="MouseHover"}e.is=n;function t(){return{type:"MouseHover",disabled:!1,actions:new ke}}e.defaultData=t})(sD||(sD={}));var oD;(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})(oD||(oD={}));var aD;(e=>{function n(r){return r.type==="Start"}e.is=n;function t(){return{type:"Start",disabled:!1,actions:new ke}}e.defaultData=t})(aD||(aD={}));var lD;(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})(lD||(lD={}));var cD;(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})(cD||(cD={}));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:Ee.generateUUID(),fi:0,data:a},{id:Ee.generateUUID(),fi:1,data:l},{id:Ee.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 us="personal camera",yl="a218fcc3-276b-49b9-b485-49037fd14f5f",pD=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 Vp;(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})(Vp||(Vp={}));var hD;(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})(hD||(hD={}));var gl;(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{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 dD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(dD||(dD={}));var fD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(fD||(fD={}));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 Kw(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 vl;(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})(vl||(vl={}));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(Zw.forEach(o=>{Object.assign(s,{[o]:i[o]??r[o]})}),s.radial={...r.radial},i.radial){let o=r.radial,a=i.radial;Jw.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;$w.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;e1.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;t1.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;r1.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 Zw=["count"],Jw=["radius","start","end","position","scale","rotation"],$w=["position","scale","rotation"],e1=["count","size"],t1=["count","position","scale","rotation"],r1=["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 Oh;(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",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(Oh||(Oh={}));var xl;(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]})(xl||(xl={}));var i1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(i1||(i1={}));var n1;(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})(n1||(n1={}));var Ov;(t=>t.defaultData={...n1.defaultData,...i1.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 Ih;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Ih||(Ih={}));var gD;(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})(gD||(gD={}));function vD(n){return n.type!=="displace"}var yD;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(yD||(yD={}));var Iv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],xD=["wrapping","image","video","name","minFilter"],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},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Ih.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},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}};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 Rh;(t=>{function n(){return{points:new ke,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(Rh||(Rh={}));var Lh;(t=>{function n(){return{points:new ke,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(Lh||(Lh={}));var s1={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Rv;(t=>{function n(e,r){let i={...e};return o1.forEach(s=>{Object.assign(i,{[s]:r[s]??e[s]})}),i}t.merge=n})(Rv||(Rv={}));var Lv={shape:s1,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},o1=["depth","offset","angle","twist","startScale","endScale"];var zp;(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})(zp||(zp={}));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 bl;(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:Lh.defaultData(),extrusion:Lv};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Rh.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})(bl||(bl={}));var a1=["width","height","depth"];var Nv;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ei.white,near:.1,far:2e3})(Nv||(Nv={}));var Bh;(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}}})(Bh||(Bh={}));var l1;(t=>t.defaultData={softShadowQuality:"low"})(l1||(l1={}));var c1;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(c1||(c1={}));var u1;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(u1||(u1={}));var Sl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Sl||(Sl={}));var h1;(t=>t.defaultData={playCamera:us,gameControlObject:null})(h1||(h1={}));var Fv;(t=>t.defaultData={backgroundColor:bt.fromHexAndA(pD,1),postprocessing:Bh.defaultData,fog:Nv.defaultData,globalPhysics:Sl.defaultData,ambient:c1.defaultData,ao:u1.defaultData,shadow:l1.defaultData,publish:h1.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 bD;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(bD||(bD={}));var Nh;(i=>{i.identity={...Cv.identity,hiddenMatrix:gl.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:gl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=r})(Nh||(Nh={}));var Mi;(t=>t.defaultData={states:new ke,events:new ke,visible:!0,raycastLock:!1,physics:xl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Nh.identity,cloner:null})(Mi||(Mi={}));var zv;(t=>t.defaultData={type:"Empty",...Mi.defaultData})(zv||(zv={}));var SD;(t=>t.defaultData={type:"ParticleCollider",...Vv.defaultData,...Mi.defaultData})(SD||(SD={}));var wD;(t=>t.defaultData={type:"Component",...Mi.defaultData})(wD||(wD={}));var AD;(t=>t.defaultData={type:"Particle",...Mi.defaultData,...Oh.defaultData})(AD||(AD={}));var Tc;(t=>t.defaultData={type:"Mesh",...Mi.defaultData,...Ov.defaultData})(Tc||(Tc={}));var Cc;(t=>t.defaultData={...Mi.defaultData,...Nh.identity,position:[0,0,vl.DefaultTargetOffset],...vl.defaultData})(Cc||(Cc={}));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 Fh;(e=>{function n(r,i,s=0){for(;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=Nh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=i})(Ao||(Ao={}));var pa;(e=>{e.defaultData={type:"Page",...Mi.defaultData,physics:{...xl.defaultData,fusedBody:!1},...Fv.defaultData,camera:Cc.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:gl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:xl.defaultData,states:new ke,events:new ke,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...vl.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,...Tc.defaultData,geometry:bl.defaultData("RectangleGeometry"),material:ei.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Mi.defaultData,...Tc.defaultData,geometry:bl.defaultData("BooleanGeometry"),material:ei.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Mi.defaultData,...Tc.defaultData,geometry:bl.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=dl(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=dl(a.materials,l=>{for(let c=0;c0){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,Nh.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 Vh;(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})(Vh||(Vh={}));var zs;(t=>t.defaultData={orbitControls:Vh.defaultData,playPage:yl,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}},stopRaycast:!0,hdTransmission:!1})(zs||(zs={}));var d1;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(d1||(d1={}));var f1;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(f1||(f1={}));var ga;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...d1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:f1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ga||(ga={}));var wl;(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=zh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(wl||(wl={}));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:yl,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:dn(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 Uh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Uh||(Uh={}));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 p1;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(p1||(p1={}));var ED;(t=>t.all=[...p1.all,"components"])(ED||(ED={}));var MD;(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})(MD||(MD={}));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"},dn(o,it.prototype)}s.defaultColors=n;function t(){return dn({},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 kh;(t=>t.list=["idle","move","jump","run"])(kh||(kh={}));var Gh;(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)}}))(Gh||(Gh={}));function TD(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={...Xn(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 Q8(n){Object.assign(n.scene.publish,{orbitControls:{...Vh.defaultData,...Vr(n.scene.publish.orbitControls)}})}function K8(n){Object.assign(n.scene.publish.settings,{video:{...zs.defaultData.settings.video,...Vr(n.scene.publish.settings.video)}})}function Z8(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))(xD.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 J8(n){n.scene.publish.withBackground=!0}function $8(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function eq(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 tq(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 rq(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 iq(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 nq(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{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 sq(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function PD(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&m1(r)}):"material"in e&&typeof e.material!="string"&&m1(e.material)}),Object.values(n.shared.materials).forEach(t=>m1(t))}function oq(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 aq(n){n.shared.audios=dn({},it.prototype)}function lq(n){n.shared.videos=dn({},it.prototype)}function cq(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 uq(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 hq(n){n.scene.publish.settings.web.preload=!1}function _D(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 DD(n){n.layers&&n.layers.forEach(t=>{vD(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 dq(n){n.shared.fonts=dn({},it.prototype)}function fq(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 pq(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=fq(i.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let l={name:i.name,...Mi.defaultData,...Tc.defaultData,flatShading:!1,wireframe:!1,geometry:{...bl.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:Ee.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,Xn(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:Ee.generateUUID(),data:c},{fi:1,id:Ee.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function gq(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={...Xn(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={...Xn(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:Ee.generateUUID(),data:{type:i,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function OD(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 ID(n){xa(n,OD),ba(n,OD)}function yq(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function vq(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 xq(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 bq(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 Sq(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 wq(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 Aq(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function Eq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function Mq(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function Tq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Gh.defaultDataThirdPerson.navmesh)})})}function Cq(n){n.scene.styles||(n.scene.styles=ga.defaultData())}function RD(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Pq(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,RD),xa(n,RD)}function _q(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ke})})})}function Dq(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function LD(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function BD(n,t){if(t<1&&(ba(n,TD),xa(n,TD),n.schema=1),t<2&&(Q8(n),n.schema=2),t<3&&(Z8(n),n.schema=3),t<4&&(J8(n),n.schema=4),t<5&&($8(n),n.schema=5),t<6&&(eq(n),n.schema=6),t<7&&(tq(n),n.schema=7),t<8&&(n.schema=8),t<9&&(PD(n),n.schema=9),t<10&&(sq(n),n.schema=10),t<11&&(oq(n),n.schema=11),t<12&&(PD(n),n.schema=12),t<13&&(aq(n),n.schema=13),t<14&&(cq(n),n.schema=14),t<15&&(uq(n),n.schema=15),t<16&&(hq(n),n.schema=16),t<17&&(ba(n,_D),xa(n,_D),n.schema=17),t<18&&(ba(n,CD),xa(n,CD),n.schema=18),t<19&&(K8(n),n.schema=19),t<20&&(dq(n),pq(n),n.schema=20),t<21&&(mq(n),gq(n),n.schema=21),t<22&&(ID(n),n.schema=22),t<23&&(yq(n),n.schema=23),t<24&&(vq(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(lq(n),t<25&&(n.schema=25)),t<26&&(rq(n),n.schema=26),t<27&&(iq(n),n.schema=27),t<28&&(ID(n),n.schema=28),t<29&&(nq(n),n.schema=29),t<30&&(xq(n),n.schema=30),t<31&&(bq(n),n.schema=31),t<33&&(Sq(n),n.schema=33),t<34&&(wq(n),n.schema=34),t<35&&(Aq(n),n.schema=35),t<36&&(Eq(n),n.schema=36),t<37&&(Mq(n),n.schema=37),t<38&&(ba(n,DD),xa(n,DD),n.schema=38),t<39&&(Tq(n),n.schema=39),t<40&&(Cq(n),n.schema=40),t<41&&(Pq(n),n.schema=41),t<42&&(_q(n),n.schema=42),t<43&&(Dq(n),n.schema=43),t<99){ba(n,LD),xa(n,LD),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=us);let e=Vr(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=yl,r.insertBefore(null,null,[{id:yl,data:{...pa.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Xn(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Xn(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Sl.defaultData,...Xn(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(yl,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,xl.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function ND(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function Oq(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 Iq(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 jh=180/Math.PI;function FD(n){n.rotation=n.rotation.slice(0,3).map(t=>t*jh)}function VD(n){FD(n),n.type==="Page"&&FD(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*jh))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*jh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*jh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=jh,t.extrusion.twist*=jh),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 Rq(n){n.shared.variables=dn({},it.prototype)}function Lq(n){let t=Vr(n.shared.variables);n.shared.variables=dn(Object.entries(t??{}).map(([e,r],i)=>({fi:i,id:e,data:r})),ke.prototype)}var Eo=113;function zD(n,t){t(n.data);for(let e of n.children)zD(e,t)}function Bq(n){let t=n.schema??104;t!==Eo&&t<105&&(zD(n.asset,VD),n.schema=105)}function Nq(n){n.shared.particles=dn({},it.prototype),n.shared.lib&&(n.shared.lib.particles=va.defaultData().particles)}function Fq(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 Vq(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 zq(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),BD(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=zs.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(ba(n,ND),xa(n,ND),n.schema=101),t<102&&(Oq(n),n.schema=102),t<104&&(n.shared.catelogs=new it,n.shared.lib=va.defaultData(),n.schema=104),t<105&&(Rq(n),n.scene.objects.traverse((e,r)=>{VD(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))Bq(e);t<106&&(Lq(n),n.schema=106),t<107&&(n.shared.lib.variables=va.defaultData().variables,n.schema=107),t<109&&(Nq(n),n.schema=109),t<110&&(Fq(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{Iq(r)}),n.schema=111),t<112&&(Vq(n),n.schema=112),t<113&&(zq(n),n.schema=113)}}var zh;(l=>{l.defaultData={schema:Eo,scene:ya.defaultData,frames:new it().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Uh.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",Uh.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",Uh.defaultData),shared:mn.emptyData()}},l.clipboard2dData=function(){return{schema:Eo,scene:ya.emptyData(),frames:new it,shared:mn.emptyData()}},l.collabHelper={...Rp,updateSchema(c){return(c.schema??0)t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(jv||(jv={}));var UD;(t=>{function n(e){return!0}t.is=n})(UD||(UD={}));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 g1;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(g1||(g1={}));var kD;(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})(kD||(kD={}));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 Up;(t=>t.defaultData={...Hv.defaultData,...g1.defaultData,states:new ke,events:new ke,visible:!0,raycastLock:!1})(Up||(Up={}));var Hh;(t=>t.defaultData={...Up.defaultData,...Wv.defaultData})(Hh||(Hh={}));var qv;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(qv||(qv={}));var y1;(t=>t.defaultData={...Hh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(y1||(y1={}));var Wh;(t=>t.defaultData={...Hh.defaultData,...qv.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Wh||(Wh={}));var v1;(t=>t.defaultData={...Hh.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"})(v1||(v1={}));var x1;(t=>t.defaultData={...Hh.defaultData,type:"path2d",path:"",name:"Path"})(x1||(x1={}));var GD;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(GD||(GD={}));var kp;(t=>t.defaultData={...Up.defaultData,name:"Group",type:"group2d"})(kp||(kp={}));var b1;(t=>t.defaultData=()=>({...Up.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}}))(b1||(b1={}));var wa;(s=>{function n(o){switch(o){case"rectangle2d":return{...Wh.defaultData};case"ellipse2d":return{...y1.defaultData};case"text2d":return{...v1.defaultData};case"vector2d":return{...Wh.defaultData};case"path2d":return{...x1.defaultData};case"frame2d":return{...b1.defaultData()};case"group2d":return{...kp.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;ue&&(e=i,t=r)}return t}function w1(n,t){t.set(n)}function A1(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]=ri?r:i}}function Gp(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;oe[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 Gq(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;si-s);for(let i=0;il&&(l=M),y&&Sp&&(p=S);let b=n[v+2],T=n[v+3],C=b-T,P=b+T;Cc&&(c=P),y&&bm&&(m=b);let D=n[v+4],_=n[v+5],O=D-_,L=D+_;Ou&&(u=L),y&&Dg&&(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 Hq(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;ua&&(a=d);let f=n[u+2];fl&&(l=f);let p=n[u+4];pc&&(c=p)}r[0]=i,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function Wq(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;)o--;if(sn.candidate-t.candidate,Al=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 Yq(n,t,e,r,i,s){let o=-1,a=0;if(s===0)o=S1(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=S1(n),o!==-1&&(a=Xq(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=M.candidate?Gp(S,e,M.rightCacheBounds):(Gp(S,e,M.leftCacheBounds),M.count++)}}for(let S=0;S=Aa&&(A=Aa-1);let M=Al[A];M.count++,Gp(x,e,M.bounds)}let y=Al[Aa-1];w1(y.bounds,y.rightCacheBounds);for(let x=Aa-2;x>=0;x--){let S=Al[x],w=Al[x+1];A1(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;xA&&(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)*HD,wt[y+3]&&(t[y+3]=A)}}return s}function Kq(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=Yq(y.boundingData,S,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let M=Wq(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 Pc,T=v,C=M-v;y.left=b,b.boundingData=new Float32Array(6),M1(o,T,C,b.boundingData,s),r(b,T,C,s,w+1);let P=new Pc,D=M,_=x-C;y.right=P,P.boundingData=new Float32Array(6),M1(o,D,_,P.boundingData,s),r(P,D,_,s,w+1)}return y}Gq(n,t);let i=new Float32Array(6),s=new Float32Array(6),o=Qq(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=jq(n);if(g.length===1){let y=g[0],v=new Pc;v.boundingData=i,Hq(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 Pc;v.boundingData=new Float32Array(6),M1(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function YD(n,t){let e=Kq(n,t),r,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;uMath.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 Tn=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;si?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;si?l:i}this.min=r,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Tn.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 efe=function(){let n=new Tn;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 Zq=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}}(),jp=function(){let n=new U,t=new E,e=new E;return function(i,s,o,a){Zq(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}}}}(),XD=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 Jq=1e-15;function Yh(n){return Math.abs(n)new E),this.satBounds=new Array(4).fill().map(()=>new Tn),this.points=[this.a,this.b,this.c],this.sphere=new Dr,this.plane=new Zr,this.needsUpdate=!0}intersectsSphere(t){return XD(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}};Cn.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]),jp(e,i,n,t),u=n.distanceToSquared(t),u1-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=Yh(y.distanceToPoint(L));if(Yh(y.normal.dot(o))&&H){u.copy(c),S=2;break}if((y.intersectLine(c,V)||H)&&!Yh(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=Yh(g.distanceToPoint(L));if(Yh(g.normal.dot(a))&&H){h.copy(c),M=2;break}if((g.intersectLine(c,V)||H)&&!Yh(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=T0?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)}}}();Cn.prototype.distanceToPoint=function(){let n=new E;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();Cn.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),dnew E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Tn),this.alignedSatBounds=new Array(3).fill().map(()=>new Tn),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}};Pn.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<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(v0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new E,materialIndex:0};Mr.getNormal(Xh,Qh,Kh,u.normal),c.face=u,c.faceIndex=s}return c}function C1(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=e9(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,i&&i.push(f),f):null}function JD(n,t,e,r,i,s){for(let o=r,a=r+i;o=0,f,p;d?(f=$h(n),p=ed(n,a)):(f=ed(n,a),p=$h(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 tO=function(){let n,t,e=[],r=new Zh(()=>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=El,A=Ml;for(;!Ea(S,w);)x=$h(x),S=x*2;return _c(x,A)}function f(x){let S=x*2,w=El,A=Ml;for(;!Ea(S,w);)x=ed(x,A),S=x*2;return _c(x,A)+Jh(S,w)}let p=s*2,m=rd,g=El,y=Ml;if(Ea(p,g)){let x=_c(s,y),S=Jh(p,g);return ds(s,m,n),l(x,S,!1,h,u+s,n)}else{let x=$h(s),S=ed(s,y),w=x,A=S,M,b,T,C;if(c&&(T=n,C=t,ds(w,m,T),ds(A,m,C),M=c(T),b=c(C),bi.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;Tnew Cn),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,[D1]:!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,[D1]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[D1]||(this._roots=YD(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;dA&&(A=D),_M&&(M=_),Ob&&(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+_]=jW?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=kn){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{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:P1(f,p,i,c,m,g,s)}else l||(c?l=(d,f,p,m)=>P1(d,f,i,c,p,m,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(id(d),u=tO(0,i,a,l,o,h),Hp(),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;nd.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;AI1.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(O1.copy(v),O1.applyMatrix4(nd),t.shapecast({intersectsBounds:x=>O1.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 Dc.set(t.min,t.max,e),Dc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Dc.intersectsBox(r),intersectsTriangle:r=>Dc.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(),Dc.set(t.boundingBox.min,t.boundingBox.max,e),Dc.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=i9,g=null,y=null;i&&(g=n9,y=s9);let v=1/0,x=null,S=null;return nd.copy(e).invert(),Wp.matrix.copy(nd),this.shapecast({boundsTraverseOrder:w=>Dc.distanceToBox(w),intersectsBounds:(w,A,M)=>M{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>Wp.distanceToBox(M),intersectsBounds:(M,b,T)=>T{for(let T=M*3,C=(M+b)*3;T(qp.copy(t).clamp(u.min,u.max),qp.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d{u.closestPointToPoint(t,qp);let d=t.distanceToSquared(qp);return d{ds(0,new Float32Array(r),iO),t.union(iO)}),t}};var Kd=Ko(sO());var o9=.5*(Math.sqrt(3)-1),Yp=(3-Math.sqrt(3))/6,a9=1/3,Co=1/6,Yfe=(Math.sqrt(5)-1)/4,Xfe=(5-Math.sqrt(5))/20,Xp=n=>Math.floor(n)|0,oO=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]),L1=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=lO(n),e=new Float64Array(t).map(i=>oO[i%12*2]),r=new Float64Array(t).map(i=>oO[i%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*o9,h=Xp(s+u),d=Xp(o+u),f=(h+d)*Yp,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+Yp,w=y-x+Yp,A=g-1+2*Yp,M=y-1+2*Yp,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 aO(n=Math.random){let t=lO(n),e=new Float64Array(t).map(s=>L1[s%12*3]),r=new Float64Array(t).map(s=>L1[s%12*3+1]),i=new Float64Array(t).map(s=>L1[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*a9,p=Xp(o+f),m=Xp(a+f),g=Xp(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):At){s=o;break}else t1&&(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 uO=Ko(B1()),l9=new ce,c9=new ce,u9=new ce,sd;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(sd||(sd={}));var od=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)sd.is(s)&&s.traverseObject(r,i+1)}traverseObject(r,i=0){if(r(this,i)!==!0)for(let o of this.children)sd.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,uO.SVD)(i),l=l9.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=c9.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=u9.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 N1=class extends od(Et){},h9=n=>n.type==="Mesh",Rr=class extends N1{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 h9(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 Oc=new E,Ic=new E,ad=new ce,dO=[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)],d9=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],f9=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],hO=(n,t,e)=>{n.updateEntityBoxSize(Oc,Ic),ad.copy(t).multiply(n.matrixWorld),Ic.x===0&&Ic.y===0&&Ic.z===0?e.push(new E(Oc.x,Oc.y,Oc.z).applyMatrix4(ad)):dO.forEach(r=>{e.push(r.clone().multiply(Ic).add(Oc).applyMatrix4(ad))})},Qp=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}hO(o,r,s)}}):hO(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(ad.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ic).multiplyScalar(.5),this.getCenter(Oc),ad.copy(this.matrix).setPosition(Oc),this.vertices=dO.map(e=>e.clone().multiply(Ic).applyMatrix4(ad))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=d9.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=f9.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Gs={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var V1=class extends cp{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;a1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var z1=.001;function U1(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=z1}function F1(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 U1(e,r,s)&&U1(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;uz1&&(m=new fc(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)>z1&&(m=new fc(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*u+1]=m}for(let u=0;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),p9={type:"completeState",isfromEntity:!0},m9=["x","y","z"],k1=new E,g9=new E().set(0,1,0),ld=n=>class extends od(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 Qp;this._recursiveBBox=new Qp;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=Ch.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*Ee.RAD2DEG,this.rotation.y*Ee.RAD2DEG,this.rotation.z*Ee.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return bh(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&&(k1.fromArray(this.getTransformValues("rotation",r,i)).multiplyScalar(Ee.DEG2RAD),this.rotation.setFromVector3(k1),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??gl.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 bh(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=Rt(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),Rt(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=Fh.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(Rt(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),Rt(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Rt(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,g9),x=k1.setFromEuler(new rr().setFromRotationMatrix(v)).multiplyScalar(Ee.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(p9)})}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=Ee.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 Ce([],3))):h||f?p=new Kp(c,u,r,i,s,o,a,l*Math.PI/180,h,h,d,f):p=new mc(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 Tl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function fO(n){return new U(n.y,-n.x)}var Kp=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=[],we=re/i,xe=we*l+a,de=new U(Math.sin(xe),Math.cos(xe));P&&T?(Y(J,we,de,V,u,P,-1,!0),Y(J,we,de,H,u,T,-1,!1)):T?(oe(J,de,T.x,0,-1),Y(J,we,de,H,u,T,-1,!1)):o||oe(J,de,e,L,-1);let Oe=fO(D).normalize();if(Tl(Oe,de,S),!te)for(let Te=0;Te<=s;Te++){let Ue=Te/s,ze=D.clone().multiplyScalar(Ue).add(M);Tl(ze,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(we,.5+w.y/r),J.push(v++)}if(C&&b?(Y(J,we,de,V,c,b,1,!1),Y(J,we,de,H,c,C,1,!0)):b?(Y(J,we,de,V,c,b,1,!1),oe(J,de,b.x,0,1)):o||oe(J,de,t,O,1),d&&!te){let Te=fO(D).multiplyScalar(-1).normalize();Tl(Te,de,S);for(let Ue=0;Ue<=s;Ue++){let ze=Ue/s,Ve=D.clone().multiplyScalar(-ze).add(j);Tl(Ve,de,w),m.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),y.push(we,.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 we=$[re][J],xe=$[re+1][J],de=$[re+1][J+1],Oe=$[re][J+1],Te=m[de*3+0],Ue=m[de*3+2];p.push(we,xe,Oe),(Te!=0||Ue!=0)&&p.push(xe,de,Oe)}lp.push(Ve,Ie,Ye):(Ve,Ie,Ye)=>p.push(Ve,Ye,Ie),Ue=new U((t+e+O+L)/4,0);Tl(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;Ve0||u>0||l<360?d=new Kp(0,t/2,r,i,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new Ja(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 j1(t,e,r,i,s,o,a,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},G1=Math.PI/2,j1=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 Ce(u,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(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;q0?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;q0?(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=G1*(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+=G1/T}A.push(C)}let b=A.length-1;for(let T=0;TS.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;Wxe[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;$A(f,()=>p.clone()));for(let W=0;Woe.add(ie),te).multiplyScalar(1/f);for(let oe=0;oeJ[xe]);a.push(...we.map(xe=>[xe.x,xe.y,xe.z]).flat()),c.push(...we.map(xe=>(w(xe,P),[S.x,S.y,S.z])).flat())}}let H=[];for(let W=0;W$%T==W),Z=j[W][q],te=j[K][G];for(let $=0;${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{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.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 Cl(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var gO=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 Zp(t*.5,s,o):new Ou(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Zp=class extends Cl{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 Zp(t.radius,t.corner,t.cornerSides)}};var Jp=1e-12,cd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=Ee.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 cd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ud=class extends cd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ud(this.parent).copy(this)}},js=class extends cd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ud(this),new ud(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;in,hd=new U,h0=new U,y9=new U,v9=new U,x9=new U,b9=new U,xO=new E,bO=new E;function SO(n){let t=new U;t.addVectors(n.v0,hd.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 $p(n,t,e=Number.EPSILON){return Math.abs(n-t)Math.PI&&(u*=-1),$p(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 Y1(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function vO(n,t){return H1(n.position,n.controls[1].position,t.position)&&H1(n.position,t.controls[0].position,t.position)}function TO(n,t,e,r,i=.5){let s=hd.subVectors(t,n).multiplyScalar(i).add(n),o=h0.subVectors(e,t).multiplyScalar(i).add(t),a=y9.subVectors(r,e).multiplyScalar(i).add(e),l=s,c=v9.subVectors(o,s).multiplyScalar(i).add(s),u=x9.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=b9.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 CO(n,t,e=12,r=!0){let i=bO.set(0,0,0),s,o=0,a=[];for(let l=0;l1&&!(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 PO(n,t,e,r=12,i=!0){let s=bO.set(0,0,0),o=0,a=[];for(let l=0;l1&&!(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 X1(n,t=12,e=!1){let r=[];for(let i=0,s=n.length;i0&&(r[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Pl(o.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Pl(n[0].roundedCurveCorner,t)*.5),r}function Pl(n,t=12){return n&&n instanceof dc?t*2:n&&(n instanceof rn||n instanceof lp)?1:n&&n instanceof Pu?t*n.points.length:t}function _O(n,t,e=12,r=!0){let i,s=0;for(let o=0;o1&&!($p(n[s-1],n[1],Jp)&&$p(n[s-2],n[0],Jp))&&(n.push(n[0],n[1]),s++),n}var Q1=new U,A9=new U,E9=new U,M9=new U,T9=new U,C9=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=Ee.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;rthis.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;o0){let r=this.points.length;for(let i=0,s=this.shapeHoles.length;i=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i=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=Q1.set(e,r);for(let s=0,o=this.points.length;s=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;eo+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=X1(this.points,e,!1),this.roundedCurveDivisions=X1(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return PO(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),_O(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=Pl(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=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(Y1(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(Q1.set(i.x,i.y))/h}let c=0;for(let h=0;h2){let r=0;for(let i=0,s=this.points.length;i0&&!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,Q1),M=d.getPointAt(w,A9);this._subSplitCurve(h,f,S,A,void 0),this._subSplitCurve(d,p,w,void 0,M);let b;if(this.useCubicForRoundedCorners){let T=q1(A,o.position,M)/2,C=Math.tan(T)*A.distanceTo(o.position),[P,D]=AO(A,M,C,E9,M9),_=EO(P,D,o.position),[O,L]=MO(_,A,M,C,T9,C9);b=new tn(A.clone(),O.clone(),L.clone(),M.clone())}else b=new Hn(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=TO(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{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;l0?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 Z1=Math.PI*2;function K1({x:n,y:t},e,r,i,s){return{x:n*e+i,y:t*r+s}}function P9(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 DO(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 _9(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=DO(1,0,x,S),b=DO(x,S,w,A);return!c&&b>0&&(b-=Z1),c&&b<0&&(b+=Z1),{centerx:y,centery:v,ang1:M,ang2:b}}function OO({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=_9(n,t,e,r,i,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(Z1/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x{let{x:S,y:w}=K1(x[0],i,s,m,g),{x:A,y:M}=K1(x[1],i,s,m,g),{x:b,y:T}=K1(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 st=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.s0?i0?(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?i0?(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}(),em=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}(),dd=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}(),IO=function(){function n(){var t=new dd,e=new em,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.sidethis.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;i0&&(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}(),J1=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}(),BO=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),O9=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new BO,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 BO;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}(),I9=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?st.vertLeq(s.Org,o.Org)?st.edgeSign(o.Dst,s.Org,o.Org)<=0:st.edgeSign(s.Dst,o.Org,s.Org)>=0:st.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return st.edgeSign(s.Dst,i,s.Org)>=0;var a=st.edgeEval(s.Dst,i,s.Org),l=st.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 J1;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(st.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=st.vertL1dist(e,t),s=st.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(st.vertLeq(i.Org,s.Org)){if(st.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;st.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(st.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(!st.vertEq(i.Dst,s.Dst)),st.vertLeq(i.Dst,s.Dst)){if(st.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(st.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 dd,f,p;if(ut(!st.vertEq(c,l)),ut(st.edgeSign(l,t.event,o)<=0),ut(st.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(st.vertLeq(o,a)){if(st.edgeSign(c,o,a)>0)return!1}else if(st.edgeSign(l,a,o)<0)return!1;return n.debugEvent(t),st.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)),st.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=st.vertLeq(o,a)?o:a,st.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),st.vertEq(d,o)||st.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!st.vertEq(l,t.event)&&st.edgeSign(l,t.event,d)>=0||!st.vertEq(c,t.event)&&st.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):(st.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),st.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),st.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),st.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}st.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,st.vertEq(i.Org,r)){ut(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!st.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),st.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 J1;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(o=r.eUp,a=i.eUp,st.edgeSign(o.Dst,e,o.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(s=st.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 J1,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 O9(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,st.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 D9(s,st.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||!st.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}(),R9=function(){function n(){this.mesh=new IO,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],sl[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.sthis.bmax[0]&&(this.bmax[0]=c.s),c.tthis.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(;st.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;st.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var s=void 0;r.Lnext!==i;)if(st.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(st.edgeGoesLeft(i.Lnext)||st.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&&(st.edgeGoesRight(r.Lprev)||st.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;f2&&(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 IO),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i2?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_(),I9.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 R9;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var v=0;vthis.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)}},tm=f0;tm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var zO=Ko(VO()),rm={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},iA={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},nA={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},rA=(n,t)=>([e,r])=>(r=e?n:n+t)<=r),Dl=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;PD.position)).getSize(new U).length()*.1:h[0].length===0?f=i:f=(0,zO.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=rm}let m;try{m=Hs({windingRule:zt.ODD,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=iA}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let P=0;Pv&&(v=O),LS&&(S=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=S-x,this._buffer=new tm(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],we=p.vertices[q*2+0],xe=p.vertices[q*2+1],de=re-oe,Oe=J-ie,Te=Math.sqrt(de*de+Oe*Oe);de/=Te,Oe/=Te;let Ue=re-we,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=[],we=[],xe=[],de=0;for(let Te=0;Teae&&(ge-=Math.PI*2);let me=ge-ae;if(V.continuous[Te]||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]=Te,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]=Te,de++}}}else re[2*de+0]=Ve+Ye,re[2*de+1]=Ie+F,xe[de]=Te,J[Te]=de,de++,re[2*de+0]=Ve,re[2*de+1]=Ie,xe[de]=Te,de++,re[2*de+0]=Ve+N,re[2*de+1]=Ie+B,xe[de]=Te,we[Te]=de,de++}let Oe=Hs({windingRule:zt.POSITIVE,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[re],edgeCreateCallback:Te=>{let ze=Te.Org.idx,Ve=xe[ze],Ie=xe[(ze+1)%xe.length];Te.idx=[Ve,Ie],Te.Sym.idx=[Ie,Ve]},vertexIdCallback:Te=>{let Ue=Te.Lprev.idx;return[Ue?Ue[1]:0,Te.idx?Te.idx[0]:0]}});if(!Oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${Y}'th loop`);if(!Oe.vertexCount){let Te=(Y-1)/this._bevelSegments*Math.PI/2;Z=(1-Math.sin(Te))*this._bevel;break}for(let Te=0;Te{let re=0,J=Y.boundary.vertexIndices.length;for(;reme){let Ne=ge/me,Re=0;for(let pe=1;pe(Re+1)*Ne&&(Re++,B=this._buildBevelVert(V,ie,(Te+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(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,Te=(Te+me)%J,xe=(xe+1)%we}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=nA}if(!oe)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel0,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 Dl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ha(this.userData),e}};var fd=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;pm&&(m=M),by&&(y=b)}let v=m-p,x=y-g;for(let S=0,w=d;S0&&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 fd(n.shape,i,{windingRule:o}):a=new pd(n.shape,t,e,i,r,o),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var kO=Math.PI*2,gd=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=Ee.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=V9(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 Ce([],3))):f=_n.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function V9(n,t,e,r,i,s){if(r>=kO)return i>30||i%4===0?(U9(n,t,e,s),Math.round(i/4)):UO(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=OO({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?z9(n,o.x,o.y,c,i,t,e,s):UO(n,r,i,t,e,s)}function z9(n,t,e,r,i,s,o,a){let l=Math.round(i/r.length);n.addPoint(md(t,e));for(let c=0,u=r.length;c0?GO(n,s,o,a):n.addPoint(md(0,0)),l}function UO(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(md(c,u))}return t0?GO(n,r,i,s):n.addPoint(md(0,0)):(n.removePoint(n.points[n.points.length-1]),s>0&&jO(n,r,i,s)),1}function U9(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&&jO(n,t,e,r)}function md(n,t){return new js(Ee.generateUUID(),new U(n,t))}function m0(n,t,e,r,i,s){let o=md(n,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(i,s),o}function GO(n,t,e,r){HO(n,t,e,r).forEach(s=>n.addPoint(s))}function jO(n,t,e,r){let i=HO(n,t,e,r),s=new Wt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,n.shapeHoles.push(s)}function HO(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=Ee.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 WO=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 im(!1,t,e,r,i,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...n,type:"HelixGeometry"}})}},sA=new uo([0,0,0],1),im=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,we=0,xe=2,de=d*xe+xe,Oe=$*de/xe,Te=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,Lt=Be?me:Le,ur=Be?$:Te,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||(we=Ar+Me,[0,1,2].forEach(He=>{ze[we*3+He]=Q.getComponent(He),Ve[we*3+He]=ye.getComponent(He)}),Ie[we*2]=+Je,Ie[we*2+1]=Me/u),g.copy(_).multiplyScalar(re),v.addVectors(y,g);for(let He=0;He{ze[we*3+Nr]=g.getComponent(Nr),Ve[we*3+Nr]=L.getComponent(Nr)});let Br=+Be+Math.sin(Pt);Ie[we*2]=(Lt+J*Br)/ge,Ie[we*2+1]=Me/u}}g.addVectors(y,D),we=Oe+Ge*$+Me,[0,1,2].forEach(He=>{ze[we*3+He]=g.getComponent(He),Ve[we*3+He]=_.getComponent(He)}),Ie[we*2]=(ae+Ge*B)/ge,Ie[we*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 Ce(ze,3)),this.setAttribute("normal",new Ce(Ve,3)),this.setAttribute("uv",new Ce(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{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 _u(i.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...n,type:"LatheGeometry"}})}};var _o=new ce,oA=new Et,g0=new E,Ol=class extends hr{constructor(){super(),this.uuid=Ee.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;r0)for(let d=0;d0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u0,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<0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Ol().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;d0){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",XO.call(new Xe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",QO.call(new Xe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",QO.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;a0){let i=new Ce(t.skinIndices.length*4,4);e.setAttribute("skinIndex",KO.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Ce(t.skinWeights.length*4,4);e.setAttribute("skinWeight",KO.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 Ce(r.vertices.length*3,3),s=new Ce(r.colors.length*3,3);if(e.setAttribute("position",y0.call(i,r.vertices)),e.setAttribute("color",XO.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Ce(r.lineDistances.length,1);e.setAttribute("lineDistance",k9.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}};Ol.prototype.isGeometry=!0;var aA=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;i0,o=i[1]&&i[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let y=0;y0){d=[];for(let y=0;y0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y0;)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;H9(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;o3&&(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;o0?(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 ku(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;m0){{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;sm(C,xe,Ve);let Ie=$.clone().add(Z).multiplyScalar(.5);Ie=W9(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;aee&&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;S0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=_n.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...n,type:"RectangleGeometry"}})}};var $O=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=Ee.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 Ce([],3))):u=new Ls(.5*t,i,s,o,a,l,c*Ee.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...n,type:"SphereGeometry"}})}};var eI=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 un(t,e,r,i);return s.scale(1,1,1),Object.assign(s,{userData:{...n,type:"PlaneGeometry"}})}};var tI=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 dA(t,e,r,i,s,o);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},dA=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{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.index0;){if(fe.binary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.lengths.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=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":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 Rc=n=>new fe(n).parse(),X9=Object.getOwnPropertyNames(fe);X9.forEach(n=>{Rc[n]===void 0&&n!=="prototype"&&(Rc[n]=fe[n])});Rc.Jsep=fe;var Q9="ConditionalExpression",K9={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:Q9,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 :")}})}};Rc.plugins.register(K9);var Z9=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],J9=["0","1","2","3","4","5","6","7","8","9","."],$9=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function e7(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}Rc.addBinaryOp("^",11,!0);function A0(n,t,e="number"){let r="";for(let o=0;o0&&"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"&&!e7(a.name)&&!J9.includes(a.name)&&!Z9.includes(a.name)&&!$9.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=Rc(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)=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 t7=new ce,r7=new ce;function i7(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=Ee.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ce().makeBasis(r[0],r[1],r[2])}var aI=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??gd.create({parameters:s1}).userData.shape;return{path:n.path??Lh.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 mA(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new _e,{userData:{...n,type:"PathGeometry"}})}},mA=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)||!oI(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{u[W]=u[W].clone().lerp(u[q],K),h[W]=i7(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 Dl(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{_=nA}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;GG+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=t7;K.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(K,j,L),K.copy(h[0]).setPosition(u[0]).multiply(r7.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;g0&&(p*=-1);for(let g=1;g{let p=f===0?0:f===s-1?1:(f-r)/(s-(i===0?0:1)-(r+(1-i)));u.makeRotationZ(Ee.lerp(o,o+a,p)*Ee.DEG2RAD);let m=Ee.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=rm}let l;try{l=Hs({windingRule:zt.ODD,elementType:Ur.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=iA}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;mh&&(h=v),xf&&(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{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=l7(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=>_n.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?zt.NONZERO:zt.ODD,subdivisions:this.isLowResolution&&o>0?a7:o7}})),w=S.length?Us(S):lI();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=dn(new _e,bd.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 l7(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 uI,M0=new Promise(n=>{uI=n}),cI=!1;var E0;function hI(){if(cI)return;if(E0)return E0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.3.1/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});uI(l),cI=!0}return E0=n(),E0}var c7=["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];Kw(h)&&!c7.includes(i)&&(u[i]=t.getVariable(h,[r.uuid,"geometry",...c,i]),Kw(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 ku().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 bd(s,t);if(s.type==="UIGeometry")return xd.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=gA(a)}catch(c){console.error(c)}if(!l){let c=Wt.createFromState(Rh.defaultData(),100,100);a.shape=c,l=gA(a)}return l}var u7=new ce;function om(n,t,e,r){let i=n.position.array,s=n.normal.array,o=u7.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=i.length;u{lt=n});var dI=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),fI=new Uint32Array([0,1,2,3]),pI=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&&om(this.subdividedGeometry.attributes,...s),this.originalGeometry&&om(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(Sd.fromArray(s));let a=Sd.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(Sd);let s={width:Sd.x,height:Sd.y,depth:Sd.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:dI,indexWASM:fI,verticesPerFaceWASM:pI},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}=Lc(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}=bA(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=dI,s=fI,o=pI);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 Ce(f,3)),S.setAttribute("normal",new Ce(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 Ce(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g>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 Lc(n,t){let e={},r=t?t.count:n.count,i=0,s=[],o=[],a=1e4;for(let c=0;c=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=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.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&af7,calcBooleanTopological:()=>d7,freeMeshSet:()=>y7,getMeshSet:()=>p7,hasOpenEdges:()=>m7,transformMeshSet:()=>g7});var gI,yI=new Promise(n=>{gI=n});var P0;function vI(){if(P0)return P0;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.3.1/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});gI(l)}return P0=n(),P0}var Mt,wd;yI.then(n=>Mt=n);function h7(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}=Lc(n.getAttribute("position"),i),a;if(t&&e){let{indices:l,verticesPerFace:c}=bA(s,o,n);a=c.length,r=[];for(let u=0,h=0;u>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 f7(n,t,e,r){wd===void 0&&(wd=Mt.init_csg());let i=xI(n),s=Mt.csg_calc(wd,i,n.length,r,bI(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 Ce(h,3)),e.setAttribute("normal",new Ce(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 p7(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;vv7[n.type].create(n);function Ad(n){return n!==null&&"booleanOp"in n}var Ed=class extends ld(tr){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ce}updateVisible(e){super.updateVisible(e),this.visible=!Ad(this.parent)&&this.visible,Ad(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ps.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ad(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ed&&(e.freeBooleanPointer(),Ad(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let i=super.updateTransformState(e,r);return i&&Ad(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ad(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var _0=new Gt;function am(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;hl&&(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 x7=new _e,b7=new Gn,dr=class extends Ed{constructor(t,e){super(x7,b7),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?am(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 lm=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 SA=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 SA;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=Ee.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 Dn=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 S7=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,SI=/[a-z_0-9]+/gi,Ae=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;h1?(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=wA;Ht.PI="PI",Ht.PI2="PI2",Ht.RECIPROCAL_PI="RECIPROCAL_PI",Ht.RECIPROCAL_PI2="RECIPROCAL_PI2",Ht.LOG2="LOG2",Ht.EPSILON="EPSILON";var A7=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.| )*?)}`,"gim"),E7=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Md=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=A7.exec(e);if(r){let i=r[2],s;for(;s=E7.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Td=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 Td});Ci.addKeyword("uv2",function(){return new Td(1)});var Bc=class extends et{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Bc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case cn:return["Linear"];case ot:return["sRGB"];default:return[]}}generate(e,r){let i=this.input.build(e,"v4"),s=this.getType(e),o=Bc.Nodes[this.method],a=e.include(o);if(a===Bc.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=Bc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Bc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},gn=Bc;gn.Nodes={LinearToLinear:new Ae(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(` `)),sRGBToLinear:new Ae(["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 Ae(["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 Ae{constructor(e="",r,i,s,o){super(e,o,s,i,r);this.nodeType="Expression"}};var yn=class extends sr{constructor(e=new Zt,r,i,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new Td,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 cm=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;ue.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=AA;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 Cd=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 cm(Cd.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 cm(Cd.Nodes.roughnessToMip,[s]),a=new ft(o,Cd.Nodes.m0,Cd.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)}},Pd=Cd;Pd.Nodes=function(){let e=new Md(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Nc=class extends et{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Nc.VIEW}getShared(){return this.scope===Nc.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 Nc.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case Nc.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case Nc.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=Nc;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)}},On=Do;On.LOCAL="local",On.WORLD="world",On.VIEW="view",On.PROJECTION="projection";Ci.addKeyword("position",function(){return new On});Ci.addKeyword("worldPosition",function(){return new On(On.WORLD)});Ci.addKeyword("viewPosition",function(){return new On(On.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 On(On.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 Pd(this.value,r??new Oo(Oo.VECTOR),i),this.irradianceNode=new Pd(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 Mu,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 wI=` uniform int frameIndex; uniform vec2 resolution; uniform mat4 previousModelViewMatrix; uniform mat4 previousProjectionMatrix; varying vec4 vCurrentPosition; varying vec4 vPreviousPosition; `,AI=` 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))); } `,EI=` // 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; `,MI=` 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); `,TI=` layout(location = 1) out vec4 gVelocity; `,CI=` // Discard fully transparent pixels if (gl_FragColor.a <= 0.0) discard; gVelocity = vec4(0.0, 0.0, 0.0, 1.0); `;var PI=["x","y","z","w"],M7=["float","vec2","vec3","vec4"],T7={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},C7={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[]"},_d=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","#include "].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(wI),this.addFragmentParsCode(AI),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r0?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(EI),this.addFragmentFinalCode(MI)),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 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(Rd.Nodes.triplanar);break;default:s=e.include(Rd.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)}},Rl=Rd;Rl.Nodes=function(){let e=new Ae(` 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 Ae(` 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 Ae(`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 Ae(`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 Ld=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 Ae(`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; }`,[Ld.Nodes.vectorLinearWorldSpaceDepth,Ld.Nodes.vectorLinearObjectSpaceDepth,Ld.Nodes.vectorSphericalObjectSpaceDepth,Ld.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)}},Bd=Ld;Bd.Nodes=function(){let e=new Ae(`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 Ae(`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 Ae(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) { float dist = length(vWPosition - origin); return ( dist - near ) / ( far - near ); }`),s=new Ae(`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 um=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 Ae(`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 TA=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(TA.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)}},Nd=TA;Nd.Nodes=function(){return{gradient:new Ae(`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 CA=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(CA.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)}},Fd=CA;Fd.Nodes=function(){return{matcap:new Ae(`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 hm=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o.VORONOI="voronoi",o))(hm||{}),zi=function(){let t=new Ae(`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 Ae(`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 Ae(`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 Ae("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new Ae("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new Ae(`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 Ae("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new Ae("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new Ae(`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 Ae(`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 Ae("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Vd=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(hm)[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 Ae(`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)}};Vd.numOctaves=5;var PA=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(PA.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."),""}},zd=PA;zd.Nodes=function(){let e=new Ae(` 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 Ae(`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 Ae(`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 Ae(`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 Ae(`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)}},Ud=Io;Ud.DrawFunctions=function(){let e=new Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`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 Ae(`// 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 _A=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(_A.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)}},kd=_A;kd.Nodes=function(){let e=new Ae(`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 Ae(`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 DA=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(DA.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)}},Gd=DA;Gd.Nodes=function(){let e=new Ae(`float rand(float n) { return fract(sin(n) * 43758.5453123); }`),r=new Ae(`float hash1(float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }`),i=new Ae(`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 Ae(`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 Ae(`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 Ae(`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 DI=function(){return{textureBicubic:new Ae(`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 OI(n,t){return n>=t?new U(t/n,1):new U(1,n/t)}var OA=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(OA.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)}},jd=OA;jd.Nodes=function(){let e=new Ae(`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 Ae(`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 Ae(`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 Ae(`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 }`,[DI.textureBicubic,i,e]),o=new Ae(`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 Ae(`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 IA=(e=>(e.NOISE="noise",e.MAP="map",e))(IA||{}),RA=class extends et{constructor(e,r,i,s,o,a,l,c,u,h,d){super("v3");this.displacementTypeIndex=new Dt(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(IA)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Dd(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(IA)[this.displacementTypeIndex.value]){case"map":{i=e.include(RA.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(hm)[this.noiseFunctionIndex.value],l=new Ae(`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 Ae(`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 Ae(`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)}},Hd=RA;Hd.Nodes=function(){let e=new Ae(`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 Ae(`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 Ae(`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 Dt(0),transmissionLod:new Dt(2)};for(let n of Object.values(Ze))n.isRenderGlobal=!0;var L0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.3.1/build/ui.wasm"};var Ca=class extends nr{constructor(){super("basic");this.nodeType="Basic";this.color=new Jt($r),this.shadingAlpha=new Fe(1),this.shadingBlend=new Dt(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 ","#include "].join(` `));let s=["#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #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 ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` `)}else{this.color===void 0&&(this.color=new Jt($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 ","#include ","varying vec3 vViewPosition;","#include "].join(` `));let l=["#include ",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 ","#include "),r=l.join(` `)}return r}};var dm=class extends nr{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Jt($r),this.emissive=new Jt(0),this.emissiveIntensity=new Fe(1),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Dt(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 ","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let s=["#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include ",` 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 "," #include "),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 Jt($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 ","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let f=["#include ",` // 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 "];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 ","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 ","#include ","#include "),r=f.join(` `)}return r}};var Pa=function(){let n=new Ae(`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 Ae(`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 fm=class extends nr{constructor(){super("phong");this.nodeType="Phong";this.color=new Jt($r),this.specular=new Jt(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Dt(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 ","#include ","#include ","#include ","#include "].join(` `));let s=["#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),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 Jt($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 ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let f=["#include ",` // 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 ","#include "),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 ","#include ","#include "),r=f.join(` `)}return r}};var pm=class extends nr{constructor(){super("standard");this.nodeType="Standard";this.color=new Jt($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 Dt(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 ","#include ","#include ","#include ","#include "].join(` `));let s=["#include ",` #include #include #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ `];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include ","#include "),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 Jt($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 ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let m=["#include "," #include ",` // 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 "),m.push("#include "),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 ","#include ","#include "),r=m.join(` `)}return r}};var mm=class extends nr{constructor(){super("toon");this.nodeType="Toon";this.color=new Jt($r),this.specular=new Jt(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new qi,this.previouseProjectionMatrix=new qi,this.shadingAlpha=new Fe(1),this.shadingBlend=new Dt(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 ","#include ","#include ","#include ","#include "].join(` `));let s=["#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&s.push(i.code,i.result?"displaced_position = "+i.result+";":""),s.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),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 Jt($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 ","#include ","#include ","#include ","#include ","#include ",` 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 ","#include ","#include "].join(` `));let d=["#include ",` // 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 ","#include "),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 ","#include ","#include "),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"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))o&&(o.image=this.img,o.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)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=II(e),this.img.onload=r}getTexture(e,r=1008){let i=this._cache[e]?.[r];if(i)return i;{let s;return this.isCanvas&&(s=new sy(this.img,void 0,e,e,void 0,r)),this.isVideo?s=new ny(this.img,void 0,e,e):s=new Zt(this.img,void 0,e,e,void 0,r),this.loaded&&(s.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]=s,s}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let i of Object.values(r))i&&(i.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[i,s]of Object.entries(r))s?.dispose(),this._cache[e][i]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var Kn=class extends Wd{};function FA(n,t){var e=O7(t);return e.formatToParts?_7(e,n):D7(e,n)}var P7={year:0,month:1,day:2,hour:3,minute:4,second:5};function _7(n,t){try{for(var e=n.formatToParts(t),r=[],i=0;i=0&&(r[s]=parseInt(e[i].value,10))}return r}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function D7(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 NA={};function O7(n){if(!NA[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";NA[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 NA[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 RI=36e5,I7=6e4,VA={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function gm(n,t,e){var r,i;if(!n||(r=VA.timezoneZ.exec(n),r))return 0;var s;if(r=VA.timezoneHH.exec(n),r)return s=parseInt(r[1],10),LI(s)?-(s*RI):NaN;if(r=VA.timezoneHHMM.exec(n),r){s=parseInt(r[1],10);var o=parseInt(r[2],10);return LI(s,o)?(i=Math.abs(s)*RI+o*I7,s>0?-i:i):NaN}if(B7(n)){t=new Date(t||Date.now());var a=e?t:R7(t),l=zA(a,n),c=e?l:L7(t,l,n);return-c}return NaN}function R7(n){return V0(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds())}function zA(n,t){var e=FA(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 L7(n,t,e){var r=n.getTime(),i=r-t,s=zA(new Date(i),e);if(t===s)return t;i-=s-t;var o=zA(new Date(i),e);return s===o?s:Math.max(s,o)}function LI(n,t){return-23<=n&&n<=23&&(t==null||0<=t&&t<=59)}var BI={};function B7(n){if(BI[n])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:n}),BI[n]=!0,!0}catch{return!1}}var WI=Ko(FI(),1),GA=Ko(zI(),1);var V7=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,UI=V7;var UA=36e5,kI=6e4,z7=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:UI};function jA(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?z7:(0,WI.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=U7(n),s=k7(i.date,r),o=s.year,a=s.restDateString,l=G7(a,o);if(isNaN(l))return new Date(NaN);if(l){var c=l.getTime(),u=0,h;if(i.time&&(u=j7(i.time),isNaN(u)))return new Date(NaN);if(i.timeZone||e.timeZone){if(h=gm(i.timeZone||e.timeZone,new Date(c+u)),isNaN(h))return new Date(NaN)}else h=(0,GA.default)(new Date(c+u)),h=(0,GA.default)(new Date(c+u+h));return new Date(c+u+h)}else return new Date(NaN)}function U7(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 k7(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 G7(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,jI(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 q7(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 jI(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,HI(t,s)?GI(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 HI(t,s,l)?GI(t,s,l):new Date(NaN)}return null}function j7(n){var t,e,r;if(t=vn.HH.exec(n),t)return e=parseFloat(t[1].replace(",",".")),kA(e)?e%24*UA:NaN;if(t=vn.HHMM.exec(n),t)return e=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),kA(e,r)?e%24*UA+r*kI: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 kA(e,r,i)?e%24*UA+r*kI+i*1e3:NaN}return null}function GI(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 H7=[31,28,31,30,31,30,31,31,30,31,30,31],W7=[31,29,31,30,31,30,31,31,30,31,30,31];function qI(n){return n%400===0||n%4===0&&n%100!==0}function jI(n,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var r=qI(n);if(r&&e>W7[t]||!r&&e>H7[t])return!1}return!0}function q7(n,t){if(t<1)return!1;var e=qI(n);return!(e&&t>366||!e&&t>365)}function HI(n,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function kA(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=jA(n,e),i=gm(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 HA(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 YI(n,t){switch(n.type){case"fresnel":return Q7(n,t);case"gradient":return K7(n,t);case"depth":return Z7(n,t);case"normal":return J7(n,t);case"noise":return $7(n,t);case"rainbow":return eY(n,t);case"toon":return tY(n,t);case"outline":return rY(n,t);case"transmission":return iY(n,t);case"color":return X7(n,t);case"pattern":return nY(n,t)}}function Y7(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{...Y7(n),alpha:s,mode:r,isMask:i}}function X7(n,t){return{...Xs(n,t),color:Yi(n.color,t)}}function Q7(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 K7(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 Z7(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 J7(n,t){let{cnormal:e}=n;return{...Xs(n,t),cnormal:new E(e[0],e[1],e[2])}}function $7(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 eY(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 tY(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 rY(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 iY(n,t){return{...Xs(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function nY(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 Ll=class extends mr{};var sY={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},oY={depth:["colors"]};function aY(n,t,e){if(t==="isMask")return!0;let r=sY[n.type],i=oY[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 WA(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 Kn||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=r;l.image instanceof Kn||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("rotation"in s&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(s.rotation??0)*Ee.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 XI(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(qA(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 Il))switch(i=i||aY(e,s,o),a.constructor){case Jt:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Ll?a.value=new mr(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case Dn:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Ll?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:{WA(o,t,e);break}case Ys:{a.value=o.map(l=>new Ke(...l));break}default:{a.value=o;break}}}return i}var Bl=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Nl=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)qA(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.canvas(r.texture.image)??i.image(r.texture.image):i.video(r.texture.video),o=new Fc(s,r.texture.wrapping,r.texture.minFilter??1008),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 Dt(r.projection??0),h=new Dt(["x","y","z"].indexOf(r.axis)??0),d=new Dt(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(Bl(r.alpha,i)),g=new Dt(r.mode??0),y=new Yr(r.isMask??!1),v=new Rl(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 Fc(s,r.texture.wrapping,r.texture.minFilter??1008),a=new Fe(Bl(r.alpha,i)),l=new Dt(r.mode??0),c=new Yr(r.isMask??!1),u=new Fe(r.texture.rotation??0),h=new Fd(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 Dt(r.noiseType??0),u=new Dt(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 Dt(r.quality??1),g=new Hd(a,l,s,u,h,d,f,p,m,o,c);return new ym(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 uY(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):XI(i.props,r.shared,this,e)}else if(i.path[0]==="texture")return"texture"in e||"video"in e?WA(i.props,r.shared,this):!0;return!1}dispose(){if(lY(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Kn||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 Nl{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}},ym=class extends Nl{constructor(e,r,i,s,o,a){super(e,r,i,s,a);this.position=o}},xn=class extends Nl{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(Bl(i.alpha,s)),l=new Dt(i.mode),c=new Fe(i.bumpMapIntensity),u=new Fe(Bl(i.alphaOverride,s)),h;if(!i.visible)o=new Ca,h={};else if(i.category==="lambert"){o=new dm;let d=new Jt(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 mm;let d=new Fe(i.shininess??30),f=new Jt(s.color(i.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(i.category==="physical"){o=new pm;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 fm;let d=new Fe(i.shininess??30),f=new Jt(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 lY(n){let t=n instanceof Nl?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function ms(n){return{alpha:new Fe(n.alpha??1),mode:new Dt(n.mode??0),isMask:new Yr(n.isMask??!1)}}function cY(n,t,e,r,i){switch(n.type){case"color":{let s=new Jt(r.color??$r),o=ms(r),a=new Vc(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 Jt(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=ms(r),h=new um(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=ms(r),d=new kd(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=ms(r),m=new jd(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 Dt(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 Dn(r.shadowColor),f=new Wi(r.offset??new E(0,0,0)),p=ms(r),m=new Gd(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 Jt(r.outlineColor??16777215),o=new Jt(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=ms(r),w=new zd(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 Dt(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=ms(r),g=new Bd(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 Dn(r.colorA),d=new Dn(r.colorB),f=new Dn(r.colorC),p=new Dn(r.colorD),m=new Dt(r.noiseType??0),g=new Dt(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 Dt(r.quality??1),A=ms(r),M=new Vd(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=ms(r),a=new Id(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 Dt(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=ms(r),f=new Nd(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 Dt(r.style??0),o=new Dt(r.projection??0),a=new Dt(["x","y","z"].indexOf(r.axis)??0),l=new Fe(r.blending??0),c=new kr(r.offset??new U(0,0)),u=new Dn(r.colorA),h=new Dn(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 Dt(r.sides??6),w=ms(r),A=new Ud(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 Jt(1,0,0,1),o=ms(r),a=new Vc(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 uY(n,t,e,r){let i=YI(e,r);return cY(e,n,t,i,r)}function qA(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=Bl(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 Uc(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 In=class extends at{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 In{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 In{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=>Nl.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=Uc(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,i){if(e[0]==="alphaOverride")this.transparent=Uc(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=Uc(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;ol.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:Bl(e.props.alpha,s,["material",this.uuid,"layer",o,"alpha"])}:c={...e.props,alphaOverride:Bl(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;e0){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&&ei instanceof xn);if(this.layers.length>r+1){for(let i=r+1;ir instanceof ym);if(e.length>0){let r=e[0].position;for(let i=1;iMath.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;re.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 Fc&&!r.image.loaded)return!1}return!0}};Object.defineProperties(In.prototype,{properties:{get:function(){return this.fragment.properties}}});var kc=class extends _a{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var QI=new Map;function KI(n){if(typeof n=="string")return n;let t=QI.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},QI.set(n,t)),t.url}var JI,$I=new Promise(n=>{JI=n}),ZI=!1;var j0;function eR(){if(ZI)return;if(j0)return j0;async function n(){await import("./howler.js"),JI(window!==void 0?window:global),ZI=!0}return j0=n(),j0}var tR;$I.then(n=>tR=n);function rR(n){let t=!1;return n.scene.objects.traverse((e,r)=>{if(r.visible===!1||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:KI(t),format:"wav"},this.sound=new tR.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 pc,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)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(;P0&&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{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,S=999999999;for(let w=0;wy&&(y=A.y),A.yx&&(x=A.x),A.x=S&&(u=S-1),g.length&&d.push({curves:m.curves,points:g,isCW:Iu.isClockWise(g),identifier:c++,boundingBox:new ju(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 pc;w.curves=S.curves,y.holes.push(w)}}),p.push(y)}}),p}};var YA=!1,nR,XA=new Promise(n=>{nR=n}),iR=!1;var W0;function sR(){if(YA=!0,iR)return;if(W0)return W0;async function n(){let e=await import("./opentype.js");nR(e),iR=!0}return W0=n(),W0}var vm=class{async load(t,e,r=()=>{}){let{load:i}=await XA;i(t,(s,o)=>{s||!o?r(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:r}=await XA;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 hY(n){return await(await fetch(n)).arrayBuffer()}var dY=new vm;async function QA(n){let t,e,r=!1;if(n.url?(t=await hY(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(YA){let i=await dY.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 fY(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=QA(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=QA(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;ce.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(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=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=pY(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{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},xm=class extends KA{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 oR={markNeedsUpdateRendererDirty:()=>{}};var ZA=class extends F0{constructor(e){super();this.shared=e}create(e){return new Wd(e,this.shared)}},Gc=class{constructor(t,e={},r=!0){this.data=t;this.needsJitter=r;this.geometryCache=new xm(!0);this.geometryCache2=new xm(!1);this.imageHolderCache=new ZA(this);this.thisContext={scene:oR,shared:this};this.deletedMaterial=new kc(ei.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Kn(jv.emptyImage,this);this.deletedVideo=new Kn(Ih.defaultVideo,this);this.materials={};this.images={};this.canvases={};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[i,s]of Object.entries(e.images))this.addImage(i,s);if(e.videos)for(let[i,s]of Object.entries(e.videos))this.addVideo(i,s);if(e.audios)for(let[i,s]of Object.entries(e.audios))this.addAudio(i,s);if(e.particles)for(let[i,s]of Object.entries(e.particles))this.addParticle(i,s);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){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 kc(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 Kn(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)}addCanvas(t,e){return this.canvases[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[t].updateSrc(e),!0):(this.canvases[t]=new Kn(e,this),!1)}canvas(t){return this.canvases[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Kn(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 Ll(e.r,e.g,e.b,e.a):this.colors[t]=new Ll(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){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(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;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{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;iOr.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):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)}}},vTe=new Gc(mn.emptyData());var gs=class extends dr{updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),I2(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(Rt(e.path,["material"])&&this.material instanceof In)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Ir.drop(e,1),r.material,i);else if(Rt(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&sr.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{e instanceof In&&(e instanceof kc||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var aR=new E,lR=new Ke,cR=new Ke,gY=new E,uR=new ce,ar=class extends gs{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 Gc){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 zp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return zp.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Rt(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&&om(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{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o{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),Yd(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(bm),this.hasNonUniformScale&&bm.divide(this.scale);let s={width:bm.x,height:bm.y,depth:bm.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 dR=-1,xY=1,fR={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},pR={polygon_center:0,edge:1,vertex:2},Sm=(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-dR)*(e-r)/(xY-dR)+r};function mR(n){let t=[],e={};for(var r=0,i=n.length;rMath.round(o*1e4)/1e4));e[s]||(t.push(n[r]),e[s]=!0)}return t}var bY=new E,Y0=new E,SY=new E,wY=new E;function Xd(n,t){let e=SY.fromArray(n),r=wY.fromArray(t);Y0.copy(r).sub(e);let i=Y0.length();return Y0.normalize().multiplyScalar(i*.5),bY.copy(e).add(Y0).toArray()}var ys=new Mr,X0=new E,Q0=new E,jc=new E;function gR(n){let t=[];for(let e=0;e<=n.index.count;e++)if(X0.fromArray(n.index.array,e*3),ys.setFromAttributeAndIndices(n.attributes.position,X0.x,X0.y,X0.z),ys.getNormal(Q0),ys.getMidpoint(jc),!(isNaN(jc.x)||isNaN(jc.y)||isNaN(jc.z))){let{a:r,b:i,c:s}=ys,o=r.toArray(),a=i.toArray(),l=s.toArray(),c=r.distanceTo(i),u=i.distanceTo(s),h=s.distanceTo(r),d=Xd(o,a),f=Xd(a,l),p=Xd(l,o),m=[c,u,h],g=Math.max(...m),y=m.filter(S=>Math.round(S)===Math.round(g)).length>1,v=[],x=ys.getMidpoint(jc).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:ys.getNormal(Q0).toArray()})}return t}function yR(n){let t=[],{position:e}=n.attributes;for(let r=0;r.5*(1-Math.cos(n*Math.PI)),$A=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=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()}},vR=$A;var xR=new E,bR=new ce,SR=new Rs;function eE(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Qd=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)&&(bR.copy(i).invert(),SR.copy(e.ray).applyMatrix4(bR),SR.intersectBox(this.singleBBox,xR))){let s=xR.applyMatrix4(i),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var bn=1e-4,Lo,ER,MR,TR,wR=new E,AR=new E;M0.then(n=>{Lo=n,ER=[Lo.get_face_center,Lo.get_edge_midpoint,Lo.get_vertex_position],MR=[Lo.get_face_normal,Lo.get_edge_normal,Lo.get_vertex_normal],TR=[Lo.face_count,Lo.edge_count,Lo.vertex_count]});var MY=new ce,TY=new ce,Fl=new E,K0=new E,wm=new E,tE=new E,CY=new E,PY=new E;var Oa=new vR,Ui=class extends od(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{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=fR[r.axis],g=this.children;p.setRandomGenerator((0,Kd.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(wm,tE):(f.length&&(wm.fromArray(f[y].pos),tE.fromArray(f[y].norm)),this.objectForSample instanceof Qs&&wm.applyMatrix4(MY.copy(this.objectForSample.matrixWorld).invert())),wm.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(wm),Fl.fromArray(m);let T=r.align==="normal"?tE:this.object.getWorldDirection(PY),C=K0.fromArray(r.position);K0.x+=l(w,vt(S,s.position[0])),K0.y+=l(w,vt(S,s.position[1])),K0.z+=l(w,vt(S,s.position[2]));let P=Math.acos(T.dot(Fl)),D=CY.crossVectors(Fl,T).normalize(),_=TY.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(Fl.y,Fl.z,Fl.x).normalize(),H=V.clone().cross(Fl).normalize(),W=new ce().makeBasis(V,Fl,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=pR[e],s=TR[i],o=ER[i],a=MR[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);wR.fromArray(h).applyMatrix4(r.matrixWorld),AR.fromArray(d),l.push({pos:wR.toArray(),norm:AR.toArray()})}return l}else return(this.objectForSample.geometry.index?gR(this.objectForSample.geometry):yR(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 Z0=new Rs,rE=new Dr,CR=new ce,No=(n,t,e,r,i=!1)=>{let s=t,o=n.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),rE.copy(s.boundingSphere),rE.applyMatrix4(o),e.ray.intersectsSphere(rE)===!1||(CR.copy(o).invert(),Z0.copy(e.ray).applyMatrix4(CR),s.boundingBox!==null&&Z0.intersectsBox(s.boundingBox)===!1))return;let a,l,c,u,h=s.index,d=s.attributes.position,f=s.drawRange,p,m;if(i===!1){let y=Math.max(0,f.start),v=Math.min(h.count,f.start+f.count);for(p=y,m=v;pC)continue;A.applyMatrix4(n.matrixWorld);let j=e.ray.origin.distanceTo(A);je.far||r.push({distance:j,point:w.clone().applyMatrix4(n.matrixWorld),object:n})}}function g(y,v,x,S,w,A,M){let b=new E,T=new E,C=new E,P=new E,D=new E;if(b.fromBufferAttribute(S,w),T.fromBufferAttribute(S,A),C.fromBufferAttribute(S,M),x.intersectTriangle(b,T,C,!1,P)===null)return null;D.copy(P),D.applyMatrix4(y.matrixWorld);let O=v.ray.origin.distanceTo(D);return Ov.far?null:{faceIndex:1,distance:O,point:D.clone(),object:y}}};var J0=new E,vs=new jn,iE=class extends Za{constructor(e){let r=new _e,i=new ns({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 Ce(s,3)),r.setAttribute("color",new Ce(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;vs.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,vs,-s,-o,a),Ks("n2",r,e,vs,s,-o,a),Ks("n3",r,e,vs,-s,o,a),Ks("n4",r,e,vs,s,o,a);let l=a;Ks("f1",r,e,vs,-s,-o,l),Ks("f2",r,e,vs,s,-o,l),Ks("f3",r,e,vs,-s,o,l),Ks("f4",r,e,vs,s,o,l);let c=l,u=.5;Ks("u1",r,e,vs,s*.7*u,o*1.1,c),Ks("u2",r,e,vs,-s*.7*u,o*1.1,c),Ks("u3",r,e,vs,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){J0.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;ct.is=e=>"objectHelper"in e)(ex||(ex={}));var xs=(n,t)=>class extends ld(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 nl&&(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 nl&&(s.visible=!1)}}};var tx=790,Zd=new E,nE=new E,sE=new Qe,oE=new E,Am=new E,aE=new E,xr=class extends xs(jn,$0){constructor(e="",r={...Cc.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=vl.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 Tu(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(Zd),this.targetOffset=Zd.distanceTo(e)}getTarget(e=new E){return this.getWorldDirection(nE),this.getWorldPosition(Zd),nE.multiplyScalar(this.targetOffset),e.copy(Zd).add(nE),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Zd),Zd.distanceTo(e)}updateUp(){this.getWorldQuaternion(sE),oE.set(0,0,1).applyQuaternion(sE),Am.copy(Et.DEFAULT_UP),this.isUpVectorFlipped&&Am.negate(),Am.applyQuaternion(sE),aE.copy(Et.DEFAULT_UP).projectOnPlane(oE),this.angleOffsetFromUp=aE.angleTo(Am),this.angleOffsetFromUp*=aE.cross(Am).dot(oE)>=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=-tx*.5*s,this.right=tx*.5*s,this.top=tx*.5*(1/o),this.bottom=-tx*.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 bh(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 Jd=new ce,DY=new ce;function lE(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var Rn=class extends gs{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;s0&&o.geometry.drawRange.count>0&&o.booleanMeshSetAddress!==0){Jd.multiplyMatrices(o.hiddenMatrix,o.matrix);try{if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=ps.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;ps.transformMeshSet(o.booleanMeshSetAddress,Jd),o.booleanMatrixInvOld.copy(Jd).invert(),o.booleanWasTransformed=!1}else o instanceof Rn&&o.needsTransformForDownstream===!0?(ps.transformMeshSet(o.booleanMeshSetAddress,Jd),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(ps.transformMeshSet(o.booleanMeshSetAddress,DY.multiplyMatrices(Jd,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(Jd).invert(),o.booleanWasTransformed=!1)}catch(a){console.error(a),o.booleanMeshSetAddress=0,o.geometry.userData.booleanOperationDidFail=!0;continue}ps.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 Ce([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return ps.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=ps.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),Yd(this)}dispose(){super.dispose(),this.geometry.dispose()}};var rx;(t=>{function n(e){return yt.is(e)&&e instanceof rl}t.is=n})(rx||(rx={}));var $d=(n,t)=>class extends xs(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 nn=n=>n instanceof dr,Sn=n=>n!==null&&n instanceof Rn,PR=n=>n instanceof xr,_R=n=>rx.is(n),Em=n=>ex.is(n);var bs=class extends Bo(xy){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){No(this.object,bs.geometryHelper,e,r)}update(){}};var Ss=class extends xs(ts,bs){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 Vl=class extends xs(ts,bs){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 NR={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Mm="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var OY=`#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;}}`,ix=class extends at{constructor(n=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:n?"2":"1"},uniforms:{kernel64:new he(null),kernel16:new he(null),inputBuffer:new he(null),cocBuffer:new he(null),texelSize:new he(new U),scale:new he(1)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:OY,vertexShader:Mm}),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 DR(n,t,e){return n*(t-e)-t}function fE(n,t,e){return Math.min(Math.max((n+t)/(t-e),0),1)}var IY=`#include #include #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));}`,RY=class extends at{constructor(n){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new he(null),focusDistance:new he(0),focusRange:new he(0),cameraNear:new he(.3),cameraFar:new he(1e3)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:IY,vertexShader:Mm}),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-DR(this.focusDistance,this.near,this.far)}set worldFocusDistance(n){this.focusDistance=fE(-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-DR(this.focusRange,this.near,this.far)}set worldFocusRange(n){this.focusRange=fE(-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)}},LY=`#include #include #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 #include }`,BY="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);}",OR=class extends at{constructor(n=new U){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new he(null),texelSize:new he(new U),halfTexelSize:new he(new U),kernel:new he(0),scale:new he(1)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:LY,vertexShader:BY}),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)}},NY=`#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 }`,FY=class extends at{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new he(null),opacity:new he(1)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:NY,vertexShader:Mm}),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 VY=`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 #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);}`,ef={DEPTH:0,LUMA:1,COLOR:2},UY={DISABLED:0,DEPTH:1,CUSTOM:2},kY=class extends at{constructor(n=new U,t=ef.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 he(null),depthBuffer:new he(null),predicationBuffer:new he(null),texelSize:new he(n)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:VY,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)}},GY=`#include #include #include #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 #endif #include }`,jY="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"},pE=class extends at{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 he(null),depthBuffer:new he(null),resolution:new he(new U),texelSize:new he(new U),cameraNear:new he(.3),cameraFar:new he(1e3),aspect:new he(1),time:new he(0)},blending:Kt,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=GY.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=jY.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 HY=`#include #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 }`,WY=class extends at{constructor(n=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:oa.replace(/\D+/g,"")},uniforms:{inputBuffer:new he(null),threshold:new he(0),smoothing:new he(1),range:new he(null)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:HY,vertexShader:Mm}),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}},qY=`#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 }`,FR={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},YY=class extends at{constructor(n=null){super({name:"MaskMaterial",uniforms:{maskTexture:new he(n),inputBuffer:new he(null),strength:new he(1)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:qY,vertexShader:Mm}),this.toneMapped=!1,this.setColorChannel(NR.RED),this.setMaskFunction(FR.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 XY=`#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;i0.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;i0.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;iend&&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;i0.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;iend&&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;i0.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;}`,QY="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);}",KY=class extends at{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 he(null),searchTexture:new he(null),areaTexture:new he(null),resolution:new he(t),texelSize:new he(n)},blending:Kt,depthWrite:!1,depthTest:!1,fragmentShader:XY,vertexShader:QY}),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 ZY=new jn,zl=null;function JY(){if(zl===null){let n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);zl=new _e,zl.setAttribute!==void 0?(zl.setAttribute("position",new Xe(n,3)),zl.setAttribute("uv",new Xe(t,2))):(zl.addAttribute("position",new Xe(n,3)),zl.addAttribute("uv",new Xe(t,2)))}return zl}var pi=class{constructor(n="Pass",t=new bi,e=ZY){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 tr(JY(),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()}}}},Tm=class extends pi{constructor(n,t=!0){super("CopyPass"),this.fullscreenMaterial=new FY,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===ot&&(this.renderTarget.texture.encoding=ot))}};var VR=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)}},cE=new We,mE=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?(cE.copy(n.getClearColor(cE)),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(cE,a):c&&n.setClearAlpha(a)}},Ul=-1,Bn=class extends hr{constructor(n,t=Ul,e=Ul,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!==Ul?r=t.width:t.height!==Ul?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!==Ul?r=t.height:t.width!==Ul?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(Ul),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 Ul}},uE=!1,IR=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=kn;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,uE){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 uE}static set workaroundEnabled(n){uE=n}},$Y=class extends pi{constructor(n,t,e=null){super("RenderPass",n,t),this.needsSwap=!1,this.clearPass=new mE,this.overrideMaterialManager=e===null?null:new IR(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 IR(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}},gE=class extends pi{constructor(n,t,{resolutionScale:e=1,width:r=Bn.AUTO_SIZE,height:i=Bn.AUTO_SIZE,renderTarget:s}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new $Y(n,t,new op({depthPacking:ow}));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:Ft,magFilter:Ft,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new Bn(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 E_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},eX="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);}",tX="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));}",rX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",iX="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);}",nX="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);}",sX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",oX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",aX="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);}",lX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",cX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",uX="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);}",hX="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);}",dX="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",fX="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);}",pX="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);}",mX="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);}",gX="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);}",yX="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);}",vX=new Map([[Ct.SKIP,null],[Ct.ADD,eX],[Ct.ALPHA,tX],[Ct.AVERAGE,rX],[Ct.COLOR_BURN,iX],[Ct.COLOR_DODGE,nX],[Ct.DARKEN,sX],[Ct.DIFFERENCE,oX],[Ct.EXCLUSION,aX],[Ct.LIGHTEN,lX],[Ct.MULTIPLY,cX],[Ct.DIVIDE,uX],[Ct.NEGATION,hX],[Ct.NORMAL,dX],[Ct.OVERLAY,fX],[Ct.REFLECT,pX],[Ct.SCREEN,mX],[Ct.SOFT_LIGHT,gX],[Ct.SUBTRACT,yX]]),xX=class extends hr{constructor(n,t=1){super(),this.f=n,this.opacity=new he(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 vX.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 xX(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 RR(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 bX(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=pE.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)),RR(n,h,i),RR(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 Hc=class extends pi{constructor(n,...t){super("EffectPass"),this.fullscreenMaterial=new pE(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=pE.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=bX(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}}},SX=[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])],sx=class extends pi{constructor({resolutionScale:n=.5,width:t=Bn.AUTO_SIZE,height:e=Bn.AUTO_SIZE,kernelSize:r=Cm.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 Bn(this,t,e,n);i.addEventListener("change",s=>this.setSize(i.baseWidth,i.baseHeight)),this.blurMaterial=new OR,this.ditheredBlurMaterial=new OR,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=SX[this.kernelSize],u=this.blurMaterial,h=t,d,f;for(this.fullscreenMaterial=u,d=0,f=c.length-1;dthis.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 mE(!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 Ln=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")}},hE=1/1e3,AX=1e3,UR=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*hE}getFixedDelta(){return this.fixedDelta*hE}setFixedDelta(n){return this.fixedDelta=n*AX,this}getElapsed(){return this.elapsed*hE}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 Cm={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var EX=`#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);}`,kR=class extends Vo{constructor({blendFunction:n=Ct.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:e=.025,resolutionScale:r=.5,intensity:i=1,width:s=Bn.AUTO_SIZE,height:o=Bn.AUTO_SIZE,kernelSize:a=Cm.LARGE}={}){super("BloomEffect",EX,{blendFunction:n,uniforms:new Map([["map",new he(null)],["intensity",new he(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 wX({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=e,this.blurPass=new sx({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===ot&&(this.renderTarget.texture.encoding=ot))}};var MX="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);}",GR=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,brightness:t=0,contrast:e=0}={}){super("BrightnessContrastEffect",MX,{blendFunction:n,uniforms:new Map([["brightness",new he(t)],["contrast",new he(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}},TX="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",jR=class extends Vo{constructor(n=Ct.NORMAL){super("ColorAverageEffect",TX,{blendFunction:n})}};var CX="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));}",PX="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;}",HR=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,offset:t=new U(.001,5e-4)}={}){super("ChromaticAberrationEffect",CX,{vertexShader:PX,blendFunction:n,attributes:Fo.CONVOLUTION,uniforms:new Map([["offset",new he(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 _X=`#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;}`,WR=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=Bn.AUTO_SIZE,height:c=Bn.AUTO_SIZE}={}){super("DepthOfFieldEffect",_X,{blendFunction:t,attributes:Fo.DEPTH,uniforms:new Map([["nearColorBuffer",new he(null)],["farColorBuffer",new he(null)],["nearCoCBuffer",new he(null)],["scale",new he(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 Ln(new RY(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 sx({kernelSize:Cm.MEDIUM,width:l,height:c});let h=this.blurPass.getResolution();h.addEventListener("change",f=>this.setSize(h.getBaseWidth(),h.getBaseHeight())),this.maskPass=new Ln(new YY(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=FR.MULTIPLY,d.colorChannel=NR.GREEN,this.bokehNearBasePass=new Ln(new ix(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new Ln(new ix(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new Ln(new ix(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new Ln(new ix(!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 fE(-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===ot&&(this.renderTarget.texture.encoding=ot,this.renderTargetNear.texture.encoding=ot,this.renderTargetFar.texture.encoding=ot,this.renderTargetMasked.texture.encoding=ot))}};var N_e=new E,F_e=new ce;var DX="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);}",qR=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,hue:t=0,saturation:e=0}={}){super("HueSaturationEffect",DX,{blendFunction:n,uniforms:new Map([["hue",new he(new E)],["saturation",new he(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 U_e=new We;var OX=`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 }`,YR=class extends Vo{constructor({blendFunction:n=Ct.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",OX,{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 IX="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));}}",XR=class extends Vo{constructor(n=30){super("PixelationEffect",IX,{uniforms:new Map([["active",new he(!1)],["d",new he(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 j_e=Math.PI*.5,H_e=new E,W_e=new E;var LR="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",BR="data:image/png;base64,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",RX="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;}",LX="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},ox=class extends Vo{constructor({preset:n=Ia.MEDIUM,edgeDetectionMode:t=ef.COLOR,predicationMode:e=UY.DISABLED}={}){super("SMAAEffect",RX,{vertexShader:LX,blendFunction:Ct.NORMAL,attributes:Fo.CONVOLUTION|Fo.DEPTH,uniforms:new Map([["weightMap",new he(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 mE(!0,!1,!1),this.clearPass.overrideClearColor=new We(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new Ln(new kY),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=e,this.weightsPass=new Ln(new KY);let s=new fp;s.onLoad=()=>{let o=new Zt(r);o.name="SMAA.Search",o.magFilter=Ft,o.minFilter=Ft,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!0,this.weightsMaterial.searchTexture=o;let a=new Zt(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=LR,i.src=BR),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 LR}static get areaImageDataURL(){return BR}};var BX=`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);}`,nx={DEFAULT:0,ESKIL:1},QR=class extends Vo{constructor({blendFunction:n=Ct.NORMAL,technique:t=nx.DEFAULT,eskil:e=!1,offset:r=.5,darkness:i=.5}={}){super("VignetteEffect",BX,{blendFunction:n,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new he(r)],["darkness",new he(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===nx.ESKIL}set eskil(n){this.technique=n?nx.ESKIL:nx.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}},X_e=[new Float32Array(3),new Float32Array(3)],Q_e=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],K_e=[[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 Z_e=[new Float32Array(2),new Float32Array(2)];var J_e=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),$_e=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],e2e=[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])],t2e=[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 r2e=new Map([[sn(0,0,0,0),new Float32Array([0,0,0,0])],[sn(0,0,0,1),new Float32Array([0,0,0,1])],[sn(0,0,1,0),new Float32Array([0,0,1,0])],[sn(0,0,1,1),new Float32Array([0,0,1,1])],[sn(0,1,0,0),new Float32Array([0,1,0,0])],[sn(0,1,0,1),new Float32Array([0,1,0,1])],[sn(0,1,1,0),new Float32Array([0,1,1,0])],[sn(0,1,1,1),new Float32Array([0,1,1,1])],[sn(1,0,0,0),new Float32Array([1,0,0,0])],[sn(1,0,0,1),new Float32Array([1,0,0,1])],[sn(1,0,1,0),new Float32Array([1,0,1,0])],[sn(1,0,1,1),new Float32Array([1,0,1,1])],[sn(1,1,0,0),new Float32Array([1,1,0,0])],[sn(1,1,0,1),new Float32Array([1,1,0,1])],[sn(1,1,1,0),new Float32Array([1,1,1,0])],[sn(1,1,1,1),new Float32Array([1,1,1,1])]]);function dE(n,t,e){return n+(t-n)*e}function sn(n,t,e,r){let i=dE(n,t,.75),s=dE(e,r,1-.25);return dE(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 tf=class extends ri{constructor(){super(kR),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 rf=class extends ri{constructor(){super(GR)}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 nf=class extends ri{constructor(){super(HR),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 sf=class extends ri{constructor(){super(jR)}};var of=class extends ri{constructor(){super(qR);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 af=class extends ri{constructor(){super(YR),this.blendFunction=Ct.OVERLAY}};var lf=class extends ri{constructor(){super(QR)}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 cf=class extends ri{constructor(e){super(WR)}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 uf=class extends ri{constructor(){super(XR)}get granularity(){return this.effect.getGranularity()}set granularity(t){this.effect.setGranularity(t)}};var KR=`#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 ZR=`#define GLSLIFY 1 #include 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_depth1.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]=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 JR=`#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 $R=`#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 hf=class extends at{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new he(null)},blending:Kt,depthWrite:!1,depthTest:!1,vertexShader:JR,fragmentShader:$R})}set inputBuffer(t){this.uniforms.inputBuffer.value=t}},ax=class extends pi{constructor(){super("TAAResolvePass");this.MRTCompatible=!0;this.needsSwap=!1,this.passThroughMaterial=new hf,this.resolutionVector=new U,this.resolveMaterial=new at({name:"TAAResolveMaterial",uniforms:{inputBuffer:new he(null),historyBuffer:new he(null),velocityBuffer:new he(null),depthBuffer:new he(null),resolution:new he(new U)},blending:Kt,depthWrite:!1,depthTest:!1,vertexShader:KR,fragmentShader:ZR}),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 lx=class extends pi{constructor(e,r,i){super("TransmissionPass",void 0,r);this.MRTCompatible=!0;this.depthPass=new gE(e,r,{renderTarget:i.transmissionDepthTarget}),this.passThroughMaterial=new hf,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new hf,this.depthPass=new gE(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 e3=new bi,kX=new at({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); } `}),Wc=class extends pi{constructor(e,r,i){super("OpaquePass",r??e3,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??e3}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=kX)}),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 cx=class{constructor(t,{depthBuffer:e=!0,stencilBuffer:r=!1,multisampling:i=0,frameBufferType:s=0}={}){this.renderer=t;this.helperStartIndex=0;this.copyPass=new Tm;this.depthTexture=null;this.timer=new UR;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===ot&&(this.inputBuffer.texture[0].encoding=ot,this.outputBuffer.texture[0].encoding=ot,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 is(this._width,this._height);return this.inputBuffer.depthTexture=t,this.inputBuffer.stencilBuffer?(t.format=Qa,t.type=qa):t.type=_s,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=Is):u=new dt(l.width,l.height,c),u.depthTexture=new is(2048,2048),u.depthTexture.type=yr),r===Cr&&a!==null&&a.outputEncoding===ot&&(Array.isArray(u.texture)?u.texture.forEach(h=>h.encoding=ot):u.texture.encoding=ot),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 VR&&(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 GX=new at({name:"CombineMaterial",uniforms:{inputBufferA:new he(null),inputBufferB:new he(null)},blending:Kt,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); } `}),ux=class extends pi{constructor(e){super("HelperPass",void 0,e);this.MRTCompatible=!1;this.fullscreenMaterial=GX,this.helperPass=new Wc(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new Wc(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let r=new ox({preset:Ia.LOW,edgeDetectionMode:ef.COLOR});this.effectPass=new Hc(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 t3=`#define GLSLIFY 1 #include out vec3 n;void main(){ #include #include #include #include #include #include vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`;var r3=`#define GLSLIFY 1 in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`;var i3=`#define GLSLIFY 1 out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`;var n3=`#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)=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 s3=`#define GLSLIFY 1 out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`;var o3=`#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 df=[[.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 QX=new at({vertexShader:t3,fragmentShader:r3}),ff=new at({vertexShader:s3,fragmentShader:o3,uniforms:{texture_ao_lrez:new he(null),texture_depth_lrez:new he(null),texture_depth_hrez:new he(null),near:new he(null),far:new he(null)}}),hx=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?Is:yr,depthTexture:new is(i,s),minFilter:tt,magFilter:tt}),this.depthBufferHighRes=new dt(i,s,{depthTexture:new is(i,s)}),this.aoBuffer=new dt(i,s,{minFilter:tt,magFilter:tt}),this.splineScene=e,this.splineCamera=r;let o=new Float32Array(df.length*2);for(let l=0;l with 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); } `,dx=class extends Ln{constructor(){super(new at({vertexShader:KX,fragmentShader:ZX,uniforms:{tInput:new he(null),tMap:new he(null),uResolution:new he(new U),uSize:new he(new U),uCoords:new he(new U),uScale:new he(1),uSceneColor:new he(new We(16711680)),uDPR:new he(1),uCurrent:new he(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 JX=` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,$X=` 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 ); } } `,eQ=[],fx=class extends Ln{constructor(){super(new at({vertexShader:JX,fragmentShader:$X,uniforms:{toScene:new he(null),fromScene:new he(null),uResolution:new he(new U),uDPR:new he(1),mixRatio:new he(0),threshold:new he(.1),useTexture:new he(0),tMixTexture:{value:eQ[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 tQ=` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,rQ=` 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 ); } `,px=class extends Ln{constructor(){super(new at({vertexShader:tQ,fragmentShader:rQ,uniforms:{inputBuffer:new he(null),blurredInputBuffer:new he(null),overlay:new he(null),uResolution:new he(new U),uDPR:new he(1),blurIntensity:new he(0)}}));this._blurEnabled=!1;this.blurTarget=new dt(1,1,{minFilter:tt,magFilter:tt,wrapS:Yt,wrapT:Yt}),this.blurPass=new sx({width:window.innerWidth,height:window.innerHeight,kernelSize:Cm.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 l3(n,t){return t&&t.enabled&&n.push(t.effect),n}var iQ=n=>Object.values(Ct).includes(n)?n:Ct.NORMAL,Pm=class extends hr{constructor(e){super();this.postprocessingState=Bh.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 tf),this.effects.set("chromaticAberration",new nf),this.effects.set("vignette",new lf),this.effects.set("noise",new af),this.effects.set("colorAverage",new sf),this.effects.set("hueSaturation",new of),this.effects.set("brightnessContrast",new rf),this.effects.set("depthOfField",new cf),this.effects.set("pixelation",new uf),this.effectComposer=new cx(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Wc(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new lx(this.scene,this.camera,this.renderer),this.aoPass=new hx(this.scene,this.camera),this.taaPass=new ax,this.taaPass.renderToScreen=!1,this.helperPass=new ux(this.camera),this.helperPass.renderToScreen=!1,this.stylesOverlayPass=new dx,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new px,this.uiOverlayPass.enabled=!1,this.sceneTransitionPass=new fx,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=Os,this.blueNoiseTexture.wrapT=Os,this.blueNoiseTexture.minFilter=Ft,this.blueNoiseTexture.magFilter=Ft,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(l3,[]);e.length>0&&(this.uvEffectPass=new Hc(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(l3,[]);if(r.length>0&&(this.effectPass=new Hc(this.camera,...r),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass),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:Os,wrapT:Os}),this._rt.samples=0,this._savePass=new Tm(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new Tm(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=iQ(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 nQ=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 `,sQ=xt.lights_fragment_begin,oQ=xt.shadowmask_pars_fragment,c3=null,aQ=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},u3=(n="medium")=>{if(c3===n)return!1;c3=n;let t=aQ(n);xt.shadowmap_pars_fragment=nQ(t);let e=sQ.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=oQ.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),xt.shadowmask_pars_fragment=r,!0};var lQ=` attribute vec3 randomColor; varying vec3 vNormal; flat out vec3 vColor; #include void main() { #include #include #include vec3 transformed = vec3(position); #include vNormal = normal; vColor = randomColor; gl_Position = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0)); } `,cQ=` 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); } `,mx=new at({vertexShader:lQ,fragmentShader:cQ,uniforms:{depthContrast:{value:1}}});var h3=new Zt,uQ=new U,gx=class extends cw{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new U;this.pipeline=new Pm(this);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.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:lc,magFilter:tt,wrapS:Yt,wrapT:Yt,depthBuffer:!1}),this.transmissionDepthTarget=new dt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Ft,magFilter:Ft,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new dt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ft,magFilter:Ft,type:yr,depthTexture:new is(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?mx.uniforms.depthContrast.value=(i.far-i.near)/1e4:mx.uniforms.depthContrast.value=1,r.overrideMaterial=mx,this.render(r,i),this.setClearColor(r.bgColor,r.bgColor.a),this.setRenderTarget(null),r.overrideMaterial=e.wireframeState?yx: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{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=h3):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(uQ),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.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=h3,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=OI(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?yx: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 pf=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,pf.geometryHelper,e,r)}};var mf=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,mf.geometryHelper,e,r)}};var vx=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,vx.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=vx._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{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>>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 $t=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 Gl;this._recursiveBBox=new Gl;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=vE();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,x3(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=Rt(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=Ch.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 $t(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 $t&&(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 $t{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}},Nn=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 Nn(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};function pQ(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 S3=[[-1,1],[-1,-1],[1,-1],[1,1]],b3=(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)):S3.forEach(o=>{let a=[o[0]*i[0]+r[0],o[1]*i[1]+r[1]];e.push(St.apply(a,s))})},Gl=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&&b3(s,e,i)}):b3(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=S3.map(([c,u])=>St.apply([c*t,u*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;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{A3=n}),w3=!1;var bx;function M3(){if(w3)return;if(bx)return bx;async function n(){let e=await import("./ui.js");A3(e.default??e),w3=!0}return bx=n(),bx}function bE(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,xE;async function mQ(n){let t=await E3;pt||(xE||(xE=t({locateFile:()=>n})),pt=await xE)}var T3=St.identity(),Dm=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=T3,this._currentTransform=new Float32Array(T3)}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 mQ(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(Sx(t),pt.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(Sx(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(Sx(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(Sx(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(!C3([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(!!C3(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 C3(n){for(let t=0;t0?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&&(Rt(e.path,["fill"])?this.fill.update(e.props):Rt(e.path,["stroke"])?this.stroke.update(e.props):Rt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Rt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Rt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Rt(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 jl=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 v3(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 jl(this.uuid,this.data,e);return r.parent=void 0,r}};var ws=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 ws(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._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 Hl(this.uuid,this.data,e);return r.parent=void 0,r}};var vf=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=>Ex.extremas(s)),r=[1/0,1/0],i=[-1/0,-1/0];for(let s=0,o=e.length;si[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{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=SE.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})(Ex||(Ex={}));var SE;(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=wE.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})(SE||(SE={}));var wE;(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})(wE||(wE={}));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 ws(e+"-background",Wh.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&&(Rt(e.path,["fill"])?this.fill.update(e.props):Rt(e.path,["stroke"])?this.stroke.update(e.props):Rt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Rt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Rt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Rt(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 O3=Ko(AE(),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 I3(n,t=1,e=1){if(t<=0||e<=0)return n;let i=(0,O3.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 R3(i)}function R3(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 L3(n,t,e){switch(t.type){case"ellipse2d":return new jl(n,t,e);case"rectangle2d":return new ws(n,t,e);case"text2d":return new Hl(n,t,e);case"vector2d":return new vf(n,t,e);case"path2d":return new Ra(n,t,e);case"frame2d":return new Qi(n,t,e);case"group2d":default:return new Nn(n,t,e)}}var EE=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Nn(EE.GROUP_ID,{...kp.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,i,s,o){let a=L3(t,e,o);a&&(i.add(a),i.children.splice(s,0,i.children.pop()),a.updateWorldMatrix(),r.length>0&&(a instanceof Nn||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)}},Xc=EE;Xc.GROUP_ID="scene2d";function ME({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 xQ=Ko(AE(),1);var GLe={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 bQ=St.identity(),xf=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.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 Xc(Ee.generateUUID(),Yv.defaultData,{dpr:window.devicePixelRatio,shared:i.shared}),this.canvas=document.createElement("canvas"),this.renderer=new Dm(this.canvas),i.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=i.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof Dm&&(this.renderer.wasmURL=L0.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}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=bQ,this.isScreenSpace&&(this.frameOverride.fill.color=bt.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},B3({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.renderer.dpr=this.isScreenSpace?e:Math.floor(2048/Math.max(r,i)),this.renderer.setSize(r,i),this.textureHolder?.dispose(),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.textureHolder?.dispose(),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 B3({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:i,initialParentHeight:s}){if(n instanceof Qi&&t instanceof Qi||n instanceof Nn&&t instanceof Nn)for(let o=0,a=n.children.length;o{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 Rn&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof gs)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&&u3(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;Rt(e.path,["fog"])?this.updateFog(a.fog,i.shared):Rt(e.path,["ao"])?this.updateAo(a.ao,i.shared):Rt(e.path,["ambient"])?this.updateAmbientLight(a.ambient,i.shared):Rt(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 gf&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof yf&&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)&&((nn(o)||Em(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Rm(o,e,r,!0)),i(o))}};return i(this),r}updateEntity2DByOp(e,r,i,s){this.uiCanvas?.updateEntity2DByOp(e,r,i,s)}};var Tx=class extends $d(dy,mf){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 nl(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 nl){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 Cx=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?am(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Wl=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=xd;break;case"Ellipse":s=gd;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?am(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 xs(ts,bs){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=zh.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,...Xn(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),Px(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(i){let o={};F3(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 Ka(d,f);c.bind(p,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Px(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)&&Px(e)}}function N3(n,t,e,r){return n.component===t&&Cp(n.identity,r)?n.overrideData===e?2:1:0}function F3(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=Fh.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=N3(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=N3(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,F3(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 _x=class extends xs(ap,bs){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=()=>{this.uiCanvas.render()};this.uiCanvas=new xf(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):Rt(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 Dx=class{constructor(t,e,r){this.variables=[],this.currentTextureIndex=0;let i=yr,s=new bi,o=new jn;o.position.z=1;let a={passThruTexture:{value:null}},l=h(f(),a),c=new tr(new un(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:Ft,magFilter:Ft};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;pt){s=o;break}else t1&&(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),Ox.set(0,0,0).addScaledVector(Ki.a,s).addScaledVector(Ki.b,o).addScaledVector(Ki.c,1-(s+o)),i.r=Ox.x,i.g=Ox.y,i.b=Ox.z),this}};function V3(n){let t=new Float32Array(n*n*2);for(let e=0;e .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 H3=` 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 W3=` #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 q3=` #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 Y3=` #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 X3=` // 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; `+H3+` 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 ) { float offset = 0.0; velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), offset); velocity *= uSpeed; } // Variation of the noise Over Time if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) { float offset = 0.0; velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed; } #endif // COLLIDER ${W3} // ATTRACTION ${q3} // VORTEX ${Y3} } // 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 PE=` // 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 Q3=` 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 K3=` 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 Z3=` 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; ${Q3} ${PE} `,J3=({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; `,$3=` 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); } `+PE+` ${K3} `,eL=({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 Rx=class extends at{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 _d;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(TI),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(CI),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(Z3),e.addFragmentParsCode($3),e.addVertexFinalCode(J3({easeSize:this.easeSize})),e.addFragmentFinalCode(eL({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 bf=class{constructor(t,e,r,i){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=z3(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}=U3(e,t*t),s=CE(r,t),o=CE(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 Lu(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new Ja(e,e,15);break}case"BoxEmitterShape":{r=new hi(e,e,e);break}case"PlaneEmitterShape":{r=new un(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 tr(r,new Gn({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 ql(n){let t={...n},e=Oh.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 tL=` // 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 _E=10,Lx=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 Rx(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 Zt(s.img);o.needsUpdate=!0,e.uTexture.value=o;return}if(typeof i!="string"){let s=new Image;s.onload=()=>{let l=new Zt(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=V3(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(ql({...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/_E),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(ql(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"]))/_E),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={...ql(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])*Ee.DEG2RAD,Number(e[1])*Ee.DEG2RAD,Number(e[2])*Ee.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 Dx(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),s=this.updateSimulationDefinition(e),o=i.addVariable("uCurrentPosition",s+j3,this.emitterShape.positionsTexture),a=i.addVariable("uCurrentVelocity",s+X3,this.emitterShape.directionsTexture),l=i.addVariable("uCurrentEmissionRate",tL,G3(this.emitterShape.textureSize));i.setVariableDependencies(o,[o,a,l]),i.setVariableDependencies(a,[o,a,l]),i.setVariableDependencies(l,[o,a,l]);let c=k3({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"]))/_E}};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={...ql(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 bf(i,r,e.type,s):new bf(i,r,"SphereEmitterShape")}else return new bf(i,r,e.type)}createPrimaryEmitter(e){let r,i=e*e;return r=new iy(new un(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._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=i,this.data={...r,...ql(r)},this.geometry.setAttribute("position",new Ce([],3)),this.material=new Gn({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Lx(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.emitTimeLoopDelayStart==="start"?0: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),Rt(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...Ir.drop(e,1).props}}),Rt(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){setTimeout(()=>{this.stopLoop||this.start(0)},e);return}this.started=!0,this.stopped=!1,this.stopLoop=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(e=!1){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),e&&(this.stopLoop=!0)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function EQ(){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 DE=EQ();function MQ(n,t,e){DE!==void 0&&(t?.geometry?.subdivisions??0)>DE&&(console.log("reducing subdivisions",t.name,t.geometry.subdivisions),t.geometry.subdivisions=DE);let r;return t.geometry.type==="TextGeometry"?new Qd(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new Qs(n,t,e):t.geometry.type==="PathGeometry"?r=new Wl(n,t,e):t.geometry.type==="VectorGeometry"?r=new Cx(n,t,e):t.geometry.type==="BooleanGeometry"?r=new Rn(n,t,e):t.geometry.type==="UIGeometry"?r=new Sr(n,t,e):r=new ar(n,t,e),r)}function Bx(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?MQ(n,t,e):t.type==="Empty"?new Ss(n,t):t.type==="Particle"?new Yl(n,t,e):t.type==="ParticleCollider"?new Vl(n,t,e):t.type==="Splat"?new Ss(n,t):t.type==="Bone"?new _x(n,t):t.type==="Page"?new lr(n,t,e):t.type==="PointLight"?new Tx(n,t,e):t.type==="SpotLight"?new yf(n,t,e):t.type==="DirectionalLight"?new gf(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 Ss(n,t))}Gs.createEntity=Bx;function TQ(n,t,e){let r=Bx(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=TQ;Gs.Cloner=Ui;function iL(n,t,e,r){n.updateByOp(t,e,r,!1)}function nL(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,Yd(n),qd(n)),r.length===0&&i.length===0&&n.layers.set(0),n instanceof gs&&n.needsAO&&n.layers.enable(5),e}function sL(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 oL(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof gs)if(Array.isArray(e.material))for(let r=0;r{if(e instanceof gs)if(Array.isArray(e.material))for(let r=0;r0&&e.push({...u[0],object:r?s:n})}}var Nx=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 lL="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var zo=class{};ec(zo,"DepthMapRange",1<<16),ec(zo,"MemoryPageSize",65536),ec(zo,"BytesPerFloat",4),ec(zo,"BytesPerInt",4);function DQ(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{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 cL(n){let t=new Worker(URL.createObjectURL(new Blob(["(",DQ.toString(),")(self)"],{type:"application/javascript"}))),e=atob(lL),r=new Uint8Array(e.length);for(let i=0;i{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var Xl=class extends tr{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=Xl.buildGeomtery(r),c=Xl.buildMaterial(o);return new Xl(e,r,l,c,i,s,o,a)}static buildMaterial(e){let r=` precision highp float; #include 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 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 at({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 mp().copy(r),a=new Uint32Array(e),l=new ho(a,1,!1);return l.setUsage(yC),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*20&&(Vx.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Vx),this.material.uniforms.basisViewport.value.set(2/Vx.x,2/Vx.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 dL,OE=new Promise(n=>{dL=n}),hL=!1;var Ux;function IE(){if(hL)return;if(Ux)return Ux;async function n(){let e=await import("./gaussian-splat-compression.js");dL(e),hL=!0}return Ux=n(),Ux}var fL;OE.then(n=>fL=n);var Lm=class{constructor(t={}){ec(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 fL.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;ee.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=Xl.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=cL(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 yx=new Gn;yx.wireframe=!0;var pL=new E,kl=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 Nx;this.invisibleObjects=new Ss("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=aL(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=oL(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===us)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(),nn(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()),nn(i)&&(i.freeBooleanPointer(),s instanceof Rn&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Wl&&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()),nn(i)&&(i.invalidateUpstreamBooleanData(),Sn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Rn&&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{iL(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=dl(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=dl(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of kh.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),Px(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(nn(a)||Em(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),Rm(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)&&((nn(o)||Em(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),Rm(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)sd.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=Bx(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 Ka(d,f);u.bind(p,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let s=0,o=e.length;s{if(r instanceof dr)if(Array.isArray(r.material))for(let i=0;i{s instanceof xr&&s.setViewplaneSize(e,r,i)})}initializeSplatViewer(){this.splatViewer=new Lm({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Bm=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},mL=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return OQ(Math.atan2(r,e))},gL=(n,t,e)=>{let r={x:0,y:0};return e=kx(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},kx=n=>n*(Math.PI/180),OQ=n=>n*(180/Math.PI),yL=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,RE=new Map,LE=n=>{RE.has(n)&&clearTimeout(RE.get(n)),RE.set(n,setTimeout(n,100))},Sf=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let s=0;s{let r=t.split(/[ ,]+/g),i;for(let s=0;s(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),NE=()=>{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}},jx=(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")},Hx=(n,t,e)=>{let r=xL(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{let e=xL(n);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},xL=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},Wx=(n,t)=>{for(let e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},bL=(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},Nm=(n,t)=>{if(n.length)for(let e=0,r=n.length;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"&&(wL="ontouchstart"in window,AL=!!window.PointerEvent,EL=!!window.MSPointerEvent);var wL,AL,EL,Fm={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"}},wf,Vm={};AL?wf=Fm.pointer:EL?wf=Fm.MSPointer:wL?(wf=Fm.touch,Vm=Fm.mouse):wf=Fm.mouse;function Qc(){}Qc.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Qc.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;se&&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&&t0?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 ML=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 Af;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